Drupal 6: Developer Documentation

  • Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • Directories

Developer Documentation

Welcome to the Drupal developer's documentation. Newcomers to Drupal development should read the conceptual information provided in the "Components of Drupal" section, and then proceed to examine one of the heavily-documented example modules below. The examples are fully-functioning Drupal modules, so you can download them from the contributions repository and alter them as you experiment.

  • Components of Drupal
    • Module system (Drupal hooks)
    • Database abstraction layer
    • Menu system
    • Form generation
    • File upload system
    • Search system
    • Node access system
    • Theme system
    • Constants
    • Global variables
  • Example modules
    • How to define blocks
    • How to define a content filter
    • How to define content (node) types
    • How to restrict access to nodes
    • How to extend existing content types
    • How to define pages
  • In-depth discussions
    • Forms API Quickstart Guide
    • Forms API Reference
    • JavaScript Startup Guide
    • Drupal Programming from an Object-Oriented Perspective
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal.
Check drupal.kollm.org for updates.


Drupal 6: Module Index

  • Classes
  • Files
  • Directories

Modules

Here is a list of all modules:
  • Batch operations
  • Database abstraction layer
  • Default theme implementations
  • Example batch definitions
  • Extra updates for 5.x
  • File interface
  • Form builder functions
  • Form generation
  • Formatting
  • Hook implementations for user-created content types.
  • Hooks
  • Image toolkits
  • Input validation
  • Menu system
  • Node access rights
  • Schema API
  • Search interface
  • Updates from 5.x to 6.x
Generated on Tue Feb 12 15:30:51 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Batch operations

Batch operations

Detailed Description

End of "defgroup form_api".

Functions allowing forms processing to be spread out over several page requests, thus ensuring that the processing does not get interrupted because of a PHP timeout, while allowing the user to receive feedback on the progress of the ongoing operations.

The API is primarily designed to integrate nicely with the Form API workflow, but can also be used by non-FAPI scripts (like update.php) or even simple page callbacks (which should probably be used sparingly).

Example:

 $batch = array(
   'title' => t('Exporting'),
   'operations' => array(
     array('my_function_1', array($account->uid, 'story')),
     array('my_function_2', array()),
   ),
   'finished' => 'my_finished_callback',
 );
 batch_set($batch);
 // only needed if not inside a form _submit handler :
 batch_process();

Sample batch operations:

 // Simple and artificial: load a node of a given type for a given user
 function my_function_1($uid, $type, &$context) {
   // The $context array gathers batch context information about the execution (read),
   // as well as 'return values' for the current operation (write)
   // The following keys are provided :
   // 'results' (read / write): The array of results gathered so far by
   //   the batch processing, for the current operation to append its own.
   // 'message' (write): A text message displayed in the progress page.
   // The following keys allow for multi-step operations :
   // 'sandbox' (read / write): An array that can be freely used to
   //   store persistent data between iterations. It is recommended to
   //   use this instead of $_SESSION, which is unsafe if the user
   //   continues browsing in a separate window while the batch is processing.
   // 'finished' (write): A float number between 0 and 1 informing
   //   the processing engine of the completion level for the operation.
   //   1 (or no value explicitly set) means the operation is finished
   //   and the batch processing can continue to the next operation.

   $node = node_load(array('uid' => $uid, 'type' => $type));
   $context['results'][] = $node->nid .' : '. $node->title;
   $context['message'] = $node->title;
 }

 // More advanced example: multi-step operation - load all nodes, five by five
 function my_function_2(&$context) {
   if (empty($context['sandbox'])) {
     $context['sandbox']['progress'] = 0;
     $context['sandbox']['current_node'] = 0;
     $context['sandbox']['max'] = db_result(db_query('SELECT COUNT(DISTINCT nid) FROM {node}'));
   }
   $limit = 5;
   $result = db_query_range("SELECT nid FROM {node} WHERE nid > %d ORDER BY nid ASC", $context['sandbox']['current_node'], 0, $limit);
   while ($row = db_fetch_array($result)) {
     $node = node_load($row['nid'], NULL, TRUE);
     $context['results'][] = $node->nid .' : '. $node->title;
     $context['sandbox']['progress']++;
     $context['sandbox']['current_node'] = $node->nid;
     $context['message'] = $node->title;
   }
   if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
     $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
   }
 }

Sample 'finished' callback:

 function batch_test_finished($success, $results, $operations) {
   if ($success) {
     $message = format_plural(count($results), 'One post processed.', '@count posts processed.');
   }
   else {
     $message = t('Finished with an error.');
   }
   drupal_set_message($message);
   // Providing data for the redirected page is done through $_SESSION.
   foreach ($results as $result) {
     $items[] = t('Loaded node %title.', array('%title' => $result));
   }
   $_SESSION['my_batch_results'] = $items;
 }

Functions

  • & batch_get ()
    Retrieve the current batch.
  • batch_process ($redirect=NULL, $url=NULL)
    Process the batch.
  • batch_set ($batch_definition)
    Open a new batch.

Function Documentation

& batch_get ( )

Retrieve the current batch.

Definition at line 2501 of file form.inc.

Referenced by _batch_current_set(), _batch_finished(), _batch_next_set(), _batch_page(), _batch_process(), _batch_progress_page_js(), _batch_progress_page_nojs(), _batch_shutdown(), batch_process(), batch_set(), drupal_process_form(), and form_execute_handlers().

batch_process | ( | $ | redirect = NULL,
 |  | $ | url = NULL
 | ) |  |

Process the batch.

Unless the batch has been marked with 'progressive' = FALSE, the function issues a drupal_goto and thus ends page execution.

This function is not needed in form submit handlers; Form API takes care of batches that were set during form submission.

Parameters:
$redirect | (optional) Path to redirect to when the batch has finished processing.
$url | (optional - should only be used for separate scripts like update.php) URL of the batch processing page.

Definition at line 2446 of file form.inc.

References $url, _batch_process(), batch_get(), db_last_insert_id(), db_query(), drupal_get_token(), drupal_goto(), get_t(), and url().

Referenced by batch_example_page(), drupal_process_form(), install_tasks(), and update_batch().

batch_set ( $ batch_definition )

Open a new batch.

Parameters:
$batch An array defining the batch. The following keys can be used: 'operations': an array of function calls to be performed. Example:
        array(
          array('my_function_1', array($arg1)),
          array('my_function_2', array($arg2_1, $arg2_2)),
        )
All the other values below are optional. batch_init() provides default values for the messages. 'title': title for the progress page. Defaults to t('Processing'). 'init_message': message displayed while the processing is initialized. Defaults to t('Initializing.'). 'progress_message': message displayed while processing the batch. Available placeholders are , , and . Defaults to t('Remaining of .'). 'error_message': message displayed if an error occurred while processing the batch. Defaults to t('An error has occurred.'). 'finished': the name of a function to be executed after the batch has completed. This should be used to perform any result massaging that may be needed, and possibly save data in $_SESSION for display after final page redirection. 'file': the path to the file containing the definitions of the 'operations' and 'finished' functions, for instance if they don't reside in the original '.module' file. The path should be relative to the base_path(), and thus should be built using drupal_get_path().
Operations are added as new batch sets. Batch sets are used to ensure clean code independence, ensuring that several batches submitted by different parts of the code (core / contrib modules) can be processed correctly while not interfering or having to cope with each other. Each batch set gets to specify his own UI messages, operates on its own set of operations and results, and triggers its own 'finished' callback. Batch sets are processed sequentially, with the progress bar starting fresh for every new set.

Definition at line 2388 of file form.inc.

References batch_get(), and get_t().

Referenced by batch_example_multistep_form_submit(), batch_example_page(), batch_example_simple_form_submit(), install_tasks(), locale_languages_predefined_form_submit(), locale_system_update(), node_access_rebuild(), node_mass_update(), and update_batch().

Generated on Tue Feb 12 15:30:50 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Database abstraction layer

Database abstraction layer

Detailed Description

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

Drupal provides a slim 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, while letting Drupal control the pieces of queries that need to be written differently for different servers and provide basic security checks.

Most Drupal database queries are performed by a call to db_query() or db_query_range(). Module authors should also consider using pager_query() for queries that return results that need to be presented on multiple pages, and tablesort_sql() 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

   SELECT n.title, n.body, n.created FROM node n WHERE n.uid = $uid LIMIT 0, 10;
one would instead call the Drupal functions:
   $result = db_query_range('SELECT n.title, n.body, n.created
     FROM {node} n WHERE n.uid = %d', $uid, 0, 10);
   while ($node = db_fetch_object($result)) {
     // Perform operations on $node->body, etc. here.
   }
Curly braces are used around "node" to provide table prefixing via db_prefix_tables(). 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 common pattern of iterating over the result set using db_fetch_object().

  • db_status_report ()
    Report database status.

Enumerations

  • enum DB_QUERY_REGEXP
    Indicates the place holders that should be replaced in _db_query_callback(). More...

Functions

  • _db_error_page ($error= '')
    Helper function to show fatal database errors.
  • _db_query_callback ($match, $init=FALSE)
    Helper function for db_query().
  • _db_rewrite_sql ($query= '', $primary_table= 'n', $primary_field= 'nid', $args=array())
    Helper function for db_rewrite_sql.
  • db_escape_table ($string)
    Restrict a dynamic table, column or constraint name to safe characters.
  • db_is_active ()
    Returns a boolean depending on the availability of the database.
  • db_placeholders ($arguments, $type= 'int')
    Generate placeholders for an array of query arguments of a single type.
  • db_prefix_tables ($sql)
    Append a database prefix to all tables in a query.
  • db_rewrite_sql ($query, $primary_table= 'n', $primary_field= 'nid', $args=array())
    Rewrites node, taxonomy and comment queries.
  • db_set_active ($name= 'default')
    Activate a database for future queries.
  • pager_query ($query, $limit=10, $element=0, $count_query=NULL)
    Perform a paged database query.
  • tablesort_sql ($header, $before= '')
    Create an SQL sort clause.
  • update_sql ($sql)
    Perform an SQL query and return success or failure.

Enumeration Type Documentation

enum DB_QUERY_REGEXP

Indicates the place holders that should be replaced in _db_query_callback().

Definition at line 241 of file database.inc.

Function Documentation

_db_error_page ( $ error = '' )

Helper function to show fatal database errors.

Prints a themed maintenance page with the 'Site off-line' text, adding the provided error message in the case of 'display_errors' set to on. Ends the page request; no return.

Parameters:
$error The error message to be appended if 'display_errors' is on.

Definition at line 173 of file database.inc.

References $db_type, drupal_maintenance_theme(), drupal_set_header(), drupal_set_title(), exit, and theme().

Referenced by db_connect(), and db_set_active().

_db_query_callback | ( | $ | match,
 |  | $ | init = FALSE
 | ) |  |

Helper function for db_query().

Definition at line 201 of file database.inc.

References db_encode_blob(), and db_escape_string().

Referenced by db_query(), db_query_range(), and db_query_temporary().

_db_rewrite_sql | ( | $ | query = '',
 |  | $ | primary_table = 'n',
 |  | $ | primary_field = 'nid',
 |  | $ | args = array()
 | ) |  |

Helper function for db_rewrite_sql.

Collects JOIN and WHERE statements via hook_db_rewrite_sql() Decides whether to select primary_key or DISTINCT(primary_key)

Parameters:
$query | Query to be rewritten.
$primary_table | Name or alias of the table which has the primary key field for this query. Typical table names would be: {blocks}, {comments}, {forum}, {node}, {menu}, {term_data} or {vocabulary}. However, in most cases the usual table alias (b, c, f, n, m, t or v) is used instead of the table name.
$primary_field | Name of the primary field.
$args | Array of additional arguments.
Returns:
An array: join statements, where statements, field or DISTINCT(field).

Definition at line 263 of file database.inc.

References $result, module_implements(), and module_invoke().

Referenced by db_rewrite_sql(), and node_search().

db_escape_table ( $ string )

Restrict a dynamic table, column or constraint name to safe characters.

Only keeps alphanumeric and underscores.

Definition at line 378 of file database.inc.

Referenced by db_column_exists(), db_last_insert_id(), db_lock_table(), and db_table_exists().

db_is_active ( )

Returns a boolean depending on the availability of the database.

Definition at line 193 of file database.inc.

References $active_db.

Referenced by drupal_get_filename(), list_themes(), and template_preprocess().

db_placeholders | ( | $ | arguments,
 |  | $ | type = 'int'
 | ) |  |

Generate placeholders for an array of query arguments of a single type.

Given a Schema API field type, return correct -placeholders to embed in a query

Parameters:
$arguments | An array with at least one element.
$type | The Schema API type of a field (e.g. 'int', 'text', or 'varchar').

Definition at line 233 of file database.inc.

References $type, and db_type_placeholder().

Referenced by _menu_navigation_links_rebuild(), block_list(), block_user(), locale_batch_by_language(), taxonomy_select_nodes(), taxonomy_term_page(), and user_access().

db_prefix_tables ( $ sql )

Append a database prefix to all tables in a query.

Queries sent to Drupal should wrap all table names in curly brackets. This function searches for this syntax and adds Drupal's table prefix to all tables, allowing Drupal to coexist with other systems in the same database if necessary.

Parameters:
$sql A string containing a partial or entire SQL query.
Returns:
The properly-prefixed string.

Definition at line 82 of file database.inc.

References $db_prefix.

Referenced by db_query(), db_query_range(), and db_query_temporary().

db_rewrite_sql | ( | $ | query,
 |  | $ | primary_table = 'n',
 |  | $ | primary_field = 'nid',
 |  | $ | args = array()
 | ) |  |

Rewrites node, taxonomy and comment queries.

Use it for listing queries. Do not use FROM table1, table2 syntax, use JOIN instead.

Parameters:
$query | Query to be rewritten.
$primary_table | Name or alias of the table which has the primary key field for this query. Typical table names would be: {blocks}, {comments}, {forum}, {node}, {menu}, {term_data} or {vocabulary}. However, it is more common to use the the usual table aliases: b, c, f, n, m, t or v.
$primary_field | Name of the primary field.
$args | An array of arguments, passed to the implementations of hook_db_rewrite_sql.
Returns:
The original query with JOIN and WHERE statements inserted from hook_db_rewrite_sql implementations. nid is rewritten if needed.

Definition at line 310 of file database.inc.

References _db_rewrite_sql(), and db_distinct_field().

Referenced by _forum_new(), _forum_topics_unread(), _node_types_build(), block_list(), blog_block(), blog_feed_last(), blog_feed_user(), blog_page_last(), blog_page_user(), book_block(), book_get_books(), comment_get_recent(), comment_render(), forum_block(), forum_get_forums(), forum_get_topics(), forum_term_load(), menu_tree_check_access(), node_admin_nodes(), node_feed(), node_page_default(), poll_block(), poll_page(), statistics_title_list(), taxonomy_autocomplete(), taxonomy_form_alter(), taxonomy_get_children(), taxonomy_get_parents(), taxonomy_get_term_by_name(), taxonomy_get_tree(), taxonomy_get_vocabularies(), taxonomy_node_get_terms(), taxonomy_node_get_terms_by_vocabulary(), taxonomy_overview_terms(), taxonomy_select_nodes(), taxonomy_term_count_nodes(), taxonomy_term_page(), template_preprocess_forum_topic_navigation(), tracker_page(), and translation_node_get_translations().

db_set_active ( $ name = 'default' )

Activate a database for future queries.

If it is necessary to use external databases in a project, this function can be used to change where database queries are sent. If the database has not yet been used, it is initialized using the URL specified for that name in Drupal's configuration file. If this name is not defined, a duplicate of the default connection is made instead.

Be sure to change the connection back to the default when done with custom code.

Parameters:
$name The name assigned to the newly active database connection. If omitted, the default connection will be made active.
Returns:
the name of the previously active database or FALSE if non was found.

Definition at line 124 of file database.inc.

References $active_db, $db_type, $db_url, $name, _db_error_page(), db_connect(), and install_goto().

Referenced by _drupal_bootstrap(), dblog_watchdog(), and install_main().

db_status_report ( )

Report database status.

Definition at line 17 of file database.pgsql.inc.

References db_version(), and get_t().

pager_query | ( | $ | query,
 |  | $ | limit = 10,
 |  | $ | element = 0,
 |  | $ | count_query = NULL
 | ) |  |

Perform a paged database query.

Use this function when doing select queries you wish to be able to page. The pager uses LIMIT-based queries to fetch only the records required to render a certain page. However, it has to learn the total number of records returned by the query to compute the number of pages (the number of records / records per page). This is done by inserting "COUNT(*)" in the original query. For example, the query "SELECT nid, type FROM node WHERE status = '1' ORDER BY sticky DESC, created DESC" would be rewritten to read "SELECT COUNT(*) FROM node WHERE status = '1' ORDER BY sticky DESC, created DESC". Rewriting the query is accomplished using a regular expression.

Unfortunately, the rewrite rule does not always work as intended for queries that already have a "COUNT(*)" or a "GROUP BY" clause, and possibly for other complex queries. In those cases, you can optionally pass a query that will be used to count the records.

For example, if you want to page the query "SELECT COUNT(*), TYPE FROM node GROUP BY TYPE", pager_query() would invoke the incorrect query "SELECT COUNT(*) FROM node GROUP BY TYPE". So instead, you should pass "SELECT COUNT(DISTINCT(TYPE)) FROM node" as the optional $count_query parameter.

Parameters:
$query | The SQL query that needs paging.
$limit | The number of query results to display per page.
$element | An optional integer to distinguish between multiple pagers on one page.
$count_query | An SQL query used to count matching records.
... A variable number of arguments which are substituted into the query (and the count query) using printf() syntax. Instead of a variable number of query arguments, you may also pass a single array containing the query arguments.
Returns:
A database query result resource, or FALSE if the query was not executed correctly.

Definition at line 51 of file pager.inc.

References $element, $pager_page_array, $pager_total, $pager_total_items, db_query(), db_query_range(), and db_result().

Referenced by _locale_translate_seek(), aggregator_feed_items_load(), blog_page_last(), blog_page_user(), comment_admin_overview(), comment_render(), dblog_overview(), dblog_top(), forum_get_topics(), node_admin_nodes(), node_page_default(), path_admin_overview(), poll_page(), poll_votes(), profile_browse(), statistics_node_tracker(), statistics_recent_hits(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), statistics_user_tracker(), system_actions_manage(), taxonomy_overview_terms(), taxonomy_select_nodes(), tracker_page(), user_admin_account(), and user_search().

tablesort_sql | ( | $ | header,
 |  | $ | before = ''
 | ) |  |

Create an SQL sort clause.

This function produces the ORDER BY clause to insert in your SQL queries, assuring that the returned database table rows match the sort order chosen by the user.

Parameters:
$header | An array of column headers in the format described in theme_table().
$before | An SQL string to insert after ORDER BY and before the table sorting code. Useful for sorting by important attributes like "sticky" first.
Returns:
An SQL string to append to the end of a query.

Definition at line 39 of file tablesort.inc.

References $header, drupal_strtoupper(), and tablesort_init().

Referenced by comment_admin_overview(), dblog_overview(), dblog_top(), forum_get_topics(), path_admin_overview(), poll_votes(), statistics_node_tracker(), statistics_recent_hits(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), statistics_user_tracker(), system_actions_manage(), user_admin_access(), and user_admin_account().

update_sql ( $ sql )

Perform an SQL query and return success or failure.

Parameters:
$sql A string containing a complete SQL query. -substitution parameters are not supported.
Returns:
An array containing the keys: success: a boolean indicating whether the query succeeded query: the SQL query executed, passed through check_plain()

Definition at line 64 of file database.inc.

References $result, check_plain(), and db_query().

Referenced by batch_test_update_1(), book_update_6000(), comment_update_6001(), db_add_column(), db_add_field(), db_add_index(), db_add_primary_key(), db_add_unique_key(), db_change_column(), db_change_field(), db_create_table(), db_drop_field(), db_drop_index(), db_drop_primary_key(), db_drop_table(), db_drop_unique_key(), db_field_set_default(), db_field_set_no_default(), db_rename_table(), locale_update_6000(), locale_update_6001(), locale_update_6002(), locale_update_6003(), statistics_update_1000(), system_update_6000(), system_update_6005(), system_update_6006(), system_update_6007(), system_update_6008(), system_update_6009(), system_update_6011(), system_update_6015(), system_update_6016(), system_update_6018(), system_update_6019(), system_update_6021(), system_update_6022(), system_update_6034(), system_update_6036(), system_update_6037(), system_update_6038(), system_update_6039(), system_update_6041(), system_update_6044(), system_update_6045(), system_update_6047(), and update_fix_compatibility().

Generated on Tue Feb 12 15:30:49 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Default theme implementations

Default theme implementations

Detailed Description

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 several arguments. For example, theme('table', $header, $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'), $header, $rows) 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 themes 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 either phptemplate_HOOK or THEMENAME_HOOK. For example, for Drupal's default theme (Garland) to implement the 'table' hook, the phptemplate.engine would find phptemplate_table() or garland_table(). The ENGINE_HOOK() syntax is preferred, as this can be used by sub-themes (which are themes that share code but use different stylesheets).

The theme system is described and defined in theme.inc.

See also:
theme()

hook_theme()

Language overview functionality

  • theme_locale_languages_overview_form ($form)
    Theme the language overview form.

Pager pieces

Use these pieces to construct your own custom pagers in your theme.

Note that you should NOT modify this file to customize your pager.

  • theme_pager_first ($text, $limit, $element=0, $parameters=array())
    Format a "first page" link.
  • theme_pager_last ($text, $limit, $element=0, $parameters=array())
    Format a "last page" link.
  • theme_pager_link ($text, $page_new, $element, $parameters=array(), $attributes=array())
    Format a link to a specific query result page.
  • theme_pager_next ($text, $limit, $element=0, $interval=1, $parameters=array())
    Format a "next page" link.
  • theme_pager_previous ($text, $limit, $element=0, $interval=1, $parameters=array())
    Format a "previous page" link.

Functions

  • phptemplate_menu_local_tasks ()
    Returns the rendered local tasks.
  • theme_admin_block ($block)
    This function formats an administrative block for display.
  • theme_admin_block_content ($content)
    This function formats the content of an administrative block.
  • theme_admin_page ($blocks)
    This function formats an administrative page for viewing.
  • theme_aggregator_block_item ($item, $feed=0)
    Format an individual feed item for display in the block.
  • theme_aggregator_categorize_items ($form)
    Theme the page list form for assigning categories.
  • theme_aggregator_page_opml ($feeds)
    Theme the OPML feed output.
  • theme_aggregator_page_rss ($feeds, $category=NULL)
    Theme the RSS output.
  • theme_blocks ($region)
    Return a set of blocks available for the current user.
  • theme_book_admin_table ($form)
    Theme function for the book administration page form.
  • theme_book_title_link ($link)
    Generate the HTML output for a link to a book title when used as a block title.
  • theme_box ($title, $content, $region= 'main')
    Return a themed box.
  • theme_breadcrumb ($breadcrumb)
    Return a themed breadcrumb trail.
  • theme_button ($element)
    Theme a form button.
  • theme_checkbox ($element)
    Format a checkbox.
  • theme_checkboxes ($element)
    Format a set of checkboxes.
  • theme_closure ($main=0)
    Execute hook_footer() which is run at the end of the page right before the close of the body tag.
  • theme_color_scheme_form ($form)
    Theme color form.
  • theme_comment_admin_overview ($form)
    Theme the comment admin form.
  • theme_comment_block ()
    Returns a formatted list of recent comments to be displayed in the comment block.
  • theme_comment_controls ($form)
    Theme comment controls box where the user can change the default display mode and display order of comments.
  • theme_comment_flat_collapsed ($comment, $node)
    Theme comment flat collapsed view.
  • theme_comment_flat_expanded ($comment, $node)
    Theme comment flat expanded view.
  • theme_comment_post_forbidden ($node)
    Theme a "you can't post comments" notice.
  • theme_comment_submitted ($comment)
    Theme a "Submitted by ..." notice.
  • theme_comment_thread_collapsed ($comment, $node)
    Theme comment thread collapsed view.
  • theme_comment_thread_expanded ($comment, $node)
    Theme comment thread expanded view.
  • theme_comment_view ($comment, $node, $links=array(), $visible=TRUE)
    Theme a single comment block.
  • theme_date ($element)
    Format a date selection element.
  • theme_dblog_filters ($form)
    Theme dblog administration filter selector.
  • theme_feed_icon ($url, $title)
    Return code that emits an feed icon.
  • theme_fieldset ($element)
    Format a group of form items.
  • theme_file ($element)
    Format a file upload field.
  • theme_filter_admin_order ($form)
    Theme filter order configuration form.
  • theme_filter_admin_overview ($form)
    Theme the admin overview form.
  • theme_filter_tips ($tips, $long=FALSE, $extra= '')
    Format a set of filter tips.
  • theme_filter_tips_more_info ()
    Format a link to the more extensive filter tips.
  • theme_form ($element)
    Format a form.
  • theme_form_element ($element, $value)
    Return a themed form element.
  • theme_help ()
    Return a themed help message.
  • theme_hidden ($element)
    Format a hidden form field.
  • theme_image ($path, $alt= '', $title= '', $attributes=NULL, $getsize=TRUE)
    Return a themed image.
  • theme_image_button ($element)
    Theme a form image button.
  • theme_indentation ($size=1)
    Create a standard indentation div.
  • theme_item ($element)
    Format a form item.
  • theme_item_list ($items=array(), $title=NULL, $type= 'ul', $attributes=NULL)
    Return a themed list of items.
  • theme_links ($links, $attributes=array('class'=> 'links'))
    Return a themed set of links.
  • theme_mark ($type=MARK_NEW)
    Return a themed marker, useful for marking new or updated content.
  • theme_markup ($element)
    Format HTML markup for use in forms.
  • theme_menu_item ($link, $has_children, $menu= '', $in_active_trail=FALSE, $extra_class=NULL)
    Generate the HTML output for a menu item and submenu.
  • theme_menu_item_link ($link)
    Generate the HTML output for a single menu link.
  • theme_menu_local_task ($link, $active=FALSE)
    Generate the HTML output for a single local task link.
  • theme_menu_local_tasks ()
    Returns the rendered local tasks.
  • theme_menu_overview_form ($form)
    Theme the menu overview form into a table.
  • theme_menu_tree ($tree)
    Generate the HTML output for a menu tree.
  • theme_more_help_link ($url)
    Returns code that emits the 'more help'-link.
  • theme_more_link ($url, $title)
    Returns code that emits the 'more' link used on blocks.
  • theme_node_add_list ($content)
    Display the list of available node types for node creation.
  • theme_node_admin_nodes ($form)
    Theme node administration overview.
  • theme_node_filter_form ($form)
    Theme node administration filter form.
  • theme_node_filters ($form)
    Theme node administration filter selector.
  • theme_node_form ($form)
    Present a node submission form.
  • theme_node_list ($items, $title=NULL)
    Format a listing of links to nodes.
  • theme_node_log_message ($log)
    Theme a log message.
  • theme_node_preview ($node)
    Display a node preview for display during node creation and editing.
  • theme_node_search_admin ($form)
    Theme the content ranking part of the search settings admin page.
  • theme_node_submitted ($node)
    Format the "Submitted by username on date/time" for each node.
  • theme_pager ($tags=array(), $limit=10, $element=0, $parameters=array(), $quantity=9)
    Format a query pager.
  • theme_password ($element)
    Format a password field.
  • theme_password_confirm ($element)
    Format a password_confirm item.
  • theme_placeholder ($text)
    Formats text for emphasized display in a placeholder inside a sentence.
  • theme_poll_choices ($form)
    Theme the admin poll form for choices.
  • theme_profile_admin_overview ($form)
    Theme the profile field overview into a drag and drop enabled table.
  • theme_progress_bar ($percent, $message)
    Return a themed progress bar.
  • theme_radio ($element)
    Format a radio button.
  • theme_radios ($element)
    Format a set of radio buttons.
  • theme_select ($element)
    Format a dropdown menu or scrolling selection box.
  • theme_status_messages ($display=NULL)
    Return a themed set of status and/or error messages.
  • theme_status_report (&$requirements)
    Theme requirements status report.
  • theme_submenu ($links)
    Return a themed submenu, typically displayed under the tabs.
  • theme_submit ($element)
    Theme a form submit button.
  • theme_system_admin_by_module ($menu_items)
    Theme output of the dashboard page.
  • theme_system_modules ($form)
    Theme callback for the modules form.
  • theme_system_modules_uninstall ($form)
    Themes a table of currently disabled modules.
  • theme_system_powered_by ($image_path)
    Format the Powered by Drupal text.
  • theme_system_theme_select_form ($form)
    Theme the theme select form.
  • theme_system_themes_form ($form)
    Theme function for the system themes form.
  • theme_table ($header, $rows, $attributes=array(), $caption=NULL)
    Return a themed table.
  • theme_table_select_header_cell ()
    Returns a header cell for tables that have a select all functionality.
  • theme_tablesort_indicator ($style)
    Return a themed sort icon.
  • theme_task_list ($items, $active=NULL)
    Return a themed list of maintenance tasks to perform.
  • theme_taxonomy_overview_terms ($form)
    Theme the terms overview as a sortable list of terms.
  • theme_taxonomy_overview_vocabularies ($form)
    Theme the vocabulary overview as a sortable list of vocabularies.
  • theme_taxonomy_term_page ($tids, $result)
    Render a taxonomy term page HTML output.
  • theme_taxonomy_term_select ($element)
    Format the selection field for choosing terms (by deafult the default selection field is used).
  • theme_textarea ($element)
    Format a textarea.
  • theme_textfield ($element)
    Format a textfield.
  • theme_token ($element)
    Format a form token.
  • theme_trigger_display ($element)
    Display actions assigned to this hook-op combination in a table.
  • theme_update_report ($data)
    Theme project status report.
  • theme_update_version ($version, $tag, $class)
    Theme the version display of a project.
  • theme_upload_attachments ($files)
    Displays file attachments in table.
  • theme_upload_form_current (&$form)
    Theme the attachments list.
  • theme_upload_form_new ($form)
    Theme the attachment form.
  • theme_user_admin_account ($form)
    Theme user administration overview.
  • theme_user_admin_new_role ($form)
    Theme the new-role form.
  • theme_user_admin_perm ($form)
    Theme the administer permissions page.
  • theme_user_filter_form ($form)
    Theme user administration filter form.
  • theme_user_filters ($form)
    Theme user administration filter selector.
  • theme_user_list ($users, $title=NULL)
    Make a list of users.
  • theme_user_signature ($signature)
    Theme output of user signature.
  • theme_username ($object)
    Format a username.
  • theme_xml_icon ($url)
    Return code that emits an XML icon.

Function Documentation

phptemplate_menu_local_tasks ( )

Returns the rendered local tasks.

The default implementation renders them as tabs. Overridden to split the secondary tasks.

Definition at line 70 of file template.php.

References menu_primary_local_tasks().

theme_admin_block ( $ block )

This function formats an administrative block for display.

Parameters:
$block An array containing information about the block. It should include a 'title', a 'description' and a formatted 'content'.

Definition at line 1821 of file system.admin.inc.

References $output, and content.

theme_admin_block_content ( $ content )

This function formats the content of an administrative block.

Parameters:
$block An array containing information about the block. It should include a 'title', a 'description' and a formatted 'content'.

Definition at line 1851 of file system.admin.inc.

References $content, $item, $output, l(), and system_admin_compact_mode().

theme_admin_page ( $ blocks )

This function formats an administrative page for viewing.

Parameters:
$blocks An array of blocks to display. Each array should include a 'title', a 'description', a formatted 'content' and a 'position' which will control which container it will be in. This is usually 'left' or 'right'.

Definition at line 1884 of file system.admin.inc.

References $id, $output, l(), system_admin_compact_mode(), t(), and theme().

theme_aggregator_block_item | ( | $ | item,
 |  | $ | feed = 0
 | ) |  |

Format an individual feed item for display in the block.

Parameters:
$item | The item to be displayed.
$feed | Not used.
Returns:
The item HTML.

Definition at line 886 of file aggregator.module.

References $image, $item, $output, $user, check_plain(), check_url(), l(), link, module_exists(), t(), theme(), and user_access().

theme_aggregator_categorize_items ( $ form )

Theme the page list form for assigning categories.

Parameters:
$form An associative array containing the structure of the form.
Returns:
The output HTML.

Definition at line 215 of file aggregator.pages.inc.

References $output, drupal_render(), element_children(), t(), and theme().

theme_aggregator_page_opml ( $ feeds )

Theme the OPML feed output.

Parameters:
$feeds An array of the feeds to theme.

Definition at line 418 of file aggregator.pages.inc.

References $output, check_plain(), check_url(), drupal_set_header(), url(), and variable_get().

theme_aggregator_page_rss | ( | $ | feeds,
 |  | $ | category = NULL
 | ) |  |

Theme the RSS output.

Parameters:
$feeds | An array of the feeds to theme.
$category | A common category, if any, for all the feeds.

Definition at line 354 of file aggregator.pages.inc.

References $items, $output, $site_name, $url, check_url(), drupal_set_header(), format_rss_channel(), format_rss_item(), link, node_teaser(), t(), url(), and variable_get().

theme_blocks ( $ region )

Return a set of blocks available for the current user.

Parameters:
$region Which set of blocks to retrieve.
Returns:
A string containing the themed blocks for this region.

Definition at line 1518 of file theme.inc.

References $output, block_list(), drupal_get_content(), and theme().

Referenced by chameleon_page().

theme_book_admin_table ( $ form )

Theme function for the book administration page form.

See also:
book_admin_table()

Definition at line 192 of file book.admin.inc.

References $header, $nid, $row, drupal_add_tabledrag(), drupal_get_destination(), drupal_render(), element_children(), l(), t(), theme(), and user_access().

theme_book_title_link ( $ link )

Generate the HTML output for a link to a book title when used as a block title.

Definition at line 245 of file book.module.

References l().

theme_box | ( | $ | title,
 |  | $ | content,
 |  | $ | region = 'main'
 | ) |  |

Return a themed box.

Parameters:
$title | The subject of the box.
$content | The content of the box.
$region | The region in which the box is displayed.
Returns:
A string containing the box output.

Definition at line 1358 of file theme.inc.

References $content, $output, and $title.

theme_breadcrumb ( $ breadcrumb )

Return a themed breadcrumb trail.

Parameters:
$breadcrumb An array containing the breadcrumb links.
Returns:
a string containing the breadcrumb output.

Definition at line 1168 of file theme.inc.

theme_button ( $ element )

Theme a form button.

Definition at line 1914 of file form.inc.

References $element, check_plain(), and drupal_attributes().

theme_checkbox ( $ element )

Format a checkbox.

Parameters:
$element An associative array containing the properties of the element. Properties used: title, value, return_value, description, required
Returns:
A themed HTML string representing the checkbox.

Definition at line 1841 of file form.inc.

References $element, _form_set_class(), drupal_attributes(), and theme().

theme_checkboxes ( $ element )

Format a set of checkboxes.

Parameters:
$element An associative array containing the properties of the element.
Returns:
A themed HTML string representing the checkbox set.

Definition at line 1869 of file form.inc.

References $element, and theme().

theme_closure ( $ main = 0 )

Execute hook_footer() which is run at the end of the page right before the close of the body tag.

Parameters:
$main (optional) Whether the current page is the front page of the site.
Returns:
A string containing the results of the hook_footer() calls.

Definition at line 1505 of file theme.inc.

References drupal_get_js(), and module_invoke_all().

Referenced by chameleon_page().

theme_color_scheme_form ( $ form )

Theme color form.

@

Definition at line 208 of file color.module.

References $name, $output, $theme, base_path(), drupal_add_css(), drupal_get_path(), drupal_render(), element_children(), and t().

theme_comment_admin_overview ( $ form )

Theme the comment admin form.

Parameters:
$form An associative array containing the structure of the form.

Definition at line 127 of file comment.admin.inc.

References $output, $row, drupal_render(), element_children(), t(), and theme().

theme_comment_block ( )

Returns a formatted list of recent comments to be displayed in the comment block.

Returns:
The comment list HTML.

Definition at line 392 of file comment.module.

References $items, comment_get_recent(), format_interval(), l(), nid, subject, t(), and theme().

theme_comment_controls ( $ form )

Theme comment controls box where the user can change the default display mode and display order of comments.

Parameters:
$form The form structure.

Definition at line 1636 of file comment.module.

References $output, drupal_render(), t(), and theme().

theme_comment_flat_collapsed | ( | $ | comment,
 |  | $ | node
 | ) |  |

Theme comment flat collapsed view.

Parameters:
$comment | The comment to be themed.
$node | The comment node.

Definition at line 1721 of file comment.module.

References theme().

theme_comment_flat_expanded | ( | $ | comment,
 |  | $ | node
 | ) |  |

Theme comment flat expanded view.

Parameters:
$comment | The comment to be themed.
$node | The comment node.

Definition at line 1734 of file comment.module.

References module_invoke_all(), and theme().

theme_comment_post_forbidden ( $ node )

Theme a "you can't post comments" notice.

Parameters:
$node The comment node.

Definition at line 1771 of file comment.module.

References $user, drupal_urlencode(), t(), url(), user_roles(), and variable_get().

theme_comment_submitted ( $ comment )

Theme a "Submitted by ..." notice.

Parameters:
$comment The comment.

Definition at line 1825 of file comment.module.

References format_date(), t(), and theme().

theme_comment_thread_collapsed | ( | $ | comment,
 |  | $ | node
 | ) |  |

Theme comment thread collapsed view.

Parameters:
$comment | The comment to be themed.
$node | The comment node.

Definition at line 1747 of file comment.module.

References theme().

theme_comment_thread_expanded | ( | $ | comment,
 |  | $ | node
 | ) |  |

Theme comment thread expanded view.

Parameters:
$comment | The comment to be themed.
$node | The comment node.

Definition at line 1760 of file comment.module.

References module_invoke_all(), and theme().

theme_comment_view | ( | $ | comment,
 |  | $ | node,
 |  | $ | links = array(),
 |  | $ | visible = TRUE
 | ) |  |

Theme a single comment block.

Parameters:
$comment | The comment object.
$node | The comment node.
$links | An associative array containing control links.
$visible | Switches between folded/unfolded view.

Definition at line 1558 of file comment.module.

References $links, $output, check_markup(), comment_invoke_comment(), nid, node_mark(), and theme().

theme_date ( $ element )

Format a date selection element.

Parameters:
$element An associative array containing the properties of the element. Properties used: title, value, options, description, required and attributes.
Returns:
A themed HTML string representing the date selection boxes.

Definition at line 1626 of file form.inc.

References $element, and theme().

theme_dblog_filters ( $ form )

Theme dblog administration filter selector.

Definition at line 151 of file dblog.module.

References $output, drupal_render(), and element_children().

theme_feed_icon | ( | $ | url,
 |  | $ | title
 | ) |  |

Return code that emits an feed icon.

Parameters:
$url | The url of the feed.
$title | A descriptive title of the feed.

Definition at line 1478 of file theme.inc.

References $image, $title, $url, check_url(), t(), and theme().

theme_fieldset ( $ element )

Format a group of form items.

Parameters:
$element An associative array containing the properties of the element. Properties used: attributes, title, value, description, children, collapsible, collapsed
Returns:
A themed HTML string representing the form item group.

Definition at line 1478 of file form.inc.

References $element, drupal_add_js(), and drupal_attributes().

theme_file ( $ element )

Format a file upload field.

Parameters:
$title | The label for the file upload field.
$name | The internal name used to refer to the field.
$size | A measure of the visible size of the field (passed directly to HTML).
$description | Explanatory text to display after the form item.
$required | Whether the user must upload a file to the field.
Returns:
A themed HTML string representing the field.
For assistance with handling the uploaded file correctly, see the API provided by file.inc.

Definition at line 2134 of file form.inc.

References $element, _form_set_class(), drupal_attributes(), and theme().

theme_filter_admin_order ( $ form )

Theme filter order configuration form.

Definition at line 361 of file filter.admin.inc.

References $header, $id, $output, drupal_add_tabledrag(), drupal_render(), element_children(), t(), and theme().

theme_filter_admin_overview ( $ form )

Theme the admin overview form.

Definition at line 55 of file filter.admin.inc.

References $element, $header, $name, $output, check_plain(), drupal_render(), t(), and theme().

theme_filter_tips | ( | $ | tips,
 |  | $ | long = FALSE,
 |  | $ | extra = ''
 | ) |  |

Format a set of filter tips.

Definition at line 30 of file filter.pages.inc.

References $name, $output, and t().

theme_filter_tips_more_info ( )

Format a link to the more extensive filter tips.

Definition at line 582 of file filter.module.

References l(), and t().

theme_form ( $ element )

Format a form.

Parameters:
$element An associative array containing the properties of the element. Properties used: action, method, attributes, children
Returns:
A themed HTML string representing the form.

Definition at line 2022 of file form.inc.

References $element, check_url(), and drupal_attributes().

theme_form_element | ( | $ | element,
 |  | $ | value
 | ) |  |

Return a themed form element.

Parameters:
element | An associative array containing the properties of the element. Properties used: title, description, id, required
$value | The form element's data.
Returns:
A string representing the form element.

Definition at line 2152 of file form.inc.

References $element, $output, $title, filter_xss_admin(), and get_t().

theme_help ( )

Return a themed help message.

Returns:
a string containing the helptext for the current page.

Definition at line 1179 of file theme.inc.

References menu_get_active_help().

theme_hidden ( $ element )

Format a hidden form field.

Parameters:
$element An associative array containing the properties of the element. Properties used: value, edit
Returns:
A themed HTML string representing the hidden form field.

Definition at line 1960 of file form.inc.

References $element, check_plain(), and drupal_attributes().

theme_image | ( | $ | path,
 |  | $ | alt = '',
 |  | $ | title = '',
 |  | $ | attributes = NULL,
 |  | $ | getsize = TRUE
 | ) |  |

Return a themed image.

Parameters:
$path | Either the path of the image file (relative to base_path()) or a full URL.
$alt | The alternative text for text-based browsers.
$title | The title text is displayed when the image is hovered in some popular browsers.
$attributes | Associative array of attributes to be placed in the img tag.
$getsize | If set to TRUE, the image's dimension are fetched and added as width/height attributes.
Returns:
A string containing the image tag.

Definition at line 1153 of file theme.inc.

References $attributes, $title, $type, $url, base_path(), check_plain(), check_url(), drupal_attributes(), and url().

theme_image_button ( $ element )

Theme a form image button.

Definition at line 1931 of file form.inc.

References $element, base_path(), check_plain(), and drupal_attributes().

theme_indentation ( $ size = 1 )

Create a standard indentation div.

Used for drag and drop tables.

Parameters:
$size Optional. The number of indentations to create.
Returns:
A string containing indentations.

Definition at line 1610 of file theme.inc.

References $output.

theme_item ( $ element )

Format a form item.

Parameters:
$element An associative array containing the properties of the element. Properties used: title, value, description, required, error
Returns:
A themed HTML string representing the form item.

Definition at line 1826 of file form.inc.

References $element, and theme().

theme_item_list | ( | $ | items = array(),
 |  | $ | title = NULL,
 |  | $ | type = 'ul',
 |  | $ | attributes = NULL
 | ) |  |

Return a themed list of items.

Parameters:
$items | An array of items to be displayed in the list. If an item is a string, then it is used as is. If an item is an array, then the "data" element of the array is used as the contents of the list item. If an item is an array with a "children" element, those children are displayed in a nested list. All other elements are treated as attributes of the list item element.
$title | The title of the list.
$attributes | The attributes applied to the list element.
$type | The type of list to return (e.g. "ul", "ol")
Returns:
A string containing the list output.

Definition at line 1403 of file theme.inc.

References $attributes, $children, $item, $items, $output, $title, $type, $value, and drupal_attributes().

theme_links | ( | $ | links,
 |  | $ | attributes = array('class' => 'links')
 | ) |  |

Return a themed set of links.

Parameters:
$links | A keyed array of links to be themed.
$attributes | A keyed array of attributes
Returns:
A string containing an unordered list of links.

Definition at line 1087 of file theme.inc.

References $attributes, $links, $output, check_plain(), drupal_attributes(), and l().

theme_locale_languages_overview_form ( $ form )

Theme the language overview form.

Definition at line 69 of file locale.inc.

References $element, $header, $output, check_plain(), drupal_render(), element_child(), l(), language, language_default(), t(), and theme().

theme_mark ( $ type = MARK_NEW )

Return a themed marker, useful for marking new or updated content.

Parameters:
$type Number representing the marker type to display
See also:
MARK_NEW, MARK_UPDATED, MARK_READ
Returns:
A string containing the marker.

Definition at line 1373 of file theme.inc.

References $type, $user, and t().

theme_markup ( $ element )

Format HTML markup for use in forms.

This is used in more advanced forms, such as theme selection and filter format.

Parameters:
$element An associative array containing the properties of the element. Properties used: value, children.
Returns:
A themed HTML string representing the HTML markup.

Definition at line 2075 of file form.inc.

References $element.

theme_menu_item | ( | $ | link,
 |  | $ | has_children,
 |  | $ | menu = '',
 |  | $ | in_active_trail = FALSE,
 |  | $ | extra_class = NULL
 | ) |  |

Generate the HTML output for a menu item and submenu.

Definition at line 1095 of file menu.inc.

theme_menu_item_link ( $ link )

Generate the HTML output for a single menu link.

Definition at line 1073 of file menu.inc.

References l().

theme_menu_local_task | ( | $ | link,
 |  | $ | active = FALSE
 | ) |  |

Generate the HTML output for a single local task link.

Definition at line 1111 of file menu.inc.

theme_menu_local_tasks ( )

Returns the rendered local tasks.

The default implementation renders them as tabs.

Definition at line 1395 of file menu.inc.

References $output, menu_primary_local_tasks(), and menu_secondary_local_tasks().

theme_menu_overview_form ( $ form )

Theme the menu overview form into a table.

Definition at line 170 of file menu.admin.inc.

References $element, $header, $op, $output, $row, drupal_add_tabledrag(), drupal_render(), element_children(), t(), and theme().

theme_menu_tree ( $ tree )

Generate the HTML output for a menu tree.

Definition at line 1086 of file menu.inc.

theme_more_help_link ( $ url )

Returns code that emits the 'more help'-link.

Definition at line 1451 of file theme.inc.

References $url, check_url(), and t().

theme_more_link | ( | $ | url,
 |  | $ | title
 | ) |  |

Returns code that emits the 'more' link used on blocks.

Parameters:
$url | The url of the main page
$title | A descriptive verb for the link, like 'Read more'

Definition at line 1492 of file theme.inc.

References $title, $url, check_url(), and t().

theme_node_add_list ( $ content )

Display the list of available node types for node creation.

Definition at line 29 of file node.pages.inc.

References $content, $item, $output, filter_xss_admin(), and l().

theme_node_admin_nodes ( $ form )

Theme node administration overview.

Definition at line 560 of file node.admin.inc.

References $header, $output, $row, drupal_render(), element_children(), t(), and theme().

theme_node_filter_form ( $ form )

Theme node administration filter form.

Definition at line 271 of file node.admin.inc.

References $output, and drupal_render().

theme_node_filters ( $ form )

Theme node administration filter selector.

Definition at line 285 of file node.admin.inc.

References $output, drupal_render(), element_children(), and t().

theme_node_form ( $ form )

Present a node submission form.

Definition at line 323 of file node.pages.inc.

References $output, and drupal_render().

theme_node_list | ( | $ | items,
 |  | $ | title = NULL
 | ) |  |

Format a listing of links to nodes.

Definition at line 150 of file node.module.

References $items, $title, and theme().

theme_node_log_message ( $ log )

Theme a log message.

Definition at line 1115 of file node.module.

References t().

theme_node_preview ( $ node )

Display a node preview for display during node creation and editing.

Parameters:
$node The node object which is being previewed.

Definition at line 415 of file node.pages.inc.

References $output, drupal_clone(), drupal_set_message(), node_view(), and t().

theme_node_search_admin ( $ form )

Theme the content ranking part of the search settings admin page.

Definition at line 1311 of file node.module.

References $header, $output, $row, drupal_render(), element_children(), t(), and theme().

theme_node_submitted ( $ node )

Format the "Submitted by username on date/time" for each node.

Definition at line 2449 of file node.module.

References format_date(), t(), and theme().

theme_pager | ( | $ | tags = array(),
 |  | $ | limit = 10,
 |  | $ | element = 0,
 |  | $ | parameters = array(),
 |  | $ | quantity = 9
 | ) |  |

Format a query pager.

Menu callbacks that display paged query results should call theme('pager') to retrieve a pager control so that users can view other results. Format a list of nearby pages with additional query results.

Parameters:
$tags | An array of labels for the controls in the pager.
$limit | The number of query results to display per page.
$element | An optional integer to distinguish between multiple pagers on one page.
$parameters | An associative array of query string parameters to append to the pager links.
$quantity | The number of pages in the list.
Returns:
An HTML string that generates the query pager.

Definition at line 115 of file pager.inc.

References $element, $items, $pager_page_array, $pager_total, t(), and theme().

theme_pager_first | ( | $ | text,
 |  | $ | limit,
 |  | $ | element = 0,
 |  | $ | parameters = array()
 | ) |  |

Format a "first page" link.

Parameters:
$text | The name (or image) of the link.
$limit | The number of query results to display per page.
$element | An optional integer to distinguish between multiple pagers on one page.
$parameters | An associative array of query string parameters to append to the pager links.
Returns:
An HTML string that generates this piece of the query pager.

Definition at line 241 of file pager.inc.

References $element, $output, $pager_page_array, pager_load_array(), and theme().

theme_pager_last | ( | $ | text,
 |  | $ | limit,
 |  | $ | element = 0,
 |  | $ | parameters = array()
 | ) |  |

Format a "last page" link.

Parameters:
$text | The name (or image) of the link.
$limit | The number of query results to display per page.
$element | An optional integer to distinguish between multiple pagers on one page.
$parameters | An associative array of query string parameters to append to the pager links.
Returns:
An HTML string that generates this piece of the query pager.

Definition at line 346 of file pager.inc.

References $element, $output, $pager_page_array, $pager_total, pager_load_array(), and theme().

theme_pager_link | ( | $ | text,
 |  | $ | page_new,
 |  | $ | element,
 |  | $ | parameters = array(),
 |  | $ | attributes = array()
 | ) |  |

Format a link to a specific query result page.

Parameters:
$page_new | The first result to display on the linked page.
$element | An optional integer to distinguish between multiple pagers on one page.
$parameters | An associative array of query string parameters to append to the pager link.
$attributes | An associative array of HTML attributes to apply to a pager anchor tag.
Returns:
An HTML string that generates the link.

Definition at line 375 of file pager.inc.

References $attributes, $element, drupal_query_string_encode(), l(), pager_get_querystring(), pager_load_array(), and t().

theme_pager_next | ( | $ | text,
 |  | $ | limit,
 |  | $ | element = 0,
 |  | $ | interval = 1,
 |  | $ | parameters = array()
 | ) |  |

Format a "next page" link.

Parameters:
$text | The name (or image) of the link.
$limit | The number of query results to display per page.
$element | An optional integer to distinguish between multiple pagers on one page.
$interval | The number of pages to move forward when the link is clicked.
$parameters | An associative array of query string parameters to append to the pager links.
Returns:
An HTML string that generates this piece of the query pager.

Definition at line 310 of file pager.inc.

References $element, $output, $pager_page_array, $pager_total, pager_load_array(), and theme().

theme_pager_previous | ( | $ | text,
 |  | $ | limit,
 |  | $ | element = 0,
 |  | $ | interval = 1,
 |  | $ | parameters = array()
 | ) |  |

Format a "previous page" link.

Parameters:
$text | The name (or image) of the link.
$limit | The number of query results to display per page.
$element | An optional integer to distinguish between multiple pagers on one page.
$interval | The number of pages to move backward when the link is clicked.
$parameters | An associative array of query string parameters to append to the pager links.
Returns:
An HTML string that generates this piece of the query pager.

Definition at line 271 of file pager.inc.

References $element, $output, $pager_page_array, pager_load_array(), and theme().

theme_password ( $ element )

Format a password field.

Parameters:
$element An associative array containing the properties of the element. Properties used: title, value, description, size, maxlength, required, attributes
Returns:
A themed HTML string representing the form.

Definition at line 2090 of file form.inc.

References $element, $output, _form_set_class(), drupal_attributes(), and theme().

theme_password_confirm ( $ element )

Format a password_confirm item.

Parameters:
$element An associative array containing the properties of the element. Properties used: title, value, id, required, error.
Returns:
A themed HTML string representing the form item.

Definition at line 1558 of file form.inc.

References $element, and theme().

theme_placeholder ( $ text )

Formats text for emphasized display in a placeholder inside a sentence.

Used automatically by t().

Parameters:
$text The text to format (plain-text).
Returns:
The formatted text (html).

Definition at line 1044 of file theme.inc.

References check_plain().

theme_poll_choices ( $ form )

Theme the admin poll form for choices.

Definition at line 670 of file poll.module.

References $output, $row, drupal_add_js(), drupal_render(), element_children(), t(), and theme().

theme_profile_admin_overview ( $ form )

Theme the profile field overview into a drag and drop enabled table.

See also:
profile_admin_overview()

Definition at line 93 of file profile.admin.inc.

References $header, $output, $row, drupal_add_css(), drupal_add_js(), drupal_add_tabledrag(), drupal_get_path(), drupal_render(), element_children(), t(), and theme().

theme_progress_bar | ( | $ | percent,
 |  | $ | message
 | ) |  |

Return a themed progress bar.

Parameters:
$percent | The percentage of the progress.
$message | A string containing information to be displayed.
Returns:
A themed HTML string representing the progress bar.

Definition at line 1592 of file theme.inc.

References $output.

theme_radio ( $ element )

Format a radio button.

Parameters:
$element An associative array containing the properties of the element. Properties used: required, return_value, value, attributes, title, description
Returns:
A themed HTML string representing the form item group.

Definition at line 1506 of file form.inc.

References $element, $output, _form_set_class(), check_plain(), drupal_attributes(), and theme().

theme_radios ( $ element )

Format a set of radio buttons.

Parameters:
$element An associative array containing the properties of the element. Properties used: title, value, options, description, required and attributes.
Returns:
A themed HTML string representing the radio button set.

Definition at line 1532 of file form.inc.

References $element, and theme().

theme_select ( $ element )

Format a dropdown menu or scrolling selection box.

Parameters:
$element An associative array containing the properties of the element. Properties used: title, value, options, description, extra, multiple, required
Returns:
A themed HTML string representing the form element.
It is possible to group options together; to do this, change the format of $options to an associative array in which the keys are group labels, and the values are associative arrays in the normal $options format.

Definition at line 1377 of file form.inc.

References $element, _form_set_class(), drupal_attributes(), form_select_options(), and theme().

theme_status_messages ( $ display = NULL )

Return a themed set of status and/or error messages.

The messages are grouped by type.

Parameters:
$display (optional) Set to 'status' or 'error' to display only messages of that type.
Returns:
A string containing the messages.

Definition at line 1058 of file theme.inc.

References $messages, $output, $type, and drupal_get_messages().

theme_status_report ( &$ requirements )

Theme requirements status report.

Parameters:
$requirements An array of requirements.

Definition at line 1974 of file system.admin.inc.

References $output.

theme_submenu ( $ links )

Return a themed submenu, typically displayed under the tabs.

Parameters:
$links An array of links.

Definition at line 1191 of file theme.inc.

References $links.

theme_submit ( $ element )

Theme a form submit button.

Definition at line 1905 of file form.inc.

References $element, and theme().

theme_system_admin_by_module ( $ menu_items )

Theme output of the dashboard page.

Parameters:
$menu_items An array of modules to be displayed.

Definition at line 1927 of file system.admin.inc.

References $id, $items, $output, t(), and theme().

theme_system_modules ( $ form )

Theme callback for the modules form.

Parameters:
$form An associative array containing the structure of the form.

Definition at line 2011 of file system.admin.inc.

References $header, $output, $row, $status, drupal_render(), module_exists(), t(), and theme().

theme_system_modules_uninstall ( $ form )

Themes a table of currently disabled modules.

Parameters:
$form The form array representing the currently disabled modules.
Returns:
An HTML string representing the table.

Definition at line 2099 of file system.admin.inc.

References $header, $output, drupal_render(), element_children(), t(), and theme().

theme_system_powered_by ( $ image_path )

Format the Powered by Drupal text.

Definition at line 1874 of file system.module.

References $image, l(), t(), and theme().

theme_system_theme_select_form ( $ form )

Theme the theme select form.

Parameters:
$form An associative array containing the structure of the form.

Definition at line 2138 of file system.admin.inc.

References $header, $output, $row, drupal_render(), element_children(), t(), and theme().

theme_system_themes_form ( $ form )

Theme function for the system themes form.

Parameters:
$form An associative array containing the structure of the form.

Definition at line 2161 of file system.admin.inc.

References $header, $output, $row, $status, $theme, drupal_render(), element_children(), t(), and theme().

theme_table | ( | $ | header,
 |  | $ | rows,
 |  | $ | attributes = array(),
 |  | $ | caption = NULL
 | ) |  |

Return a themed table.

Parameters:
$header An array containing the table headers. Each element of the array can be either a localized string or an associative array with the following keys:
  • "data": The localized title of the table column.
  • "field": The database field represented in the table column (required if user is to be able to sort on this column).
  • "sort": A default sort order for this column ("asc" or "desc").
  • Any HTML attributes, such as "colspan", to apply to the column header cell.
$rows An array of table rows. Every row is an array of cells, or an associative array with the following keys:
  • "data": an array of cells
  • Any HTML attributes, such as "class", to apply to the table row.
Each cell can be either a string or an associative array with the following keys:
  • "data": The string to display in the table cell.
  • "header": Indicates this cell is a header.
  • Any HTML attributes, such as "colspan", to apply to the table cell.

Here's an example for $rows:

 *   $rows = array(
 *     // Simple row
 *     array(
 *       'Cell 1', 'Cell 2', 'Cell 3'
 *     ),
 *     // Row with attributes on the row and some of its cells.
 *     array(
 *       'data' => array('Cell 1', array('data' => 'Cell 2', 'colspan' => 2)), 'class' => 'funky'
 *     )
 *   );
 *

Parameters:
$attributes | An array of HTML attributes to apply to the table tag.
$caption | A localized string to use for the tag.
Returns:
An HTML string representing the table.

Definition at line 1238 of file theme.inc.

References $attributes, $header, $output, $row, $value, _theme_table_cell(), drupal_add_js(), drupal_attributes(), tablesort_cell(), tablesort_header(), and tablesort_init().

theme_table_select_header_cell ( )

Returns a header cell for tables that have a select all functionality.

Definition at line 1323 of file theme.inc.

References drupal_add_js().

theme_tablesort_indicator ( $ style )

Return a themed sort icon.

Parameters:
$style Set to either asc or desc. This sets which icon to show.
Returns:
A themed sort icon.

Definition at line 1337 of file theme.inc.

References t(), and theme().

theme_task_list | ( | $ | items,
 |  | $ | active = NULL
 | ) |  |

Return a themed list of maintenance tasks to perform.

Definition at line 84 of file theme.maintenance.inc.

References $item, $items, and $output.

Referenced by install_task_list().

theme_taxonomy_overview_terms ( $ form )

Theme the terms overview as a sortable list of terms.

See also:
taxonomy_overview_terms()

Definition at line 540 of file taxonomy.admin.inc.

References $header, $output, $row, drupal_add_css(), drupal_add_js(), drupal_add_tabledrag(), drupal_get_path(), drupal_render(), element_children(), form_get_errors(), t(), and theme().

theme_taxonomy_overview_vocabularies ( $ form )

Theme the vocabulary overview as a sortable list of vocabularies.

See also:
taxonomy_overview_vocabularies()

Definition at line 65 of file taxonomy.admin.inc.

References $header, $row, drupal_add_tabledrag(), drupal_render(), element_children(), t(), and theme().

theme_taxonomy_term_page | ( | $ | tids,
 |  | $ | result
 | ) |  |

Render a taxonomy term page HTML output.

Parameters:
$tids | An array of term ids.
$result | A pager_query() result, such as that performed by taxonomy_select_nodes().

Definition at line 88 of file taxonomy.pages.inc.

References $output, $result, drupal_add_css(), drupal_get_path(), filter_xss_admin(), taxonomy_get_term(), and taxonomy_render_nodes().

theme_taxonomy_term_select ( $ element )

Format the selection field for choosing terms (by deafult the default selection field is used).

Definition at line 1052 of file taxonomy.module.

References $element, and theme().

theme_textarea ( $ element )

Format a textarea.

Parameters:
$element An associative array containing the properties of the element. Properties used: title, value, description, rows, cols, required, attributes
Returns:
A themed HTML string representing the textarea.

Definition at line 2039 of file form.inc.

References $element, _form_set_class(), check_plain(), drupal_add_js(), drupal_attributes(), and theme().

theme_textfield ( $ element )

Format a textfield.

Parameters:
$element An associative array containing the properties of the element. Properties used: title, value, description, size, maxlength, required, attributes autocomplete_path
Returns:
A themed HTML string representing the textfield.

Definition at line 1984 of file form.inc.

References $element, $output, _form_set_class(), check_plain(), check_url(), drupal_add_js(), drupal_attributes(), theme(), and url().

theme_token ( $ element )

Format a form token.

Definition at line 1969 of file form.inc.

References $element, and theme().

theme_trigger_display ( $ element )

Display actions assigned to this hook-op combination in a table.

Parameters:
array $element The fieldset including all assigned actions.
Returns:
The rendered form with the table prepended.

Definition at line 234 of file trigger.admin.inc.

References $element, $header, $output, drupal_render(), t(), and theme().

theme_update_report ( $ data )

Theme project status report.

Definition at line 28 of file update.report.inc.

References $header, $output, $row, $value, check_plain(), drupal_add_css(), drupal_get_path(), format_date(), format_interval(), l(), t(), theme(), and variable_get().

theme_update_version | ( | $ | version,
 |  | $ | tag,
 |  | $ | class
 | ) |  |

Theme the version display of a project.

Definition at line 217 of file update.report.inc.

References $links, $output, $tag, format_date(), l(), t(), and theme().

theme_upload_attachments ( $ files )

Displays file attachments in table.

Definition at line 352 of file upload.module.

References $header, file_create_url(), format_size(), l(), t(), and theme().

theme_upload_form_current ( &$ form )

Theme the attachments list.

Definition at line 529 of file upload.module.

References $header, $output, $row, drupal_add_tabledrag(), drupal_render(), element_children(), t(), and theme().

theme_upload_form_new ( $ form )

Theme the attachment form.

Note: required to output prefix/suffix.

Definition at line 556 of file upload.module.

References $output, drupal_add_tabledrag(), and drupal_render().

theme_user_admin_account ( $ form )

Theme user administration overview.

Definition at line 904 of file user.admin.inc.

References $header, $output, drupal_render(), element_children(), t(), and theme().

theme_user_admin_new_role ( $ form )

Theme the new-role form.

Definition at line 949 of file user.admin.inc.

References $header, $name, $output, drupal_render(), l(), t(), theme(), and user_roles().

theme_user_admin_perm ( $ form )

Theme the administer permissions page.

Definition at line 574 of file user.admin.inc.

References $header, $output, $row, drupal_render(), element_children(), t(), theme(), and user_roles().

theme_user_filter_form ( $ form )

Theme user administration filter form.

Definition at line 973 of file user.admin.inc.

References $output, and drupal_render().

theme_user_filters ( $ form )

Theme user administration filter selector.

Definition at line 986 of file user.admin.inc.

References $output, drupal_render(), element_children(), and t().

theme_user_list | ( | $ | users,
 |  | $ | title = NULL
 | ) |  |

Make a list of users.

Parameters:
$users | An array with user objects. Should contain at least the name and uid.
$title | (optional) Title to pass on to theme_item_list().

Definition at line 836 of file user.module.

References $items, $title, $user, and theme().

theme_user_signature ( $ signature )

Theme output of user signature.

Definition at line 2026 of file user.module.

References $output.

theme_username ( $ object )

Format a username.

Parameters:
$object The user object to format, usually returned from user_load().
Returns:
A string containing an HTML link to the user's page if the passed object suggests that this is a site user. Otherwise, only the username is returned.

Definition at line 1543 of file theme.inc.

References $name, $output, check_plain(), drupal_strlen(), drupal_substr(), l(), name, t(), user_access(), and variable_get().

theme_xml_icon ( $ url )

Return code that emits an XML icon.

For most use cases, this function has been superseded by theme_feed_icon().

See also:
theme_feed_icon()
Parameters:
$url The url of the feed.

Definition at line 1464 of file theme.inc.

References $image, $url, check_url(), t(), and theme().

Generated on Tue Feb 12 15:30:51 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Example batch definitions

Example batch definitions

Detailed Description

Definitions of the batches used in this module.

Functions

  • batch_example_batch_1 ()
    Batch 1 : Load 100 times the node with the lowest nid.
  • batch_example_batch_2 ()
    Batch 2 : load all nodes 5 by 5, 20 times (Multipart operation).
  • batch_example_finished ($success, $results, $operations)
    Batch 'finished' callback used by both batch 1 and batch 2.
  • batch_example_op_1 ($nid, &$context)
    Batch operation for batch 1 : lode a node.
  • batch_example_op_2 (&$context)
    Batch operation for batch 2 : load all nodes, 5 by five This is a multipart operation, using the.

Function Documentation

batch_example_batch_1 ( )

Batch 1 : Load 100 times the node with the lowest nid.

Definition at line 157 of file batch_example.module.

References $nid, db_query_range(), and db_result().

Referenced by batch_example_multistep_form_submit(), and batch_example_page().

batch_example_batch_2 ( )

Batch 2 : load all nodes 5 by 5, 20 times (Multipart operation).

Definition at line 187 of file batch_example.module.

References t().

Referenced by batch_example_multistep_form_submit().

batch_example_finished | ( | $ | success,
 |  | $ | results,
 |  | $ | operations
 | ) |  |

Batch 'finished' callback used by both batch 1 and batch 2.

Definition at line 248 of file batch_example.module.

References $results, and drupal_set_message().

batch_example_op_1 | ( | $ | nid,
 |  | &$ | context
 | ) |  |

Batch operation for batch 1 : lode a node.

..

Definition at line 174 of file batch_example.module.

References $nid, and node_load().

batch_example_op_2 ( &$ context )

Batch operation for batch 2 : load all nodes, 5 by five This is a multipart operation, using the.

Definition at line 208 of file batch_example.module.

References $result, $row, db_fetch_array(), db_query(), db_query_range(), db_result(), and node_load().

Generated on Tue Feb 12 15:30:49 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Extra updates for 5.x

Extra updates for 5.x

Functions

  • system_update_1022 ()
    Add index on users created column.

Function Documentation

system_update_1022 ( )

Add index on users created column.

Definition at line 1108 of file system.install.

References db_add_index(), and variable_set().

Generated on Tue Feb 12 15:30:51 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: File interface

File interface

Detailed Description

Common file handling functions.

Enumerations

  • enum FILE_CREATE_DIRECTORY
  • enum FILE_DOWNLOADS_PRIVATE
  • enum FILE_DOWNLOADS_PUBLIC
  • enum FILE_EXISTS_ERROR
  • enum FILE_EXISTS_RENAME
  • enum FILE_EXISTS_REPLACE
  • enum FILE_MODIFY_PERMISSIONS
  • enum FILE_STATUS_PERMANENT
  • enum FILE_STATUS_TEMPORARY
    A files status can be one of two values: temporary or permanent. More...

Functions

  • file_check_directory (&$directory, $mode=0, $form_item=NULL)
    Check that the directory exists and is writable.
  • file_check_location ($source, $directory= '')
    Check if a file is really located inside $directory.
  • file_check_path (&$path)
    Checks path to see if it is a directory, or a dir/file.
  • file_copy (&$source, $dest=0, $replace=FILE_EXISTS_RENAME)
    Copies a file to a new location.
  • file_create_filename ($basename, $directory)
    Create a full file path from a directory and filename.
  • file_create_path ($dest=0)
    Make sure the destination is a complete path and resides in the file system directory, if it is not prepend the file system directory.
  • file_create_url ($path)
    Create the download path to a file.
  • file_delete ($path)
    Delete a file.
  • file_destination ($destination, $replace)
    Determines the destination path for a file depending on how replacement of existing files should be handled.
  • file_directory_path ()
    Determine the default 'files' directory.
  • file_directory_temp ()
    Determine the default temporary directory.
  • file_download ()
    Call modules that implement hook_file_download() to find out if a file is accessible and what headers it should be transferred with.
  • file_move (&$source, $dest=0, $replace=FILE_EXISTS_RENAME)
    Moves a file to a new location.
  • file_munge_filename ($filename, $extensions, $alerts=TRUE)
    Munge the filename as needed for security purposes.
  • file_save_data ($data, $dest, $replace=FILE_EXISTS_RENAME)
    Save a string to the specified destination.
  • file_save_upload ($source, $validators=array(), $dest=FALSE, $replace=FILE_EXISTS_RENAME)
    Saves a file upload to a new location.
  • file_scan_directory ($dir, $mask, $nomask=array('.', '..', 'CVS'), $callback=0, $recurse=TRUE, $key= 'filename', $min_depth=0, $depth=0)
    Finds all files that match a given mask in a given directory.
  • file_set_status (&$file, $status)
    Set the status of a file.
  • file_space_used ($uid=NULL)
    Determine total disk space used by a single user or the whole filesystem.
  • file_transfer ($source, $headers)
    Transfer file using http to client.
  • file_unmunge_filename ($filename)
    Undo the effect of upload_munge_filename().
  • file_upload_max_size ()
    Determine the maximum file upload size by querying the PHP settings.
  • file_validate_extensions ($file, $extensions)
    Check that the filename ends with an allowed extension.
  • file_validate_image_resolution (&$file, $maximum_dimensions=0, $minimum_dimensions=0)
    If the file is an image verify that its dimensions are within the specified maximum and minimum dimensions.
  • file_validate_is_image (&$file)
    Check that the file is recognized by image_get_info() as an image.
  • file_validate_name_length ($file)
    Check for files with names longer than we can store in the database.
  • file_validate_size ($file, $file_limit=0, $user_limit=0)
    Check that the file's size is below certain limits.

Enumeration Type Documentation

enum FILE_CREATE_DIRECTORY

Definition at line 17 of file file.inc.

enum FILE_DOWNLOADS_PRIVATE

Definition at line 16 of file file.inc.

enum FILE_DOWNLOADS_PUBLIC

Definition at line 15 of file file.inc.

enum FILE_EXISTS_ERROR

Definition at line 21 of file file.inc.

enum FILE_EXISTS_RENAME

Definition at line 19 of file file.inc.

enum FILE_EXISTS_REPLACE

Definition at line 20 of file file.inc.

enum FILE_MODIFY_PERMISSIONS

Definition at line 18 of file file.inc.

enum FILE_STATUS_PERMANENT

Definition at line 33 of file file.inc.

enum FILE_STATUS_TEMPORARY

A files status can be one of two values: temporary or permanent.

The status for each file Drupal manages is stored in the {files} tables. If the status is temporary Drupal's file garbage collection will delete the file and remove it from the files table after a set period of time.

If you wish to add custom statuses for use by contrib modules please expand as binary flags and consider the first 8 bits reserved. (0,1,2,4,8,16,32,64,128)

Definition at line 32 of file file.inc.

Function Documentation

file_check_directory | ( | &$ | directory,
 |  | $ | mode = 0,
 |  | $ | form_item = NULL
 | ) |  |

Check that the directory exists and is writable.

Directories need to have execute permissions to be considered a directory by FTP servers, etc.

Parameters:
$directory | A string containing the name of a directory path.
$mode | A Boolean value to indicate if the directory should be created if it does not exist or made writable if it is read-only.
$form_item | An optional string containing the name of a form item that any errors will be attached to. This is useful for settings forms that require the user to specify a writable directory. If it can't be made to work, a form error will be set preventing them from saving the settings.
Returns:
FALSE when directory not found, or TRUE when directory exists.

Definition at line 98 of file file.inc.

References check_plain(), drupal_set_message(), file_directory_path(), file_directory_temp(), form_set_error(), t(), and watchdog().

Referenced by _locale_rebuild_js(), color_scheme_form_submit(), drupal_build_css_cache(), drupal_build_js_cache(), file_check_path(), system_check_directory(), system_theme_settings(), upload_form_alter(), and user_admin_settings().

file_check_location | ( | $ | source,
 |  | $ | directory = ''
 | ) |  |

Check if a file is really located inside $directory.

Should be used to make sure a file specified is really located within the directory to prevent exploits.

   // Returns FALSE:
   file_check_location('/www/example.com/files/../../../etc/passwd', '/www/example.com/files');

Parameters:
$source | A string set to the file to check.
$directory | A string where the file should be located.
Returns:
0 for invalid path or the real path of the source.

Definition at line 181 of file file.inc.

Referenced by file_create_path(), and fileupload_view().

file_check_path ( &$ path )

Checks path to see if it is a directory, or a dir/file.

Parameters:
$path A string containing a file path. This will be set to the directory's path.
Returns:
If the directory is not in a Drupal writable directory, FALSE is returned. Otherwise, the base name of the path is returned.

Definition at line 151 of file file.inc.

References file_check_directory().

Referenced by file_copy(), and file_save_upload().

file_copy | ( | &$ | source,
 |  | $ | dest = 0,
 |  | $ | replace = FILE_EXISTS_RENAME
 | ) |  |

Copies a file to a new location.

This is a powerful function that in many ways performs like an advanced version of copy().

  • Checks if $source and $dest are valid and readable/writable.
  • Performs a file copy if $source is not equal to $dest.
  • If file already exists in $dest either the call will error out, replace the file or rename the file based on the $replace parameter.

Parameters:
$source | A string specifying the file location of the original file. This parameter will contain the resulting destination filename in case of success.
$dest | A string containing the directory $source should be copied to. If this value is omitted, Drupal's 'files' directory will be used.
$replace Replace behavior when the destination file already exists.
  • FILE_EXISTS_REPLACE - Replace the existing file
  • FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique
  • FILE_EXISTS_ERROR - Do nothing and return FALSE.
Returns:
True for success, FALSE for failure.

Definition at line 216 of file file.inc.

References drupal_set_message(), file_check_path(), file_create_path(), file_destination(), t(), and watchdog().

Referenced by color_scheme_form_submit(), file_move(), system_theme_settings(), and user_validate_picture().

file_create_filename | ( | $ | basename,
 |  | $ | directory
 | ) |  |

Create a full file path from a directory and filename.

If a file with the specified name already exists, an alternative will be used.

Parameters:
$basename | string filename
$directory | string directory
Returns:

Definition at line 405 of file file.inc.

References $name.

Referenced by file_destination().

file_create_path ( $ dest = 0 )

Make sure the destination is a complete path and resides in the file system directory, if it is not prepend the file system directory.

Parameters:
$dest A string containing the path to verify. If this value is omitted, Drupal's 'files' directory will be used.
Returns:
A string containing the path to file, with file system directory appended if necessary, or FALSE if the path is invalid (i.e. outside the configured 'files' or temp directories).

Definition at line 64 of file file.inc.

References file_check_location(), file_directory_path(), and file_directory_temp().

Referenced by _locale_rebuild_js(), drupal_build_css_cache(), drupal_build_js_cache(), drupal_clear_css_cache(), drupal_clear_js_cache(), file_copy(), file_download(), file_save_upload(), file_transfer(), fileupload_file_download(), hook_file_download(), locale_uninstall(), locale_update_js_files(), upload_file_download(), user_admin_settings(), and user_file_download().

file_create_url ( $ path )

Create the download path to a file.

Parameters:
$path A string containing the path of the file to generate URL for.
Returns:
A string containing a URL that can be used to download the file.

Definition at line 41 of file file.inc.

References file_directory_path(), url(), and variable_get().

Referenced by _upload_form(), blogapi_metaweblog_new_media_object(), fileupload_view(), template_preprocess_user_picture(), theme_upload_attachments(), and upload_nodeapi().

file_delete ( $ path )

Delete a file.

Parameters:
$path A string containing a file path.
Returns:
TRUE for success, FALSE for failure.

Definition at line 433 of file file.inc.

Referenced by _locale_rebuild_js(), _user_edit_submit(), file_move(), fileupload_delete(), fileupload_update(), locale_uninstall(), system_cron(), upload_delete(), upload_delete_revision(), upload_save(), and user_validate_picture().

file_destination | ( | $ | destination,
 |  | $ | replace
 | ) |  |

Determines the destination path for a file depending on how replacement of existing files should be handled.

Parameters:
$destination A string specifying the desired path.
$replace Replace behavior when the destination file already exists.
  • FILE_EXISTS_REPLACE - Replace the existing file
  • FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique
  • FILE_EXISTS_ERROR - Do nothing and return FALSE.
Returns:
The destination file path or FALSE if the file already exists and FILE_EXISTS_ERROR was specified.

Definition at line 295 of file file.inc.

References drupal_set_message(), file_create_filename(), and t().

Referenced by file_copy(), and file_save_upload().

file_directory_path ( )

Determine the default 'files' directory.

Returns:
A string containing the path to Drupal's 'files' directory.

Definition at line 961 of file file.inc.

References conf_path(), and variable_get().

Referenced by color_scheme_form_submit(), drupal_get_css(), drupal_get_js(), file_check_directory(), file_create_path(), file_create_url(), file_directory_temp(), fileupload_submit(), fileupload_view(), hook_submit(), system_file_system_settings(), system_performance_settings(), system_requirements(), system_theme_settings(), upload_form_alter(), upload_node_form_submit(), and user_admin_settings().

file_directory_temp ( )

Determine the default temporary directory.

Returns:
A string containing a temp directory.

Definition at line 920 of file file.inc.

References file_directory_path(), variable_get(), and variable_set().

Referenced by file_check_directory(), file_create_path(), file_save_data(), file_save_upload(), system_file_system_settings(), and upload_form_alter().

file_download ( )

Call modules that implement hook_file_download() to find out if a file is accessible and what headers it should be transferred with.

If a module returns -1 drupal_access_denied() will be returned. If one or more modules returned headers the download will start with the returned headers. If no modules respond drupal_not_found() will be returned.

Definition at line 827 of file file.inc.

References drupal_access_denied(), drupal_not_found(), file_create_path(), file_transfer(), and module_invoke_all().

file_move | ( | &$ | source,
 |  | $ | dest = 0,
 |  | $ | replace = FILE_EXISTS_RENAME
 | ) |  |

Moves a file to a new location.

  • Checks if $source and $dest are valid and readable/writable.
  • Performs a file move if $source is not equal to $dest.
  • If file already exists in $dest either the call will error out, replace the file or rename the file based on the $replace parameter.

Parameters:
$source | A string specifying the file location of the original file. This parameter will contain the resulting destination filename in case of success.
$dest | A string containing the directory $source should be copied to. If this value is omitted, Drupal's 'files' directory will be used.
$replace Replace behavior when the destination file already exists.
  • FILE_EXISTS_REPLACE - Replace the existing file
  • FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique
  • FILE_EXISTS_ERROR - Do nothing and return FALSE.
Returns:
True for success, FALSE for failure.

Definition at line 330 of file file.inc.

References drupal_set_message(), file_copy(), file_delete(), and t().

Referenced by file_save_data().

file_munge_filename | ( | $ | filename,
 |  | $ | extensions,
 |  | $ | alerts = TRUE
 | ) |  |

Munge the filename as needed for security purposes.

For instance the file name "exploit.php.pps" would become "exploit.php_.pps".

Parameters:
$filename | The name of a file to modify.
$extensions | A space separated list of extensions that should not be altered.
$alerts | Whether alerts (watchdog, drupal_set_message()) should be displayed.
Returns:
$filename The potentially modified $filename.

Definition at line 355 of file file.inc.

References drupal_set_message(), t(), and variable_get().

Referenced by file_save_upload().

file_save_data | ( | $ | data,
 |  | $ | dest,
 |  | $ | replace = FILE_EXISTS_RENAME
 | ) |  |

Save a string to the specified destination.

Parameters:
$data | A string containing the contents of the file.
$dest | A string containing the destination location.
$replace Replace behavior when the destination file already exists.
  • FILE_EXISTS_REPLACE - Replace the existing file
  • FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique
  • FILE_EXISTS_ERROR - Do nothing and return FALSE.
Returns:
A string containing the resulting filename or 0 on error

Definition at line 753 of file file.inc.

References drupal_set_message(), file_directory_temp(), file_move(), and t().

Referenced by _color_save_stylesheet(), _locale_rebuild_js(), blogapi_metaweblog_new_media_object(), drupal_build_css_cache(), and drupal_build_js_cache().

file_save_upload | ( | $ | source,
 |  | $ | validators = array(),
 |  | $ | dest = FALSE,
 |  | $ | replace = FILE_EXISTS_RENAME
 | ) |  |

Saves a file upload to a new location.

The source file is validated as a proper upload and handled as such.

The file will be added to the files table as a temporary file. Temporary files are periodically cleaned. To make the file permanent file call file_set_status() to change its status.

Parameters:
$source | A string specifying the name of the upload field to save.
$validators | An optional, associative array of callback functions used to validate the file. The keys are function names and the values arrays of callback parameters which will be passed in after the user and file objects. The functions should return an array of error messages, an empty array indicates that the file passed validation. The functions will be called in the order specified.
$dest | A string containing the directory $source should be copied to. If this is not provided or is not writable, the temporary directory will be used.
$replace | A boolean indicating whether an existing file of the same name in the destination directory should overwritten. A false value will generate a new, unique filename in the destination directory.
Returns:
An object containing the file information, or 0 in the event of an error.

Definition at line 480 of file file.inc.

References $name, $user, drupal_set_message(), drupal_write_record(), file_check_path(), file_create_path(), file_destination(), file_directory_temp(), file_munge_filename(), file_upload_max_size(), form_set_error(), format_size(), t(), variable_get(), and watchdog().

Referenced by fileupload_submit(), hook_prepare(), hook_submit(), locale_translate_import_form_submit(), system_theme_settings(), upload_node_form_submit(), and user_validate_picture().

file_scan_directory | ( | $ | dir,
 |  | $ | mask,
 |  | $ | nomask = array('.', '..', 'CVS'),
 |  | $ | callback = 0,
 |  | $ | recurse = TRUE,
 |  | $ | key = 'filename',
 |  | $ | min_depth = 0,
 |  | $ | depth = 0
 | ) |  |

Finds all files that match a given mask in a given directory.

Directories and files beginning with a period are excluded; this prevents hidden files and directories (such as SVN working directories) from being scanned.

Parameters:
$dir | The base directory for the scan, without trailing slash.
$mask | The regular expression of the files to find.
$nomask | An array of files/directories to ignore.
$callback | The callback function to call for each match.
$recurse | When TRUE, the directory scan will recurse the entire tree starting at the provided directory.
$key | The key to be used for the returned array of files. Possible values are "filename", for the path starting with $dir, "basename", for the basename of the file, and "name" for the name of the file without an extension.
$min_depth | Minimum depth of directories to return files from.
$depth | Current depth of recursion. This parameter is only used internally and should not be passed.
Returns:
An associative array (keyed on the provided key) of objects with "path", "basename", and "name" members corresponding to the matching files.

Definition at line 882 of file file.inc.

References $depth, and $name.

Referenced by drupal_clear_css_cache(), drupal_clear_js_cache(), drupal_system_listing(), image_get_available_toolkits(), install_find_locales(), install_find_profiles(), locale_batch_by_component(), and locale_batch_by_language().

file_set_status | ( | &$ | file,
 |  | $ | status
 | ) |  |

Set the status of a file.

Parameters:
file | A Drupal file object
status | A status value to set the file to.
Returns:
FALSE on failure, TRUE on success and $file->status will contain the status.

Definition at line 779 of file file.inc.

References $status, and db_query().

Referenced by upload_save().

file_space_used ( $ uid = NULL )

Determine total disk space used by a single user or the whole filesystem.

Parameters:
$uid An optional user id. A NULL value returns the total space used by all files.

Definition at line 446 of file file.inc.

References db_query(), and db_result().

Referenced by file_validate_size(), and upload_space_used().

file_transfer | ( | $ | source,
 |  | $ | headers
 | ) |  |

Transfer file using http to client.

Pipes a file through Drupal to the client.

Parameters:
$source | File to transfer.
$headers | An array of http headers to send along with file.

Definition at line 794 of file file.inc.

References $header, drupal_not_found(), drupal_set_header(), exit, and file_create_path().

Referenced by file_download().

file_unmunge_filename ( $ filename )

Undo the effect of upload_munge_filename().

Parameters:
$filename string filename
Returns:
string

Definition at line 393 of file file.inc.

file_upload_max_size ( )

Determine the maximum file upload size by querying the PHP settings.

Returns:
A file size limit in bytes based on the PHP upload_max_filesize and post_max_size

Definition at line 971 of file file.inc.

References parse_size().

Referenced by file_save_upload(), upload_admin_settings(), and upload_admin_settings_validate().

file_validate_extensions | ( | $ | file,
 |  | $ | extensions
 | ) |  |

Check that the filename ends with an allowed extension.

This check is not enforced for the user #1.

Parameters:
$file | A Drupal file object.
$extensions | A string with a space separated
Returns:
An array. If the file extension is not allowed, it will contain an error message.

Definition at line 619 of file file.inc.

References $user, and t().

file_validate_image_resolution | ( | &$ | file,
 |  | $ | maximum_dimensions = 0,
 |  | $ | minimum_dimensions = 0
 | ) |  |

If the file is an image verify that its dimensions are within the specified maximum and minimum dimensions.

Non-image files will be ignored.

Parameters:
$file | A Drupal file object. This function may resize the file affecting its size.
$maximum_dimensions | An optional string in the form WIDTHxHEIGHT e.g. '640x480' or '85x85'. If an image toolkit is installed the image will be resized down to these dimensions. A value of 0 indicates no restriction on size, so resizing will be attempted.
$minimum_dimensions | An optional string in the form WIDTHxHEIGHT. This will check that the image meets a minimum size. A value of 0 indicates no restriction.
Returns:
An array. If the file is an image and did not meet the requirements, it will contain an error message.

Definition at line 705 of file file.inc.

References drupal_set_message(), image_get_info(), image_get_toolkit(), image_scale(), and t().

file_validate_is_image ( &$ file )

Check that the file is recognized by image_get_info() as an image.

Parameters:
$file A Drupal file object.
Returns:
An array. If the file is not an image, it will contain an error message.

Definition at line 676 of file file.inc.

References image_get_info(), and t().

file_validate_name_length ( $ file )

Check for files with names longer than we can store in the database.

Parameters:
$file A Drupal file object.
Returns:
An array. If the file name is too long, it will contain an error message.

Definition at line 599 of file file.inc.

References t().

file_validate_size | ( | $ | file,
 |  | $ | file_limit = 0,
 |  | $ | user_limit = 0
 | ) |  |

Check that the file's size is below certain limits.

This check is not enforced for the user #1.

Parameters:
$file | A Drupal file object.
$file_limit | An integer specifying the maximum file size in bytes. Zero indicates that no limit should be enforced.
$$user_limit | An integer specifying the maximum number of bytes the user is allowed. Zero indicates that no limit should be enforced.
Returns:
An array. If the file size exceeds limits, it will contain an error message.

Definition at line 649 of file file.inc.

References $user, file_space_used(), format_size(), and t().

Generated on Tue Feb 12 15:30:49 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Form builder functions

Form builder functions

Detailed Description

Functions that build an abstract representation of a HTML form.

All modules should declare their form builder functions to be in this group and each builder function should reference its validate and submit functions using @see. Conversely, validate and submit functions should reference the form builder function using @see. For examples, of this see system_modules_uninstall() or user_pass(), the latter of which has the following in its doxygen documentation:

@ingroup forms @see user_pass_validate(). @see user_pass_submit().

End of "defgroup forms".

Filtering functions

Modules which need to have content filtered can use these functions to interact with the filter system.

For more info, see the hook_filter() documentation.

Note: because filters can inject JavaScript or execute PHP code, security is vital here. When a user supplies a $format, you should validate it with filter_access($format) before accepting/using it. This is normally done in the validation stage of the node system. You should for example never make a preview of content in a disallowed format.

  • filter_form ($value=FILTER_FORMAT_DEFAULT, $weight=NULL, $parents=array('format'))
    Generate a selector for choosing a format in a form.

Functions

  • aggregator_admin_settings ()
    Form builder; Configure the aggregator system.
  • aggregator_categorize_items ($items, $feed_source= '')
    Form builder; build the page list form.
  • aggregator_form_category (&$form_state, $edit=array('title'=> '', 'description'=> '', 'cid'=> NULL))
    Form builder; Generate a form to add/edit/delete aggregator categories.
  • aggregator_form_feed (&$form_state, $edit=array('refresh'=> 900, 'title'=> '', 'url'=> '', 'fid'=> NULL))
    Form builder; Generate a form to add/edit feed sources.
  • book_admin_edit ($form_state, $node)
    Build the form to administrate the hierarchy of a single book.
  • book_admin_settings ()
    Builds and returns the book settings form.
  • book_outline_form (&$form_state, $node)
    Build the form to handle all book outline operations via the outline tab.
  • book_remove_form (&$form_state, $node)
    Menu callback; builds a form to confirm removal of a node from the book.
  • comment_admin_overview ($type= 'new', $arg)
    Form builder; Builds the comment overview form for the admin.
  • comment_confirm_delete (&$form_state, $comment)
    Form builder; Builds the confirmation form for deleting a single comment.
  • comment_controls ($mode=COMMENT_MODE_THREADED_EXPANDED, $order=COMMENT_ORDER_NEWEST_FIRST, $comments_per_page=50)
    Build a comment control form.
  • comment_edit ($cid)
    Form builder; generate a comment editing form.
  • comment_form (&$form_state, $edit, $title=NULL)
    Generate the basic commenting form, for appending to a node or display on a separate page.
  • comment_form_add_preview ($form, &$form_state)
    Form builder; Generate and validate a comment preview form.
  • comment_multiple_delete_confirm (&$form_state)
    List the selected comments and verify that the admin really wants to delete them.
  • comment_unpublish_by_keyword_action_form ($context)
    Form builder; Prepare a form for blacklisted keywords.
  • confirm_form ($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
    Output a confirmation form.
  • dblog_admin_settings ()
    dblog module settings form.
  • dblog_filter_form ()
    Return form for dblog administration filters.
  • filter_admin_configure (&$form_state, $format)
    Build a form to change the settings for a format's filters.
  • filter_admin_delete ()
    Menu callback; confirm deletion of a format.
  • filter_admin_format_form (&$form_state, $format)
    Generate a filter format form.
  • filter_admin_order (&$form_state, $format=NULL)
    Build the form for ordering filters for a format.
  • filter_admin_overview ()
    Menu callback; Displays a list of all input formats and which one is the default.
  • forum_form_container (&$form_state, $edit=array())
    Returns a form for adding a container to the forum vocabulary.
  • forum_form_forum (&$form_state, $edit=array())
    Returns a form for adding a forum to the forum vocabulary.
  • openid_user_add ()
    Form builder; Add an OpenID identity.
  • path_admin_filter_form (&$form_state, $keys= '')
    Return a form to filter URL aliases.
  • path_admin_form (&$form_state, $edit=array('src'=> '', 'dst'=> '', 'language'=> '', 'pid'=> NULL))
    Return a form for editing or creating an individual URL alias.
  • poll_cancel_form (&$form_state, $nid)
    Builds the cancel form for a poll.
  • poll_view_voting (&$form_state, $node, $block)
    Generates the voting form for a poll.
  • profile_admin_overview ()
    Form builder to display a listing of all editable profile fields.
  • profile_field_form (&$form_state, $arg=NULL)
    Menu callback: Generate a form to add/edit a user profile field.
  • search_admin_settings ()
    Menu callback; displays the search module settings page.
  • search_box (&$form_state, $form_id)
    Form builder; Output a search form for the search block and the theme's search box.
  • statistics_access_logging_settings ()
    Form builder; Configure access logging.
  • system_actions_delete_form ($form_state, $action)
    Create the form for confirmation of deleting an action.
  • system_actions_manage_form ($form_state, $options=array())
    Define the form for the actions overview page.
  • system_admin_theme_settings ()
    Form builder; This function allows selection of the theme to show in administration sections.
  • system_clean_url_settings ()
    Form builder; Configure Clean URL settings.
  • system_clear_cache_submit (&$form_state, $form)
    Submit callback; clear system caches.
  • system_date_time_settings ()
    Form builder; Configure the site date and time settings.
  • system_error_reporting_settings ()
    Form builder; Configure error reporting settings.
  • system_file_system_settings ()
    Form builder; Configure the site file handling.
  • system_image_toolkit_settings ()
    Form builder; Configure site image toolkit usage.
  • system_modules ($form_state=array())
    Menu callback; provides module enable/disable interface.
  • system_modules_confirm_form ($modules, $storage)
    Display confirmation form for dependencies.
  • system_modules_disable ($form, $edit)
    Form process callback function to disable check boxes.
  • system_modules_uninstall ($form_state=NULL)
    Uninstall functions.
  • system_modules_uninstall_confirm_form ($storage)
    Confirm uninstall of selected modules.
  • system_performance_settings ()
    Form builder; Configure site performance settings.
  • system_rss_feeds_settings ()
    Form builder; Configure how the site handles RSS feeds.
  • system_settings_form ($form)
    Add default buttons to a form and set its prefix.
  • system_site_information_settings ()
    Form builder; The general site information form.
  • system_site_maintenance_settings ()
    Form builder; Configure the site's maintenance status.
  • system_theme_settings (&$form_state, $key= '')
    Form builder; display theme configuration for entire site and individual themes.
  • system_themes_form ()
    Menu callback; displays a listing of all themes.
  • taxonomy_form_term (&$form_state, $vocabulary, $edit=array())
    Form function for the term edit form.
  • taxonomy_form_vocabulary (&$form_state, $edit=array())
    Display form for adding and editing vocabularies.
  • taxonomy_overview_terms (&$form_state, $vocabulary)
    Form builder for the taxonomy terms overview.
  • taxonomy_overview_vocabularies ()
    Form builder to list and manage vocabularies.
  • taxonomy_term_confirm_delete (&$form_state, $tid)
    Form builder for the term delete form.
  • taxonomy_term_confirm_parents (&$form_state, $vocabulary)
    Form builder for the confirmation of multiple term parents.
  • taxonomy_vocabulary_confirm_delete (&$form_state, $vid)
    Form builder for the vocabulary delete confirmation form.
  • taxonomy_vocabulary_confirm_reset_alphabetical (&$form_state, $vid)
    Form builder to confirm reseting a vocabulary to alphabetical order.
  • throttle_admin_settings ()
    Form builder; Configure the throttle system.
  • trigger_unassign ($form_state, $hook=NULL, $op=NULL, $aid=NULL)
    Confirm removal of an assigned action.
  • user_admin_access_delete_confirm ($form_state, $aid=0)
    Menu callback: delete an access rule.
  • user_admin_access_form (&$form_state, $edit, $submit)
    Form builder; Configure access rules.
  • user_admin_account ()
    Form builder; User administration page.
  • user_admin_perm ($form_state, $rid=NULL)
    Menu callback: administer permissions.
  • user_admin_role ()
    Menu callback: administer roles.
  • user_admin_settings ()
    Form builder; Configure user settings for this site.
  • user_confirm_delete (&$form_state, $account)
    Form builder; confirm form for user deletion.
  • user_edit ($account, $category= 'account')
    Form builder; Present the form to edit a given user or profile category.
  • user_filter_form ()
    Form builder; Return form for user administration filters.
  • user_login (&$form_state, $msg= '')
    Form builder; the main user login form.
  • user_pass ()
    Form builder; Request a password reset.
  • user_profile_form ($form_state, $account, $category= 'account')
    Form builder; edit a user account or one of their profile categories.
  • user_register ()
    Form builder; The user registration form.

Function Documentation

aggregator_admin_settings ( )

Form builder; Configure the aggregator system.

See also:
system_settings_form()

Definition at line 223 of file aggregator.admin.inc.

References $items, drupal_map_assoc(), system_settings_form(), t(), url(), and variable_get().

aggregator_categorize_items | ( | $ | items,
 |  | $ | feed_source = ''
 | ) |  |

Form builder; build the page list form.

Parameters:
$items | An array of the feed items.
$feed_source | The feed source URL.
Returns:
The form structure.
See also:
aggregator_categorize_items_validate()

aggregator_categorize_items_submit()

Definition at line 144 of file aggregator.pages.inc.

References $item, $items, check_plain(), db_fetch_object(), db_query(), t(), theme(), and variable_get().

Referenced by _aggregator_page_list().

aggregator_form_category | ( | &$ | form_state,
 |  | $ | edit = array('title' => '', 'description' => '', 'cid' => NULL)
 | ) |  |

Form builder; Generate a form to add/edit/delete aggregator categories.

See also:
aggregator_form_category_validate()

aggregator_form_category_submit()

Definition at line 261 of file aggregator.admin.inc.

References t().

aggregator_form_feed | ( | &$ | form_state,
 |  | $ | edit = array('refresh' => 900, 'title' => '', 'url' => '', 'fid' => NULL)
 | ) |  |

Form builder; Generate a form to add/edit feed sources.

See also:
aggregator_form_feed_validate()

aggregator_form_feed_submit()

Definition at line 55 of file aggregator.admin.inc.

References check_plain(), db_fetch_object(), db_query(), drupal_map_assoc(), t(), and url().

book_admin_edit | ( | $ | form_state,
 |  | $ | node
 | ) |  |

Build the form to administrate the hierarchy of a single book.

See also:
book_admin_edit_submit()

Definition at line 71 of file book.admin.inc.

References _book_admin_table(), check_plain(), drupal_set_title(), and t().

book_admin_settings ( )

Builds and returns the book settings form.

See also:
book_admin_settings_validate()

Definition at line 29 of file book.admin.inc.

References node_get_types(), system_settings_form(), t(), and variable_get().

book_outline_form | ( | &$ | form_state,
 |  | $ | node
 | ) |  |

Build the form to handle all book outline operations via the outline tab.

See also:
book_outline_form_submit()

book_remove_button_submit()

Definition at line 105 of file book.pages.inc.

References _book_add_form_elements(), _book_link_defaults(), _book_parent_depth_limit(), nid, and t().

book_remove_form | ( | &$ | form_state,
 |  | $ | node
 | ) |  |

Menu callback; builds a form to confirm removal of a node from the book.

See also:
book_remove_form_submit()

Definition at line 188 of file book.pages.inc.

References $title, confirm_form(), nid, and t().

comment_admin_overview | ( | $ | type = 'new',
 |  | $ | arg
 | ) |  |

Form builder; Builds the comment overview form for the admin.

Parameters:
$type | Not used.
$arg | Current path's fourth component deciding the form type (Published comments/Approval queue)
Returns:
The form structure.
See also:
comment_admin_overview_validate()

comment_admin_overview_submit()

theme_comment_admin_overview()

Definition at line 37 of file comment.admin.inc.

References $result, $status, $value, comment_operations(), db_fetch_object(), drupal_get_destination(), format_date(), l(), nid, pager_query(), subject, t(), tablesort_sql(), theme(), and truncate_utf8().

comment_confirm_delete | ( | &$ | form_state,
 |  | $ | comment
 | ) |  |

Form builder; Builds the confirmation form for deleting a single comment.

See also:
comment_confirm_delete_submit()

Definition at line 240 of file comment.admin.inc.

References confirm_form(), nid, subject, and t().

comment_controls | ( | $ | mode = COMMENT_MODE_THREADED_EXPANDED,
 |  | $ | order = COMMENT_ORDER_NEWEST_FIRST,
 |  | $ | comments_per_page = 50
 | ) |  |

Build a comment control form.

Parameters:
$mode | Comment display mode.
$order | Comment order mode.
$comments_per_page | Comments per page.

Definition at line 1600 of file comment.module.

References _comment_get_modes(), _comment_get_orders(), _comment_per_page(), and t().

comment_edit ( $ cid )

Form builder; generate a comment editing form.

Parameters:
$cid ID of the comment to be edited.

Definition at line 16 of file comment.pages.inc.

References $user, comment_access(), comment_form_box(), db_fetch_object(), db_query(), drupal_access_denied(), and drupal_unpack().

comment_form | ( | &$ | form_state,
 |  | $ | edit,
 |  | $ | title = NULL
 | ) |  |

Generate the basic commenting form, for appending to a node or display on a separate page.

Parameters:
$title Not used.
See also:
comment_form_validate()

comment_form_submit()

Definition at line 1240 of file comment.module.

References $op, $status, $user, drupal_add_js(), drupal_get_path(), filter_form(), form_get_errors(), format_date(), name, node_load(), t(), theme(), url(), user_access(), and variable_get().

comment_form_add_preview | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Form builder; Generate and validate a comment preview form.

Definition at line 1422 of file comment.module.

References $output, $user, _comment_form_submit(), check_plain(), db_fetch_object(), db_query(), drupal_set_title(), drupal_unpack(), drupal_validate_form(), form_get_errors(), name, node_load(), node_view(), t(), theme(), user_load(), and variable_get().

comment_multiple_delete_confirm ( &$ form_state )

List the selected comments and verify that the admin really wants to delete them.

Parameters:
$form_state An associative array containing the current state of the form.
Returns:
TRUE if the comments should be deleted, FALSE otherwise.
See also:
comment_multiple_delete_confirm_submit()

Definition at line 166 of file comment.admin.inc.

References $value, _comment_load(), check_plain(), confirm_form(), db_query(), db_result(), drupal_goto(), drupal_set_message(), and t().

comment_unpublish_by_keyword_action_form ( $ context )

Form builder; Prepare a form for blacklisted keywords.

Definition at line 2066 of file comment.module.

References drupal_implode_tags(), and t().

confirm_form | ( | $ | form,
 |  | $ | question,
 |  | $ | path,
 |  | $ | description = NULL,
 |  | $ | yes = NULL,
 |  | $ | no = NULL,
 |  | $ | name = 'confirm'
 | ) |  |

Output a confirmation form.

This function returns a complete form for confirming an action. A link is offered to go back to the item that is being changed in case the user changes his/her mind.

If the submit handler for this form is invoked, the user successfully confirmed the action. You should never directly inspect $_POST to see if an action was confirmed.

Parameters:
$form | Additional elements to inject into the form, for example hidden elements.
$question | The question to ask the user (e.g. "Are you sure you want to delete the block foo?").
$path | The page to go to if the user denies the action. Can be either a drupal path, or an array with the keys 'path', 'query', 'fragment'.
$description | Additional text to display (defaults to "This action cannot be undone.").
$yes | A caption for the button which confirms the action (e.g. "Delete", "Replace", ...).
$no | A caption for the link which denies the action (e.g. "Cancel").
$name | The internal name used to refer to the confirmation item.
Returns:
The form.

Definition at line 1125 of file system.module.

References $name, drupal_set_title(), l(), and t().

Referenced by aggregator_admin_remove_feed(), block_box_delete(), book_remove_form(), comment_confirm_delete(), comment_multiple_delete_confirm(), contact_admin_delete(), filter_admin_delete(), forum_confirm_delete(), locale_languages_delete_form(), menu_delete_menu_confirm(), menu_item_delete_form(), menu_reset_item_confirm(), node_configure_rebuild_confirm(), node_delete_confirm(), node_multiple_delete_confirm(), node_revision_delete_confirm(), node_revision_revert_confirm(), node_type_delete_confirm(), path_admin_delete_confirm(), profile_field_delete(), search_wipe_confirm(), system_actions_delete_form(), system_modules_confirm_form(), system_modules_uninstall_confirm_form(), taxonomy_term_confirm_delete(), taxonomy_term_confirm_parents(), taxonomy_vocabulary_confirm_delete(), taxonomy_vocabulary_confirm_reset_alphabetical(), trigger_unassign(), user_admin_access_delete_confirm(), user_confirm_delete(), and user_multiple_delete_confirm().

dblog_admin_settings ( )

dblog module settings form.

See also:
system_settings_form()

Definition at line 15 of file dblog.admin.inc.

References drupal_map_assoc(), system_settings_form(), t(), url(), and variable_get().

dblog_filter_form ( )

Return form for dblog administration filters.

See also:
dblog_filter_form_submit()

dblog_filter_form_validate()

Definition at line 253 of file dblog.admin.inc.

References dblog_filters(), and t().

filter_admin_configure | ( | &$ | form_state,
 |  | $ | format
 | ) |  |

Build a form to change the settings for a format's filters.

Definition at line 298 of file filter.admin.inc.

References delta, filter_list_format(), module, module_invoke(), system_settings_form(), and t().

filter_admin_delete ( )

Menu callback; confirm deletion of a format.

See also:
filter_admin_delete_submit()

Definition at line 243 of file filter.admin.inc.

References arg(), confirm_form(), db_fetch_object(), db_query(), drupal_goto(), drupal_not_found(), drupal_set_message(), name, t(), and variable_get().

filter_admin_format_form | ( | &$ | form_state,
 |  | $ | format
 | ) |  |

Generate a filter format form.

See also:
filter_admin_format_form_validate()

filter_admin_format_form_submit()

Definition at line 94 of file filter.admin.inc.

References $id, $name, _filter_tips(), delta, filter_list_all(), filter_list_format(), l(), module, module_invoke(), name, t(), theme(), user_roles(), and variable_get().

filter_admin_order | ( | &$ | form_state,
 |  | $ | format = NULL
 | ) |  |

Build the form for ordering filters for a format.

See also:
theme_filter_admin_order()

filter_admin_order_submit()

Definition at line 341 of file filter.admin.inc.

References $id, filter_list_format(), name, and t().

filter_admin_overview ( )

Menu callback; Displays a list of all input formats and which one is the default.

See also:
filter_admin_overview_submit()

Definition at line 16 of file filter.admin.inc.

References $id, $name, filter_formats(), l(), t(), user_roles(), and variable_get().

filter_form | ( | $ | value = FILTER_FORMAT_DEFAULT,
 |  | $ | weight = NULL,
 |  | $ | parents = array('format')
 | ) |  |

Generate a selector for choosing a format in a form.

See also:
filter_form_validate()
Parameters:
$value | The ID of the format that is currently selected.
$weight | The weight of the input format.
$parents | Required when defining multiple input formats on a single node or having a different parent than 'format'.
Returns:
HTML for the form element.

Definition at line 475 of file filter.module.

References $value, _filter_tips(), filter_formats(), filter_resolve_format(), form_clean_id(), name, t(), theme(), and variable_get().

Referenced by block_box_form(), comment_form(), and node_body_field().

forum_form_container | ( | &$ | form_state,
 |  | $ | edit = array()
 | ) |  |

Returns a form for adding a container to the forum vocabulary.

Parameters:
$edit Associative array containing a container term to be added or edited.
See also:
forum_form_submit()

Definition at line 107 of file forum.admin.inc.

References _forum_parent_select(), t(), and variable_get().

forum_form_forum | ( | &$ | form_state,
 |  | $ | edit = array()
 | ) |  |

Returns a form for adding a forum to the forum vocabulary.

Parameters:
$edit Associative array containing a forum term to be added or edited.
See also:
forum_form_submit()

Definition at line 30 of file forum.admin.inc.

References _forum_parent_select(), t(), and variable_get().

openid_user_add ( )

Form builder; Add an OpenID identity.

See also:
openid_user_add_validate()

Definition at line 61 of file openid.pages.inc.

References t().

path_admin_filter_form | ( | &$ | form_state,
 |  | $ | keys = ''
 | ) |  |

Return a form to filter URL aliases.

See also:
path_admin_filter_form_submit()

Definition at line 191 of file path.admin.inc.

References t().

path_admin_form | ( | &$ | form_state,
 |  | $ | edit = array('src' => '', 'dst' => '', 'language' => '', 'pid' => NULL)
 | ) |  |

Return a form for editing or creating an individual URL alias.

See also:
path_admin_form_validate()

path_admin_form_submit()

Definition at line 87 of file path.admin.inc.

References t(), url(), and variable_get().

poll_cancel_form | ( | &$ | form_state,
 |  | $ | nid
 | ) |  |

Builds the cancel form for a poll.

See also:
poll_cancel()

Definition at line 753 of file poll.module.

References $nid, and t().

poll_view_voting | ( | &$ | form_state,
 |  | $ | node,
 |  | $ | block
 | ) |  |

Generates the voting form for a poll.

See also:
poll_vote()

phptemplate_preprocess_poll_vote()

Definition at line 556 of file poll.module.

References check_plain(), and t().

profile_admin_overview ( )

Form builder to display a listing of all editable profile fields.

See also:
profile_admin_overview_submit()

Definition at line 15 of file profile.admin.inc.

References $result, $value, _profile_field_types(), check_plain(), db_fetch_object(), db_query(), l(), name, and t().

profile_field_form | ( | &$ | form_state,
 |  | $ | arg = NULL
 | ) |  |

Menu callback: Generate a form to add/edit a user profile field.

See also:
profile_field_form_validate()

profile_field_form_submit()

Definition at line 167 of file profile.admin.inc.

References $type, _profile_field_types(), arg(), db_fetch_array(), db_query(), drupal_not_found(), drupal_set_title(), and t().

search_admin_settings ( )

Menu callback; displays the search module settings page.

See also:
system_settings_form()

search_admin_settings_validate()

Definition at line 36 of file search.admin.inc.

References $items, $percentage, $status, drupal_map_assoc(), format_plural(), module_hook(), module_invoke(), module_invoke_all(), module_list(), system_settings_form(), t(), url(), and variable_get().

search_box | ( | &$ | form_state,
 |  | $ | form_id
 | ) |  |

Form builder; Output a search form for the search block and the theme's search box.

See also:
search_box_form_submit()

theme_search_box_form()

Definition at line 1057 of file search.module.

statistics_access_logging_settings ( )

Form builder; Configure access logging.

See also:
system_settings_form()

Definition at line 183 of file statistics.admin.inc.

References drupal_map_assoc(), system_settings_form(), t(), url(), and variable_get().

system_actions_delete_form | ( | $ | form_state,
 |  | $ | action
 | ) |  |

Create the form for confirmation of deleting an action.

See also:
system_actions_delete_form_submit()

Definition at line 1502 of file system.module.

References confirm_form(), and t().

system_actions_manage_form | ( | $ | form_state,
 |  | $ | options = array()
 | ) |  |

Define the form for the actions overview page.

See also:
system_actions_manage_form_submit()
Parameters:
$form_state | An associative array containing the current state of the form; not used.
$options | An array of configurable actions.
Returns:
Form definition.

Definition at line 1353 of file system.module.

References t().

system_admin_theme_settings ( )

Form builder; This function allows selection of the theme to show in administration sections.

See also:
system_settings_form()

Definition at line 153 of file system.admin.inc.

References $theme, system_settings_form(), system_theme_data(), t(), and variable_get().

system_clean_url_settings ( )

Form builder; Configure Clean URL settings.

See also:
system_settings_form()

Definition at line 1658 of file system.admin.inc.

References base_path(), drupal_add_js(), drupal_get_path(), request_uri(), system_settings_form(), t(), and variable_get().

system_clear_cache_submit | ( | &$ | form_state,
 |  | $ | form
 | ) |  |

Submit callback; clear system caches.

Definition at line 1360 of file system.admin.inc.

References drupal_flush_all_caches(), and drupal_set_message().

system_date_time_settings ( )

Form builder; Configure the site date and time settings.

See also:
system_settings_form()

system_date_time_settings_submit()

Definition at line 1460 of file system.admin.inc.

References _system_zonelist(), drupal_add_js(), drupal_get_path(), format_date(), system_settings_form(), t(), url(), and variable_get().

system_error_reporting_settings ( )

Form builder; Configure error reporting settings.

See also:
system_settings_form()

Definition at line 1206 of file system.admin.inc.

References system_settings_form(), t(), url(), and variable_get().

system_file_system_settings ( )

Form builder; Configure the site file handling.

See also:
system_settings_form()

Definition at line 1371 of file system.admin.inc.

References file_directory_path(), file_directory_temp(), system_settings_form(), t(), and variable_get().

system_image_toolkit_settings ( )

Form builder; Configure site image toolkit usage.

See also:
system_settings_form()

Definition at line 1408 of file system.admin.inc.

References image_get_available_toolkits(), image_get_toolkit(), image_toolkit_invoke(), system_settings_form(), t(), variable_get(), and variable_set().

system_modules ( $ form_state = array() )

Menu callback; provides module enable/disable interface.

Modules can be enabled or disabled and set for throttling if the throttle module is enabled. The list of modules gets populated by module.info files, which contain each module's name, description and dependencies.

See also:
drupal_parse_info_file for information on module.info descriptors.
Dependency checking is performed to ensure that a module cannot be enabled if the module has disabled dependencies and also to ensure that the module cannot be disabled if the module has enabled dependents.

Parameters:
$form_state An associative array containing the current state of the form.
See also:
theme_system_modules()

system_modules_submit()

Returns:
The form array.

Definition at line 620 of file system.admin.inc.

References $status, _system_is_incompatible(), cache_clear_all(), drupal_rebuild_theme_registry(), drupal_required_modules(), drupal_ucfirst(), menu_rebuild(), module_exists(), module_rebuild_cache(), node_types_rebuild(), system_modules_confirm_form(), t(), and url().

system_modules_confirm_form | ( | $ | modules,
 |  | $ | storage
 | ) |  |

Display confirmation form for dependencies.

Parameters:
$modules | Array of module file objects as returned from module_rebuild_cache().
$storage | The contents of $form_state['storage']; an array with two elements: the list of dependencies and the list of status form field values from the previous screen.

Definition at line 811 of file system.admin.inc.

References $items, $name, $status, confirm_form(), drupal_ucfirst(), format_plural(), t(), and theme().

Referenced by system_modules().

system_modules_disable | ( | $ | form,
 |  | $ | edit
 | ) |  |

Form process callback function to disable check boxes.

Parameters:
$form | The form structure.
$edit | Not used.
Returns:
The form structure.

Definition at line 793 of file system.admin.inc.

system_modules_uninstall ( $ form_state = NULL )

Uninstall functions.

Builds a form of currently disabled modules.

See also:
system_modules_uninstall_validate()

system_modules_uninstall_submit()

Parameters:
$form_state['values'] Submitted form values.
Returns:
A form array representing the currently disabled modules.

Definition at line 1000 of file system.admin.inc.

References db_fetch_object(), db_query(), module_hook(), module_load_install(), name, system_modules_uninstall_confirm_form(), t(), and url().

system_modules_uninstall_confirm_form ( $ storage )

Confirm uninstall of selected modules.

Parameters:
$storage An associative array of modules selected to be uninstalled.
Returns:
A form array representing modules to confirm.

Definition at line 1056 of file system.admin.inc.

References $value, confirm_form(), drupal_get_filename(), drupal_parse_info_file(), t(), and theme().

Referenced by system_modules_uninstall().

system_performance_settings ( )

Form builder; Configure site performance settings.

See also:
system_settings_form()

Definition at line 1253 of file system.admin.inc.

References drupal_map_assoc(), file_directory_path(), module_implements(), system_settings_form(), t(), and variable_get().

system_rss_feeds_settings ( )

Form builder; Configure how the site handles RSS feeds.

See also:
system_settings_form()

Definition at line 1433 of file system.admin.inc.

References drupal_map_assoc(), system_settings_form(), t(), and variable_get().

system_settings_form ( $ form )

Add default buttons to a form and set its prefix.

See also:
system_settings_form_submit()
Parameters:
$form An associative array containing the structure of the form.
Returns:
The form structure.

Definition at line 1015 of file system.module.

References drupal_set_message(), form_get_errors(), and t().

Referenced by aggregator_admin_settings(), blogapi_admin_settings(), book_admin_settings(), contact_admin_settings(), dblog_admin_settings(), example_element_demo_form(), filter_admin_configure(), forum_admin_settings(), menu_configure(), node_configure(), search_admin_settings(), statistics_access_logging_settings(), system_admin_theme_settings(), system_clean_url_settings(), system_date_time_settings(), system_error_reporting_settings(), system_file_system_settings(), system_image_toolkit_settings(), system_performance_settings(), system_rss_feeds_settings(), system_site_information_settings(), system_site_maintenance_settings(), system_theme_settings(), throttle_admin_settings(), update_settings(), upload_admin_settings(), and user_admin_settings().

system_site_information_settings ( )

Form builder; The general site information form.

See also:
system_settings_form()

Definition at line 1126 of file system.admin.inc.

References system_settings_form(), t(), url(), and variable_get().

system_site_maintenance_settings ( )

Form builder; Configure the site's maintenance status.

See also:
system_settings_form()

Definition at line 1632 of file system.admin.inc.

References system_settings_form(), t(), url(), and variable_get().

system_theme_settings | ( | &$ | form_state,
 |  | $ | key = ''
 | ) |  |

Form builder; display theme configuration for entire site and individual themes.

Parameters:
$key A theme name.
Returns:
The form structure.
See also:
system_theme_settings_submit()

Definition at line 327 of file system.admin.inc.

References $name, $title, $type, check_plain(), element_children(), file_check_directory(), file_copy(), file_directory_path(), file_save_upload(), module_exists(), node_get_types(), system_settings_form(), system_theme_data(), t(), theme_get_settings(), and variable_get().

system_themes_form ( )

Menu callback; displays a listing of all themes.

See also:
system_themes_form_submit()

Definition at line 188 of file system.admin.inc.

References $status, $theme, $theme_key, drupal_clear_css_cache(), drupal_map_assoc(), l(), name, system_theme_data(), t(), theme(), and variable_get().

taxonomy_form_term | ( | &$ | form_state,
 |  | $ | vocabulary,
 |  | $ | edit = array()
 | ) |  |

Form function for the term edit form.

See also:
taxonomy_form_term_submit()

Definition at line 634 of file taxonomy.admin.inc.

References $children, _taxonomy_term_select(), drupal_map_assoc(), t(), taxonomy_get_parents(), taxonomy_get_related(), taxonomy_get_synonyms(), taxonomy_get_tree(), taxonomy_term_confirm_delete(), taxonomy_term_confirm_parents(), and variable_get().

taxonomy_form_vocabulary | ( | &$ | form_state,
 |  | $ | edit = array()
 | ) |  |

Display form for adding and editing vocabularies.

See also:
taxonomy_form_vocabulary_submit()

Definition at line 103 of file taxonomy.admin.inc.

References node_get_types(), and t().

taxonomy_overview_terms | ( | &$ | form_state,
 |  | $ | vocabulary
 | ) |  |

Form builder for the taxonomy terms overview.

Display a tree of all the terms in a vocabulary, with options to edit each one. The form is made drag and drop by the theme function.

See also:
taxonomy_overview_terms_submit()

theme_taxonomy_overview_terms()

Definition at line 246 of file taxonomy.admin.inc.

References $pager_page_array, $pager_total, $pager_total_items, $results, db_fetch_object(), db_query(), db_rewrite_sql(), drupal_get_destination(), drupal_set_title(), l(), name, pager_query(), t(), taxonomy_get_tree(), and taxonomy_vocabulary_confirm_reset_alphabetical().

Referenced by forum_overview().

taxonomy_overview_vocabularies ( )

Form builder to list and manage vocabularies.

See also:
taxonomy_overview_vocabularies_submit()

theme_taxonomy_overview_vocabularies()

Definition at line 16 of file taxonomy.admin.inc.

References $type, check_plain(), l(), name, node_get_types(), t(), and taxonomy_get_vocabularies().

taxonomy_term_confirm_delete | ( | &$ | form_state,
 |  | $ | tid
 | ) |  |

Form builder for the term delete form.

See also:
taxonomy_term_confirm_delete_submit()

Definition at line 830 of file taxonomy.admin.inc.

References confirm_form(), name, t(), and taxonomy_get_term().

Referenced by taxonomy_form_term().

taxonomy_term_confirm_parents | ( | &$ | form_state,
 |  | $ | vocabulary
 | ) |  |

Form builder for the confirmation of multiple term parents.

See also:
taxonomy_form_term()

Definition at line 810 of file taxonomy.admin.inc.

References confirm_form(), drupal_get_destination(), element_children(), name, and t().

Referenced by taxonomy_form_term().

taxonomy_vocabulary_confirm_delete | ( | &$ | form_state,
 |  | $ | vid
 | ) |  |

Form builder for the vocabulary delete confirmation form.

See also:
taxonomy_vocabulary_confirm_delete_submit()

Definition at line 866 of file taxonomy.admin.inc.

References confirm_form(), name, t(), and taxonomy_vocabulary_load().

taxonomy_vocabulary_confirm_reset_alphabetical | ( | &$ | form_state,
 |  | $ | vid
 | ) |  |

Form builder to confirm reseting a vocabulary to alphabetical order.

See also:
taxonomy_vocabulary_confirm_reset_alphabetical_submit()

Definition at line 900 of file taxonomy.admin.inc.

References confirm_form(), name, t(), and taxonomy_vocabulary_load().

Referenced by taxonomy_overview_terms().

throttle_admin_settings ( )

Form builder; Configure the throttle system.

See also:
system_settings_form()

throttle_admin_settings_validate()

Definition at line 16 of file throttle.admin.inc.

References system_settings_form(), t(), and variable_get().

trigger_unassign | ( | $ | form_state,
 |  | $ | hook = NULL,
 |  | $ | op = NULL,
 |  | $ | aid = NULL
 | ) |  |

Confirm removal of an assigned action.

Parameters:
$hook
$op
$aid The action ID.
See also:
trigger_unassign_submit()

Definition at line 50 of file trigger.admin.inc.

References $op, actions_function_lookup(), actions_get_all_actions(), confirm_form(), drupal_goto(), and t().

user_admin_access_delete_confirm | ( | $ | form_state,
 |  | $ | aid = 0
 | ) |  |

Menu callback: delete an access rule.

See also:
user_admin_access_delete_confirm_submit()

Definition at line 860 of file user.admin.inc.

References $output, confirm_form(), db_fetch_object(), db_query(), and t().

user_admin_access_form | ( | &$ | form_state,
 |  | $ | edit,
 |  | $ | submit
 | ) |  |

Form builder; Configure access rules.

Definition at line 756 of file user.admin.inc.

References t().

user_admin_account ( )

Form builder; User administration page.

See also:
user_admin_account_validate()

user_admin_account_submit()

Definition at line 129 of file user.admin.inc.

References $header, $result, $status, db_fetch_object(), db_query(), drupal_get_destination(), format_interval(), l(), module_invoke_all(), pager_query(), t(), tablesort_sql(), theme(), user_build_filter_query(), and user_roles().

user_admin_perm | ( | $ | form_state,
 |  | $ | rid = NULL
 | ) |  |

Menu callback: administer permissions.

See also:
user_admin_perm_submit()

theme_user_admin_perm()

Definition at line 495 of file user.admin.inc.

References $name, $result, $status, db_fetch_object(), db_query(), module_invoke(), module_list(), t(), and user_roles().

user_admin_role ( )

Menu callback: administer roles.

See also:
user_admin_role_validate()

user_admin_role_submit()

theme_user_admin_new_role()

Definition at line 614 of file user.admin.inc.

References arg(), db_fetch_object(), db_query(), drupal_goto(), name, and t().

user_admin_settings ( )

Form builder; Configure user settings for this site.

See also:
system_settings_form()

Definition at line 231 of file user.admin.inc.

References _user_mail_text(), drupal_add_js(), drupal_get_path(), file_check_directory(), file_create_path(), file_directory_path(), system_settings_form(), t(), and variable_get().

user_confirm_delete | ( | &$ | form_state,
 |  | $ | account
 | ) |  |

Form builder; confirm form for user deletion.

See also:
user_confirm_delete_submit()

Definition at line 303 of file user.pages.inc.

References confirm_form(), name, and t().

user_edit | ( | $ | account,
 |  | $ | category = 'account'
 | ) |  |

Form builder; Present the form to edit a given user or profile category.

See also:
user_edit_validate()

user_edit_submit()

Definition at line 220 of file user.pages.inc.

References check_plain(), drupal_get_form(), drupal_set_title(), and name.

user_filter_form ( )

Form builder; Return form for user administration filters.

See also:
user_filter_form_submit()

Definition at line 35 of file user.admin.inc.

References $type, $value, drupal_add_js(), t(), and user_filters().

user_login | ( | &$ | form_state,
 |  | $ | msg = ''
 | ) |  |

Form builder; the main user login form.

Definition at line 1227 of file user.module.

References $user, check_plain(), drupal_goto(), t(), user_login_default_validators(), and variable_get().

user_pass ( )

Form builder; Request a password reset.

See also:
user_pass_validate()

user_pass_submit()

Definition at line 31 of file user.pages.inc.

References t().

user_profile_form | ( | $ | form_state,
 |  | $ | account,
 |  | $ | category = 'account'
 | ) |  |

Form builder; edit a user account or one of their profile categories.

See also:
user_profile_form_validate()

user_profile_form_submit()

user_edit_delete_submit()

Definition at line 233 of file user.pages.inc.

References _user_forms(), t(), and user_access().

user_register ( )

Form builder; The user registration form.

See also:
user_register_validate()

user_register_submit()

Definition at line 2360 of file user.module.

References $user, _user_forms(), drupal_add_js(), drupal_goto(), filter_xss_admin(), t(), user_access(), user_edit_form(), and variable_get().

Generated on Tue Feb 12 15:30:50 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Form generation

Form generation

Detailed Description

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 drupal_get_form() function handles retrieving, processing, and displaying a rendered HTML form for modules automatically. For example:

 // Display the user registration form.
 $output = drupal_get_form('user_register');

Forms can also be built and submitted programmatically without any user input using the drupal_execute() function.

For information on the format of the structured arrays used to define forms, and more detailed explanations of the Form API workflow, see the reference and the quickstart guide.

Functions

  • _element_info ($type, $refresh=NULL)
    Retrieve the default properties for the defined element type.
  • _form_builder_handle_input_element ($form_id, &$form, &$form_state, $complete_form)
    Populate the value and name properties of input elements so they can be processed and rendered.
  • _form_builder_ie_cleanup ($form, &$form_state)
    In IE, if only one submit button is present, AND the enter key is used to submit the form, no form value is sent for it and our normal button detection code will never detect a match.
  • _form_button_was_clicked ($form)
    Helper function to handle the sometimes-convoluted logic of button click detection.
  • _form_set_class (&$element, $class=array())
    Sets a form element's class attribute.
  • _form_set_value (&$form_values, $form, $parents, $value)
    Helper function for form_set_value().
  • _form_validate ($elements, &$form_state, $form_id=NULL)
    Performs validation on form elements.
  • date_validate ($form)
    Validates the date type to stop dates like February 30, 2006.
  • drupal_execute ($form_id, &$form_state)
    Retrieves a form using a form_id, populates it with $form_state['values'], processes it, and returns any validation errors encountered.
  • drupal_get_form ($form_id)
    Retrieves a form from a constructor function, or from the cache if the form was built in a previous page-load.
  • drupal_prepare_form ($form_id, &$form, &$form_state)
    Prepares a structured form array by adding required elements, executing any hook_form_alter functions, and optionally inserting a validation token to prevent tampering.
  • drupal_process_form ($form_id, &$form, &$form_state)
    This function is the heart of form API.
  • drupal_rebuild_form ($form_id, &$form_state, $args, $form_build_id=NULL)
    Retrieves a form, caches it and processes it with an empty $_POST.
  • drupal_redirect_form ($form, $redirect=NULL)
    Redirect the user to a URL after a form has been processed.
  • drupal_render_form ($form_id, &$form)
    Renders a structured form array into themed HTML.
  • drupal_retrieve_form ($form_id, &$form_state)
    Retrieves the structured array that defines a given form.
  • drupal_validate_form ($form_id, $form, &$form_state)
    Validates user-submitted form data from the $form_state using the validate functions defined in a structured form array.
  • expand_checkboxes ($element)
  • expand_date ($element)
    Roll out a single date element.
  • expand_password_confirm ($element)
    Expand a password_confirm field into two text boxes.
  • expand_radios ($element)
    Roll out a single radios element to a list of radios, using the options array as index.
  • form_builder ($form_id, $form, &$form_state)
    Walk through the structured form array, adding any required properties to each element and mapping the incoming $_POST data to the proper elements.
  • form_clean_id ($id=NULL, $flush=FALSE)
    Prepare an HTML ID attribute string for a form item.
  • form_error (&$element, $message= '')
    Flag an element as having an error.
  • form_execute_handlers ($type, &$form, &$form_state)
    A helper function used to execute custom validation and submission handlers for a given form.
  • form_expand_ahah ($element)
    Add AHAH information about a form element to the page to communicate with javascript.
  • form_get_cache ($form_build_id, &$form_state)
    Fetch a form from cache.
  • form_get_error ($element)
    Return the error message filed against the form with the specified name.
  • form_get_errors ()
    Return an associative array of all errors.
  • form_get_options ($element, $key)
    Traverses a select element's option array looking for any values that hold the given key.
  • form_options_flatten ($array, $reset=TRUE)
  • form_select_options ($element, $choices=NULL)
  • form_set_cache ($form_build_id, $form, $form_state)
    Store a form in the cache.
  • form_set_error ($name=NULL, $message= '')
    File an error against a form element.
  • form_set_value ($form, $value, &$form_state)
    Use this function to make changes to form values in the form validate phase, so they will be available in the submit phase in $form_state.
  • form_type_checkbox_value ($form, $edit=FALSE)
    Helper function to determine the value for a checkbox form element.
  • form_type_checkboxes_value ($form, $edit=FALSE)
    Helper function to determine the value for a checkboxes form element.
  • form_type_image_button_value ($form, $edit=FALSE)
    Helper function to determine the value for an image button form element.
  • form_type_password_confirm_value ($form, $edit=FALSE)
    Helper function to determine the value for a password_confirm form element.
  • form_type_select_value ($form, $edit=FALSE)
    Helper function to determine the value for a select form element.
  • form_type_textfield_value ($form, $edit=FALSE)
    Helper function to determine the value for a textfield form element.
  • form_type_token_value ($form, $edit=FALSE)
    Helper function to determine the value for form's token value.
  • map_month ($month)
    Helper function for usage with drupal_map_assoc to display month names.
  • password_confirm_validate ($form, &$form_state)
    Validate password_confirm element.
  • process_weight ($element)
    Expand weight elements into selects.
  • weight_value (&$form)
    If no default value is set for weight select boxes, use 0.

Function Documentation

_element_info | ( | $ | type,
 |  | $ | refresh = NULL
 | ) |  |

Retrieve the default properties for the defined element type.

Definition at line 1312 of file form.inc.

References $type, module_implements(), and module_invoke().

Referenced by drupal_prepare_form(), drupal_render(), form_builder(), and process_weight().

_form_builder_handle_input_element | ( | $ | form_id,
 |  | &$ | form,
 |  | &$ | form_state,
 |  | $ | complete_form
 | ) |  |

Populate the value and name properties of input elements so they can be processed and rendered.

Also, execute any process handlers attached to a specific element.

Definition at line 944 of file form.inc.

References $name, _form_button_was_clicked(), form_clean_id(), and form_set_value().

Referenced by form_builder().

_form_builder_ie_cleanup | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

In IE, if only one submit button is present, AND the enter key is used to submit the form, no form value is sent for it and our normal button detection code will never detect a match.

We call this function after all other button-detection is complete to check for the proper conditions, and treat the single button on the form as 'clicked' if they are met.

Definition at line 1081 of file form.inc.

Referenced by form_builder().

_form_button_was_clicked ( $ form )

Helper function to handle the sometimes-convoluted logic of button click detection.

In Internet Explorer, if ONLY one submit button is present, AND the enter key is used to submit the form, no form value is sent for it and we'll never detect a match. That special case is handled by _form_builder_ie_cleanup().

Definition at line 1053 of file form.inc.

Referenced by _form_builder_handle_input_element().

_form_set_class | ( | &$ | element,
 |  | $ | class = array()
 | ) |  |

Sets a form element's class attribute.

Adds 'required' and 'error' classes as needed.

Parameters:
&$element | The form element.
$name | Array of new class names to be added.

Definition at line 2194 of file form.inc.

References $element, and form_get_error().

Referenced by theme_checkbox(), theme_file(), theme_password(), theme_radio(), theme_select(), theme_textarea(), and theme_textfield().

_form_set_value | ( | &$ | form_values,
 |  | $ | form,
 |  | $ | parents,
 |  | $ | value
 | ) |  |

Helper function for form_set_value().

We iterate over $parents and create nested arrays for them in $form_state['values'] if needed. Then we insert the value into the right array.

Definition at line 1296 of file form.inc.

References $value.

Referenced by form_set_value().

_form_validate | ( | $ | elements,
 |  | &$ | form_state,
 |  | $ | form_id = NULL
 | ) |  |

Performs validation on form elements.

First ensures required fields are completed, maxlength is not exceeded, and selected options were in the list of options given to the user. Then calls user-defined validators.

Parameters:
$elements | An associative array containing the structure of the form.
$form_state | A keyed array containing the current state of the form. The current user-submitted data is stored in $form_state['values'], though form validation functions are passed an explicit copy of the values for the sake of simplicity. Validation handlers can also $form_state to pass information on to submit handlers. For example: $form_state['data_for_submision'] = $data; This technique is useful when validation requires file parsing, web service requests, or other expensive requests that should not be repeated in the submission step.
$form_id | A unique string identifying the form for validation, submission, theming, and hook_form_alter functions.

Definition at line 652 of file form.inc.

References $value, drupal_strlen(), element_children(), form_error(), form_execute_handlers(), form_options_flatten(), get_t(), and watchdog().

Referenced by drupal_validate_form().

date_validate ( $ form )

Validates the date type to stop dates like February 30, 2006.

Definition at line 1681 of file form.inc.

References form_error(), and t().

drupal_execute | ( | $ | form_id,
 |  | &$ | form_state
 | ) |  |

Retrieves a form using a form_id, populates it with $form_state['values'], processes it, and returns any validation errors encountered.

This function is the programmatic counterpart to drupal_get_form().

Parameters:
$form_id | The unique string identifying the desired form. If a function with that name exists, it is called to build the form array. Modules that need to generate the same form (or very similar forms) using different $form_ids can implement hook_forms(), which maps different $form_id values to the proper form constructor function. Examples may be found in node_forms(), search_forms(), and user_forms().
$form_state | A keyed array containing the current state of the form. Most important is the $form_state['values'] collection, a tree of data used to simulate the incoming $_POST information from a user's form submission.
... Any additional arguments are passed on to the functions called by drupal_execute(), including the unique form constructor function. For example, the node_edit form requires that a node object be passed in here when it is called. For example:
// register a new user $form_state = array(); $form_state['values']['name'] = 'robo-user'; $form_state['values']['mail'] = 'robouser.com'; $form_state['values']['pass'] = 'password'; $form_state['values']['op'] = t('Create new account'); drupal_execute('user_register', $form_state);

// Create a new node $form_state = array(); module_load_include('inc', 'node', 'node.pages'); $node = array('type' => 'story'); $form_state['values']['title'] = 'My node'; $form_state['values']['body'] = 'This is the body text!'; $form_state['values']['name'] = 'robo-user'; $form_state['values']['op'] = t('Save'); drupal_execute('story_node_form', $form_state, (object)$node);

Definition at line 285 of file form.inc.

References drupal_prepare_form(), and drupal_process_form().

drupal_get_form ( $ form_id )

Retrieves a form from a constructor function, or from the cache if the form was built in a previous page-load.

The form is then passesed on for processing, after and rendered for display if necessary.

Parameters:
$form_id The unique string identifying the desired form. If a function with that name exists, it is called to build the form array. Modules that need to generate the same form (or very similar forms) using different $form_ids can implement hook_forms(), which maps different $form_id values to the proper form constructor function. Examples may be found in node_forms(), search_forms(), and user_forms().
... Any additional arguments are passed on to the functions called by drupal_get_form(), including the unique form constructor function. For example, the node_edit form requires that a node object be passed in here when it is called.
Returns:
The rendered form.

Definition at line 69 of file form.inc.

References drupal_prepare_form(), drupal_process_form(), drupal_rebuild_form(), drupal_render_form(), form_get_cache(), and form_set_cache().

Referenced by block_admin_display(), book_outline(), comment_admin(), comment_delete(), comment_form_box(), comment_render(), contact_site_page(), contact_user_page(), dblog_overview(), example_profile_tasks(), filter_admin_configure_page(), filter_admin_format_page(), filter_admin_order_page(), forum_form_main(), install_change_settings(), install_select_locale(), install_select_profile(), install_tasks(), locale_languages_add_screen(), locale_translate_export_screen(), locale_translate_seek_screen(), menu_delete_menu_page(), menu_item_delete_page(), node_add(), node_page_edit(), openid_redirect(), openid_user_identities(), path_admin_edit(), path_admin_overview(), poll_view(), search_view(), system_actions_manage(), taxonomy_add_term_page(), taxonomy_admin_term_edit(), taxonomy_admin_vocabulary_edit(), template_preprocess_page(), template_preprocess_poll_results(), trigger_assign(), update_selection_page(), user_admin(), user_admin_access_add(), user_admin_access_check(), user_admin_access_edit(), user_block(), user_edit(), user_external_login(), and user_page().

drupal_prepare_form | ( | $ | form_id,
 |  | &$ | form,
 |  | &$ | form_state
 | ) |  |

Prepares a structured form array by adding required elements, executing any hook_form_alter functions, and optionally inserting a validation token to prevent tampering.

Parameters:
$form_id | A unique string identifying the form for validation, submission, theming, and hook_form_alter functions.
$form | An associative array containing the structure of the form.
$form_state | A keyed array containing the current state of the form. Passed in here so that hook_form_alter() calls can use it, as well.

Definition at line 456 of file form.inc.

References $user, _element_info(), drupal_alter(), drupal_get_token(), and form_clean_id().

Referenced by drupal_execute(), drupal_get_form(), drupal_rebuild_form(), and openid_authentication().

drupal_process_form | ( | $ | form_id,
 |  | &$ | form,
 |  | &$ | form_state
 | ) |  |

This function is the heart of form API.

The form gets built, validated and in appropriate cases, submitted.

Parameters:
$form_id | The unique string identifying the current form.
$form | An associative array containing the structure of the form.
$form_state | A keyed array containing the current state of the form. This includes the current persistent storage data for the form, and any data passed along by earlier steps when displaying a multi-step form. Additional information, like the sanitized $_POST data, is also accumulated here.

Definition at line 383 of file form.inc.

References batch_get(), batch_process(), cache_clear_all(), drupal_redirect_form(), drupal_validate_form(), form_builder(), form_clean_id(), form_execute_handlers(), form_get_errors(), and variable_get().

Referenced by drupal_execute(), drupal_get_form(), and drupal_rebuild_form().

drupal_rebuild_form | ( | $ | form_id,
 |  | &$ | form_state,
 |  | $ | args,
 |  | $ | form_build_id = NULL
 | ) |  |

Retrieves a form, caches it and processes it with an empty $_POST.

This function clears $_POST and passes the empty $_POST to the form_builder. To preserve some parts from $_POST, pass them in $form_state.

If your AHAH callback simulates the pressing of a button, then your AHAH callback will need to do the same as what drupal_get_form would do when the button is pressed: get the form from the cache, run drupal_process_form over it and then if it needs rebuild, run drupal_rebuild_form over it. Then send back a part of the returned form. $form_state['clicked_button']['array_parents'] will help you to find which part.

Parameters:
$form_id | The unique string identifying the desired form. If a function with that name exists, it is called to build the form array. Modules that need to generate the same form (or very similar forms) using different $form_ids can implement hook_forms(), which maps different $form_id values to the proper form constructor function. Examples may be found in node_forms(), search_forms(), and user_forms().
$form_state | A keyed array containing the current state of the form. Most important is the $form_state['storage'] collection.
$args | Any additional arguments are passed on to the functions called by drupal_get_form(), plus the original form_state in the beginning. If you are getting a form from the cache, use $form['parameters'] to shift off the $form_id from its beginning then the resulting array can be used as $arg here.
$form_build_id | If the AHAH callback calling this function only alters part of the form, then pass in the existing form_build_id so we can re-cache with the same csid.
Returns:
The newly built form.

Definition at line 188 of file form.inc.

References drupal_prepare_form(), drupal_process_form(), and form_set_cache().

Referenced by drupal_get_form().

drupal_redirect_form | ( | $ | form,
 |  | $ | redirect = NULL
 | ) |  |

Redirect the user to a URL after a form has been processed.

Parameters:
$form | An associative array containing the structure of the form.
$redirect | An optional value containing the destination path to redirect to if none is specified by the form.

Definition at line 610 of file form.inc.

References drupal_goto().

Referenced by _batch_finished(), drupal_process_form(), and openid_authentication().

drupal_render_form | ( | $ | form_id,
 |  | &$ | form
 | ) |  |

Renders a structured form array into themed HTML.

Parameters:
$form_id | A unique string identifying the form for validation, submission, theming, and hook_form_alter functions.
$form | An associative array containing the structure of the form.
Returns:
A string containing the path of the page to display when processing is complete.

Definition at line 587 of file form.inc.

References $output, drupal_render(), init_theme(), and theme_get_registry().

Referenced by drupal_get_form().

drupal_retrieve_form | ( | $ | form_id,
 |  | &$ | form_state
 | ) |  |

Retrieves the structured array that defines a given form.

Parameters:
$form_id | The unique string identifying the desired form. If a function with that name exists, it is called to build the form array. Modules that need to generate the same form (or very similar forms) using different $form_ids can implement hook_forms(), which maps different $form_id values to the proper form constructor function.
$form_state | A keyed array containing the current state of the form.
... Any additional arguments needed by the unique form constructor function. Generally, these are any arguments passed into the drupal_get_form() or drupal_execute() functions after the first argument. If a module implements hook_forms(), it can examine these additional arguments and conditionally return different builder functions as well.

Definition at line 312 of file form.inc.

References module_invoke_all().

Referenced by openid_authentication().

drupal_validate_form | ( | $ | form_id,
 |  | $ | form,
 |  | &$ | form_state
 | ) |  |

Validates user-submitted form data from the $form_state using the validate functions defined in a structured form array.

Parameters:
$form_id | A unique string identifying the form for validation, submission, theming, and hook_form_alter functions.
$form | An associative array containing the structure of the form.
$form_state | A keyed array containing the current state of the form. The current user-submitted data is stored in $form_state['values'], though form validation functions are passed an explicit copy of the values for the sake of simplicity. Validation handlers can also $form_state to pass information on to submit handlers. For example: $form_state['data_for_submision'] = $data; This technique is useful when validation requires file parsing, web service requests, or other expensive requests that should not be repeated in the submission step.

Definition at line 555 of file form.inc.

References _form_validate(), drupal_valid_token(), form_set_error(), and t().

Referenced by comment_form_add_preview(), drupal_process_form(), and openid_authentication().

expand_checkboxes ( $ element )

Definition at line 1884 of file form.inc.

References $element, and $value.

expand_date ( $ element )

Roll out a single date element.

Definition at line 1633 of file form.inc.

References $element, $type, drupal_map_assoc(), format_date(), and variable_get().

expand_password_confirm ( $ element )

Expand a password_confirm field into two text boxes.

Definition at line 1565 of file form.inc.

References $element, and t().

expand_radios ( $ element )

Roll out a single radios element to a list of radios, using the options array as index.

Definition at line 1710 of file form.inc.

References $element, check_plain(), and form_clean_id().

form_builder | ( | $ | form_id,
 |  | $ | form,
 |  | &$ | form_state
 | ) |  |

Walk through the structured form array, adding any required properties to each element and mapping the incoming $_POST data to the proper elements.

Parameters:
$form_id | A unique string identifying the form for validation, submission, theming, and hook_form_alter functions.
$form | An associative array containing the structure of the form.
$form_state | A keyed array containing the current state of the form. In this context, it is used to accumulate information about which button was clicked when the form was submitted, as well as the sanitized $_POST data.

Definition at line 840 of file form.inc.

References _element_info(), _form_builder_handle_input_element(), _form_builder_ie_cleanup(), and element_children().

Referenced by book_form_update(), drupal_process_form(), poll_choice_js(), and upload_js().

form_clean_id | ( | $ | id = NULL,
 |  | $ | flush = FALSE
 | ) |  |

Prepare an HTML ID attribute string for a form item.

Remove invalid characters and guarantee uniqueness.

Parameters:
$id | The ID to clean.
$flush | If set to TRUE, the function will flush and reset the static array which is built to test the uniqueness of element IDs. This is only used if a form has completed the validation process. This parameter should never be set to TRUE if this function is being called to assign an ID to the ID element.
Returns:
The cleaned ID.

Definition at line 2223 of file form.inc.

References $id.

Referenced by _form_builder_handle_input_element(), drupal_prepare_form(), drupal_process_form(), expand_radios(), filter_form(), and template_preprocess_page().

form_error | ( | &$ | element,
 |  | $ | message = ''
 | ) |  |

Flag an element as having an error.

Definition at line 820 of file form.inc.

References $element, and form_set_error().

Referenced by _form_validate(), aggregator_categorize_items_validate(), date_validate(), example_element_phonenumber_validate(), filter_form_validate(), install_configure_form_validate(), and password_confirm_validate().

form_execute_handlers | ( | $ | type,
 |  | &$ | form,
 |  | &$ | form_state
 | ) |  |

A helper function used to execute custom validation and submission handlers for a given form.

Button-specific handlers are checked first. If none exist, the function falls back to form-level handlers.

Parameters:
$type | The type of handler to execute. 'validate' or 'submit' are the defaults used by Form API.
$form | An associative array containing the structure of the form.
$form_state | A keyed array containing the current state of the form. If the user submitted the form by clicking a button with custom handler functions defined, those handlers will be stored here.

Definition at line 738 of file form.inc.

References $return, $type, and batch_get().

Referenced by _form_validate(), drupal_process_form(), and node_form_submit_build_node().

form_expand_ahah ( $ element )

Add AHAH information about a form element to the page to communicate with javascript.

If ahah[path] is set on an element, this additional javascript is added to the page header to attach the AHAH behaviors. See ahah.js for more information.

Parameters:
$element An associative array containing the properties of the element. Properties used: ahah_event, ahah_path, ahah_wrapper, ahah_parameters, ahah_effect.
Returns:
None. Additional code is added to the header of the page using drupal_add_js.

Definition at line 1746 of file form.inc.

References $element, drupal_add_js(), and url().

form_get_cache | ( | $ | form_build_id,
 |  | &$ | form_state
 | ) |  |

Fetch a form from cache.

Definition at line 221 of file form.inc.

References cache_get().

Referenced by drupal_get_form(), and poll_choice_js().

form_get_error ( $ element )

Return the error message filed against the form with the specified name.

Definition at line 805 of file form.inc.

References $element, and form_set_error().

Referenced by _form_set_class().

form_get_errors ( )

Return an associative array of all errors.

Definition at line 795 of file form.inc.

References form_set_error().

Referenced by block_admin_configure_submit(), blogapi_blogger_edit_post(), blogapi_blogger_new_post(), comment_form(), comment_form_add_preview(), comment_save(), drupal_process_form(), install_verify_settings(), multipage_form_example_pre_render(), node_preview(), openid_authentication(), system_settings_form(), theme_taxonomy_overview_terms(), and user_external_login().

form_get_options | ( | $ | element,
 |  | $ | key
 | ) |  |

Traverses a select element's option array looking for any values that hold the given key.

Returns an array of indexes that match.

This function is useful if you need to modify the options that are already in a form element; for example, to remove choices which are not valid because of additional filters imposed by another module. One example might be altering the choices in a taxonomy selector. To correctly handle the case of a multiple hierarchy taxonomy, options arrays can now hold an array of objects, instead of a direct mapping of keys to labels, so that multiple choices in the selector can have the same key (and label). This makes it difficult to manipulate directly, which is why this helper function exists.

This function does not support optgroups (when the elements of the options array are themselves arrays), and will return FALSE if arrays are found. The caller must either flatten/restore or manually do their manipulations in this case, since returning the index is not sufficient, and supporting this would make the "helper" too complicated and cumbersome to be of any help.

As usual with functions that can return array() or FALSE, do not forget to use === and !== if needed.

Parameters:
$element | The select element to search.
$key | The key to look for.
Returns:
An array of indexes that match the given $key. Array will be empty if no elements were found. FALSE if optgroups were found.

Definition at line 1449 of file form.inc.

References $element.

form_options_flatten | ( | $ | array,
 |  | $ | reset = TRUE
 | ) |  |

Definition at line 1340 of file form.inc.

References $return, and $value.

Referenced by _form_validate(), and node_filter_form_submit().

form_select_options | ( | $ | element,
 |  | $ | choices = NULL
 | ) |  |

Definition at line 1385 of file form.inc.

References $element, and check_plain().

Referenced by theme_select().

form_set_cache | ( | $ | form_build_id,
 |  | $ | form,
 |  | $ | form_state
 | ) |  |

Store a form in the cache.

Definition at line 234 of file form.inc.

References cache_set().

Referenced by drupal_get_form(), drupal_rebuild_form(), and poll_choice_js().

form_set_error | ( | $ | name = NULL,
 |  | $ | message = ''
 | ) |  |

File an error against a form element.

Parameters:
$name | The name of the form element. If the parents property of your form element is array('foo', 'bar', 'baz') then you may set an error on 'foo' or 'foo][bar][baz'. Setting an error on 'foo' sets an error for every element where the parents array starts with 'foo'.
$message | The error message to present to the user.
Returns:
Never use the return value of this function, use form_get_errors and form_get_error instead.

Definition at line 781 of file form.inc.

References $name, and drupal_set_message().

Referenced by _install_settings_form_validate(), _user_edit_validate(), aggregator_form_category_validate(), aggregator_form_feed_validate(), block_add_block_form_validate(), block_admin_configure_validate(), book_admin_settings_validate(), comment_admin_overview_validate(), comment_validate(), contact_admin_edit_validate(), contact_mail_page_validate(), dblog_filter_form_validate(), drupal_validate_form(), file_check_directory(), file_save_upload(), fileupload_validate(), filter_admin_format_form_validate(), form_error(), form_get_error(), form_get_errors(), forum_nodeapi(), hook_prepare(), hook_validate(), image_gd_settings(), image_gd_settings_validate(), locale_languages_edit_form_validate(), locale_languages_predefined_form_validate(), menu_edit_item_validate(), menu_edit_menu_validate(), multipage_form_example_custom_validate(), node_admin_nodes_validate(), node_assign_owner_action_validate(), node_example_validate(), node_type_form_validate(), node_validate(), nodeapi_example_nodeapi(), openid_begin(), openid_user_add_validate(), path_admin_form_validate(), path_nodeapi(), poll_validate(), poll_view_voting_validate(), profile_field_form_validate(), profile_validate_profile(), search_form_submit(), system_send_email_action_validate(), system_site_information_settings_validate(), taxonomy_form_term_validate(), taxonomy_node_validate(), throttle_admin_settings_validate(), trigger_assign_form_validate(), update_settings_validate(), upload_admin_settings_validate(), user_admin_access_add(), user_admin_access_check_validate(), user_admin_access_edit(), user_admin_account_validate(), user_admin_role_validate(), user_edit_validate(), user_login_final_validate(), user_login_name_validate(), user_pass_validate(), user_profile_form_validate(), and user_validate_picture().

form_set_value | ( | $ | form,
 |  | $ | value,
 |  | &$ | form_state
 | ) |  |

Use this function to make changes to form values in the form validate phase, so they will be available in the submit phase in $form_state.

Specifically, if $form['parents'] is array('foo', 'bar') and $value is 'baz' then this function will make $form_state['values']['foo']['bar'] to be 'baz'.

Parameters:
$form | The form item. Keys used: parents, value
$value | The value for the form item.

Definition at line 1285 of file form.inc.

References $value, and _form_set_value().

Referenced by _form_builder_handle_input_element(), _install_settings_form_validate(), node_search_validate(), node_teaser_include_verify(), node_teaser_js(), password_confirm_validate(), search_form_validate(), and user_pass_validate().

form_type_checkbox_value | ( | $ | form,
 |  | $ | edit = FALSE
 | ) |  |

Helper function to determine the value for a checkbox form element.

Parameters:
$form | The form element whose value is being populated.
$edit | The incoming POST data to populate the form element. If this is FALSE, the element's default value should be returned.
Returns:
The data that will appear in the $form_state['values'] collection for this element. Return nothing to use the default.

Definition at line 1159 of file form.inc.

form_type_checkboxes_value | ( | $ | form,
 |  | $ | edit = FALSE
 | ) |  |

Helper function to determine the value for a checkboxes form element.

Parameters:
$form | The form element whose value is being populated.
$edit | The incoming POST data to populate the form element. If this is FALSE, the element's default value should be returned.
Returns:
The data that will appear in the $form_state['values'] collection for this element. Return nothing to use the default.

Definition at line 1177 of file form.inc.

References $value.

form_type_image_button_value | ( | $ | form,
 |  | $ | edit = FALSE
 | ) |  |

Helper function to determine the value for an image button form element.

Parameters:
$form | The form element whose value is being populated.
$edit | The incoming POST data to populate the form element. If this is FALSE, the element's default value should be returned.
Returns:
The data that will appear in the $form_state['values'] collection for this element. Return nothing to use the default.

Definition at line 1114 of file form.inc.

form_type_password_confirm_value | ( | $ | form,
 |  | $ | edit = FALSE
 | ) |  |

Helper function to determine the value for a password_confirm form element.

Parameters:
$form | The form element whose value is being populated.
$edit | The incoming POST data to populate the form element. If this is FALSE, the element's default value should be returned.
Returns:
The data that will appear in the $form_state['values'] collection for this element. Return nothing to use the default.

Definition at line 1204 of file form.inc.

form_type_select_value | ( | $ | form,
 |  | $ | edit = FALSE
 | ) |  |

Helper function to determine the value for a select form element.

Parameters:
$form | The form element whose value is being populated.
$edit | The incoming POST data to populate the form element. If this is FALSE, the element's default value should be returned.
Returns:
The data that will appear in the $form_state['values'] collection for this element. Return nothing to use the default.

Definition at line 1223 of file form.inc.

References drupal_map_assoc().

form_type_textfield_value | ( | $ | form,
 |  | $ | edit = FALSE
 | ) |  |

Helper function to determine the value for a textfield form element.

Parameters:
$form | The form element whose value is being populated.
$edit | The incoming POST data to populate the form element. If this is FALSE, the element's default value should be returned.
Returns:
The data that will appear in the $form_state['values'] collection for this element. Return nothing to use the default.

Definition at line 1246 of file form.inc.

form_type_token_value | ( | $ | form,
 |  | $ | edit = FALSE
 | ) |  |

Helper function to determine the value for form's token value.

Parameters:
$form | The form element whose value is being populated.
$edit | The incoming POST data to populate the form element. If this is FALSE, the element's default value should be returned.
Returns:
The data that will appear in the $form_state['values'] collection for this element. Return nothing to use the default.

Definition at line 1266 of file form.inc.

map_month ( $ month )

Helper function for usage with drupal_map_assoc to display month names.

Definition at line 1690 of file form.inc.

References format_date().

Referenced by profile_view_field().

password_confirm_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate password_confirm element.

Definition at line 1593 of file form.inc.

References form_error(), form_set_value(), and t().

process_weight ( $ element )

Expand weight elements into selects.

Definition at line 2102 of file form.inc.

References $element, and _element_info().

weight_value ( &$ form )

If no default value is set for weight select boxes, use 0.

Definition at line 1697 of file form.inc.

Generated on Tue Feb 12 15:30:50 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Formatting

Formatting

Detailed Description

Functions to format numbers, strings, dates, etc.

Functions

  • format_date ($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
    Format a date with the given configured format or a custom format string.
  • format_interval ($timestamp, $granularity=2, $langcode=NULL)
    Format a time interval with the requested granularity.
  • format_plural ($count, $singular, $plural, $args=array(), $langcode=NULL)
    Format a string containing a count of items.
  • format_rss_channel ($title, $link, $description, $items, $langcode=NULL, $args=array())
    Formats an RSS channel.
  • format_rss_item ($title, $link, $description, $args=array())
    Format a single RSS item.
  • format_size ($size, $langcode=NULL)
    Generate a string representation for the given byte count.
  • format_xml_elements ($array)
    Format XML elements.
  • parse_size ($size)
    Parse a given byte count.

Function Documentation

format_date | ( | $ | timestamp,
 |  | $ | type = 'medium',
 |  | $ | format = '',
 |  | $ | timezone = NULL,
 |  | $ | langcode = NULL
 | ) |  |

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.

Parameters:
$timestamp | The exact date to format, as a UNIX timestamp.
$type | The format to use. Can be "small", "medium" or "large" for the preconfigured date formats. If "custom" is specified, then $format is required as well.
$format | A PHP date format string as required by date(). A backslash should be used before a character to avoid interpreting the character as part of a date format.
$timezone | Time zone offset in seconds; if omitted, the user's time zone is used.
$langcode | Optional language code to translate to a language other than what is used to display the page.
Returns:
A translated date string in the requested format.

Definition at line 1151 of file common.inc.

References $type, $user, t(), and variable_get().

Referenced by _blogapi_mt_extra(), _system_zonelist(), blogapi_blogger_edit_post(), blogapi_blogger_new_post(), chameleon_comment(), chameleon_node(), comment_admin_overview(), comment_form(), dblog_event(), dblog_overview(), expand_date(), filter_example_filter(), hook_watchdog(), map_month(), node_feed(), node_form(), node_object_prepare(), node_revision_delete_confirm(), node_revision_delete_confirm_submit(), node_revision_overview(), node_revision_revert_confirm(), node_revision_revert_confirm_submit(), node_show(), phptemplate_comment_submitted(), phptemplate_node_submitted(), statistics_access_log(), statistics_node_tracker(), statistics_recent_hits(), statistics_user_tracker(), system_date_time_lookup(), system_date_time_settings(), template_preprocess_aggregator_item(), template_preprocess_comment(), template_preprocess_comment_folded(), template_preprocess_node(), template_preprocess_search_result(), theme_comment_submitted(), theme_node_submitted(), theme_update_report(), theme_update_version(), user_mail_tokens(), and user_pass_reset().

format_interval | ( | $ | timestamp,
 |  | $ | granularity = 2,
 |  | $ | langcode = NULL
 | ) |  |

Format a time interval with the requested granularity.

Parameters:
$timestamp | The length of the interval in seconds.
$granularity | How many different units to display in the string.
$langcode | Optional language code to translate to a language other than what is used to display the page.
Returns:
A translated string representation of the interval.

Definition at line 1109 of file common.inc.

References $output, $value, format_plural(), and t().

Referenced by aggregator_view(), hook_requirements(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), system_requirements(), template_preprocess_aggregator_feed_source(), template_preprocess_aggregator_item(), template_preprocess_aggregator_summary_item(), template_preprocess_forum_submitted(), theme_comment_block(), theme_update_report(), tracker_page(), user_admin_account(), and user_user().

format_plural | ( | $ | count,
 |  | $ | singular,
 |  | $ | plural,
 |  | $ | args = array(),
 |  | $ | langcode = NULL
 | ) |  |

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:

   $output = format_plural($node->comment_count, '1 comment', '@count comments');

Example with additional replacements:

   $output = format_plural($update_count,
     'Changed the content type of 1 post from %old-type to %new-type.',
     'Changed the content type of @count posts from %old-type to %new-type.',
     array('%old-type' => $info->old_type, '%new-type' => $info->new_type)));

Parameters:
$count | The item count to display.
$singular | The string for the singular case. Please make sure it is clear this is singular, to ease translation (e.g. use "1 new comment" instead of "1 new"). Do not use in the singular string.
$plural | The string for the plural case. Please make sure it is clear this is plural, to ease translation. Use in place of the item count, as in " new comments".
$args An associative array of replacements to make after translation. Incidences of any key in this array are replaced with the corresponding value. Based on the first character of the key, the value is escaped and/or themed:
  • !variable: inserted as is
  • : escape plain text to HTML (check_plain)
  • variable: escape text and theme as a placeholder for user-submitted content (check_plain + theme_placeholder) Note that you do not need to include in this array. This replacement is done automatically for the plural case.
$langcode | Optional language code to translate to a language other than what is used to display the page.
Returns:
A translated string.

Definition at line 1023 of file common.inc.

References locale_get_plural(), and t().

Referenced by _aggregator_items(), _locale_batch_language_finished(), _locale_batch_system_finished(), _node_mass_update_batch_finished(), actions_synchronize(), aggregator_view(), comment_link(), comment_nodeapi(), format_interval(), format_size(), hook_link(), menu_delete_menu_confirm(), menu_edit_menu_validate(), node_node_type(), node_title_list(), node_type_delete_confirm(), poll_page(), search_admin_settings(), statistics_link(), system_modules_confirm_form(), template_preprocess_forum_list(), template_preprocess_forum_topic_list(), throttle_exit(), tracker_page(), upload_link(), upload_nodeapi(), and user_block().

format_rss_channel | ( | $ | title,
 |  | $ | link,
 |  | $ | description,
 |  | $ | items,
 |  | $ | langcode = NULL,
 |  | $ | args = array()
 | ) |  |

Formats an RSS channel.

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

Definition at line 902 of file common.inc.

References $items, $language, $output, $title, check_plain(), check_url(), decode_entities(), and format_xml_elements().

Referenced by node_feed(), and theme_aggregator_page_rss().

format_rss_item | ( | $ | title,
 |  | $ | link,
 |  | $ | description,
 |  | $ | args = array()
 | ) |  |

Format a single RSS item.

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

Definition at line 927 of file common.inc.

References $output, $title, check_plain(), check_url(), and format_xml_elements().

Referenced by node_feed(), and theme_aggregator_page_rss().

format_size | ( | $ | size,
 |  | $ | langcode = NULL
 | ) |  |

Generate a string representation for the given byte count.

Parameters:
$size | A size in bytes.
$langcode | Optional language code to translate to a language other than what is used to display the page.
Returns:
A translated string representation of the size.

Definition at line 1081 of file common.inc.

References format_plural(), and t().

Referenced by _upload_form(), color_scheme_form_submit(), file_save_upload(), file_validate_size(), fileupload_view(), theme_upload_attachments(), upload_admin_settings(), and upload_admin_settings_validate().

format_xml_elements ( $ array )

Format XML elements.

Parameters:
$array An array where each item represent an element and is either a:
  • (key => value) pair (<key>value</key>)
  • Associative array with fields:
    • 'key': element name
    • 'value': element contents
    • 'attributes': associative array of element attributes
In both cases, 'value' can be a simple string, or it can be another array with the same format as $array itself for nesting.

Definition at line 952 of file common.inc.

References $output, $value, check_plain(), and drupal_attributes().

Referenced by format_rss_channel(), and format_rss_item().

parse_size ( $ size )

Parse a given byte count.

Parameters:
$size A size expressed as a number of bytes with optional SI size and unit suffix (e.g. 2, 3K, 5MB, 10G).
Returns:
An integer representation of the size.

Definition at line 1058 of file common.inc.

References drupal_strtolower().

Referenced by color_scheme_form_submit(), file_upload_max_size(), and system_requirements().

Generated on Tue Feb 12 15:30:49 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Hook implementations for user-created content types.

Hook implementations for user-created content types.

Detailed Description

End of "defgroup node_access".

Functions

  • node_content_access ($op, $node, $account)
    Implementation of hook_access().
  • node_content_form ($node, $form_state)
    Implementation of hook_form().

Function Documentation

node_content_access | ( | $ | op,
 |  | $ | node,
 |  | $ | account
 | ) |  |

Implementation of hook_access().

Named so as not to conflict with node_access()

Definition at line 2382 of file node.module.

References $op, $type, and user_access().

node_content_form | ( | $ | node,
 |  | $ | form_state
 | ) |  |

Implementation of hook_form().

Definition at line 2405 of file node.module.

References $type, check_plain(), node_body_field(), and node_get_types().

Generated on Tue Feb 12 15:30:51 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Hooks

Hooks

Detailed Description

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 call 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 is 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().

Functions

  • custom_url_rewrite_inbound (&$result, $path, $path_language)
    custom_url_rewrite_inbound is not a hook, it's a function you can add to settings.php to alter incoming requests so they map to a Drupal path.
  • custom_url_rewrite_outbound (&$path, &$options, $original_path)
    custom_url_rewrite_outbound is not a hook, it's a function you can add to settings.php to alter all links generated by Drupal.
  • hook_block ($op= 'list', $delta=0, $edit=array())
    Declare a block or set of blocks.
  • hook_boot ()
    Perform setup tasks.
  • hook_comment ($a1, $op)
    Act on comments.
  • hook_cron ()
    Perform periodic actions.
  • hook_db_rewrite_sql ($query, $primary_table, $primary_field, $args)
    Rewrite database queries, usually for access control.
  • hook_delete (&$node)
    Respond to node deletion.
  • hook_disable ()
    Perform necessary actions before module is disabled.
  • hook_elements ()
    Allows modules to declare their own form element types and specify their default values.
  • hook_enable ()
    Perform necessary actions after module is enabled.
  • hook_exit ($destination=NULL)
    Perform cleanup tasks.
  • hook_file_download ($file)
    Allow file downloads.
  • hook_filter ($op, $delta=0, $format=-1, $text= '')
    Define content filters.
  • hook_filter_tips ($delta, $format, $long=false)
    Provide tips for using filters.
  • hook_footer ($main=0)
    Insert closing HTML.
  • hook_form (&$node, &$param)
    Display a node editing form.
  • hook_form_alter (&$form, $form_state, $form_id)
    Perform alterations before a form is rendered.
  • hook_forms ()
    Map form_ids to builder functions.
  • hook_help ($path, $arg)
    Provide online user help.
  • hook_init ()
    Perform setup tasks.
  • hook_insert ($node)
    Respond to node insertion.
  • hook_install ()
    Install the current version of the database schema, and any other setup tasks.
  • hook_link ($type, $object, $teaser=FALSE)
    Define internal Drupal links.
  • hook_link_alter (&$links, $node)
    Perform alterations before links on a node are rendered.
  • hook_load ($node)
    Load node-type-specific information.
  • hook_mail ($key, &$message, $params)
    Prepare a message based on parameters.
  • hook_mail_alter (&$message)
    Alter any aspect of the emails sent by Drupal.
  • hook_menu ()
    Define menu items and page callbacks.
  • hook_menu_alter (&$callbacks)
    Alter the data being saved to the {menu_router} table after hook_menu is invoked.
  • hook_menu_link_alter (&$item, $menu)
    Alter the data being saved to the {menu_links} table by menu_link_save().
  • hook_node_info ()
    Define module-provided node types.
  • hook_node_operations ()
    Add mass node operations.
  • hook_node_type ($op, $info)
    Act on node type changes.
  • hook_nodeapi (&$node, $op, $a3=NULL, $a4=NULL)
    Act on nodes defined by other modules.
  • hook_perm ()
    Define user permissions.
  • hook_ping ($name= '', $url= '')
    Ping another server.
  • hook_prepare (&$node)
    This is a hook used by node modules.
  • hook_profile_alter (&$fields, $account)
    Perform alterations profile items before they are rendered.
  • hook_requirements ($phase)
    Check installation requirements and do status reporting.
  • hook_schema ()
    Define the current version of the database schema.
  • hook_search_preprocess ($text)
    Preprocess text for the search index.
  • hook_submit (&$node)
    This is a hook used by node modules.
  • hook_taxonomy ($op, $type, $array=NULL)
    Act on taxonomy changes.
  • hook_theme ()
    Register a module (or theme's) theme implementations.
  • hook_translated_menu_link_alter (&$item, $map)
    Alter a menu link after it's translated, but before it's rendered.
  • hook_uninstall ()
    Remove any tables or variables that the module sets.
  • hook_update ($node)
    Respond to node updating.
  • hook_update_N ()
    Perform a single update.
  • hook_user ($op, &$edit, &$account, $category=NULL)
    Act on user account actions.
  • hook_user_operations ()
    Add mass user operations.
  • hook_validate ($node)
    Verify a node editing form.
  • hook_view ($node, $teaser=FALSE, $page=FALSE)
    Display a node.
  • hook_watchdog ($log_msg)
    Log an event message.
  • hook_xmlrpc ()
    Register XML-RPC callbacks.
  • module_hook ($module, $hook)
    Determine whether a module implements a hook.
  • module_implements ($hook, $sort=FALSE, $refresh=FALSE)
    Determine which modules are implementing a hook.
  • module_invoke ()
    Invoke a hook in a particular module.
  • module_invoke_all ()
    Invoke a hook in all enabled modules that implement it.

Function Documentation

custom_url_rewrite_inbound | ( | &$ | result,
 |  | $ | path,
 |  | $ | path_language
 | ) |  |

custom_url_rewrite_inbound is not a hook, it's a function you can add to settings.php to alter incoming requests so they map to a Drupal path.

This function is called before modules are loaded and the menu system is initialized and it changes $_GET['q'].

This function should change the value of $result by reference.

Parameters:
$result | The Drupal path based on the database. If there is no match in the database it'll be the same as $path.
$path | The path to be rewritten.
$path_language | An optional language code to rewrite the path into.

Definition at line 1790 of file core.php.

References $result, and $user.

Referenced by drupal_get_normal_path().

custom_url_rewrite_outbound | ( | &$ | path,
 |  | &$ | options,
 |  | $ | original_path
 | ) |  |

custom_url_rewrite_outbound is not a hook, it's a function you can add to settings.php to alter all links generated by Drupal.

This function is called from url(). This function is called very frequently (100+ times per page) so performance is critical.

This function should change the value of $path and $options by reference.

Parameters:
$path | The alias of the $priginal_path as defined in the database. If there is no match in the database it'll be the same as $original_path
$options | An array of link attributes such as querystring and fragment. See url().
$orignal_path | The unaliased Drupal path that is being linked to.

Definition at line 1761 of file core.php.

References $user.

Referenced by url().

hook_block | ( | $ | op = 'list',
 |  | $ | delta = 0,
 |  | $ | edit = array()
 | ) |  |

Declare a block or set of blocks.

Any module can export a block (or blocks) to be displayed by defining the _block hook. This hook is called by theme.inc to display a block, and also by block.module to procure the list of available blocks.

Parameters:
$op What kind of information to retrieve about the block or blocks. Possible values:
  • 'list': A list of all blocks defined by the module.
  • 'configure': A configuration form.
  • 'save': Save the configuration options.
  • 'view': Information about a particular block and default settings.
$delta | Which block to return (not applicable if $op is 'list'). Although it is most commonly an integer starting at 0, this is not mandatory. For instance, aggregator.module uses string values for $delta
$edit | If $op is 'save', the submitted form data from the configuration form.
Returns:
  • If $op is 'list': An array of block descriptions. Each block description is an associative array, with the following key-value pairs:
    • 'info': (required) The human-readable name of the block.
    • 'cache': A bitmask of flags describing how the block should behave with respect to block caching. The following shortcut bitmasks are provided as constants in block.module:
      • BLOCK_CACHE_PER_ROLE (default): The block can change depending on the roles the user viewing the page belongs to.
      • BLOCK_CACHE_PER_USER: The block can change depending on the user viewing the page. This setting can be resource-consuming for sites with large number of users, and should only be used when BLOCK_CACHE_PER_ROLE is not sufficient.
      • BLOCK_CACHE_PER_PAGE: The block can change depending on the page being viewed.
      • BLOCK_CACHE_GLOBAL: The block is the same for every user on every page where it is visible.
      • BLOCK_NO_CACHE: The block should not get cached.
    • 'weight', 'status', 'region', 'visibility', 'pages': You can give your blocks an explicit weight, enable them, limit them to given pages, etc. These settings will be registered when the block is first loaded at admin/block, and from there can be changed manually via block administration. Note that if you set a region that isn't available in a given theme, the block will be registered instead to that theme's default region (the first item in the _regions array).
  • If $op is 'configure': optionally return the configuration form.
  • If $op is 'save': return nothing.
  • If $op is 'view': return an array which must define a 'subject' element and a 'content' element defining the block indexed by $delta.
The functions mymodule_display_block_1 and 2, as used in the example, should of course be defined somewhere in your module and return the content you want to display to your users. If the "content" element is empty, no block will be displayed even if "subject" is present.

After completing your blocks, do not forget to enable them in the block admin menu.

For a detailed usage example, see block_example.module.

Definition at line 78 of file core.php.

References $op, t(), variable_get(), and variable_set().

hook_boot ( )

Perform setup tasks.

See also, hook_init.

This hook is run at the beginning of the page request. It is typically used to set up global parameters which are needed later in the request.

Only use this hook if your code must run even for cached page views.This hook is called before modules or most include files are loaded into memory. It happens while Drupal is still in bootstrap mode.

Returns:
None.

Definition at line 618 of file core.php.

References drupal_load().

hook_comment | ( | $ | a1,
 |  | $ | op
 | ) |  |

Act on comments.

This hook allows modules to extend the comments system.

Parameters:
$a1 Dependent on the action being performed.
  • For "form", passes in the comment form.
  • For "validate","update","insert", passes in an array of form values submitted by the user.
  • For all other operations, passes in the comment the action is being performed on.
$op What kind of action is being performed. Possible values:
  • "insert": The comment is being inserted.
  • "update": The comment is being updated.
  • "view": The comment is being viewed. This hook can be used to add additional data to the comment before theming.
  • "form": The comment form is about to be shown. Modules may add fields to the form at this point.
  • "validate": The user has just finished editing the comment and is trying to preview or submit it. This hook can be used to check or even modify the node. Errors should be set with form_set_error().
  • "publish": The comment is being published by the moderator.
  • "unpublish": The comment is being unpublished by the moderator.
  • "delete": The comment is being deleted by the moderator.
Returns:
Dependent on the action being performed.
  • For "form", an array of form elements to add to the comment form.
  • For all other operations, nothing.

Definition at line 143 of file core.php.

References $nid, and $op.

hook_cron ( )

Perform periodic actions.

Modules that require to schedule some commands to be executed at regular intervals can implement hook_cron(). The engine will then call the hook at the appropriate intervals defined by the administrator. This interface is particularly handy to implement timers or to automate certain tasks. Database maintenance, recalculation of settings or parameters, and automatic mailings are good candidates for cron tasks.

Returns:
None.
This hook will only be called if cron.php is run (e.g. by crontab).

Definition at line 166 of file core.php.

References $result, db_fetch_array(), and db_query().

hook_db_rewrite_sql | ( | $ | query,
 |  | $ | primary_table,
 |  | $ | primary_field,
 |  | $ | args
 | ) |  |

Rewrite database queries, usually for access control.

Add JOIN and WHERE statements to queries and decide whether the primary_field shall be made DISTINCT. For node objects, primary field is always called nid. For taxonomy terms, it is tid and for vocabularies it is vid. For comments, it is cid. Primary table is the table where the primary object (node, file, term_node etc.) is.

You shall return an associative array. Possible keys are 'join', 'where' and 'distinct'. The value of 'distinct' shall be 1 if you want that the primary_field made DISTINCT.

Parameters:
$query | Query to be rewritten.
$primary_table | Name or alias of the table which has the primary key field for this query. Typical table names would be: {blocks}, {comments}, {forum}, {node}, {menu}, {term_data} or {vocabulary}. However, it is more common for $primary_table to contain the usual table alias: b, c, f, n, m, t or v.
$primary_field | Name of the primary field.
$args | Array of additional arguments.
Returns:
An array of join statements, where statements, distinct decision.

Definition at line 262 of file core.php.

References $return.

hook_delete ( &$ node )

Respond to node deletion.

This is a hook used by node modules. It is called to allow the module to take action when a node is being deleted from the database by, for example, deleting information from related tables.

Parameters:
&$node The node being deleted.
Returns:
None.
To take action when nodes of any type are deleted (not just nodes of the type defined by this module), use hook_nodeapi() instead.

For a detailed usage example, see node_example.module.

Definition at line 172 of file node.php.

References db_query(), and nid.

hook_disable ( )

Perform necessary actions before module is disabled.

The hook is called everytime module is disabled.

Definition at line 243 of file install.php.

hook_elements ( )

Allows modules to declare their own form element types and specify their default values.

Returns:
An array of element types

Definition at line 289 of file core.php.

References $type.

hook_enable ( )

Perform necessary actions after module is enabled.

The hook is called everytime module is enabled.

Definition at line 234 of file install.php.

hook_exit ( $ destination = NULL )

Perform cleanup tasks.

This hook is run at the end of each page request. It is often used for page logging and printing out debugging information.

Only use this hook if your code must run even for cached page views. If you have code which must run once on all non cached pages, use hook_init instead. Thats the usual case. If you implement this hook and see an error like 'Call to undefined function', it is likely that you are depending on the presence of a module which has not been loaded yet. It is not loaded because Drupal is still in bootstrap mode.

Parameters:
$destination If this hook is invoked as part of a drupal_goto() call, then this argument will be a fully-qualified URL that is the destination of the redirect. Modules may use this to react appropriately; for example, nothing should be output in this case, because PHP will then throw a "headers cannot be modified" error when attempting the redirection.
Returns:
None.

Definition at line 316 of file core.php.

References db_query().

hook_file_download ( $ file )

Allow file downloads.

Parameters:
$file String of the file's path.
Returns:
If the user does not have permission to access the file, return -1. If the user has permission, return an array with the appropriate headers.

Definition at line 329 of file core.php.

References db_query(), db_result(), file_create_path(), and user_access().

hook_filter | ( | $ | op,
 |  | $ | delta = 0,
 |  | $ | format = -1,
 |  | $ | text = ''
 | ) |  |

Define content filters.

Content in Drupal is passed through all enabled filters before it is output. This lets a module modify content to the site administrator's liking.

This hook contains all that is needed for having a module provide filtering functionality.

Depending on $op, different tasks are performed.

A module can contain as many filters as it wants. The 'list' operation tells the filter system which filters are available. Every filter has a numerical 'delta' which is used to refer to it in every operation.

Filtering is a two-step process. First, the content is 'prepared' by calling the 'prepare' operation for every filter. The purpose of 'prepare' is to escape HTML-like structures. For example, imagine a filter which allows the user to paste entire chunks of programming code without requiring manual escaping of special HTML characters like < or &. If the programming code were left untouched, then other filters could think it was HTML and change it. For most filters however, the prepare-step is not necessary, and they can just return the input without changes.

Filters should not use the 'prepare' step for anything other than escaping, because that would short-circuits the control the user has over the order in which filters are applied.

The second step is the actual processing step. The result from the prepare-step gets passed to all the filters again, this time with the 'process' operation. It's here that filters should perform actual changing of the content: transforming URLs into hyperlinks, converting smileys into images, etc.

An important aspect of the filtering system are 'input formats'. Every input format is an entire filter setup: which filters to enable, in what order and with what settings. Filters that provide settings should usually store these settings per format.

If the filter's behaviour depends on an extensive list and/or external data (e.g. a list of smileys, a list of glossary terms) then filters are allowed to provide a separate, global configuration page rather than provide settings per format. In that case, there should be a link from the format-specific settings to the separate settings page.

For performance reasons content is only filtered once; the result is stored in the cache table and retrieved the next time the piece of content is displayed. If a filter's output is dynamic it can override the cache mechanism, but obviously this feature should be used with caution: having one 'no cache' filter in a particular input format disables caching for the entire format, not just for one filter.

Beware of the filter cache when developing your module: it is advised to set your filter to 'no cache' while developing, but be sure to remove it again if it's not needed. You can clear the cache by running the SQL query 'DELETE FROM cache_filter';

Parameters:
$op Which filtering operation to perform. Possible values:
  • list: provide a list of available filters. Returns an associative array of filter names with numerical keys. These keys are used for subsequent operations and passed back through the $delta parameter.
  • no cache: Return true if caching should be disabled for this filter.
  • description: Return a short description of what this filter does.
  • prepare: Return the prepared version of the content in $text.
  • process: Return the processed version of the content in $text.
  • settings: Return HTML form controls for the filter's settings. These settings are stored with variable_set() when the form is submitted. Remember to use the $format identifier in the variable and control names to store settings per input format (e.g. "mymodule_setting_$format").
$delta | Which of the module's filters to use (applies to every operation except 'list'). Modules that only contain one filter can ignore this parameter.
$format | Which input format the filter is being used in (applies to 'prepare', 'process' and 'settings').
$text | The content to filter (applies to 'prepare' and 'process').
Returns:
The return value depends on $op. The filter hook is designed so that a module can return $text for operations it does not use/need.
For a detailed usage example, see filter_example.module. For an example of using multiple filters in one module, see filter_filter() and filter_filter_tips().

Definition at line 428 of file core.php.

References $op, and t().

hook_filter_tips | ( | $ | delta,
 |  | $ | format,
 |  | $ | long = false
 | ) |  |

Provide tips for using filters.

A module's tips should be informative and to the point. Short tips are preferably one-liners.

Parameters:
$delta | Which of this module's filters to use. Modules which only implement one filter can ignore this parameter.
$format | Which format we are providing tips for.
$long | If set to true, long tips are requested, otherwise short tips are needed.
Returns:
The text of the filter tip.

Definition at line 472 of file core.php.

References t().

hook_footer ( $ main = 0 )

Insert closing HTML.

This hook enables modules to insert HTML just before the </body> closing tag of web pages. This is useful for including javascript code and for outputting debug information.

Parameters:
$main Whether the current page is the front page of the site.
Returns:
The HTML to be inserted.

Definition at line 493 of file core.php.

References variable_get().

hook_form | ( | &$ | node,
 |  | &$ | param
 | ) |  |

Display a node editing form.

This hook, implemented by node modules, is called to retrieve the form that is displayed when one attempts to "create/edit" an item. This form is displayed at the URI http://www.example.com/?q=node/<add|edit>/nodetype.

Parameters:
&$node | The node being added or edited.
&$param | The hook can set this variable to an associative array of attributes to add to the enclosing <form> tag.
Returns:
An array containing the form elements to be displayed in the node edit form.
The submit and preview buttons, taxonomy controls, and administrative accoutrements are displayed automatically by node.module. This hook needs to return the node title, the body text area, and fields specific to the node type.

For a detailed usage example, see node_example.module.

Definition at line 250 of file node.php.

References $type, check_plain(), node_get_types(), and t().

hook_form_alter | ( | &$ | form,
 |  | $ | form_state,
 |  | $ | form_id
 | ) |  |

Perform alterations before a form is rendered.

One popular use of this hook is to add form elements to the node form. When altering a node form, the node object retrieved at from $form['node'].

Parameters:
$form | Nested array of form elements that comprise the form.
$form_state | A keyed array containing the current state of the form.
$form_id | String representing the name of the form itself. Typically this is the name of the function that generated the form.
Returns:
None.

Definition at line 515 of file core.php.

References t(), and variable_get().

hook_forms ( )

Map form_ids to builder functions.

This hook allows modules to build multiple forms from a single form "factory" function but each form will have a different form id for submission, validation, theming or alteration by other modules.

The callback arguments will be passed as parameters to the function. Callers of drupal_get_form() are also able to pass in parameters. These will be appended after those specified by hook_forms().

See node_forms() for an actual example of how multiple forms share a common building function.

Returns:
An array keyed by form id with callbacks and optional, callback arguments.

Definition at line 543 of file core.php.

hook_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Provide online user help.

By implementing hook_help(), a module can make documentation available to the engine or to other modules. All user help should be returned using this hook; developer help should be provided with Doxygen/api.module comments.

Parameters:
$path A Drupal menu router path the help is being requested for, e.g. admin/node or user/edit. If the router path includes a % wildcard, then this will appear in the path - for example all node pages will have the path node/% or node//view. Also recognizes special descriptors after a "#" sign. Some examples:
  • admin/helpmodulename The module's help text, displayed on the admin/help page and through the module's individual help link.
  • user/helpmodulename The help for a distributed authorization module (if applicable).
$arg An array that corresponds to the return of the arg() function - if a module needs to provide help for a page with additional parameters after the Drupal path or help for a specific value for a wildcard in the path, then the values in this array can be referenced. For example you could provide help for user/1 by looking for the path user/% and $arg[1] == '1'. This array should always be used rather than directly invoking arg(). Note that depending on which module is invoking hook_help, $arg may contain only, empty strings. Regardless, $arg[0] to $arg[11] will always be set.
Returns:
A localized string containing the help text. Every web link, l(), or url() must be replaced with something and put into the final t() call: $output .= 'A role defines a group of users that have certain privileges as defined in permission.'; $output = t($output, array('permission' => l(t('user permissions'), 'admin/user/permission')));
For a detailed usage example, see page_example.module.

Definition at line 593 of file core.php.

References t(), and url().

hook_init ( )

Perform setup tasks.

See also, hook_boot.

This hook is run at the beginning of the page request. It is typically used to set up global parameters which are needed later in the request. when this hook is called, all modules are already loaded in memory.

For example, this hook is a typical place for modules to add CSS or JS that should be present on every page. This hook is not run on cached pages - though CSS or JS added this way will be present on a cached page.

Returns:
None.

Definition at line 638 of file core.php.

References drupal_add_css(), and drupal_get_path().

hook_insert ( $ node )

Respond to node insertion.

This is a hook used by node modules. It is called to allow the module to take action when a new node is being inserted in the database by, for example, inserting information into related tables.

Parameters:
$node The node being inserted.
Returns:
None.
To take action when nodes of any type are inserted (not just nodes of the type(s) defined by this module), use hook_nodeapi() instead.

For a detailed usage example, see node_example.module.

Definition at line 302 of file node.php.

References db_query(), and nid.

hook_install ( )

Install the current version of the database schema, and any other setup tasks.

The hook will be called the first time a module is installed, and the module's schema version will be set to the module's greatest numbered update hook. Because of this, anytime a hook_update_N() is added to the module, this function needs to be updated to reflect the current version of the database schema.

See the Schema API documentation at http://drupal.org/node/146843 for details on hook_schema, where a database tables are defined.

Note that since this function is called from a full bootstrap, all functions (including those in modules enabled by the current page request) are available when this hook is called. Use cases could be displaying a user message, or calling a module function necessary for initial setup, etc.

Definition at line 164 of file install.php.

References drupal_install_schema().

hook_link | ( | $ | type,
 |  | $ | object,
 |  | $ | teaser = FALSE
 | ) |  |

Define internal Drupal links.

This hook enables modules to add links to many parts of Drupal. Links may be added in nodes or in the navigation block, for example.

The returned array should be a keyed array of link entries. Each link can be in one of two formats.

The first format will use the l() function to render the link:

  • attributes: Optional. See l() for usage.
  • fragment: Optional. See l() for usage.
  • href: Required. The URL of the link.
  • html: Optional. See l() for usage.
  • query: Optional. See l() for usage.
  • title: Required. The name of the link.

The second format can be used for non-links. Leaving out the href index will select this format:

  • title: Required. The text or HTML code to display.
  • html: Optional. If not set to true, check_plain() will be run on the title before it is displayed.

Parameters:
$type An identifier declaring what kind of link is being requested. Possible values:
  • comment: Links to be placed below a comment being viewed.
  • node: Links to be placed below a node being viewed.
$object | A node object or a comment object according to the $type.
$teaser | In case of node link: a 0/1 flag depending on whether the node is displayed with its teaser or its full form.
Returns:
An array of the requested links.

Definition at line 678 of file core.php.

References $links, $type, format_plural(), nid, t(), user_access(), and variable_get().

hook_link_alter | ( | &$ | links,
 |  | $ | node
 | ) |  |

Perform alterations before links on a node are rendered.

One popular use of this hook is to add/delete links from other modules.

Parameters:
$links | Nested array of links for the node
$node | A node object for editing links on
Returns:
None.

Definition at line 730 of file core.php.

References $links.

hook_load ( $ node )

Load node-type-specific information.

This is a hook used by node modules. It is called to allow the module a chance to load extra information that it stores about a node, or possibly replace already loaded information - which can be dangerous.

Parameters:
$node The node being loaded. At call time, node.module has already loaded the basic information about the node, such as its node ID (nid), title, and body.
Returns:
An object containing properties of the node being loaded. This will be merged with the passed-in $node to result in an object containing a set of properties resulting from adding the extra properties to the passed-in ones, and overwriting the passed-in ones with the extra properties if they have the same name as passed-in properties.
For a detailed usage example, see node_example.module.

Definition at line 327 of file node.php.

References db_fetch_object(), and db_query().

hook_mail | ( | $ | key,
 |  | &$ | message,
 |  | $ | params
 | ) |  |

Prepare a message based on parameters.

See also:
drupal_mail for more.
Parameters:
$key | An identifier of the mail.
$message | An array to be filled in. Keys in this array include: mail_id An id to identify the mail sent. Look into the module source codes for possible mail_id values. to The mail address or addresses where the message will be send to. The formatting of this string must comply with RFC 2822. subject Subject of the e-mail to be sent. This must not contain any newline characters, or the mail may not be sent properly. Empty string when the hook is invoked. body An array of lines containing the message to be sent. Drupal will format the correct line endings for you. Empty array when the hook is invoked. from The From, Reply-To, Return-Path and Error-To headers in $headers are already set to this value (if given). headers Associative array containing the headers to add. This is typically used to add extra headers (From, Cc, and Bcc).
$params | An arbitrary array of parameters set by the caller to drupal_mail.

Definition at line 1707 of file core.php.

References drupal_html_to_text(), name, nid, node_get_types(), taxonomy_vocabulary_load(), url(), and variable_get().

hook_mail_alter ( &$ message )

Alter any aspect of the emails sent by Drupal.

You can use this hook to add a common site footer to all outgoing emails; add extra header fields and/or modify the mails sent out in any way. HTML-izing the outgoing mails is one possibility. See also drupal_mail().

Parameters:
$message A structured array containing the message to be altered. Keys in this array include: mail_id An id to identify the mail sent. Look into the module source codes for possible mail_id values. to The mail address or addresses where the message will be send to. The formatting of this string must comply with RFC 2822. subject Subject of the e-mail to be sent. This must not contain any newline characters, or the mail may not be sent properly. body An array of lines containing the message to be sent. Drupal will format the correct line endings for you. from The From, Reply-To, Return-Path and Error-To headers in $headers are already set to this value (if given). headers Associative array containing the headers to add. This is typically used to add extra headers (From, Cc, and Bcc).
Returns:
None.

Definition at line 785 of file core.php.

References t(), and variable_get().

hook_menu ( )

Define menu items and page callbacks.

This hook enables modules to register paths, which determines whose requests are to be handled. Depending on the type of registration requested by each path, a link is placed in the the navigation block and/or an item appears in the menu administration page (q=admin/menu).

This hook is called rarely - for example when modules are enabled.

Returns:
An array of menu items. Each menu item has a key corresponding to the Drupal path being registered. The item is an associative array that may contain the following key-value pairs:
  • "title": Required. The untranslated title of the menu item.
  • "description": The untranslated description of the menu item.
  • "page callback": The function to call to display a web page when the user visits the path. If omitted, the parent menu item's callback will be used instead.
  • "page arguments": An array of arguments to pass to the page callback function. An interger value passes the corresponding data loaded using a wildcard.
  • "access callback": A function returning aboolean value that determines whether the user has access rights to this menu item. Defaults to user_access() unless a value is inherited from a parent menu item..
  • "access arguments": An array of arguments to pass to the page callback function. An interger value passes the corresponding data loaded using a wildcard.
  • "weight": An integer that determines relative position of items in the menu; higher-weighted items sink. Defaults to 0. When in doubt, leave this alone; the default alphabetical order is usually best.
  • "type": A bitmask of flags describing properties of the menu item. Many shortcut bitmasks are provided as constants in menu.inc:
    • MENU_NORMAL_ITEM: Normal menu items show up in the menu tree and can be moved/hidden by the administrator.
    • MENU_CALLBACK: Callbacks simply register a path so that the correct function is fired when the URL is accessed.
    • MENU_SUGGESTED_ITEM: Modules may "suggest" menu items that the administrator may enable.
    • MENU_LOCAL_TASK: Local tasks are rendered as tabs by default.
    • MENU_DEFAULT_LOCAL_TASK: Every set of local tasks should provide one "default" task, that links to the same path as its parent when clicked. If the "type" key is omitted, MENU_NORMAL_ITEM is assumed.

For a detailed usage example, see page_example.module.

For comprehensive documentation on the menu system, see http://drupal.org/node/102338.

Definition at line 842 of file core.php.

References $items, and t().

hook_menu_alter ( &$ callbacks )

Alter the data being saved to the {menu_router} table after hook_menu is invoked.

This hook is invoked by menu_router_build(). The menu definitions are passed in by reference. Each element of the $callbacks array is one item returned by a module from hook_menu. Additional items may be added, or existing items altered.

Parameters:
$callbacks Associative array of menu router definitions returned from hook_menu().
Returns:
None.

Definition at line 188 of file core.php.

hook_menu_link_alter | ( | &$ | item,
 |  | $ | menu
 | ) |  |

Alter the data being saved to the {menu_links} table by menu_link_save().

Parameters:
$item | Associative array defining a menu link as passed into menu_link_save().
$menu | Associative array containg the menu router returned from menu_router_build().
Returns:
None.

Definition at line 203 of file core.php.

References $item.

hook_node_info ( )

Define module-provided node types.

This is a hook used by node modules. This hook is required for modules to define one or more node types. It is called to determine the names and the attributes of a module's node types.

Only module-provided node types should be defined through this hook. User- provided (or 'custom') node types should be defined only in the 'node_type' database table, and should be maintained by using the node_type_save() and node_type_delete() functions.

Returns:
An array of information on the module's node types. The array contains a sub-array for each node type, with the machine-readable type name as the key. Each sub-array has up to 10 attributes. Possible attributes:
  • "name": the human-readable name of the node type. Required.
  • "module": a string telling Drupal how a module's functions map to hooks (i.e. if module is defined as example_foo, then example_foo_insert will be called when inserting a node of that type). This string is usually the name of the module in question, but not always. Required.
  • "description": a brief description of the node type. Required.
  • "help": text that will be displayed at the top of the submission form for this content type. Optional (defaults to '').
  • "has_title": boolean indicating whether or not this node type has a title field. Optional (defaults to TRUE).
  • "title_label": the label for the title field of this content type. Optional (defaults to 'Title').
  • "has_body": boolean indicating whether or not this node type has a body field. Optional (defaults to TRUE).
  • "body_label": the label for the body field of this content type. Optional (defaults to 'Body').
  • "min_word_count": the minimum number of words for the body field to be considered valid for this content type. Optional (defaults to 0).
  • "locked": boolean indicating whether the machine-readable name of this content type can (FALSE) or cannot (TRUE) be edited by a site administrator. Optional (defaults to TRUE).
The machine-readable name of a node type should contain only letters, numbers, and underscores. Underscores will be converted into hyphens for the purpose of contructing URLs.

All attributes of a node type that are defined through this hook (except for 'locked') can be edited by a site administrator. This includes the machine-readable name of a node type, if 'locked' is set to FALSE.

For a detailed usage example, see node_example.module.

Definition at line 69 of file node.php.

References t().

hook_node_operations ( )

Add mass node operations.

This hook enables modules to inject custom operations into the mass operations dropdown found at admin/content/node, by associating a callback function with the operation, which is called when the form is submitted. The callback function receives one initial argument, which is an array of the checked nodes.

Returns:
An array of operations. Each operation is an associative array that may contain the following key-value pairs:
  • "label": Required. The label for the operation, displayed in the dropdown menu.
  • "callback": Required. The function to call for the operation.
  • "callback arguments": Optional. An array of additional arguments to pass to the callback function.

Definition at line 976 of file core.php.

References t().

hook_node_type | ( | $ | op,
 |  | $ | info
 | ) |  |

Act on node type changes.

This hook allows modules to take action when a node type is modified.

Parameters:
$op What is being done to $info. Possible values:
  • "delete"
  • "insert"
  • "update"
$info The node type object on which $op is being performed.
Returns:
None.

Definition at line 94 of file node.php.

References $op, variable_del(), variable_get(), and variable_set().

hook_nodeapi | ( | &$ | node,
 |  | $ | op,
 |  | $ | a3 = NULL,
 |  | $ | a4 = NULL
 | ) |  |

Act on nodes defined by other modules.

Despite what its name might make you think, hook_nodeapi() is not reserved for node modules. On the contrary, it allows modules to react to actions affecting all kinds of nodes, regardless of whether that module defined the node.

Parameters:
&$node The node the action is being performed on.
$op What kind of action is being performed. Possible values:
  • "alter": the $node->content array has been rendered, so the node body or teaser is filtered and now contains HTML. This op should only be used when text substitution, filtering, or other raw text operations are necessary.
  • "delete": The node is being deleted.
  • "delete revision": The revision of the node is deleted. You can delete data associated with that revision.
  • "insert": The node is being created (inserted in the database).
  • "load": The node is about to be loaded from the database. This hook can be used to load additional data at this time.
  • "prepare": The node is about to be shown on the add/edit form.
  • "print": Prepare a node view for printing. Used for printer-friendly view in book_module
  • "rss item": An RSS feed is generated. The module can return properties to be added to the RSS item generated for this node. See comment_nodeapi() and upload_nodeapi() for examples. The $node passed can also be modified to add or remove contents to the feed item.
  • "search result": The node is displayed as a search result. If you want to display extra information with the result, return it.
  • "presave": The node passed validation and is about to be saved. Modules may use this to make changes to the node before it is saved to the database.
  • "update": The node is being updated.
  • "update index": The node is being indexed. If you want additional information to be indexed which is not already visible through nodeapi "view", then you should return it here.
  • "validate": The user has just finished editing the node and is trying to preview or submit it. This hook can be used to check the node data. Errors should be set with form_set_error().
  • "view": The node content is being assembled before rendering. The module may add elements $node->content prior to rendering. This hook will be called after hook_view(). The format of $node->content is the same as used by Forms API.
$a3
  • For "view", passes in the $teaser parameter from node_view().
  • For "validate", passes in the $form parameter from node_validate().
$a4
  • For "view", passes in the $page parameter from node_view().
Returns:
This varies depending on the operation.
  • The "presave", "insert", "update", "delete", "print" and "view" operations have no return value.
  • The "load" operation should return an array containing pairs of fields => values to be merged into the node object.
If you are writing a node module, do not use this hook to perform actions on your type of node alone. Instead, use the hooks set aside for node modules, such as hook_insert() and hook_form().

Definition at line 1064 of file core.php.

References $op, drupal_set_message(), nid, t(), theme(), and user_access().

hook_perm ( )

Define user permissions.

This hook can supply permissions that the module defines, so that they can be selected on the user permissions page and used to restrict access to actions the module performs.

Returns:
An array of permissions strings.
The permissions in the array do not need to be wrapped with the function t(), since the string extractor takes care of extracting permission names defined in the perm hook for translation.

Permissions are checked using user_access().

For a detailed usage example, see page_example.module.

Definition at line 1109 of file core.php.

hook_ping | ( | $ | name = '',
 |  | $ | url = ''
 | ) |  |

Ping another server.

This hook allows a module to notify other sites of updates on your Drupal site.

Parameters:
$name | The name of your Drupal site.
$url | The URL of your Drupal site.
Returns:
None.

Definition at line 1126 of file core.php.

References $name, $result, $url, url(), and watchdog().

hook_prepare ( &$ node )

This is a hook used by node modules.

It is called after load but before the node is shown on the add/edit form.

Parameters:
&$node The node being saved.
Returns:
None.
For a usage example, see image.module.

Definition at line 208 of file node.php.

References file_save_upload(), form_set_error(), image_get_info(), and t().

hook_profile_alter | ( | &$ | fields,
 |  | $ | account
 | ) |  |

Perform alterations profile items before they are rendered.

You may omit/add/re-sort/re-categorize, etc.

Parameters:
$fields | An array of $field objects, with unique module specified keys. Use this $key to find the item you care about.
$account | A user object specifying whose profile is being rendered
Returns:
None.

Definition at line 749 of file core.php.

hook_requirements ( $ phase )

Check installation requirements and do status reporting.

This hook has two closely related uses, determined by the $phase argument: checking installation requirements ($phase == 'install') and status reporting ($phase == 'runtime').

During the 'install' phase, modules can for example assert that library or server versions are available or sufficient. Note that the installation of a module can happen during installation of Drupal itself (by install.php) with an installation profile or later by hand. As a consequence, install-time requirements must be checked without access to the full Drupal API, because it is not available during install.php. For localisation you should for example use $t = get_t() to retrieve the appropriate localisation function name (t() or st()). If a requirement has a severity of REQUIREMENT_ERROR, install.php will abort or at least the module will not install. Other severity levels have no effect on the installation. Module dependencies do not belong to these installation requirements, but should be defined in the module's .info file.

The 'runtime' phase is not limited to pure installation requirements but can also be used for more general status information like maintenance tasks and security issues. The returned 'requirements' will be listed on the status report in the administration section, with indication of the severity level. Moreover, any requirement with a severity of REQUIREMENT_ERROR severity will result in a notice on the the administration overview page.

Parameters:
$phase The phase in which hook_requirements is run:
  • 'install': the module is being installed.
  • 'runtime': the runtime requirements are being checked and shown on the status report page.
Returns:
A keyed array of requirements. Each requirement is itself an array with the following items:
  • 'title': the name of the requirement.
  • 'value': the current value (e.g. version, time, level, ...). During install phase, this should only be used for version numbers, do not set it if not applicable.
  • 'description': description of the requirement/status.
  • 'severity': the requirement's result/severity level, one of:
    • REQUIREMENT_INFO: For info only.
    • REQUIREMENT_OK: The requirement is satisfied.
    • REQUIREMENT_WARNING: The requirement failed with a warning.
    • REQUIREMENT_ERROR: The requirement failed with an error.

Definition at line 69 of file install.php.

References format_interval(), get_t(), l(), t(), url(), and variable_get().

hook_schema ( )

Define the current version of the database schema.

A Drupal schema definition is an array structure representing one or more tables and their related keys and indexes. A schema is defined by hook_schema() which must live in your module's .install file.

By implementing hook_schema() and specifying the tables your module declares, you can easily create and drop these tables on all supported database engines. You don't have to deal with the different SQL dialects for table creation and alteration of the supported database engines.

See the Schema API Handbook at http://drupal.org/node/146843 for details on schema definition structures.

Returns:
A schema definition structure array. For each element of the array, the key is a table name and the value is a table structure definition.

Definition at line 137 of file install.php.

hook_search_preprocess ( $ text )

Preprocess text for the search index.

This hook is called both for text added to the search index, as well as the keywords users have submitted for searching.

This is required for example to allow Japanese or Chinese text to be searched. As these languages do not use spaces, it needs to be split into separate words before it can be indexed. There are various external libraries for this.

Parameters:
$text The text to split. This is a single piece of plain-text that was extracted from between two HTML tags. Will not contain any HTML entities.
Returns:
The text after processing.

Definition at line 1241 of file core.php.

hook_submit ( &$ node )

This is a hook used by node modules.

It is called after validation has succeeded and before insert/update. It is used to for actions which must happen only if the node is to be saved. Usually, $node is changed in some way and then the actual saving of that change is left for the insert/update hooks.

Parameters:
&$node The node being saved.
Returns:
None.
For a detailed usage example, see fileupload.module.

Definition at line 190 of file node.php.

References file_directory_path(), and file_save_upload().

hook_taxonomy | ( | $ | op,
 |  | $ | type,
 |  | $ | array = NULL
 | ) |  |

Act on taxonomy changes.

This hook allows modules to take action when the terms and vocabularies in the taxonomy are modified.

Parameters:
$op What is being done to $object. Possible values:
  • "delete"
  • "insert"
  • "update"
$type What manner of item $object is. Possible values:
  • "term"
  • "vocabulary"
$array The item on which $op is being performed. Possible values:
  • for vocabularies, 'insert' and 'update' ops: $form_values from taxonomy_form_vocabulary_submit()
  • for vocabularies, 'delete' op: $vocabulary from taxonomy_get_vocabulary() cast to an array
  • for terms, 'insert' and 'update' ops: $form_values from taxonomy_form_term_submit()
  • for terms, 'delete' op: $term from taxonomy_get_term() cast to an array
Returns:
None.

Definition at line 1274 of file core.php.

References $op, $type, variable_get(), and variable_set().

hook_theme ( )

Register a module (or theme's) theme implementations.

Modules and themes implementing this return an array of arrays. The key to each sub-array is the internal name of the hook, and the array contains info about the hook. Each array may contain the following items:

  • file: The file the implementation resides in. This file will be included prior to the theme being rendered, to make sure that the function or preprocess function (as needed) is actually loaded; this makes it possible to split theme functions out into separate files quite easily.
  • path: Override the path of the file to be used. Ordinarily the module or theme path will be used, but if the file will not be in the default path, include it here. This path should be relative to the Drupal root directory.
  • template: If specified, this theme implementation is a template, and this is the template file without an extension. Do not put .tpl.php on this file; that extension will be added automatically by the default rendering engine (which is PHPTemplate). If 'path', above, is specified, the template should also be in this path.
  • function: If specified, this will be the function name to invoke for this implementation. If neither file nor function is specified, a default function name will be assumed. For example, if a module registers the 'node' theme hook, 'theme_node' will be assigned to its function. If the chameleon theme registers the node hook, it will be assigned 'chameleon_node' as its function.
  • arguments: An array of arguments that this theme hook uses. This is required so that the theme layer may properly utilize templates. The array keys represent the name of the variable, and the value will be used as the default value if not specified to the theme() function. These arguments must be in the same order that they will be given to the theme() function.
  • pattern: A regular expression pattern to be used to allow this theme implementation to have a dynamic name. The convention is to use __ to differentiate the dynamic portion of the theme. For example, to allow forums to be themed individually, the pattern might be: 'forum__'. Then, when the forum is themed, call: theme(array('forum__'. $tid, 'forum'), $forum).
  • preprocess functions: A list of functions used to preprocess this data. Ordinarily this won't be used; it's automatically filled in. By default, for a module this will be filled in as template_preprocess_HOOK. For a theme this will be filled in as phptemplate_preprocess and phptemplate_preprocess_HOOK as well as themename_preprocess and themename_preprocess_HOOK.
  • override preprocess functions: Set to TRUE when a theme does NOT want the standard preprocess functions to run. This can be used to give a theme FULL control over how variables are set. For example, if a theme wants total control over how certain variables in the page.tpl.php are set, this can be set to true. Please keep in mind that when this is used by a theme, that theme becomes responsible for making sure necessary variables are set.

Parameters:
$existing | An array of existing implementations that may be used for override purposes. This is primarily useful for themes that may wish to examine existing implementations to extract data (such as arguments) so that it may properly register its own, higher priority implementations.
$type What 'type' is being processed. This is primarily useful so that themes tell if they are the actual theme being called or a parent theme. May be one of:
  • module: A module is being checked for theme implementations.
  • base_theme_engine: A theme engine is being checked for a theme which is a parent of the actual theme being used
  • theme_engine: A theme engine is being checked for the actual theme being used
  • base_theme: A base theme is being checked for theme implementations.
  • theme: The actual theme in use is being checked.
$theme | The actual name of theme that is being being checked (mostly only useful for theme engine)
$path | The directory path of the theme or module, so that it doesn't need to be looked up.
Returns:
A keyed array of theme hooks.

Definition at line 1361 of file core.php.

hook_translated_menu_link_alter | ( | &$ | item,
 |  | $ | map
 | ) |  |

Alter a menu link after it's translated, but before it's rendered.

This hook may be used, for example, to add a page-specific query string. For performance reasons, only links that have $item['options']['alter'] == TRUE will be passed into this hook. The $item['options']['alter'] flag should generally be set using hook_menu_link_alter().

Parameters:
$item | Associative array defining a menu link after _menu_link_translate()
$map | Associative array containing the menu $map (path parts and/or objects).
Returns:
None.

Definition at line 229 of file core.php.

References $item, and drupal_get_destination().

hook_uninstall ( )

Remove any tables or variables that the module sets.

The uninstall hook will fire when the module gets uninstalled.

Definition at line 224 of file install.php.

References drupal_uninstall_schema(), and variable_del().

hook_update ( $ node )

Respond to node updating.

This is a hook used by node modules. It is called to allow the module to take action when an edited node is being updated in the database by, for example, updating information in related tables.

Parameters:
$node The node being updated.
Returns:
None.
To take action when nodes of any type are updated (not just nodes of the type(s) defined by this module), use hook_nodeapi() instead.

For a detailed usage example, see node_example.module.

Definition at line 349 of file node.php.

References db_query(), and nid.

hook_update_N ( )

Perform a single update.

For each patch which requires a database change add a new hook_update_N() which will be called by update.php.

The database updates are numbered sequentially according to the version of Drupal you are compatible with.

Schema updates should adhere to the Schema API: http://drupal.org/node/150215

Database updates consist of 3 parts:

  • 1 digit for Drupal core compatibility
  • 1 digit for your module's major release version (e.g. is this the 5.x-1.* (1) or 5.x-2.* (2) series of your module?)
  • 2 digits for sequential counting starting with 00

The 2nd digit should be 0 for initial porting of your module to a new Drupal core API.

Examples:

  • mymodule_update_5200()
    • This is the first update to get the database ready to run mymodule 5.x-2.*.
  • mymodule_update_6000()
    • This is the required update for mymodule to run with Drupal core API 6.x.
  • mymodule_update_6100()
    • This is the first update to get the database ready to run mymodule 6.x-1.*.
  • mymodule_update_6200()
    • This is the first update to get the database ready to run mymodule 6.x-2.*. Users can directly update from 5.x-2.* to 6.x-2.* and they get all 60XX and 62XX updates, but not 61XX updates, because those reside in the 6.x-1.x branch only.

A good rule of thumb is to remove updates older than two major releases of Drupal.

Never renumber update functions.

Further information about releases and release numbers:

  • http://drupal.org/handbook/version-info
  • http://drupal.org/node/93999 (Overview of contributions branches and tags)
  • http://drupal.org/handbook/cvs/releases

Implementations of this hook should be placed in a mymodule.install file in the same directory at mymodule.module. Drupal core's updates are implemented using the system module as a name and stored in database/updates.inc.

Returns:
An array with the results of the calls to update_sql().

Definition at line 213 of file install.php.

References db_add_field().

hook_user | ( | $ | op,
 |  | &$ | edit,
 |  | &$ | account,
 |  | $ | category = NULL
 | ) |  |

Act on user account actions.

This hook allows modules to react when operations are performed on user accounts.

Parameters:
$op What kind of action is being performed. Possible values (in alphabetical order):
  • "after_update": The user object has been updated and changed. Use this if (probably along with 'insert') if you want to reuse some information from the user object.
  • "categories": A set of user information categories is requested.
  • "delete": The user account is being deleted. The module should remove its custom additions to the user object from the database.
  • "form": The user account edit form is about to be displayed. The module should present the form elements it wishes to inject into the form.
  • "insert": The user account is being added. The module should save its custom additions to the user object into the database and set the saved fields to NULL in $edit.
  • "load": The user account is being loaded. The module may respond to this
  • "login": The user just logged in.
  • "logout": The user just logged out. and insert additional information into the user object.
  • "register": The user account registration form is about to be displayed. The module should present the form elements it wishes to inject into the form.
  • "submit": Modify the account before it gets saved.
  • "update": The user account is being changed. The module should save its custom additions to the user object into the database and set the saved fields to NULL in $edit.
  • "validate": The user account is about to be modified. The module should validate its custom additions to the user object, registering errors as necessary.
  • "view": The user's account information is being displayed. The module should format its custom additions for display.
&$edit | The array of form values submitted by the user.
&$account | The user object on which the operation is being performed.
$category | The active category of user information being edited.
Returns:
This varies depending on the operation.
  • "categories": A linear array of associative arrays. These arrays have keys:
    • "name": The internal name of the category.
    • "title": The human-readable, localized name of the category.
    • "weight": An integer specifying the category's sort ordering.
  • "delete": None.
  • "form", "register": A $form array containing the form elements to display.
  • "insert": None.
  • "load": None.
  • "login": None.
  • "logout": None.
  • "submit": None:
  • "update": None.
  • "validate": None.
  • "view": An associative array of associative arrays. The outer array should be keyed by category name. The interior array(s) should have a unique textual key and have 'title', 'value' and 'class' elements. See theme_user_profile() and an example at user_user()

Definition at line 1505 of file core.php.

References $op, and t().

hook_user_operations ( )

Add mass user operations.

This hook enables modules to inject custom operations into the mass operations dropdown found at admin/user/user, by associating a callback function with the operation, which is called when the form is submitted. The callback function receives one initial argument, which is an array of the checked users.

Returns:
An array of operations. Each operation is an associative array that may contain the following key-value pairs:
  • "label": Required. The label for the operation, displayed in the dropdown menu.
  • "callback": Required. The function to call for the operation.
  • "callback arguments": Optional. An array of additional arguments to pass to the callback function.

Definition at line 1538 of file core.php.

References t().

hook_validate ( $ node )

Verify a node editing form.

This is a hook used by node modules. It is called to allow the module to verify that the node is in a format valid to post to the site. Errors should be set with form_set_error().

Parameters:
$node The node to be validated.
Returns:
None.
To validate nodes of all types (not just nodes of the type(s) defined by this module), use hook_nodeapi() instead.

Changes made to the $node object within a hook_validate() function will have no effect. The preferred method to change a node's content is to use hook_submit() or hook_nodeapi($op='submit') instead. If it is really necessary to change the node at the validate stage, you can use function form_set_value().

For a detailed usage example, see node_example.module.

Definition at line 377 of file node.php.

References form_set_error(), and t().

hook_view | ( | $ | node,
 |  | $ | teaser = FALSE,
 |  | $ | page = FALSE
 | ) |  |

Display a node.

This is a hook used by node modules. It allows a module to define a custom method of displaying its nodes, usually by displaying extra information particular to that node type.

Parameters:
$node | The node to be displayed.
$teaser | Whether we are to generate a "teaser" or summary of the node, rather than display the whole thing.
$page | Whether the node is being displayed as a standalone page. If this is TRUE, the node title should not be displayed, as it will be printed automatically by the theme system. Also, the module may choose to alter the default breadcrumb trail in this case.
Returns:
$node. The passed $node parameter should be modified as necessary and returned so it can be properly presented. Nodes are prepared for display by assembling a structured array in $node->content, rather than directly manipulating $node->body and $node->teaser. The format of this array is the same used by the Forms API. As with FormAPI arrays, the weight property can be used to control the relative positions of added elements. If for some reason you need to change the body or teaser returned by node_prepare(), you can modify $node->content['body']['value']. Not that this will be the un- rendered content. To modify the rendered output, see hook_nodeapi($op = 'alter').
For a detailed usage example, see node_example.module.

Definition at line 416 of file node.php.

References nid, node_prepare(), t(), and theme().

hook_watchdog ( $ log_msg )

Log an event message.

This hook allows modules to route log events to custom destinations, such as SMS, Email, pager, syslog, ...etc.

Parameters:
$log_entry The log_entry is an associative array containing the following keys:
  • type: The type of message for this entry. For contributed modules, this is normally the module name. Do not use 'debug', use severity WATCHDOG_DEBUG instead.
  • user: The user object for the user who was logged in when the event happened.
  • request_uri: The Request URI for the page the event happened in.
  • referer: The page that referred the use to the page where the event occurred.
  • ip: The IP address where the request for the page came from.
  • timestamp: The UNIX timetamp of the date/time the event occurred
  • severity: One of the following values as defined in RFC 3164 http://www.faqs.org/rfcs/rfc3164.html WATCHDOG_EMERG Emergency: system is unusable WATCHDOG_ALERT Alert: action must be taken immediately WATCHDOG_CRITICAL Critical: critical conditions WATCHDOG_ERROR Error: error conditions WATCHDOG_WARNING Warning: warning conditions WATCHDOG_NOTICE Notice: normal but significant condition WATCHDOG_INFO Informational: informational messages WATCHDOG_DEBUG Debug: debug-level messages
  • link: an optional link provided by the module that called the watchdog() function.
  • message: The text of the message to be logged.
Returns:
None.

Definition at line 1629 of file core.php.

References $base_url, drupal_mail(), format_date(), name, t(), and variable_get().

hook_xmlrpc ( )

Register XML-RPC callbacks.

This hook lets a module register callback functions to be called when particular XML-RPC methods are invoked by a client.

Returns:
An array which maps XML-RPC methods to Drupal functions. Each array element is either a pair of method => function or an array with four entries:
  • The XML-RPC method name (for example, module.function).
  • The Drupal callback function (for example, module_function).
  • The method signature is an array of XML-RPC types. The first element of this array is the type of return value and then you should write a list of the types of the parameters. XML-RPC types are the following (See the types at http://www.xmlrpc.com/spec):
    • "boolean": 0 (false) or 1 (true).
    • "double": a floating point number (for example, -12.214).
    • "int": a integer number (for example, -12).
    • "array": an array without keys (for example, array(1, 2, 3)).
    • "struct": an associative array or an object (for example, array('one' => 1, 'two' => 2)).
    • "date": when you return a date, then you may either return a timestamp (time(), mktime() etc.) or an ISO8601 timestamp. When date is specified as an input parameter, then you get an object, which is described in the function xmlrpc_date
    • "base64": a string containing binary data, automatically encoded/decoded automatically.
    • "string": anything else, typically a string.
  • A descriptive help string, enclosed in a t() function for translation purposes. Both forms are shown in the example.

Definition at line 1588 of file core.php.

References t().

module_hook | ( | $ | module,
 |  | $ | hook
 | ) |  |

Determine whether a module implements a hook.

Parameters:
$module | The name of the module (without the .module extension).
$hook | The name of the hook (e.g. "help" or "menu").
Returns:
TRUE if the module is both installed and enabled, and the hook is implemented in that module.

Definition at line 385 of file module.inc.

Referenced by drupal_check_profile(), help_page(), menu_get_active_help(), module_disable(), module_enable(), module_implements(), module_invoke(), module_rebuild_cache(), node_hook(), search_admin_settings(), system_get_module_admin_tasks(), and system_modules_uninstall().

module_implements | ( | $ | hook,
 |  | $ | sort = FALSE,
 |  | $ | refresh = FALSE
 | ) |  |

Determine which modules are implementing a hook.

Parameters:
$hook | The name of the hook (e.g. "help" or "menu").
$sort | By default, modules are ordered by weight and filename, settings this option to TRUE, module list will be ordered by module name.
$refresh | For internal use only: Whether to force the stored list of hook implementations to be regenerated (such as after enabling a new module, before processing hook_enable).
Returns:
An array with the names of the modules which are implementing this hook.

Definition at line 404 of file module.inc.

References module_hook(), and module_list().

Referenced by _db_rewrite_sql(), _element_info(), _theme_build_registry(), block_list(), comment_invoke_comment(), drupal_alter(), drupal_get_schema(), help_links_as_list(), help_menu(), menu_router_build(), module_disable(), module_enable(), module_invoke_all(), node_access_rebuild(), node_access_write_grants(), node_configure(), node_invoke_nodeapi(), system_performance_settings(), and watchdog().

module_invoke ( )

Invoke a hook in a particular module.

Parameters:
$module | The name of the module (without the .module extension).
$hook | The name of the hook to invoke.
... Arguments to pass to the hook implementation.
Returns:
The return value of the hook implementation.

Definition at line 443 of file module.inc.

References module_hook().

Referenced by _block_rehash(), _db_rewrite_sql(), _drupal_install_module(), _element_info(), _filter_tips(), _update_refresh(), _user_categories(), _user_forms(), aggregator_refresh(), block_admin_configure(), block_admin_configure_submit(), block_list(), block_user(), blogapi_metaweblog_get_category_list(), blogapi_mt_get_post_categories(), bootstrap_invoke_all(), check_markup(), drupal_check_module(), drupal_check_profile(), drupal_get_schema(), drupal_get_schema_unprocessed(), drupal_http_request(), drupal_install_system(), drupal_uninstall_module(), filter_admin_configure(), filter_admin_format_form(), filter_admin_format_form_submit(), filter_list_all(), filter_list_format(), help_links_as_list(), help_page(), menu_get_active_help(), module_disable(), module_enable(), node_access(), node_filter_form(), node_filters(), node_form_alter(), node_search(), openid_association(), openid_discovery(), openid_verify_assertion(), path_admin_overview(), search_admin_settings(), search_view(), statistics_exit(), system_admin_by_module(), system_get_module_admin_tasks(), system_modules_submit(), system_themes_form_submit(), system_update_6027(), taxonomy_term_path(), update_check_requirements(), update_script_selection_form(), user_admin_perm(), user_filters(), watchdog(), and xmlrpc_error().

module_invoke_all ( )

Invoke a hook in all enabled modules that implement it.

Parameters:
$hook The name of the hook to invoke.
... Arguments to pass to the hook.
Returns:
An array of return values of the hook implementations. If modules return arrays from their implementations, those are merged into one array.

Definition at line 464 of file module.inc.

References $result, $return, and module_implements().

Referenced by _drupal_bootstrap_full(), _locale_translate_seek(), _node_types_build(), _ping_notify(), actions_delete(), actions_list(), comment_render(), drupal_cron_run(), drupal_flush_all_caches(), drupal_goto(), drupal_page_footer(), drupal_retrieve_form(), file_download(), locale_translate_export_po_form(), locale_translate_export_pot_form(), locale_translate_import_form(), locale_translate_overview_screen(), locale_translate_seek_form(), node_access_acquire_grants(), node_access_grants(), node_admin_nodes(), node_admin_nodes_submit(), node_type_delete(), node_type_reset(), node_type_save(), node_view(), openid_authentication_request(), poll_view(), search_admin_settings(), system_status(), taxonomy_del_term(), taxonomy_del_vocabulary(), taxonomy_save_term(), taxonomy_save_vocabulary(), theme_closure(), theme_comment_flat_expanded(), theme_comment_thread_expanded(), trigger_assign(), trigger_forms(), trigger_menu(), user_admin_account(), user_admin_account_submit(), user_delete(), and user_logout().

Generated on Tue Feb 12 15:30:50 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Image toolkits

Image toolkits

Detailed Description

Drupal's image toolkits provide an abstraction layer for common image file manipulations like scaling, cropping, and rotating.

The abstraction frees module authors from the need to support multiple image libraries, and it allows site administrators to choose the library that's best for them.

PHP includes the GD library by default so a GD toolkit is installed with Drupal. Other toolkits like ImageMagic are available from contrib modules. GD works well for small images, but using it with larger files may cause PHP to run out of memory. In contrast the ImageMagick library does not suffer from this problem, but it requires the ISP to have installed additional software.

Image toolkits are installed by copying the image.ToolkitName.inc file into Drupal's includes directory. The toolkit must then be enabled using the admin/settings/image-toolkit form.

Only one toolkit maybe selected at a time. If a module author wishes to call a specific toolkit they can check that it is installed by calling image_get_available_toolkits(), and then calling its functions directly.

  • image_gd_info ()
    Retrieve information about the toolkit.

Functions

  • image_crop ($source, $destination, $x, $y, $width, $height)
    Crop an image to the rectangle specified by the given rectangle.
  • image_get_available_toolkits ()
    Return a list of available toolkits.
  • image_get_info ($file)
    Get details about an image.
  • image_get_toolkit ()
    Retrieve the name of the currently used toolkit.
  • image_resize ($source, $destination, $width, $height)
    Resize an image to the given dimensions (ignoring aspect ratio).
  • image_rotate ($source, $destination, $degrees, $background=0x000000)
    Rotate an image by the given number of degrees.
  • image_scale ($source, $destination, $width, $height)
    Scales an image to the given width and height while maintaining aspect ratio.
  • image_scale_and_crop ($source, $destination, $width, $height)
    Scales an image to the exact width and height given.
  • image_toolkit_invoke ($method, $params=array())
    Invokes the given method using the currently selected toolkit.

Function Documentation

image_crop | ( | $ | source,
 |  | $ | destination,
 |  | $ | x,
 |  | $ | y,
 |  | $ | width,
 |  | $ | height
 | ) |  |

Crop an image to the rectangle specified by the given rectangle.

Parameters:
$source | The file path of the source image.
$destination | The file path of the destination image.
$x | The top left co-ordinate, in pixels, of the crop area (x axis value).
$y | The top left co-ordinate, in pixels, of the crop area (y axis value).
$width | The target width, in pixels.
$height | The target height, in pixels.
Returns:
TRUE or FALSE, based on success.

Definition at line 264 of file image.inc.

References image_toolkit_invoke().

image_gd_info ( )

Retrieve information about the toolkit.

Definition at line 17 of file image.gd.inc.

References t().

image_get_available_toolkits ( )

Return a list of available toolkits.

Returns:
An array of toolkit name => descriptive title.

Definition at line 39 of file image.inc.

References $output, file_scan_directory(), and name.

Referenced by system_image_toolkit_settings().

image_get_info ( $ file )

Get details about an image.

Drupal only supports GIF, JPG and PNG file formats.

Returns:
FALSE, if the file could not be found or is not an image. Otherwise, a keyed array containing information about the image: 'width' - Width in pixels. 'height' - Height in pixels. 'extension' - Commonly used file extension for the image. 'mime_type' - MIME type ('image/jpeg', 'image/gif', 'image/png'). 'file_size' - File size in bytes.

Definition at line 116 of file image.inc.

Referenced by file_validate_image_resolution(), file_validate_is_image(), hook_prepare(), image_gd_crop(), image_gd_resize(), image_gd_rotate(), image_scale(), image_scale_and_crop(), user_file_download(), and user_validate_picture().

image_get_toolkit ( )

Retrieve the name of the currently used toolkit.

Returns:
String containing the name of the selected toolkit, or FALSE on error.

Definition at line 61 of file image.inc.

References image_gd_check_settings(), and variable_get().

Referenced by file_validate_image_resolution(), image_toolkit_invoke(), and system_image_toolkit_settings().

image_resize | ( | $ | source,
 |  | $ | destination,
 |  | $ | width,
 |  | $ | height
 | ) |  |

Resize an image to the given dimensions (ignoring aspect ratio).

Parameters:
$source | The file path of the source image.
$destination | The file path of the destination image.
$width | The target width, in pixels.
$height | The target height, in pixels.
Returns:
TRUE or FALSE, based on success.

Definition at line 222 of file image.inc.

References image_toolkit_invoke().

image_rotate | ( | $ | source,
 |  | $ | destination,
 |  | $ | degrees,
 |  | $ | background = 0x000000
 | ) |  |

Rotate an image by the given number of degrees.

Parameters:
$source | The file path of the source image.
$destination | The file path of the destination image.
$degrees | The number of (clockwise) degrees to rotate the image.
$background | An hexidecimal integer specifying the background color to use for the uncovered area of the image after the rotation. E.g. 0x000000 for black, 0xff00ff for magenta, and 0xffffff for white.
Returns:
TRUE or FALSE, based on success.

Definition at line 242 of file image.inc.

References image_toolkit_invoke().

image_scale | ( | $ | source,
 |  | $ | destination,
 |  | $ | width,
 |  | $ | height
 | ) |  |

Scales an image to the given width and height while maintaining aspect ratio.

The resulting image can be smaller for one or both target dimensions.

Parameters:
$source | The file path of the source image.
$destination | The file path of the destination image.
$width | The target width, in pixels.
$height | The target height, in pixels.
Returns:
TRUE or FALSE, based on success.

Definition at line 187 of file image.inc.

References image_get_info(), and image_toolkit_invoke().

Referenced by file_validate_image_resolution().

image_scale_and_crop | ( | $ | source,
 |  | $ | destination,
 |  | $ | width,
 |  | $ | height
 | ) |  |

Scales an image to the exact width and height given.

Achieves the target aspect ratio by cropping the original image equally on both sides, or equally on the top and bottom. This function is, for example, useful to create uniform sized avatars from larger images.

The resulting image always has the exact target dimensions.

Parameters:
$source | The file path of the source image.
$destination | The file path of the destination image.
$width | The target width, in pixels.
$height | The target height, in pixels.
Returns:
TRUE or FALSE, based on success.

Definition at line 157 of file image.inc.

References image_get_info(), and image_toolkit_invoke().

image_toolkit_invoke | ( | $ | method,
 |  | $ | params = array()
 | ) |  |

Invokes the given method using the currently selected toolkit.

Parameters:
$method | A string containing the method to invoke.
$params | An optional array of parameters to pass to the toolkit method.
Returns:
Mixed values (typically Boolean indicating successful operation).

Definition at line 88 of file image.inc.

References image_get_toolkit(), and watchdog().

Referenced by image_crop(), image_resize(), image_rotate(), image_scale(), image_scale_and_crop(), and system_image_toolkit_settings().

Generated on Tue Feb 12 15:30:50 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Input validation

Input validation

Detailed Description

Functions to validate user input.

Functions

  • valid_email_address ($mail)
    Verify the syntax of the given e-mail address.
  • valid_url ($url, $absolute=FALSE)
    Verify the syntax of the given URL.

Function Documentation

valid_email_address ( $ mail )

Verify the syntax of the given e-mail address.

Empty e-mail addresses are allowed. See RFC 2822 for details.

Parameters:
$mail A string containing an e-mail address.
Returns:
TRUE if the address is in a valid format.

Definition at line 816 of file common.inc.

References $user.

Referenced by comment_validate(), contact_admin_edit_validate(), contact_mail_page_validate(), contact_user_page(), system_send_email_action_validate(), update_settings_validate(), and user_validate_mail().

valid_url | ( | $ | url,
 |  | $ | absolute = FALSE
 | ) |  |

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.

Parameters:
$url | The URL to verify.
$absolute | Whether the URL is absolute (beginning with a scheme such as "http:").
Returns:
TRUE if the URL is in a valid format.

Definition at line 838 of file common.inc.

References $url.

Referenced by aggregator_form_feed_validate(), comment_validate(), and profile_validate_profile().

Generated on Tue Feb 12 15:30:49 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Menu system

Menu system

Detailed Description

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().

Menu status codes

End of "Menu item types".

Status codes for menu callbacks.

  • enum MENU_ACCESS_DENIED
  • enum MENU_FOUND
  • enum MENU_NOT_FOUND
  • enum MENU_SITE_OFFLINE

Menu item types

End of "Menu flags".

Menu item definitions provide one of these constants, which are shortcuts for combinations of the above flags.

  • enum MENU_CALLBACK
    Callbacks simply register a path so that the correct function is fired when the URL is accessed. More...
  • enum MENU_DEFAULT_LOCAL_TASK
    Every set of local tasks should provide one "default" task, that links to the same path as its parent when clicked. More...
  • enum MENU_LOCAL_TASK
    Local tasks are rendered as tabs by default. More...
  • enum MENU_NORMAL_ITEM
    Normal menu items show up in the menu tree and can be moved/hidden by the administrator. More...
  • enum MENU_SUGGESTED_ITEM
    Modules may "suggest" menu items that the administrator may enable. More...

Menu flags

Flags for use in the "type" attribute of menu items.
  • enum MENU_CREATED_BY_ADMIN
  • enum MENU_IS_LOCAL_TASK
  • enum MENU_IS_ROOT
  • enum MENU_LINKS_TO_PARENT
  • enum MENU_MODIFIED_BY_ADMIN
  • enum MENU_VISIBLE_IN_BREADCRUMB
  • enum MENU_VISIBLE_IN_TREE
  • enum MENU_MAX_DEPTH
    The maximum depth of a menu links tree - matches the number of p columns. More...
  • enum MENU_MAX_PARTS
    End of "Menu status codes". More...

Functions

  • _menu_check_access (&$item, $map)
    Check access to a menu item using the access callback.
  • _menu_clear_page_cache ()
    Helper function to clear the page and block caches at most twice per page load.
  • _menu_delete_item ($item, $force=FALSE)
    Helper function for menu_link_delete; deletes a single menu link.
  • _menu_find_router_path ($menu, $link_path)
    Find the router path which will serve this path.
  • _menu_item_localize (&$item, $map, $link_translate=FALSE)
    Localize the router item title using t() or another callback.
  • _menu_link_build ($item)
    Builds a link from a router item.
  • _menu_link_map_translate (&$map, $to_arg_functions)
    This function translates the path elements in the map using any to_arg helper function.
  • _menu_link_move_children ($item, $existing_item)
    Update the children of a menu link that's being moved.
  • _menu_link_parents_set (&$item, $parent)
    Helper function that sets the p1.
  • _menu_link_translate (&$item)
    This function is similar to _menu_translate() but does link-specific preparation such as always calling to_arg functions.
  • _menu_load_objects (&$item, &$map)
    Loads objects into the map as defined in the $item['load_functions'].
  • _menu_navigation_links_rebuild ($menu)
    Helper function to build menu links for the items in the menu router.
  • _menu_router_build ($callbacks)
    Helper function to build the router table based on the data from hook_menu.
  • _menu_set_expanded_menus ()
    Helper function to update a list of menus with expanded items.
  • _menu_site_is_offline ()
    Checks whether the site is off-line for maintenance.
  • _menu_translate (&$router_item, $map, $to_arg=FALSE)
    Handles dynamic path translation and menu access control.
  • _menu_tree_check_access (&$tree)
    Recursive helper function for menu_tree_check_access().
  • _menu_tree_data ($result, $parents, $depth, $previous_element= '')
    Recursive helper function to build the data representing a menu tree.
  • _menu_update_parental_status ($item, $exclude=FALSE)
    Check and update the has_children status for the parent of a link.
  • drupal_help_arg ($arg=array())
    Generates elements for the $arg array in the help hook.
  • menu_cache_clear ($menu_name= 'navigation')
    Clears the cached cached data for a single named menu.
  • menu_cache_clear_all ()
    Clears all cached menu data.
  • menu_execute_active_handler ($path=NULL)
    Execute the page callback associated with the current path.
  • menu_get_active_breadcrumb ()
    Get the breadcrumb for the current page, as determined by the active trail.
  • menu_get_active_help ()
    Returns the help associated with the active menu item.
  • menu_get_active_menu_name ()
    Get the active menu for the current page - determines the active trail.
  • menu_get_active_title ()
    Get the title of the current page, as determined by the active trail.
  • menu_get_active_trail ()
    Get the active trail for the current page - the path to root in the menu tree.
  • menu_get_ancestors ($parts)
    End of "Menu tree parameters".
  • menu_get_item ($path=NULL, $router_item=NULL)
    Get a router item.
  • menu_get_names ($reset=FALSE)
    Build a list of named menus.
  • menu_get_object ($type= 'node', $position=1, $path=NULL)
    Get a loaded object from a router item.
  • menu_link_children_relative_depth ($item)
    Find the depth of an item's children relative to its depth.
  • menu_link_delete ($mlid, $path=NULL)
    Delete one or several menu links.
  • menu_link_load ($mlid)
    Get a menu link by its mlid, access checked and link translated for rendering.
  • menu_link_maintain ($module, $op, $link_path, $link_title)
    Insert, update or delete an uncustomized menu link related to a module.
  • menu_link_save (&$item)
    Save a menu link.
  • menu_list_system_menus ()
    Return an array containing the names of system-defined (default) menus.
  • menu_local_tasks ($level=0, $return_root=FALSE)
    Collects the local tasks (tabs) for a given level.
  • menu_navigation_links ($menu_name, $level=0)
    Return an array of links for a navigation menu.
  • menu_path_is_external ($path)
    Returns TRUE if a path is external (e.g.
  • menu_primary_links ()
    Return an array of links to be rendered as the Primary links.
  • menu_primary_local_tasks ()
    Returns the rendered local tasks at the top level.
  • menu_rebuild ()
    (Re)populate the database tables used by various menu functions.
  • menu_router_build ($reset=FALSE)
    Collect, alter and store the menu definitions.
  • menu_secondary_links ()
    Return an array of links to be rendered as the Secondary links.
  • menu_secondary_local_tasks ()
    Returns the rendered local tasks at the second level.
  • menu_set_active_item ($path)
    Set the active path, which determines which page is loaded.
  • menu_set_active_menu_name ($menu_name=NULL)
    Set (or get) the active menu for the current page - determines the active trail.
  • menu_set_active_trail ($new_trail=NULL)
    Set (or get) the active trail for the current page - the path to root in the menu tree.
  • menu_set_item ($path, $router_item)
    Replaces the statically cached item for a given path.
  • menu_tab_root_path ()
    Returns the router path, or the path of the parent tab of a default local task.
  • menu_tail_to_arg ($arg, $map, $index)
  • menu_tree ($menu_name= 'navigation')
    Render a menu tree based on the current path.
  • menu_tree_all_data ($menu_name= 'navigation', $item=NULL)
    Get the data structure representing a named menu tree.
  • menu_tree_check_access (&$tree, $node_links=array())
    Check access and perform other dynamic operations for each link in the tree.
  • menu_tree_collect_node_links (&$tree, &$node_links)
    Recursive helper function - collect node links.
  • menu_tree_data ($result=NULL, $parents=array(), $depth=1)
    Build the data representing a menu tree.
  • menu_tree_output ($tree)
    Returns a rendered menu tree.
  • menu_tree_page_data ($menu_name= 'navigation')
    Get the data structure representing a named menu tree, based on the current page.
  • menu_unserialize ($data, $map)
    The menu system uses serialized arrays stored in the database for arguments.
  • menu_valid_path ($form_item)
    Validates the path of a menu link being created or edited.

Enumeration Type Documentation

enum MENU_ACCESS_DENIED

Definition at line 145 of file menu.inc.

enum MENU_CALLBACK

Callbacks simply register a path so that the correct function is fired when the URL is accessed.

They are not shown in the menu.

Definition at line 110 of file menu.inc.

enum MENU_CREATED_BY_ADMIN

Definition at line 85 of file menu.inc.

enum MENU_DEFAULT_LOCAL_TASK

Every set of local tasks should provide one "default" task, that links to the same path as its parent when clicked.

Definition at line 131 of file menu.inc.

enum MENU_FOUND

Definition at line 143 of file menu.inc.

enum MENU_IS_LOCAL_TASK

Definition at line 86 of file menu.inc.

enum MENU_IS_ROOT

Definition at line 80 of file menu.inc.

enum MENU_LINKS_TO_PARENT

Definition at line 83 of file menu.inc.

enum MENU_LOCAL_TASK

Local tasks are rendered as tabs by default.

Use this for menu items that describe actions to be performed on their parent item. An example is the path "node/52/edit", which performs the "edit" task on "node/52".

Definition at line 125 of file menu.inc.

enum MENU_MAX_DEPTH

The maximum depth of a menu links tree - matches the number of p columns.

Definition at line 167 of file menu.inc.

enum MENU_MAX_PARTS

End of "Menu status codes".

Menu tree parameters

Menu tree The maximum number of path elements for a menu callback

Definition at line 161 of file menu.inc.

enum MENU_MODIFIED_BY_ADMIN

Definition at line 84 of file menu.inc.

enum MENU_NORMAL_ITEM

Normal menu items show up in the menu tree and can be moved/hidden by the administrator.

Use this for most menu items. It is the default value if no menu item type is specified.

Definition at line 104 of file menu.inc.

enum MENU_NOT_FOUND

Definition at line 144 of file menu.inc.

enum MENU_SITE_OFFLINE

Definition at line 146 of file menu.inc.

enum MENU_SUGGESTED_ITEM

Modules may "suggest" menu items that the administrator may enable.

They act just as callbacks do until enabled, at which time they act like normal items. Note for the value: 0x0010 was a flag which is no longer used, but this way the values of MENU_CALLBACK and MENU_SUGGESTED_ITEM are separate.

Definition at line 118 of file menu.inc.

enum MENU_VISIBLE_IN_BREADCRUMB

Definition at line 82 of file menu.inc.

enum MENU_VISIBLE_IN_TREE

Definition at line 81 of file menu.inc.

Function Documentation

_menu_check_access | ( | &$ | item,
 |  | $ | map
 | ) |  |

Check access to a menu item using the access callback.

Parameters:
$item | A menu router or menu link item
$map | An array of path arguments (ex: array('node', '5'))
Returns:
$item['access'] becomes TRUE if the item is accessible, FALSE otherwise.

Definition at line 435 of file menu.inc.

References $item, menu_unserialize(), and user_access().

Referenced by _menu_link_translate(), and _menu_translate().

_menu_clear_page_cache ( )

Helper function to clear the page and block caches at most twice per page load.

Definition at line 1939 of file menu.inc.

References _menu_set_expanded_menus(), and cache_clear_all().

Referenced by _menu_delete_item(), menu_link_save(), and menu_rebuild().

_menu_delete_item | ( | $ | item,
 |  | $ | force = FALSE
 | ) |  |

Helper function for menu_link_delete; deletes a single menu link.

Parameters:
$item | Item to be deleted.
$force | Forces deletion. Internal use only, setting to TRUE is discouraged.

Definition at line 1758 of file menu.inc.

References $item, $result, _menu_clear_page_cache(), _menu_update_parental_status(), db_fetch_array(), db_query(), menu_cache_clear(), menu_link_load(), and menu_link_save().

Referenced by _menu_navigation_links_rebuild(), drupal_uninstall_module(), and menu_link_delete().

_menu_find_router_path | ( | $ | menu,
 |  | $ | link_path
 | ) |  |

Find the router path which will serve this path.

Parameters:
$menu | The full built menu.
$link_path | The path for we are looking up its router path.
Returns:
A path from $menu keys or empty if $link_path points to a nonexisting place.

Definition at line 1981 of file menu.inc.

References menu_get_ancestors().

Referenced by _menu_navigation_links_rebuild(), and menu_link_save().

_menu_item_localize | ( | &$ | item,
 |  | $ | map,
 |  | $ | link_translate = FALSE
 | ) |  |

Localize the router item title using t() or another callback.

Translate the title and description to allow storage of English title strings in the database, yet display of them in the language required by the current user.

Parameters:
$item | A menu router item or a menu link item.
$map | The path as an array with objects already replaced. E.g., for path node/123 $map would be array('node', $node) where $node is the node object for node 123.
$link_translate | TRUE if we are translating a menu link item; FALSE if we are translating a menu router item.
Returns:
No return value. $item['title'] is localized according to $item['title_callback']. If an item's callback is check_plain(), $item['options']['html'] becomes TRUE. $item['description'] is translated using t(). When doing link translation and the $item['options']['attributes']['title'] (link title attribute) matches the description, it is translated as well.

Definition at line 481 of file menu.inc.

References $item, menu_unserialize(), and t().

Referenced by _menu_link_translate(), and _menu_translate().

_menu_link_build ( $ item )

Builds a link from a router item.

Definition at line 1658 of file menu.inc.

References $item.

Referenced by _menu_navigation_links_rebuild(), and menu_reset_item().

_menu_link_map_translate | ( | &$ | map,
 |  | $ | to_arg_functions
 | ) |  |

This function translates the path elements in the map using any to_arg helper function.

These functions take an argument and return an object. See http://drupal.org/node/109153 for more information.

Parameters:
map | An array of path arguments (ex: array('node', '5'))
$to_arg_functions | An array of helper function (ex: array(2 => 'menu_tail_to_arg'))

Definition at line 590 of file menu.inc.

Referenced by _menu_link_translate(), and _menu_translate().

_menu_link_move_children | ( | $ | item,
 |  | $ | existing_item
 | ) |  |

Update the children of a menu link that's being moved.

The menu name, parents (p1 - p6), and depth are updated for all children of the link, and the has_children status of the previous parent is updated.

Definition at line 2065 of file menu.inc.

References $item, _menu_update_parental_status(), and db_query().

Referenced by menu_link_save().

_menu_link_parents_set | ( | &$ | item,
 |  | $ | parent
 | ) |  |

Helper function that sets the p1.

.p9 values for a menu link being saved.

Definition at line 2130 of file menu.inc.

References $item.

Referenced by menu_link_save().

_menu_link_translate ( &$ item )

This function is similar to _menu_translate() but does link-specific preparation such as always calling to_arg functions.

Parameters:
$item A menu link
Returns:
Returns the map of path arguments with objects loaded as defined in the $item['load_functions']. $item['access'] becomes TRUE if the item is accessible, FALSE otherwise. $item['href'] is generated from link_path, possibly by to_arg functions. $item['title'] is generated from link_title, and may be localized. $item['options'] is unserialized; it is also changed within the call here to $item['localized_options'] by _menu_item_localize().

Definition at line 625 of file menu.inc.

References $item, _menu_check_access(), _menu_item_localize(), _menu_link_map_translate(), _menu_load_objects(), and drupal_alter().

Referenced by _menu_tree_check_access(), book_link_load(), menu_link_load(), menu_valid_path(), system_admin_menu_block(), system_get_module_admin_tasks(), and system_main_admin_page().

_menu_load_objects | ( | &$ | item,
 |  | &$ | map
 | ) |  |

Loads objects into the map as defined in the $item['load_functions'].

Parameters:
$item | A menu router or menu link item
$map | An array of path arguments (ex: array('node', '5'))
Returns:
Returns TRUE for success, FALSE if an object cannot be loaded. Names of object loading functions are placed in $item['load_functions']. Loaded objects are placed in $map[]; keys are the same as keys in the $item['load_functions'] array. $item['access'] is set to FALSE if an object cannot be loaded.

Definition at line 370 of file menu.inc.

References $item, $return, and $value.

Referenced by _menu_link_translate(), and _menu_translate().

_menu_navigation_links_rebuild ( $ menu )

Helper function to build menu links for the items in the menu router.

Definition at line 1681 of file menu.inc.

References $item, $result, _menu_delete_item(), _menu_find_router_path(), _menu_link_build(), db_fetch_array(), db_placeholders(), db_query(), and menu_link_save().

Referenced by menu_rebuild().

_menu_router_build ( $ callbacks )

Helper function to build the router table based on the data from hook_menu.

Definition at line 2148 of file menu.inc.

References $item, db_query(), drupal_get_path(), and variable_set().

Referenced by menu_router_build().

_menu_set_expanded_menus ( )

Helper function to update a list of menus with expanded items.

Definition at line 1961 of file menu.inc.

References $result, db_fetch_array(), db_query(), and variable_set().

Referenced by _menu_clear_page_cache().

_menu_site_is_offline ( )

Checks whether the site is off-line for maintenance.

This function will log the current user out and redirect to front page if the current user has no 'administer site configuration' permission.

Returns:
FALSE if the site is not off-line or its the login page or the user has 'administer site configuration' permission. TRUE for anonymous users not on the login page if the site is off-line.

Definition at line 2351 of file menu.inc.

References drupal_get_normal_path(), drupal_get_path(), drupal_set_message(), t(), user_access(), user_is_anonymous(), user_logout(), and variable_get().

Referenced by menu_execute_active_handler().

_menu_translate | ( | &$ | router_item,
 |  | $ | map,
 |  | $ | to_arg = FALSE
 | ) |  |

Handles dynamic path translation and menu access control.

When a user arrives on a page such as node/5, this function determines what "5" corresponds to, by inspecting the page's menu path definition, node/node. This will call node_load(5) to load the corresponding node object.

It also works in reverse, to allow the display of tabs and menu items which contain these dynamic arguments, translating node/node to node/5.

Translation of menu item titles and descriptions are done here to allow for storage of English strings in the database, and translation to the language required to generate the current page

Parameters:
$router_item | A menu router item
$map | An array of path arguments (ex: array('node', '5'))
$to_arg | Execute $item['to_arg_functions'] or not. Use only if you want to render a path from the menu table, for example tabs.
Returns:
Returns the map with objects loaded as defined in the $item['load_functions. $item['access'] becomes TRUE if the item is accessible, FALSE otherwise. $item['href'] is set according to the map. If an error occurs during calling the load_functions (like trying to load a non existing node) then this function return FALSE.

Definition at line 553 of file menu.inc.

References _menu_check_access(), _menu_item_localize(), _menu_link_map_translate(), and _menu_load_objects().

Referenced by menu_get_item(), and menu_local_tasks().

_menu_tree_check_access ( &$ tree )

Recursive helper function for menu_tree_check_access().

Definition at line 968 of file menu.inc.

References $item, and _menu_link_translate().

Referenced by menu_tree_check_access().

_menu_tree_data | ( | $ | result,
 |  | $ | parents,
 |  | $ | depth,
 |  | $ | previous_element = ''
 | ) |  |

Recursive helper function to build the data representing a menu tree.

The function is a bit complex because the rendering of an item depends on the next menu item. So we are always rendering the element previously processed not the current one.

Definition at line 1013 of file menu.inc.

References $depth, $item, $result, and db_fetch_array().

Referenced by menu_tree_data().

_menu_update_parental_status | ( | $ | item,
 |  | $ | exclude = FALSE
 | ) |  |

Check and update the has_children status for the parent of a link.

Definition at line 2116 of file menu.inc.

References $item, db_query(), db_query_range(), and db_result().

Referenced by _menu_delete_item(), _menu_link_move_children(), and menu_link_save().

drupal_help_arg ( $ arg = array() )

Generates elements for the $arg array in the help hook.

Definition at line 1118 of file menu.inc.

Referenced by help_links_as_list(), help_page(), menu_get_active_help(), search_view(), and system_admin_by_module().

menu_cache_clear ( $ menu_name = 'navigation' )

Clears the cached cached data for a single named menu.

Definition at line 1579 of file menu.inc.

References cache_clear_all().

Referenced by _menu_delete_item(), menu_link_maintain(), and menu_link_save().

menu_cache_clear_all ( )

Clears all cached menu data.

This should be called any time broad changes might have been made to the router items or menu links.

Definition at line 1596 of file menu.inc.

References cache_clear_all().

Referenced by book_uninstall(), menu_delete_menu_confirm_submit(), menu_enable(), and menu_rebuild().

menu_execute_active_handler ( $ path = NULL )

Execute the page callback associated with the current path.

Definition at line 335 of file menu.inc.

References _menu_site_is_offline(), menu_get_item(), menu_rebuild(), and variable_get().

Referenced by drupal_access_denied(), drupal_not_found(), system_check_http_request(), and user_page().

menu_get_active_breadcrumb ( )

Get the breadcrumb for the current page, as determined by the active trail.

Definition at line 1517 of file menu.inc.

References $item, drupal_is_front_page(), l(), menu_get_active_trail(), and menu_get_item().

Referenced by drupal_get_breadcrumb().

menu_get_active_help ( )

Returns the help associated with the active menu item.

Definition at line 1126 of file menu.inc.

References $name, $output, arg(), drupal_help_arg(), menu_tab_root_path(), module_exists(), module_hook(), module_invoke(), module_list(), theme(), and url().

Referenced by chameleon_help(), and theme_help().

menu_get_active_menu_name ( )

Get the active menu for the current page - determines the active trail.

Definition at line 1426 of file menu.inc.

References menu_set_active_menu_name().

Referenced by menu_set_active_trail().

menu_get_active_title ( )

Get the title of the current page, as determined by the active trail.

Definition at line 1545 of file menu.inc.

References $item, and menu_get_active_trail().

Referenced by drupal_get_title().

menu_get_active_trail ( )

Get the active trail for the current page - the path to root in the menu tree.

Definition at line 1510 of file menu.inc.

References menu_set_active_trail().

Referenced by menu_get_active_breadcrumb(), and menu_get_active_title().

menu_get_ancestors ( $ parts )

End of "Menu tree parameters".

Returns the ancestors (and relevant placeholders) for any given path.

For example, the ancestors of node/12345/edit are:

node/12345/edit node/12345/% node//edit node//% node/12345 node/% node

To generate these, we will use binary numbers. Each bit represents a part of the path. If the bit is 1, then it represents the original value while 0 means wildcard. If the path is node/12/edit/foo then the 1011 bitstring represents node//edit/foo where % means that any argument matches that part. We limit ourselves to using binary numbers that correspond the patterns of wildcards of router items that actually exists. This list of 'masks' is built in menu_rebuild().

Parameters:
$parts An array of path parts, for the above example array('node', '12345', 'edit').
Returns:
An array which contains the ancestors and placeholders. Placeholders simply contain as many 's' as the ancestors.

Definition at line 202 of file menu.inc.

References variable_get().

Referenced by _menu_find_router_path(), and menu_get_item().

menu_get_item | ( | $ | path = NULL,
 |  | $ | router_item = NULL
 | ) |  |

Get a router item.

Parameters:
$path | The path, for example node/5. The function will find the corresponding node/% item and return that.
$router_item | Internal use only.
Returns:
The router item, an associate array corresponding to one row in the menu_router table. The value of key map holds the loaded objects. The value of key access is TRUE if the current user can access this page. The values for key title, page_arguments, access_arguments will be filled in based on the database values and the objects loaded.

Definition at line 303 of file menu.inc.

References _menu_translate(), arg(), db_fetch_array(), db_query_range(), menu_get_ancestors(), and menu_unserialize().

Referenced by menu_execute_active_handler(), menu_get_active_breadcrumb(), menu_get_object(), menu_local_tasks(), menu_set_active_trail(), menu_set_item(), menu_tree_page_data(), menu_valid_path(), node_add_page(), path_admin_form_validate(), system_admin_menu_block_page(), system_logging_overview(), and system_settings_overview().

menu_get_names ( $ reset = FALSE )

Build a list of named menus.

Definition at line 1152 of file menu.inc.

References $name, $result, db_fetch_array(), and db_query().

menu_get_object | ( | $ | type = 'node',
 |  | $ | position = 1,
 |  | $ | path = NULL
 | ) |  |

Get a loaded object from a router item.

menu_get_object() will provide you the current node on paths like node/5, node/5/revisions/48 etc. menu_get_object('user') will give you the user account on user/5 etc. Note - this function should never be called within a _to_arg function (like user_current_to_arg()) since this may result in an infinite recursion.

Parameters:
$type | Type of the object. These appear in hook_menu definitons as type. Core provides aggregator_feed, aggregator_category, contact, filter_format, forum_term, menu, menu_link, node, taxonomy_vocabulary, user. See the relevant {$type}_load function for more on each. Defaults to node.
$position | The expected position for $type object. For node/node this is 1, for comment/reply/node this is 2. Defaults to 1.
$path | See for more on this. Defaults to the current path.

Definition at line 687 of file menu.inc.

References $type, and menu_get_item().

Referenced by book_block(), and template_preprocess_page().

menu_link_children_relative_depth ( $ item )

Find the depth of an item's children relative to its depth.

For example, if the item has a depth of 2, and the maximum of any child in the menu link tree is 5, the relative depth is 3.

Parameters:
$item An array representing a menu link item.
Returns:
The relative depth, or zero.

Definition at line 2043 of file menu.inc.

References $item, db_query_range(), and db_result().

Referenced by _book_parent_depth_limit(), _menu_parent_depth_limit(), and menu_link_save().

menu_link_delete | ( | $ | mlid,
 |  | $ | path = NULL
 | ) |  |

Delete one or several menu links.

Parameters:
$mlid | A valid menu link mlid or NULL. If NULL, $path is used.
$path | The path to the menu items to be deleted. $mlid must be NULL.

Definition at line 1738 of file menu.inc.

References $result, _menu_delete_item(), db_fetch_array(), and db_query().

Referenced by book_nodeapi(), book_remove_form_submit(), menu_delete_menu_confirm_submit(), menu_item_delete_form_submit(), menu_link_maintain(), and menu_nodeapi().

menu_link_load ( $ mlid )

Get a menu link by its mlid, access checked and link translated for rendering.

This function should never be called from within node_load() or any other function used as a menu object load function since an infinite recursion may occur.

Parameters:
$mlid The mlid of the menu item.
Returns:
A menu link, with $item['access'] filled and link translated for rendering.

Definition at line 1568 of file menu.inc.

References $item, _menu_link_translate(), db_fetch_array(), and db_query().

Referenced by _menu_delete_item(), menu_edit_menu_submit(), and menu_nodeapi().

menu_link_maintain | ( | $ | module,
 |  | $ | op,
 |  | $ | link_path,
 |  | $ | link_title
 | ) |  |

Insert, update or delete an uncustomized menu link related to a module.

Parameters:
$module | The name of the module.
$op | Operation to perform: insert, update or delete.
$link_path | The path this link points to.
$link_title | Title of the link to insert or new title to update the link to. Unused for delete.
Returns:
The insert op returns the mlid of the new item. Others op return NULL.

Definition at line 2011 of file menu.inc.

References $op, db_query(), menu_cache_clear(), menu_link_delete(), and menu_link_save().

Referenced by aggregator_save_category().

menu_link_save ( &$ item )

Save a menu link.

Parameters:
$item An array representing a menu link item. The only mandatory keys are link_path and link_title. Possible keys are menu_name default is navigation weight default is 0 expanded whether the item is expanded. options An array of options,
See also:
l for more. mlid Set to an existing value, or 0 or NULL to insert a new link. plid The mlid of the parent. router_path The path of the relevant router item.

Definition at line 1792 of file menu.inc.

References $item, $result, _menu_clear_page_cache(), _menu_find_router_path(), _menu_link_move_children(), _menu_link_parents_set(), _menu_update_parental_status(), db_fetch_array(), db_last_insert_id(), db_query(), db_result(), drupal_alter(), menu_cache_clear(), menu_link_children_relative_depth(), menu_path_is_external(), and menu_router_build().

Referenced by _book_update_outline(), _menu_delete_item(), _menu_navigation_links_rebuild(), book_admin_edit_submit(), book_update_6000(), menu_edit_item_submit(), menu_edit_menu_submit(), menu_enable(), menu_link_maintain(), menu_nodeapi(), menu_overview_form_submit(), menu_reset_item(), and system_update_6021().

menu_list_system_menus ( )

Return an array containing the names of system-defined (default) menus.

Definition at line 1168 of file menu.inc.

Referenced by menu_delete_menu_confirm_submit(), menu_delete_menu_page(), menu_edit_menu(), and menu_get_menus().

menu_local_tasks | ( | $ | level = 0,
 |  | $ | return_root = FALSE
 | ) |  |

Collects the local tasks (tabs) for a given level.

Parameters:
$level | The level of tasks you ask for. Primary tasks are 0, secondary are 1.
$return_root | Whether to return the root path for the current page.
Returns:
Themed output corresponding to the tabs of the requested level, or router path if $return_root == TRUE. This router path corresponds to a parent tab, if the current page is a default local task.

Definition at line 1251 of file menu.inc.

References $children, $depth, $item, $result, _menu_translate(), arg(), db_fetch_array(), db_query(), menu_get_item(), and theme().

Referenced by menu_primary_local_tasks(), menu_secondary_local_tasks(), and menu_tab_root_path().

menu_navigation_links | ( | $ | menu_name,
 |  | $ | level = 0
 | ) |  |

Return an array of links for a navigation menu.

Parameters:
$menu_name | The name of the menu.
$level | Optional, the depth of the menu to be returned.
Returns:
An array of links of the specified menu and level.

Definition at line 1204 of file menu.inc.

References $item, $links, and menu_tree_page_data().

Referenced by menu_primary_links(), and menu_secondary_links().

menu_path_is_external ( $ path )

Returns TRUE if a path is external (e.g.

http://example.com).

Definition at line 2335 of file menu.inc.

References check_plain(), and filter_xss_bad_protocol().

Referenced by menu_edit_item_validate(), menu_link_save(), and menu_valid_path().

menu_primary_links ( )

Return an array of links to be rendered as the Primary links.

Definition at line 1175 of file menu.inc.

References menu_navigation_links(), and variable_get().

Referenced by chameleon_page(), and template_preprocess_page().

menu_primary_local_tasks ( )

Returns the rendered local tasks at the top level.

Definition at line 1372 of file menu.inc.

References menu_local_tasks().

Referenced by phptemplate_menu_local_tasks(), and theme_menu_local_tasks().

menu_rebuild ( )

(Re)populate the database tables used by various menu functions.

This function will clear and populate the {menu_router} table, add entries to {menu_links} for new router items, then remove stale items from {menu_links}. If called from update.php or install.php, it will also schedule a call to itself on the first real page load from menu_execute_active_handler(), because the maintenance page environment is different and leaves stale data in the menu tables.

Definition at line 1610 of file menu.inc.

References _menu_clear_page_cache(), _menu_navigation_links_rebuild(), menu_cache_clear_all(), menu_router_build(), variable_del(), and variable_set().

Referenced by _locale_import_po(), default_profile_tasks(), drupal_flush_all_caches(), example_profile_tasks(), install_tasks(), menu_enable(), menu_execute_active_handler(), menu_uninstall(), node_type_delete_confirm_submit(), node_type_form_submit(), profile_admin_overview_submit(), profile_field_form_submit(), system_modules(), system_themes_form_submit(), system_update_6021(), system_update_6029(), and update_uninstall().

menu_router_build ( $ reset = FALSE )

Collect, alter and store the menu definitions.

Definition at line 1625 of file menu.inc.

References _menu_router_build(), cache_get(), cache_set(), db_query(), drupal_alter(), and module_implements().

Referenced by menu_link_save(), menu_rebuild(), and menu_reset_item().

menu_secondary_links ( )

Return an array of links to be rendered as the Secondary links.

Definition at line 1182 of file menu.inc.

References menu_navigation_links(), and variable_get().

Referenced by chameleon_page(), and template_preprocess_page().

menu_secondary_local_tasks ( )

Returns the rendered local tasks at the second level.

Definition at line 1379 of file menu.inc.

References menu_local_tasks().

Referenced by phptemplate_preprocess_page(), and theme_menu_local_tasks().

menu_set_active_item ( $ path )

Set the active path, which determines which page is loaded.

Parameters:
$path A Drupal path - not a path alias.
Note that this may not have the desired effect unless invoked very early in the page load, such as during hook_boot, or unless you call menu_execute_active_handler() to generate your page output.

Definition at line 1440 of file menu.inc.

Referenced by drupal_access_denied(), drupal_not_found(), and user_page().

menu_set_active_menu_name ( $ menu_name = NULL )

Set (or get) the active menu for the current page - determines the active trail.

Definition at line 1411 of file menu.inc.

Referenced by book_nodeapi(), and menu_get_active_menu_name().

menu_set_active_trail ( $ new_trail = NULL )

Set (or get) the active trail for the current page - the path to root in the menu tree.

Definition at line 1447 of file menu.inc.

References $item, arg(), drupal_is_front_page(), menu_get_active_menu_name(), menu_get_item(), menu_tree_page_data(), and t().

Referenced by book_nodeapi(), and menu_get_active_trail().

menu_set_item | ( | $ | path,
 |  | $ | router_item
 | ) |  |

Replaces the statically cached item for a given path.

Parameters:
$path | The path.
$router_item | The router item. Usually you take a router entry from menu_get_item and set it back either modified or to a different path. This lets you modify the navigation block, the page title, the breadcrumb and the page help in one call.

Definition at line 284 of file menu.inc.

References menu_get_item().

menu_tab_root_path ( )

Returns the router path, or the path of the parent tab of a default local task.

Definition at line 1386 of file menu.inc.

References menu_local_tasks().

Referenced by menu_get_active_help().

menu_tail_to_arg | ( | $ | arg,
 |  | $ | map,
 |  | $ | index
 | ) |  |

Definition at line 606 of file menu.inc.

menu_tree ( $ menu_name = 'navigation' )

Render a menu tree based on the current path.

The tree is expanded based on the current path and dynamic paths are also changed according to the defined to_arg functions (for example the 'My account' link is changed from user/% to a link with the current user's uid).

Parameters:
$menu_name The name of the menu.
Returns:
The rendered HTML of that menu on the current page.

Definition at line 706 of file menu.inc.

References menu_tree_output(), and menu_tree_page_data().

Referenced by menu_block(), and user_block().

menu_tree_all_data | ( | $ | menu_name = 'navigation',
 |  | $ | item = NULL
 | ) |  |

Get the data structure representing a named menu tree.

Since this can be the full tree including hidden items, the data returned may be used for generating an an admin interface or a select.

Parameters:
$menu_name | The named menu links to return
$item | A fully loaded menu link, or NULL. If a link is supplied, only the path to root will be included in the returned tree- as if this link represented the current page in a visible menu.
Returns:
An tree of menu links in an array, in the order they should be rendered.

Definition at line 771 of file menu.inc.

References $item, cache_get(), cache_set(), db_query(), menu_tree_check_access(), menu_tree_collect_node_links(), and menu_tree_data().

Referenced by book_block(), book_build_active_trail(), book_get_flat_menu(), book_toc(), and menu_parent_options().

menu_tree_check_access | ( | &$ | tree,
 |  | $ | node_links = array()
 | ) |  |

Check access and perform other dynamic operations for each link in the tree.

Definition at line 947 of file menu.inc.

References $nid, $result, _menu_tree_check_access(), db_fetch_array(), db_query(), and db_rewrite_sql().

Referenced by book_menu_subtree_data(), menu_overview_form(), menu_tree_all_data(), and menu_tree_page_data().

menu_tree_collect_node_links | ( | &$ | tree,
 |  | &$ | node_links
 | ) |  |

Recursive helper function - collect node links.

Definition at line 929 of file menu.inc.

References $nid.

Referenced by book_menu_subtree_data(), menu_overview_form(), menu_tree_all_data(), and menu_tree_page_data().

menu_tree_data | ( | $ | result = NULL,
 |  | $ | parents = array(),
 |  | $ | depth = 1
 | ) |  |

Build the data representing a menu tree.

Parameters:
$result | The database result.
$parents | An array of the plid values that represent the path from the current page to the root of the menu tree.
$depth | The depth of the current menu tree.
Returns:
See menu_tree_page_data for a description of the data structure.

Definition at line 1001 of file menu.inc.

References $depth, $result, and _menu_tree_data().

Referenced by book_menu_subtree_data(), menu_overview_form(), menu_tree_all_data(), and menu_tree_page_data().

menu_tree_output ( $ tree )

Returns a rendered menu tree.

Parameters:
$tree A data structure representing the tree as returned from menu_tree_data.
Returns:
The rendered HTML of that data structure.

Definition at line 724 of file menu.inc.

References $items, $output, and theme().

Referenced by book_block(), book_children(), and menu_tree().

menu_tree_page_data ( $ menu_name = 'navigation' )

Get the data structure representing a named menu tree, based on the current page.

The tree order is maintained by storing each parent in an individual field, see http://drupal.org/node/141866 for more.

Parameters:
$menu_name The named menu links to return
Returns:
An array of menu links, in the order they should be rendered. The array is a list of associative arrays -- these have two keys, link and below. link is a menu item, ready for theming as a link. Below represents the submenu below the link if there is one, and it is a subtree that has the same structure described for the top-level array.

Definition at line 843 of file menu.inc.

References $item, $result, cache_get(), cache_set(), db_fetch_array(), db_query(), drupal_is_front_page(), menu_get_item(), menu_tree_check_access(), menu_tree_collect_node_links(), menu_tree_data(), and variable_get().

Referenced by menu_navigation_links(), menu_set_active_trail(), and menu_tree().

menu_unserialize | ( | $ | data,
 |  | $ | map
 | ) |  |

The menu system uses serialized arrays stored in the database for arguments.

However, often these need to change according to the current path. This function unserializes such an array and does the necessary change.

Integer values are mapped according to the $map parameter. For example, if unserialize($data) is array('view', 1) and $map is array('node', '12345') then 'view' will not be changed because it is not an integer, but 1 will as it is an integer. As $map[1] is '12345', 1 will be replaced with '12345'. So the result will be array('node_load', '12345').

Parameters:
@data | A serialized array.
@map | An array of potential replacements.
Returns:
The $data array unserialized and mapped.

Definition at line 257 of file menu.inc.

Referenced by _menu_check_access(), _menu_item_localize(), and menu_get_item().

menu_valid_path ( $ form_item )

Validates the path of a menu link being created or edited.

Returns:
TRUE if it is a valid path AND the current user has access permission, FALSE otherwise.

Definition at line 2383 of file menu.inc.

References $item, $menu_admin, _menu_link_translate(), db_fetch_array(), db_query(), menu_get_item(), and menu_path_is_external().

Referenced by menu_edit_item_validate(), and system_site_information_settings_validate().

Generated on Tue Feb 12 15:30:50 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Node access rights

Node access rights

Detailed Description

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 "administer nodes" permission. Such users have unrestricted access to all nodes. Then the node module's hook_access() is called, and a TRUE or FALSE return value will grant or deny access. This allows, for example, the blog module to always grant access to the blog author, and for the book module to always deny editing access to PHP pages.

If node module does not intervene (returns NULL), 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_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 db_rewrite_sql() to add the appropriate clauses to your query for access checks.

To see how to write a node access module of your own, see node_access_example.module.

Functions

  • _node_access_join_sql ($node_alias= 'n', $node_access_alias= 'na')
    Generate an SQL join clause for use in fetching a node listing.
  • _node_access_rebuild_batch_finished ($success, $results, $operations)
    Post-processing for node_access_rebuild_batch.
  • _node_access_rebuild_batch_operation (&$context)
    Batch operation for node_access_rebuild_batch.
  • _node_access_where_sql ($op= 'view', $node_access_alias= 'na', $account=NULL)
    Generate an SQL where clause for use in fetching a node listing.
  • hook_access ($op, $node, $account)
    Define access restrictions.
  • hook_node_access_records ($node)
    Set permissions for a node to be written to the database.
  • hook_node_grants ($account, $op)
    Inform the node access system what permissions the user has.
  • node_access ($op, $node, $account=NULL)
    Determine whether the current user may perform the given operation on the specified node.
  • node_access_acquire_grants ($node)
    This function will call module invoke to get a list of grants and then write them to the database.
  • node_access_grants ($op, $account=NULL)
    Fetch an array of permission IDs granted to the given user ID.
  • node_access_needs_rebuild ($rebuild=NULL)
    Flag / unflag the node access grants for rebuilding, or read the current value of the flag.
  • node_access_rebuild ($batch_mode=FALSE)
    Rebuild the node access database.
  • node_access_view_all_nodes ()
    Determine whether the user has a global viewing grant for all nodes.
  • node_access_write_grants ($node, $grants, $realm=NULL, $delete=TRUE)
    This function will write a list of grants to the database, deleting any pre-existing grants.
  • node_db_rewrite_sql ($query, $primary_table, $primary_field)
    Implementation of hook_db_rewrite_sql.

Function Documentation

_node_access_join_sql | ( | $ | node_alias = 'n',
 |  | $ | node_access_alias = 'na'
 | ) |  |

Generate an SQL join clause for use in fetching a node listing.

Parameters:
$node_alias | If the node table has been given an SQL alias other than the default "n", that must be passed here.
$node_access_alias | If the node_access table has been given an SQL alias other than the default "na", that must be passed here.
Returns:
An SQL join clause.

Definition at line 2043 of file node.module.

References user_access().

Referenced by node_db_rewrite_sql().

_node_access_rebuild_batch_finished | ( | $ | success,
 |  | $ | results,
 |  | $ | operations
 | ) |  |

Post-processing for node_access_rebuild_batch.

Definition at line 2356 of file node.module.

References cache_clear_all(), drupal_set_message(), node_access_needs_rebuild(), and t().

_node_access_rebuild_batch_operation ( &$ context )

Batch operation for node_access_rebuild_batch.

This is a mutlistep operation : we go through all nodes by packs of 20. The batch processing engine interrupts processing and sends progress feedback after 1 second execution time.

Definition at line 2325 of file node.module.

References $result, $row, db_fetch_array(), db_query(), db_query_range(), db_result(), node_access_acquire_grants(), and node_load().

_node_access_where_sql | ( | $ | op = 'view',
 |  | $ | node_access_alias = 'na',
 |  | $ | account = NULL
 | ) |  |

Generate an SQL where clause for use in fetching a node listing.

Parameters:
$op | The operation that must be allowed to return a node.
$node_access_alias | If the node_access table has been given an SQL alias other than the default "na", that must be passed here.
$account | The user object for the user performing the operation. If omitted, the current user is used.
Returns:
An SQL where clause.

Definition at line 2065 of file node.module.

References $op, node_access_grants(), and user_access().

Referenced by node_db_rewrite_sql().

hook_access | ( | $ | op,
 |  | $ | node,
 |  | $ | account
 | ) |  |

Define access restrictions.

This hook allows node modules to limit access to the node types they define.

Parameters:
$op The operation to be performed. Possible values:
  • "create"
  • "delete"
  • "update"
  • "view"
$node | The node on which the operation is to be performed, or, if it does not yet exist, the type of node to be created.
$account | A user object representing the user for whom the operation is to be performed.
Returns:
TRUE if the operation may be performed; FALSE if the operation may not be returned; NULL to not override the settings in the node_access table.
The administrative account (user ID #1) always passes any access check, so this hook is not called in that case. If this hook is not defined for a node type, all access checks will fail, so only the administrator will be able to see content of that type. However, users with the "administer nodes" permission may always view and edit content through the administrative interface.

For a detailed usage example, see node_example.module.

Definition at line 143 of file node.php.

References $op, and user_access().

hook_node_access_records ( $ node )

Set permissions for a node to be written to the database.

When a node is saved, a module implementing node access will be asked if it is interested in the access permissions to a node. If it is interested, it must respond with an array of array of permissions for that node.

Each item in the array should contain:

'realm' This should only be realms for which the module has returned grant IDs in hook_node_grants. 'gid' This is a 'grant ID', which can have an arbitrary meaning per realm. 'grant_view' If set to TRUE a user with the gid in the realm can view this node. 'grant_edit' If set to TRUE a user with the gid in the realm can edit this node. 'grant_delete' If set to TRUE a user with the gid in the realm can delete this node. 'priority' If multiple modules seek to set permissions on a node, the realms that have the highest priority will win out, and realms with a lower priority will not be written. If there is any doubt, it is best to leave this 0.

Definition at line 927 of file core.php.

hook_node_grants | ( | $ | account,
 |  | $ | op
 | ) |  |

Inform the node access system what permissions the user has.

This hook is for implementation by node access modules. In addition to managing access rights for nodes, the node access module must tell the node access system what 'grant IDs' the current user has. In many cases, the grant IDs will simply be role IDs, but grant IDs can be arbitrary based upon the module.

For example, modules can maintain their own lists of users, where each list has an ID. In that case, the module could return a list of all IDs of all lists that the current user is a member of.

A node access module may implement as many realms as necessary to properly define the access privileges for the nodes.

Parameters:
$user | The user object whose grants are requested.
$op | The node operation to be performed, such as "view", "update", or "delete".
Returns:
An array whose keys are "realms" of grants such as "user" or "role", and whose values are linear lists of grant IDs.
For a detailed example, see node_access_example.module.

Definition at line 890 of file core.php.

References $user, and user_access().

node_access | ( | $ | op,
 |  | $ | node,
 |  | $ | account = NULL
 | ) |  |

Determine whether the current user may perform the given operation on the specified node.

Parameters:
$op The operation to be performed on the node. Possible values are:
  • "view"
  • "update"
  • "delete"
  • "create"
$node | The node object (or node array) on which the operation is to be performed, or node type (e.g. 'forum') for "create" operation.
$account | Optional, a user object representing the user for whom the operation is to be performed. Determines access for a user other than the current user.
Returns:
TRUE if the operation may be performed.

Definition at line 1965 of file node.module.

References $op, $result, $user, db_query(), db_result(), filter_access(), module_invoke(), nid, node_access_grants(), node_get_types(), and user_access().

Referenced by _blogapi_get_node_types(), _book_outline_access(), _node_add_access(), _node_revision_access(), blogap_mti_publish_post(), blogapi_blogger_edit_post(), blogapi_blogger_new_post(), book_link(), node_add(), node_delete(), node_form(), node_preview(), node_revision_overview(), template_preprocess_forums(), and translation_node_overview().

node_access_acquire_grants ( $ node )

This function will call module invoke to get a list of grants and then write them to the database.

It is called at node save, and should be called by modules whenever something other than a node_save causes the permissions on a node to change.

This function is the only function that should write to the node_access table.

Parameters:
$node The $node to acquire grants for.

Definition at line 2162 of file node.module.

References module_invoke_all(), and node_access_write_grants().

Referenced by _node_access_rebuild_batch_operation(), node_access_rebuild(), and node_save().

node_access_grants | ( | $ | op,
 |  | $ | account = NULL
 | ) |  |

Fetch an array of permission IDs granted to the given user ID.

The implementation here provides only the universal "all" grant. A node access module should implement hook_node_grants() to provide a grant list for the user.

Parameters:
$op | The operation that the user is trying to perform.
$account | The user object for the user performing the operation. If omitted, the current user is used.
Returns:
An associative array in which the keys are realms, and the values are arrays of grants for those realms.

Definition at line 2102 of file node.module.

References $op, and module_invoke_all().

Referenced by _node_access_where_sql(), node_access(), and node_access_view_all_nodes().

node_access_needs_rebuild ( $ rebuild = NULL )

Flag / unflag the node access grants for rebuilding, or read the current value of the flag.

When the flag is set, a message is displayed to users with 'access administration pages' permission, pointing to the 'rebuild' confirm form. This can be used as an alternative to direct node_access_rebuild calls, allowing administrators to decide when they want to perform the actual (possibly time consuming) rebuild. When unsure the current user is an adminisrator, node_access_rebuild should be used instead.

Parameters:
$rebuild (Optional) The boolean value to be written.
Returns:
(If no value was provided for $rebuild) The current value of the flag.

Definition at line 2242 of file node.module.

References variable_del(), variable_get(), and variable_set().

Referenced by _node_access_rebuild_batch_finished(), module_disable(), module_enable(), node_access_rebuild(), and node_help().

node_access_rebuild ( $ batch_mode = FALSE )

Rebuild the node access database.

This is occasionally needed by modules that make system-wide changes to access levels.

When the rebuild is required by an admin-triggered action (e.g module settings form), calling node_access_needs_rebuild(TRUE) instead of node_access_rebuild() lets the user perform his changes and actually rebuild only once he is done.

Note : As of Drupal 6, node access modules are not required to (and actually should not) call node_access_rebuild() in hook_enable/disable anymore.

See also:
node_access_needs_rebuild()
Parameters:
$batch_mode Set to TRUE to process in 'batch' mode, spawning processing over several HTTP requests (thus avoiding the risk of PHP timeout if the site has a large number of nodes). hook_update_N and any form submit handler are safe contexts to use the 'batch mode'. Less decidable cases (such as calls from hook_user, hook_taxonomy, hook_node_type...) might consider using the non-batch mode.

Definition at line 2276 of file node.module.

References $result, batch_set(), cache_clear_all(), db_fetch_object(), db_query(), drupal_set_message(), module_implements(), nid, node_access_acquire_grants(), node_access_needs_rebuild(), node_load(), and t().

Referenced by module_disable(), and node_configure_rebuild_confirm_submit().

node_access_view_all_nodes ( )

Determine whether the user has a global viewing grant for all nodes.

Definition at line 2114 of file node.module.

References $result, db_query(), db_result(), and node_access_grants().

Referenced by node_db_rewrite_sql().

node_access_write_grants | ( | $ | node,
 |  | $ | grants,
 |  | $ | realm = NULL,
 |  | $ | delete = TRUE
 | ) |  |

This function will write a list of grants to the database, deleting any pre-existing grants.

If a realm is provided, it will only delete grants from that realm, but it will always delete a grant from the 'all' realm. Modules which utilize node_access can use this function when doing mass updates due to widespread permission changes.

Parameters:
$node | The $node being written to. All that is necessary is that it contain a nid.
$grants | A list of grants to write. Each grant is an array that must contain the following keys: realm, gid, grant_view, grant_update, grant_delete. The realm is specified by a particular module; the gid is as well, and is a module-defined id to define grant privileges. each grant_* field is a boolean value.
$realm | If provided, only read/write grants for that realm.
$delete | If false, do not delete records. This is only for optimization purposes, and assumes the caller has already performed a mass delete of some form.

Definition at line 2202 of file node.module.

References db_query(), module_implements(), and nid.

Referenced by node_access_acquire_grants().

node_db_rewrite_sql | ( | $ | query,
 |  | $ | primary_table,
 |  | $ | primary_field
 | ) |  |

Implementation of hook_db_rewrite_sql.

Definition at line 2141 of file node.module.

References $return, _node_access_join_sql(), _node_access_where_sql(), and node_access_view_all_nodes().

Generated on Tue Feb 12 15:30:51 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Schema API

Schema API

Detailed Description

End of "defgroup database".

A Drupal schema definition is an array structure representing one or more tables and their related keys and indexes. A schema is defined by hook_schema(), which usually lives in a modulename.install file.

By implementing hook_schema() and specifying the tables your module declares, you can easily create and drop these tables on all supported database engines. You don't have to deal with the different SQL dialects for table creation and alteration of the supported database engines.

hook_schema() should return an array with a key for each table that the module defines.

The following keys are defined:

  • 'description': A string describing this table and its purpose. References to other tables should be enclosed in curly-brackets. For example, the node_revisions table description field might contain "Stores per-revision title and body data for each {node}."
  • 'fields': An associative array ('fieldname' => specification) that describes the table's database columns. The specification is also an array. The following specification parameters are defined:

  • 'description': A string describing this field and its purpose. References to other tables should be enclosed in curly-brackets. For example, the node table vid field description might contain "Always holds the largest (most recent) {node_revisions}.vid value for this nid."
  • 'type': The generic datatype: 'varchar', 'int', 'serial' 'float', 'numeric', 'text', 'blob' or 'datetime'. Most types just map to the according database engine specific datatypes. Use 'serial' for auto incrementing fields. This will expand to 'int auto_increment' on mysql.
  • 'size': The data size: 'tiny', 'small', 'medium', 'normal', 'big'. This is a hint about the largest value the field will store and determines which of the database engine specific datatypes will be used (e.g. on MySQL, TINYINT vs. INT vs. BIGINT). 'normal', the default, selects the base type (e.g. on MySQL, INT, VARCHAR, BLOB, etc.).

Not all sizes are available for all data types. See db_type_map() for possible combinations.

  • 'not null': If true, no NULL values will be allowed in this database column. Defaults to false.
  • 'default': The field's default value. The PHP type of the value matters: '', '0', and 0 are all different. If you specify '0' as the default value for a type 'int' field it will not work because '0' is a string containing the character "zero", not an integer.
  • 'length': The maximal length of a type 'varchar' or 'text' field. Ignored for other field types.
  • 'unsigned': A boolean indicating whether a type 'int', 'float' and 'numeric' only is signed or unsigned. Defaults to FALSE. Ignored for other field types.
  • 'precision', 'scale': For type 'numeric' fields, indicates the precision (total number of significant digits) and scale (decimal digits right of the decimal point). Both values are mandatory. Ignored for other field types.

All parameters apart from 'type' are optional except that type 'numeric' columns must specify 'precision' and 'scale'.

  • 'primary key': An array of one or more key column specifiers (see below) that form the primary key.
  • 'unique key': An associative array of unique keys ('keyname' => specification). Each specification is an array of one or more key column specifiers (see below) that form a unique key on the table.
  • 'indexes': An associative array of indexes ('indexame' => specification). Each specification is an array of one or more key column specifiers (see below) that form an index on the table.

A key column specifier is either a string naming a column or an array of two elements, column name and length, specifying a prefix of the named column.

As an example, here is a SUBSET of the schema definition for Drupal's 'node' table. It show four fields (nid, vid, type, and title), the primary key on field 'nid', a unique key named 'vid' on field 'vid', and two indexes, one named 'nid' on field 'nid' and one named 'node_title_type' on the field 'title' and the first four bytes of the field 'type':

 $schema['node'] = array(
   'fields' => array(
     'nid'      => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
     'vid'      => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
     'type'     => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''),
     'title'    => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''),
   ),
   'primary key' => array('nid'),
   'unique keys' => array(
     'vid'     => array('vid')
   ),
   'indexes' => array(
     'nid'                 => array('nid'),
     'node_title_type'     => array('title', array('type', 4)),
   ),
 );

See also:
drupal_install_schema()

  • db_create_table_sql ($name, $table)
    Generate SQL to create a new table from a Drupal schema definition.
  • db_type_map ()
    End of "ingroup database".
  • drupal_get_schema ($table=NULL, $rebuild=FALSE)
    Get the schema definition of a table, or the whole database schema.

Functions

  • db_create_table (&$ret, $name, $table)
    Create a new table from a Drupal table definition.
  • db_field_names ($fields)
    Return an array of field names from an array of key/index column specifiers.
  • db_type_placeholder ($type)
    Given a Schema API field type, return the correct -placeholder.

Function Documentation

db_create_table | ( | &$ | ret,
 |  | $ | name,
 |  | $ | table
 | ) |  |

Create a new table from a Drupal table definition.

Parameters:
$ret | Array to which query results will be added.
$name | The name of the table to create.
$table | A Schema API table definition array.

Definition at line 506 of file database.inc.

References $name, db_create_table_sql(), and update_sql().

Referenced by book_update_6000(), drupal_install_schema(), locale_update_6000(), system_update_6020(), system_update_6021(), system_update_6030(), system_update_6036(), update_create_batch_table(), and update_fix_d6_requirements().

db_create_table_sql | ( | $ | name,
 |  | $ | table
 | ) |  |

Generate SQL to create a new table from a Drupal schema definition.

Parameters:
$name | The name of the table to create.
$table | A Schema API table definition array.
Returns:
An array of SQL statements to create the table.

Definition at line 60 of file database.mysql-common.inc.

References $name, _db_create_field_sql(), _db_create_keys_sql(), and _db_process_field().

Referenced by db_create_table().

db_field_names ( $ fields )

Return an array of field names from an array of key/index column specifiers.

This is usually an identity function but if a key/index uses a column prefix specification, this function extracts just the name.

Parameters:
$fields An array of key/index column specifiers.
Returns:
An array of field names.

Definition at line 524 of file database.inc.

db_type_map ( )

End of "ingroup database".

This maps a generic data type in combination with its data size to the engine-specific data type.

Definition at line 441 of file database.pgsql.inc.

db_type_placeholder ( $ type )

Given a Schema API field type, return the correct -placeholder.

Embed the placeholder in a query to be passed to db_query and and pass as an argument to db_query a value of the specified type.

Parameters:
$type The Schema API type of a field.
Returns:
The placeholder string to embed in a query for that type.

Definition at line 548 of file database.inc.

References $type.

Referenced by db_add_field(), db_placeholders(), and drupal_write_record().

drupal_get_schema | ( | $ | table = NULL,
 |  | $ | rebuild = FALSE
 | ) |  |

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().

Parameters:
$table | The name of the table. If not given, the schema of all tables is returned.
$rebuild | If true, the schema will be rebuilt instead of retrieved from the cache.

Definition at line 3040 of file common.inc.

References _drupal_initialize_schema(), cache_get(), cache_set(), drupal_alter(), module_implements(), module_invoke(), and module_load_all_includes().

Referenced by drupal_schema_fields_sql(), and drupal_write_record().

Generated on Tue Feb 12 15:30:49 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Search interface

Search interface

Detailed Description

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 nodeapi('update index') and nodeapi('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_nodeapi('view'). This is usually sufficient. You should only use this mechanism if you want additional, non-visible data to be indexed.
  • Implement hook_search(). This will create a search tab for your module on the /search page with a simple keyword search form. You may optionally implement hook_search_item() to customize the display of your results.
  • 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(). 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

  • do_search ($keywords, $type, $join1= '', $where1= '1', $arguments1=array(), $columns2= 'i.relevance AS score', $join2= '', $arguments2=array(), $sort_parameters= 'ORDER BY score DESC')
    Do a query on the full-text search index for a word or words.
  • hook_search ($op= 'search', $keys=null)
    Define a custom search routine.
  • hook_update_index ()
    Update Drupal's full-text index for this module.
  • search_box_form_submit ($form, &$form_state)
    Process a block search form submission.
  • search_data ($keys=NULL, $type= 'node')
    Perform a standard search on the given keys, and return the formatted results.
  • search_excerpt ($keys, $text)
    Returns snippets from a piece of text, with certain keywords highlighted.
  • search_form (&$form_state, $action= '', $keys= '', $type=NULL, $prompt=NULL)
    Render a search form.
  • search_index ($sid, $type, $text)
    Update the full-text search index for a particular item.
  • template_preprocess_search_block_form (&$variables)
    Process variables for search-block-form.tpl.php.
  • template_preprocess_search_theme_form (&$variables)
    Process variables for search-theme-form.tpl.php.

Function Documentation

do_search | ( | $ | keywords,
 |  | $ | type,
 |  | $ | join1 = '',
 |  | $ | where1 = '1',
 |  | $ | arguments1 = array(),
 |  | $ | columns2 = 'i.relevance AS score',
 |  | $ | join2 = '',
 |  | $ | arguments2 = array(),
 |  | $ | sort_parameters = 'ORDER BY score DESC'
 | ) |  |

Do a query on the full-text search index for a word or words.

This function is normally only called by each module that support the indexed search (and thus, implements hook_update_index()).

Results are retrieved in two logical passes. However, the two passes are joined together into a single query. And in the case of most simple queries the second pass is not even used.

The first pass selects a set of all possible matches, which has the benefit of also providing the exact result set for simple "AND" or "OR" searches.

The second portion of the query further refines this set by verifying advanced text conditions (such negative or phrase matches)

Parameters:
$keywords | A search string as entered by the user.
$type | A string identifying the calling module.
$join1 | (optional) Inserted into the JOIN part of the first SQL query. For example "INNER JOIN {node} n ON n.nid = i.sid".
$where1 | (optional) Inserted into the WHERE part of the first SQL query. For example "(n.status > %d)".
$arguments1 | (optional) Extra SQL arguments belonging to the first query.
$columns2 | (optional) Inserted into the SELECT pat of the second query. Must contain a column selected as 'score'. defaults to 'i.relevance AS score'
$join2 | (optional) Inserted into the JOIN par of the second SQL query. For example "INNER JOIN {node_comment_statistics} n ON n.nid = i.sid"
$arguments2 | (optional) Extra SQL arguments belonging to the second query parameter.
$sort_parameters | (optional) SQL arguments for sorting the final results. Default: 'ORDER BY score DESC'
Returns:
An array of SIDs for the search results.

Definition at line 910 of file search.module.

Referenced by hook_search(), and node_search().

hook_search | ( | $ | op = 'search',
 |  | $ | keys = null
 | ) |  |

Define a custom search routine.

This hook allows a module to perform searches on content it defines (custom node types, users, or comments, for example) when a site search is performed.

Note that you can use form API to extend the search. You will need to use hook_form_alter() to add any additional required form elements. You can process their values on submission using a custom validation function. You will need to merge any custom search values into the search keys using a key:value syntax. This allows all search queries to have a clean and permanent URL. See node_form_alter() for an example.

Parameters:
$op A string defining which operation to perform:
  • 'name': the hook should return a translated name defining the type of items that are searched for with this module ('content', 'users', ...)
  • 'reset': the search index is going to be rebuilt. Modules which use hook_update_index() should update their indexing bookkeeping so that it starts from scratch the next time hook_update_index() is called.
  • 'search': the hook should perform a search using the keywords in $keys
  • 'status': if the module implements hook_update_index(), it should return an array containing the following keys:
    • remaining: the amount of items that still need to be indexed
    • total: the total amount of items (both indexed and unindexed)
$keys The search keywords as entered by the user.
Returns:
An array of search results. Each item in the result set array may contain whatever information the module wishes to display as a search result. To use the default search result display, each item should be an array which can have the following keys:
  • link: the URL of the found item
  • type: the type of item
  • title: the name of the item
  • user: the author of the item
  • date: a timestamp when the item was last modified
  • extra: an array of optional extra information items
  • snippet: an excerpt or preview to show with the result (can be generated with search_excerpt()) Only 'link' and 'title' are required, but it is advised to fill in as many of these fields as possible.
The example given here is for node.module, which uses the indexed search capabilities. To do this, node module also implements hook_update_index() which is used to create and maintain the index.

We call do_search() with the keys, the module name and extra SQL fragments to use when searching. See hook_update_index() for more information.

Definition at line 1199 of file core.php.

References $item, $op, $results, do_search(), node_invoke(), node_invoke_nodeapi(), node_load(), search_excerpt(), t(), theme(), url(), and variable_del().

hook_update_index ( )

Update Drupal's full-text index for this module.

Modules can implement this hook if they want to use the full-text indexing mechanism in Drupal.

This hook is called every cron run if search.module is enabled. A module should check which of its items were modified or added since the last run. It is advised that you implement a throttling mechanism which indexes at most 'search_cron_limit' items per run (see example below).

You should also be aware that indexing may take too long and be aborted if there is a PHP time limit. That's why you should update your internal bookkeeping multiple times per run, preferably after every item that is indexed.

Per item that needs to be indexed, you should call search_index() with its content as a single HTML string. The search indexer will analyse the HTML and use it to assign higher weights to important words (such as titles). It will also check for links that point to nodes, and use them to boost the ranking of the target nodes.

Definition at line 1405 of file core.php.

References $result, db_fetch_object(), db_query_range(), nid, node_hook(), node_invoke(), node_invoke_nodeapi(), node_load(), node_prepare(), search_index(), variable_get(), and variable_set().

search_box_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process a block search form submission.

Definition at line 1075 of file search.module.

search_data | ( | $ | keys = NULL,
 |  | $ | type = 'node'
 | ) |  |

Perform a standard search on the given keys, and return the formatted results.

Definition at line 1137 of file search.module.

Referenced by search_view().

search_excerpt | ( | $ | keys,
 |  | $ | text
 | ) |  |

Returns snippets from a piece of text, with certain keywords highlighted.

Used for formatting search results.

Parameters:
$keys | A string containing a search query.
$text | The text to extract fragments from.
Returns:
A string containing HTML for the excerpt.

Definition at line 1167 of file search.module.

Referenced by hook_search(), and node_search().

search_form | ( | &$ | form_state,
 |  | $ | action = '',
 |  | $ | keys = '',
 |  | $ | type = NULL,
 |  | $ | prompt = NULL
 | ) |  |

Render a search form.

Parameters:
$action | Form action. Defaults to "search".
$keys | The search string entered by the user, containing keywords for the search.
$type | The type of search to render the node for. Must be the name of module which implements hook_search(). Defaults to 'node'.
$prompt | A piece of text to put before the form (e.g. "Enter your keywords")
Returns:
An HTML string containing the search form.

Definition at line 1016 of file search.module.

search_index | ( | $ | sid,
 |  | $ | type,
 |  | $ | text
 | ) |  |

Update the full-text search index for a particular item.

Parameters:
$sid | A number identifying this particular item (e.g. node id).
$type | A string defining this type of item (e.g. 'node')
$text | The content of this item. Must be a piece of HTML text.

Definition at line 416 of file search.module.

Referenced by _node_index_node(), and hook_update_index().

template_preprocess_search_block_form ( &$ variables )

Process variables for search-block-form.tpl.php.

The $variables array contains the following arguments:

  • $form

See also:
search-block-form.tpl.php

Definition at line 1115 of file search.module.

template_preprocess_search_theme_form ( &$ variables )

Process variables for search-theme-form.tpl.php.

The $variables array contains the following arguments:

  • $form

See also:
search-theme-form.tpl.php

Definition at line 1088 of file search.module.

Generated on Tue Feb 12 15:30:51 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Updates from 5.x to 6.x

Updates from 5.x to 6.x

Detailed Description

End of "defgroup updates_5x_extra".

Functions

  • blogapi_update_6000 ()
    Inform users about the new permission.
  • locale_update_6000 ()
    {locales_meta} table became {languages}.
  • locale_update_6001 ()
    Change locale column to language.
  • locale_update_6002 ()
    Remove empty translations, we don't need these anymore.
  • locale_update_6003 ()
    Prune strings with no translations (will be automatically re-registered if still in use).
  • locale_update_6004 ()
    Fix remaining inconsistent indexes.
  • locale_update_6005 ()
    Change language setting variable of content types.
  • system_update_6000 ()
    Remove auto_increment from {boxes} to allow adding custom blocks with visibility settings.
  • system_update_6001 ()
    Add version id column to {term_node} to allow taxonomy module to use revisions.
  • system_update_6002 ()
    Increase the maximum length of variable names from 48 to 128.
  • system_update_6003 ()
    Add index on comments status column.
  • system_update_6004 ()
    This update used to add an index on users created column (#127941).
  • system_update_6005 ()
    Add language to url_alias table and modify indexes.
  • system_update_6006 ()
    Drop useless indices on node_counter table.
  • system_update_6007 ()
    Change the severity column in the watchdog table to the new values.
  • system_update_6008 ()
    Add info files to themes.
  • system_update_6009 ()
    The PHP filter is now a separate module.
  • system_update_6010 ()
    Add variable replacement for watchdog messages.
  • system_update_6011 ()
    Add language support to nodes.
  • system_update_6012 ()
    Add serialized field to cache tables.
  • system_update_6013 ()
    Rebuild cache data for theme system changes.
  • system_update_6014 ()
    Record that the installer is done, so it is not possible to run the installer on upgraded sites.
  • system_update_6015 ()
    Add the form cache table.
  • system_update_6016 ()
    Make {node}'s primary key be nid, change nid,vid to a unique key.
  • system_update_6017 ()
    Rename settings related to user.module email notifications.
  • system_update_6018 ()
    Add HTML corrector to HTML formats or replace the old module if it was in use.
  • system_update_6019 ()
    Reconcile small differences in the previous, manually created mysql and pgsql schemas so they are the same and can be represented by a single schema structure.
  • system_update_6020 ()
    Create the tables for the new menu system.
  • system_update_6021 ()
    Migrate the menu items from the old menu system to the new menu_links table.
  • system_update_6022 ()
    Update files tables to associate files to a uid by default instead of a nid.
  • system_update_6023 ()
  • system_update_6024 ()
    Add translation fields to nodes used by translation module.
  • system_update_6025 ()
    Increase the maximum length of node titles from 128 to 255.
  • system_update_6026 ()
    Display warning about new Update status module.
  • system_update_6027 ()
    Add block cache.
  • system_update_6028 ()
    Add the node load cache table.
  • system_update_6029 ()
    Enable the dblog module on sites that upgrade, since otherwise watchdog logging will stop unexpectedly.
  • system_update_6030 ()
    Add the tables required by actions.inc.
  • system_update_6031 ()
    Ensure that installer cannot be run again after updating from Drupal 5.x to 6.x Actually, this is already done by system_update_6014(), so this is now a no-op.
  • system_update_6032 ()
    profile_fields.name used to be nullable but is part of a unique key and so shouldn't be.
  • system_update_6033 ()
    Change node_comment_statistics to be not autoincrement.
  • system_update_6034 ()
    Rename permission "administer access control" to "administer permissions".
  • system_update_6035 ()
    Change index on system table for better performance.
  • system_update_6036 ()
    Change the search schema and indexing.
  • system_update_6037 ()
    Create consistent empty region for disabled blocks.
  • system_update_6038 ()
    Ensure that "Account" is not used as a Profile category.
  • system_update_6039 ()
    Rename permissions "edit foo content" to "edit any foo content".
  • system_update_6040 ()
    Add a weight column to the upload table.
  • system_update_6041 ()
    Change forum vocabulary not to be required by default and set the weight of the forum.module 1 higher than the taxonomy.module.
  • system_update_6042 ()
    Upgrade recolored theme stylesheets to new array structure.
  • system_update_6043 ()
    Update table indices to make them more rational and useful.
  • system_update_6044 ()
    RC1 to RC2 index cleanup.
  • system_update_6045 ()
    Update blog, book and locale module permissions.
  • system_update_6046 ()
    Ensure that the file_directory_path variable is set (using the old 5.x default, if necessary), so that the changed 6.x default won't break existing sites.
  • system_update_6047 ()
    Fix cache mode for blocks inserted in system_install() in fresh installs of previous RC.

Function Documentation

blogapi_update_6000 ( )

Inform users about the new permission.

Definition at line 12 of file blogapi.install.

References drupal_set_message(), and url().

locale_update_6000 ( )

{locales_meta} table became {languages}.

Definition at line 26 of file locale.install.

References db_create_table(), db_fetch_object(), db_query(), db_result(), locale(), name, update_sql(), and variable_set().

locale_update_6001 ( )

Change locale column to language.

The language column is added by update_fix_d6_requirements() in update.php to avoid a large number of error messages from update.php. All we need to do here is copy locale to language and then drop locale.

Definition at line 123 of file locale.install.

References db_drop_field(), and update_sql().

locale_update_6002 ( )

Remove empty translations, we don't need these anymore.

Definition at line 133 of file locale.install.

References update_sql().

locale_update_6003 ( )

Prune strings with no translations (will be automatically re-registered if still in use).

Definition at line 142 of file locale.install.

References update_sql().

locale_update_6004 ( )

Fix remaining inconsistent indexes.

Definition at line 151 of file locale.install.

References db_add_index(), and db_drop_index().

locale_update_6005 ( )

Change language setting variable of content types.

Use language_content_type_<content_type> instead of language_<content_type> so content types such as 'default', 'count' or 'negotiation' will not interfere with language variables.

Definition at line 172 of file locale.install.

References $type, db_query(), db_result(), drupal_set_message(), l(), name, node_get_types(), variable_del(), variable_get(), and variable_set().

system_update_6000 ( )

Remove auto_increment from {boxes} to allow adding custom blocks with visibility settings.

Definition at line 1129 of file system.install.

References db_query(), db_result(), and update_sql().

system_update_6001 ( )

Add version id column to {term_node} to allow taxonomy module to use revisions.

Definition at line 1145 of file system.install.

References db_add_field(), db_add_index(), db_add_primary_key(), db_drop_primary_key(), and db_query().

system_update_6002 ( )

Increase the maximum length of variable names from 48 to 128.

Definition at line 1161 of file system.install.

References db_add_primary_key(), db_change_field(), and db_drop_primary_key().

system_update_6003 ( )

Add index on comments status column.

Definition at line 1172 of file system.install.

References db_add_index().

system_update_6004 ( )

This update used to add an index on users created column (#127941).

However, system_update_1022() does the same thing. This update tried to detect if 1022 had already run but failed to do so, resulting in an "index already exists" error.

Adding the index here is never necessary. Sites installed before 1022 will run 1022, getting the update. Sites installed on/after 1022 got the index when the table was first created. Therefore, this function is now a no-op.

Definition at line 1189 of file system.install.

system_update_6005 ( )

Add language to url_alias table and modify indexes.

Definition at line 1196 of file system.install.

References db_add_column(), db_drop_unique_key(), and update_sql().

system_update_6006 ( )

Drop useless indices on node_counter table.

Definition at line 1244 of file system.install.

References update_sql().

system_update_6007 ( )

Change the severity column in the watchdog table to the new values.

Definition at line 1265 of file system.install.

References update_sql().

system_update_6008 ( )

Add info files to themes.

The info and owner columns are added by update_fix_d6_requirements() in update.php to avoid a large number of error messages from update.php. All we need to do here is copy description to owner and then drop description.

Definition at line 1279 of file system.install.

References db_drop_field(), module_rebuild_cache(), system_theme_data(), and update_sql().

system_update_6009 ( )

The PHP filter is now a separate module.

Definition at line 1294 of file system.install.

References db_query(), db_result(), and update_sql().

system_update_6010 ( )

Add variable replacement for watchdog messages.

The variables field is NOT NULL and does not have a default value. Existing log messages should not be translated in the new system, so we insert 'N;' (serialize(NULL)) as the temporary default but then remove the default value to match the schema.

Definition at line 1321 of file system.install.

References db_add_field().

system_update_6011 ( )

Add language support to nodes.

Definition at line 1330 of file system.install.

References db_add_column(), and update_sql().

system_update_6012 ( )

Add serialized field to cache tables.

This is now handled directly by update.php, so this function is a no-op.

Definition at line 1348 of file system.install.

system_update_6013 ( )

Rebuild cache data for theme system changes.

Definition at line 1355 of file system.install.

References module_rebuild_cache(), and system_theme_data().

system_update_6014 ( )

Record that the installer is done, so it is not possible to run the installer on upgraded sites.

Definition at line 1367 of file system.install.

References variable_set().

system_update_6015 ( )

Add the form cache table.

Definition at line 1376 of file system.install.

References update_sql().

system_update_6016 ( )

Make {node}'s primary key be nid, change nid,vid to a unique key.

Add primary keys to block, filters, flood, permission, and term_relation.

Definition at line 1414 of file system.install.

References db_add_column(), and update_sql().

system_update_6017 ( )

Rename settings related to user.module email notifications.

Definition at line 1451 of file system.install.

References $new, drupal_set_message(), url(), variable_del(), variable_get(), and variable_set().

system_update_6018 ( )

Add HTML corrector to HTML formats or replace the old module if it was in use.

Definition at line 1481 of file system.install.

References $result, db_fetch_object(), db_query(), db_result(), module_disable(), module_exists(), name, and update_sql().

system_update_6019 ( )

Reconcile small differences in the previous, manually created mysql and pgsql schemas so they are the same and can be represented by a single schema structure.

Note that the mysql and pgsql cases make different changes. This is because each schema needs to be tweaked in different ways to conform to the new schema structure. Also, since they operate on tables defined by many optional core modules which may not ever have been installed, they must test each table for existence. If the modules are first installed after this update exists the tables will be created from the schema structure and will start out correct.

Definition at line 1517 of file system.install.

References db_add_index(), db_add_primary_key(), db_add_unique_key(), db_change_field(), db_drop_index(), db_drop_primary_key(), db_drop_unique_key(), db_field_set_no_default(), db_query(), db_result(), db_table_exists(), and update_sql().

system_update_6020 ( )

Create the tables for the new menu system.

Definition at line 1625 of file system.install.

References $name, and db_create_table().

system_update_6021 ( )

Migrate the menu items from the old menu system to the new menu_links table.

Definition at line 1704 of file system.install.

References $item, db_add_field(), db_create_table(), db_fetch_array(), db_query(), db_query_range(), db_result(), drupal_get_normal_path(), menu_enable(), menu_link_save(), menu_rebuild(), update_sql(), variable_del(), variable_get(), and variable_set().

system_update_6022 ( )

Update files tables to associate files to a uid by default instead of a nid.

Rename file_revisions to upload since it should only be used by the upload module used by upload to link files to nodes.

Definition at line 1929 of file system.install.

References db_add_field(), db_add_index(), db_add_primary_key(), db_change_field(), db_drop_index(), db_drop_primary_key(), db_rename_table(), and update_sql().

system_update_6023 ( )

Definition at line 1963 of file system.install.

References db_add_index(), db_change_field(), and db_drop_index().

system_update_6024 ( )

Add translation fields to nodes used by translation module.

Definition at line 1976 of file system.install.

References db_add_field(), and db_add_index().

system_update_6025 ( )

Increase the maximum length of node titles from 128 to 255.

Definition at line 1988 of file system.install.

References db_add_index(), db_change_field(), and db_drop_index().

system_update_6026 ( )

Display warning about new Update status module.

Definition at line 2000 of file system.install.

References drupal_set_message(), and url().

system_update_6027 ( )

Add block cache.

Definition at line 2012 of file system.install.

References db_add_field(), db_query(), module_invoke(), and module_list().

system_update_6028 ( )

Add the node load cache table.

Definition at line 2038 of file system.install.

system_update_6029 ( )

Enable the dblog module on sites that upgrade, since otherwise watchdog logging will stop unexpectedly.

Definition at line 2047 of file system.install.

References drupal_set_installed_schema_version(), menu_rebuild(), and module_enable().

system_update_6030 ( )

Add the tables required by actions.inc.

Definition at line 2068 of file system.install.

References db_create_table(), db_rename_table(), and db_table_exists().

system_update_6031 ( )

Ensure that installer cannot be run again after updating from Drupal 5.x to 6.x Actually, this is already done by system_update_6014(), so this is now a no-op.

Definition at line 2105 of file system.install.

system_update_6032 ( )

profile_fields.name used to be nullable but is part of a unique key and so shouldn't be.

Definition at line 2113 of file system.install.

References db_add_unique_key(), db_change_field(), db_drop_unique_key(), and db_table_exists().

system_update_6033 ( )

Change node_comment_statistics to be not autoincrement.

Definition at line 2126 of file system.install.

References db_add_primary_key(), db_change_field(), and db_table_exists().

system_update_6034 ( )

Rename permission "administer access control" to "administer permissions".

Definition at line 2153 of file system.install.

References $result, db_fetch_object(), db_query(), and update_sql().

system_update_6035 ( )

Change index on system table for better performance.

Definition at line 2168 of file system.install.

References db_add_index(), and db_drop_index().

system_update_6036 ( )

Change the search schema and indexing.

The table data is preserved where possible in MYSQL and MYSQLi using ALTER IGNORE. Other databases don't support that, so for them the tables are dropped and re-created, and will need to be re-indexed from scratch.

Definition at line 2184 of file system.install.

References db_add_field(), db_add_unique_key(), db_create_table(), db_drop_field(), db_drop_index(), db_query(), db_result(), db_table_exists(), update_sql(), and variable_del().

system_update_6037 ( )

Create consistent empty region for disabled blocks.

Definition at line 2249 of file system.install.

References db_change_field(), and update_sql().

system_update_6038 ( )

Ensure that "Account" is not used as a Profile category.

Definition at line 2259 of file system.install.

References db_affected_rows(), db_table_exists(), drupal_set_message(), and update_sql().

system_update_6039 ( )

Rename permissions "edit foo content" to "edit any foo content".

Also update poll module permission "create polls" to "create poll content".

Definition at line 2275 of file system.install.

References $result, db_fetch_object(), db_query(), and update_sql().

system_update_6040 ( )

Add a weight column to the upload table.

Definition at line 2291 of file system.install.

References db_add_field(), and db_table_exists().

system_update_6041 ( )

Change forum vocabulary not to be required by default and set the weight of the forum.module 1 higher than the taxonomy.module.

Definition at line 2302 of file system.install.

References db_query(), db_result(), db_table_exists(), update_sql(), and variable_get().

system_update_6042 ( )

Upgrade recolored theme stylesheets to new array structure.

Definition at line 2316 of file system.install.

References $theme, list_themes(), name, variable_del(), variable_get(), and variable_set().

system_update_6043 ( )

Update table indices to make them more rational and useful.

Definition at line 2330 of file system.install.

References db_add_index(), db_add_primary_key(), db_add_unique_key(), db_change_field(), db_drop_index(), db_drop_primary_key(), db_drop_unique_key(), db_table_exists(), and variable_set().

system_update_6044 ( )

RC1 to RC2 index cleanup.

Definition at line 2426 of file system.install.

References db_add_index(), db_drop_unique_key(), db_table_exists(), update_sql(), variable_del(), and variable_get().

system_update_6045 ( )

Update blog, book and locale module permissions.

Blog module got "edit own blog" replaced with the more granular "create blog entries", "edit own blog entries" and "delete own blog entries" permissions. We grant create and edit to previously privileged users, but delete is not granted to be in line with other permission changes in Drupal 6.

Book module's "edit book pages" was upgraded to the bogus "edit book content" in Drupal 6 RC1 instead of "edit any book content", which would be correct.

Locale module introduced "administer languages" and "translate interface" in place of "administer locales".

Modeled after system_update_6039().

Definition at line 2472 of file system.install.

References $result, db_fetch_object(), db_query(), drupal_set_message(), update_sql(), and url().

system_update_6046 ( )

Ensure that the file_directory_path variable is set (using the old 5.x default, if necessary), so that the changed 6.x default won't break existing sites.

Definition at line 2495 of file system.install.

References variable_get(), and variable_set().

system_update_6047 ( )

Fix cache mode for blocks inserted in system_install() in fresh installs of previous RC.

Definition at line 2507 of file system.install.

References update_sql().

Generated on Tue Feb 12 15:30:51 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: File Index

  • File List
  • File Members

File List

Here is a list of all files with brief descriptions:
cron.php [code] | Handles incoming requests to fire off regularly-scheduled tasks (cron jobs)
index.php [code] | The PHP page that serves all page requests on a Drupal installation
install.php [code] |
update.php [code] | Administrative page for handling updates from one Drupal version to another
xmlrpc.php [code] | PHP page for handling incoming XML-RPC requests from clients
docs/example.profile [code] |
docs/globals.php [code] | These are the global variables that Drupal uses
docs/index.php [code] |
docs/examples/batch_example.install [code] |
docs/examples/batch_example.module [code] | This is an example outlining how a module can define batches
docs/examples/block_example.module [code] | This is an example outlining how a module can define blocks to be displayed on each page
docs/examples/example_element.module [code] | This is an example demonstrating how a module can define custom form elements
docs/examples/fileupload.module [code] | This is an example to demonstrate how to make a Drupal node support file uploads
docs/examples/filter_example.module [code] | This is an example outlining how a module can be used to define a filter to be run on user-submitted content before it is output to the browser
docs/examples/multipage_form_example.module [code] |
docs/examples/node_access_example.install [code] |
docs/examples/node_access_example.module [code] | This is an example illustrating how to restrict access to nodes based on some criterion associated with the user
docs/examples/node_example.install [code] |
docs/examples/node_example.module [code] | This is an example outlining how a module can be used to define a new node type
docs/examples/nodeapi_example.install [code] |
docs/examples/nodeapi_example.module [code] | This is an example outlining how a module can be used to extend existing content types
docs/examples/page_example.module [code] | This is an example outlining how a module can be used to display a custom page at a given URL
docs/examples/xmlrpc_example.module [code] | This is an example of how to implement XML-RPC callbacks by implementing a validation suite
docs/hooks/core.php [code] | These are the hooks that are invoked by the Drupal core
docs/hooks/install.php [code] | Documentation for the installation and update system
docs/hooks/node.php [code] | These hooks are defined by node modules, modules that define a new kind of node
includes/actions.inc [code] | This is the actions engine for executing stored actions
includes/batch.inc [code] | Batch processing API for processes to run in multiple HTTP requests
includes/bootstrap.inc [code] | Functions that need to be loaded on every Drupal request
includes/cache-install.inc [code] |
includes/cache.inc [code] |
includes/common.inc [code] | Common functions that many Drupal modules will need to reference
includes/database.inc [code] | Wrapper for database interface code
includes/database.mysql-common.inc [code] | Functions shared between mysql and mysqli database engines
includes/database.mysql.inc [code] | Database interface code for MySQL database servers
includes/database.mysqli.inc [code] | Database interface code for MySQL database servers using the mysqli client libraries
includes/database.pgsql.inc [code] | Database interface code for PostgreSQL database servers
includes/file.inc [code] | API for handling file uploads and server file management
includes/form.inc [code] |
includes/image.gd.inc [code] | GD2 toolkit for image manipulation within Drupal
includes/image.inc [code] | API for manipulating images
includes/install.inc [code] |
includes/install.mysql.inc [code] |
includes/install.mysqli.inc [code] |
includes/install.pgsql.inc [code] |
includes/language.inc [code] | Multiple language handling functionality
includes/locale.inc [code] | Administration functions for locale.module
includes/mail.inc [code] |
includes/menu.inc [code] | API for the Drupal menu system
includes/module.inc [code] | API for loading and interacting with Drupal modules
includes/pager.inc [code] | Functions to aid in presenting database results as a set of pages
includes/path.inc [code] | Functions to handle paths in Drupal, including path aliasing
includes/session.inc [code] | User session handling functions
includes/tablesort.inc [code] | Functions to aid in the creation of sortable tables
includes/theme.inc [code] | The theme system, which controls the output of Drupal
includes/theme.maintenance.inc [code] | Theming for maintenance pages
includes/unicode.inc [code] |
includes/xmlrpc.inc [code] | Drupal XML-RPC library
includes/xmlrpcs.inc [code] |
modules/aggregator/aggregator-feed-source.tpl.php [code] | Default theme implementation to present the source of the feed
modules/aggregator/aggregator-item.tpl.php [code] | Default theme implementation to format an individual feed item for display on the aggregator page
modules/aggregator/aggregator-summary-item.tpl.php [code] | Default theme implementation to present a linked feed item for summaries
modules/aggregator/aggregator-summary-items.tpl.php [code] | Default theme implementation to present feeds as list items
modules/aggregator/aggregator-wrapper.tpl.php [code] |
modules/aggregator/aggregator.admin.inc [code] | Admin page callbacks for the aggregator module
modules/aggregator/aggregator.install [code] |
modules/aggregator/aggregator.module [code] | Used to aggregate syndicated content (RSS, RDF, and Atom)
modules/aggregator/aggregator.pages.inc [code] | User page callbacks for the aggregator module
modules/block/block-admin-display-form.tpl.php [code] | Default theme implementation to configure blocks
modules/block/block.admin.inc [code] | Admin page callbacks for the block module
modules/block/block.install [code] |
modules/block/block.module [code] | Controls the boxes that are displayed around the main content
modules/blog/blog.module [code] | Enables keeping an easily and regularly updated web page or a blog
modules/blog/blog.pages.inc [code] | Page callback file for the blog module
modules/blogapi/blogapi.install [code] |
modules/blogapi/blogapi.module [code] | Enable users to post using applications that support XML-RPC blog APIs
modules/book/book-all-books-block.tpl.php [code] | Default theme implementation for rendering book outlines within a block
modules/book/book-export-html.tpl.php [code] | Default theme implementation for printed version of book outline
modules/book/book-navigation.tpl.php [code] | Default theme implementation to navigate books
modules/book/book-node-export-html.tpl.php [code] | Default theme implementation for rendering a single node in a printer friendly outline
modules/book/book.admin.inc [code] | Admin page callbacks for the book module
modules/book/book.install [code] |
modules/book/book.module [code] | Allows users to structure the pages of a site in a hierarchy or outline
modules/book/book.pages.inc [code] | User page callbacks for the book module
modules/color/color.install [code] |
modules/color/color.module [code] |
modules/comment/comment-folded.tpl.php [code] | Default theme implementation for folded comments
modules/comment/comment-wrapper.tpl.php [code] | Default theme implementation to wrap aggregator content
modules/comment/comment.admin.inc [code] | Admin page callbacks for the comment module
modules/comment/comment.install [code] |
modules/comment/comment.module [code] | Enables users to comment on published content
modules/comment/comment.pages.inc [code] | User page callbacks for the comment module
modules/comment/comment.tpl.php [code] |
modules/contact/contact.admin.inc [code] | Admin page callbacks for the contact module
modules/contact/contact.install [code] |
modules/contact/contact.module [code] | Enables the use of personal and site-wide contact forms
modules/contact/contact.pages.inc [code] | User page callbacks for the contact module
modules/dblog/dblog.admin.inc [code] | Administrative page callbacks for the dblog module
modules/dblog/dblog.install [code] |
modules/dblog/dblog.module [code] | System monitoring and logging for administrators
modules/filter/filter.admin.inc [code] | Admin page callbacks for the filter module
modules/filter/filter.install [code] |
modules/filter/filter.module [code] | Framework for handling filtering of content
modules/filter/filter.pages.inc [code] | User page callbacks for the filter module
modules/forum/forum-icon.tpl.php [code] | Display an appropriate icon for a forum post
modules/forum/forum-list.tpl.php [code] | Default theme implementation to display a list of forums and containers
modules/forum/forum-submitted.tpl.php [code] | Default theme implementation to format a simple string indicated when and by whom a topic was submitted
modules/forum/forum-topic-list.tpl.php [code] | Theme implementation to display a list of forum topics
modules/forum/forum-topic-navigation.tpl.php [code] | Default theme implementation to display the topic navigation string at the bottom of all forum topics
modules/forum/forum.admin.inc [code] | Administrative page callbacks for the forum module
modules/forum/forum.install [code] |
modules/forum/forum.module [code] | Enable threaded discussions about general topics
modules/forum/forum.pages.inc [code] | User page callbacks for the forum module
modules/forum/forums.tpl.php [code] | Default theme implementation to display a forum which may contain forum containers as well as forum topics
modules/help/help.admin.inc [code] | Admin page callbacks for the help module
modules/help/help.module [code] | Manages displaying online help
modules/locale/locale.install [code] |
modules/locale/locale.module [code] | Add language handling functionality and enables the translation of the user interface to languages other than English
modules/menu/menu.admin.inc [code] | Administrative page callbaks for menu module
modules/menu/menu.install [code] |
modules/menu/menu.module [code] | Allows administrators to customize the site navigation menu
modules/node/content_types.inc [code] | Content type editing UI
modules/node/node.admin.inc [code] | Content administration and module settings UI
modules/node/node.install [code] |
modules/node/node.module [code] | The core that allows content to be submitted to the site
modules/node/node.pages.inc [code] | Page callbacks for adding, editing, deleting, and revisions management for content
modules/node/node.tpl.php [code] |
modules/openid/openid.inc [code] | OpenID utility functions
modules/openid/openid.install [code] |
modules/openid/openid.module [code] | Implement OpenID Relying Party support for Drupal
modules/openid/openid.pages.inc [code] | User page callbacks for the openid module
modules/openid/xrds.inc [code] |
modules/path/path.admin.inc [code] | Administrative page callbacks for the path module
modules/path/path.module [code] | Enables users to rename URLs
modules/php/php.install [code] |
modules/php/php.module [code] | Additional filter for PHP input
modules/ping/ping.module [code] | Alerts other sites that your site has been updated
modules/poll/poll-bar-block.tpl.php [code] | Display the bar for a single choice in a poll
modules/poll/poll-bar.tpl.php [code] | Display the bar for a single choice in a poll
modules/poll/poll-results-block.tpl.php [code] | Display the poll results in a block
modules/poll/poll-results.tpl.php [code] |
modules/poll/poll-vote.tpl.php [code] | Voting form for a poll
modules/poll/poll.install [code] |
modules/poll/poll.module [code] | Enables your site to capture votes on different topics in the form of multiple choice questions
modules/poll/poll.pages.inc [code] | User page callbacks for the poll module
modules/profile/profile-block.tpl.php [code] | Default theme implementation for displaying a users profile within a block
modules/profile/profile-listing.tpl.php [code] | Default theme implementation for displaying a user and their profile data for member listing pages
modules/profile/profile-wrapper.tpl.php [code] | Default theme implementation for wrapping member listings and their profiles
modules/profile/profile.admin.inc [code] | Administrative page callbacks for the profile module
modules/profile/profile.install [code] |
modules/profile/profile.module [code] | Support for configurable user profiles
modules/profile/profile.pages.inc [code] | User page callbacks for the profile module
modules/search/search-block-form.tpl.php [code] | Default theme implementation for displaying a search form within a block region
modules/search/search-result.tpl.php [code] | Default theme implementation for displaying a single search result
modules/search/search-results.tpl.php [code] | Default theme implementation for displaying search results
modules/search/search-theme-form.tpl.php [code] | Default theme implementation for displaying a search form directly into the theme layout
modules/search/search.admin.inc [code] | Admin page callbacks for the search module
modules/search/search.install [code] |
modules/search/search.module [code] | Enables site-wide keyword searching
modules/search/search.pages.inc [code] | User page callbacks for the search module
modules/statistics/statistics.admin.inc [code] | Admin page callbacks for the statistics module
modules/statistics/statistics.install [code] |
modules/statistics/statistics.module [code] | Logs access statistics for your site
modules/statistics/statistics.pages.inc [code] | User page callbacks for the statistics module
modules/syslog/syslog.module [code] | Redirects logging messages to syslog
modules/system/block.tpl.php [code] |
modules/system/box.tpl.php [code] |
modules/system/maintenance-page.tpl.php [code] |
modules/system/page.tpl.php [code] |
modules/system/system.admin.inc [code] | Admin page callbacks for the system module
modules/system/system.install [code] |
modules/system/system.module [code] | Configuration system that lets administrators modify the workings of the site
modules/taxonomy/taxonomy.admin.inc [code] | Administrative page callbacks for the taxonomy module
modules/taxonomy/taxonomy.install [code] |
modules/taxonomy/taxonomy.module [code] | Enables the organization of content into categories
modules/taxonomy/taxonomy.pages.inc [code] | Page callbacks for the taxonomy module
modules/throttle/throttle.admin.inc [code] | Admin page callbacks for the throttle module
modules/throttle/throttle.module [code] | Allows configuration of congestion control auto-throttle mechanism
modules/tracker/tracker.module [code] | Enables tracking of recent posts for users
modules/tracker/tracker.pages.inc [code] | User page callbacks for the tracker module
modules/translation/translation.module [code] | Manages content translations
modules/translation/translation.pages.inc [code] | User page callbacks for the translation module
modules/trigger/trigger.admin.inc [code] | Admin page callbacks for the trigger module
modules/trigger/trigger.install [code] |
modules/trigger/trigger.module [code] | Enables functions to be stored and executed at a later time when triggered by other modules or by one of Drupal's core API hooks
modules/update/update.compare.inc [code] | Code required only when comparing available updates to existing data
modules/update/update.fetch.inc [code] | Code required only when fetching information about available updates
modules/update/update.install [code] |
modules/update/update.module [code] | The "Update status" module checks for available updates of Drupal core and any installed contributed modules and themes
modules/update/update.report.inc [code] | Code required only when rendering the available updates report
modules/update/update.settings.inc [code] | Code required only for the update status settings form
modules/upload/upload.admin.inc [code] |
modules/upload/upload.install [code] |
modules/upload/upload.module [code] | File-handling and attaching files to nodes
modules/user/user-picture.tpl.php [code] | Default theme implementation to present an picture configured for the user's account
modules/user/user-profile-category.tpl.php [code] | Default theme implementation to present profile categories (groups of profile items)
modules/user/user-profile-item.tpl.php [code] | Default theme implementation to present profile items (values from user account profile fields or modules)
modules/user/user-profile.tpl.php [code] | Default theme implementation to present all user profile data
modules/user/user.admin.inc [code] | Admin page callback file for the user module
modules/user/user.install [code] |
modules/user/user.module [code] | Enables the user registration and login system
modules/user/user.pages.inc [code] | User page callback file for the user module
profiles/default/default.profile [code] |
themes/bluemarine/block.tpl.php [code] |
themes/bluemarine/box.tpl.php [code] |
themes/bluemarine/comment.tpl.php [code] |
themes/bluemarine/node.tpl.php [code] |
themes/bluemarine/page.tpl.php [code] |
themes/chameleon/chameleon.theme [code] | A slim, CSS-driven theme which does not depend on a template engine like phptemplate
themes/engines/phptemplate/phptemplate.engine [code] | Handles integration of templates written in pure php with the Drupal theme system
themes/garland/block.tpl.php [code] |
themes/garland/comment.tpl.php [code] |
themes/garland/maintenance-page.tpl.php [code] |
themes/garland/node.tpl.php [code] |
themes/garland/page.tpl.php [code] |
themes/garland/template.php [code] |
themes/garland/color/color.inc [code] |
themes/garland/minnelli/color/color.inc [code] |
themes/pushbutton/block.tpl.php [code] |
themes/pushbutton/box.tpl.php [code] |
themes/pushbutton/comment.tpl.php [code] |
themes/pushbutton/node.tpl.php [code] |
themes/pushbutton/page.tpl.php [code] |
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: cron.php File Reference

cron.php File Reference

Detailed Description

Handles incoming requests to fire off regularly-scheduled tasks (cron jobs).

Definition in file cron.php.

Go to the source code of this file.

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: index.php File Reference

index.php File Reference

Detailed Description

The PHP page that serves all page requests on a Drupal installation.

The routines here dispatch control to the appropriate handler, which then prints the appropriate page.

All Drupal code is released under the GNU General Public License. See COPYRIGHT.txt and LICENSE.txt.

Definition in file index.php.

Go to the source code of this file.

Variables

  • $return = menu_execute_active_handler()
  • break
  • case MENU_ACCESS_DENIED
  • case MENU_SITE_OFFLINE

Variable Documentation

$return = menu_execute_active_handler()

Definition at line 18 of file index.php.

Referenced by _menu_load_objects(), block_user(), comment_invoke_comment(), comment_links(), drupal_access_denied(), drupal_not_found(), drupal_verify_install_file(), drupal_write_record(), filter_admin_format_form_submit(), form_execute_handlers(), form_options_flatten(), hook_db_rewrite_sql(), module_invoke_all(), node_db_rewrite_sql(), node_invoke_nodeapi(), xmlrpc_server_method_signature(), xmlrpc_server_multicall(), and xmlrpc_value_get_xml().

break

Definition at line 25 of file index.php.

case MENU_ACCESS_DENIED

Definition at line 27 of file index.php.

case MENU_SITE_OFFLINE

Definition at line 30 of file index.php.

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: install.php File Reference

install.php File Reference

Go to the source code of this file.

Enumerations

  • enum MAINTENANCE_MODE

Functions

  • _install_locale_initial_batch_finished ($success, $results)
    Finished callback for the first locale import batch.
  • _install_locale_remaining_batch_finished ($success, $results)
    Finished callback for the second locale import batch.
  • _install_module_batch ($module, $module_name, &$context)
    Batch callback for batch installation of modules.
  • _install_profile_batch_finished ($success, $results)
    Finished callback for the modules install batch.
  • _install_settings_form_validate ($db_prefix, $db_type, $db_user, $db_pass, $db_host, $db_port, $db_path, $settings_file, &$form_state, $form=NULL)
    Helper function for install_settings_validate.
  • install_already_done_error ()
    Show an error page when Drupal has already been installed.
  • install_change_settings ($profile= 'default', $install_locale= '')
    Configure and rewrite settings.php.
  • install_check_requirements ($profile, $verify)
    Check installation requirements and report any errors.
  • install_configure_form (&$form_state, $url)
    Form API array definition for site configuration.
  • install_configure_form_submit ($form, &$form_state)
    Form API submit for the site configuration form.
  • install_configure_form_validate ($form, &$form_state)
    Form API validate for the site configuration form.
  • install_find_locales ($profilename)
    Find all .po files for the current profile.
  • install_find_profiles ()
    Find all .profile files.
  • install_main ()
    The Drupal installation happens in a series of steps.
  • install_no_profile_error ()
    Show an error page when there are no profiles available.
  • install_reserved_tasks ()
    The list of reserved tasks to run in the installer.
  • install_select_locale ($profilename)
    Allow admin to select which locale to use for the current profile.
  • install_select_locale_form (&$form_state, $locales)
    Form API array definition for language selection.
  • install_select_profile ()
    Allow admin to select which profile to install.
  • install_select_profile_form (&$form_state, $profiles)
    Form API array definition for the profile selection form.
  • install_settings_form (&$form_state, $profile, $install_locale, $settings_file, $db_url, $db_type, $db_prefix, $db_user, $db_pass, $db_host, $db_port, $db_path)
    Form API array definition for install_settings.
  • install_settings_form_submit ($form, &$form_state)
    Form API submit for install_settings form.
  • install_settings_form_validate ($form, &$form_state)
    Form API validate for install_settings form.
  • install_task_list ($active=NULL)
    Add the installation task list to the current page.
  • install_tasks ($profile, $task)
    Tasks performed after the database is initialized.
  • install_verify_drupal ()
    Verify if Drupal is installed.
  • install_verify_settings ()
    Verify existing settings.php.

Enumeration Type Documentation

enum MAINTENANCE_MODE

Definition at line 6 of file install.php.

Function Documentation

_install_locale_initial_batch_finished | ( | $ | success,
 |  | $ | results
 | ) |  |

Finished callback for the first locale import batch.

Advance installer task to the configure screen.

Definition at line 841 of file install.php.

References variable_set().

_install_locale_remaining_batch_finished | ( | $ | success,
 |  | $ | results
 | ) |  |

Finished callback for the second locale import batch.

Advance installer task to the finished screen.

Definition at line 850 of file install.php.

References variable_set().

_install_module_batch | ( | $ | module,
 |  | $ | module_name,
 |  | &$ | context
 | ) |  |

Batch callback for batch installation of modules.

Definition at line 816 of file install.php.

References _drupal_install_module(), and module_enable().

_install_profile_batch_finished | ( | $ | success,
 |  | $ | results
 | ) |  |

Finished callback for the modules install batch.

Advance installer task to language import.

Definition at line 832 of file install.php.

References variable_set().

_install_settings_form_validate | ( | $ | db_prefix,
 |  | $ | db_type,
 |  | $ | db_user,
 |  | $ | db_pass,
 |  | $ | db_host,
 |  | $ | db_port,
 |  | $ | db_path,
 |  | $ | settings_file,
 |  | &$ | form_state,
 |  | $ | form = NULL
 | ) |  |

Helper function for install_settings_validate.

Definition at line 350 of file install.php.

References $db_prefix, $db_type, $db_url, drupal_detect_database_types(), drupal_install_profile_name(), form_set_error(), form_set_value(), and st().

Referenced by install_settings_form_validate(), and install_verify_settings().

install_already_done_error ( )

Show an error page when Drupal has already been installed.

Definition at line 597 of file install.php.

References $base_url, drupal_set_title(), exit, st(), and theme().

Referenced by install_change_settings(), install_main(), and install_tasks().

install_change_settings | ( | $ | profile = 'default',
 |  | $ | install_locale = ''
 | ) |  |

Configure and rewrite settings.php.

Definition at line 176 of file install.php.

References $db_prefix, $db_type, $db_url, $install_locale, $output, $profile, $url, conf_path(), drupal_get_form(), drupal_set_title(), exit, install_already_done_error(), install_task_list(), st(), and theme().

Referenced by install_main().

install_check_requirements | ( | $ | profile,
 |  | $ | verify
 | ) |  |

Check installation requirements and report any errors.

Definition at line 864 of file install.php.

References $profile, conf_path(), drupal_check_profile(), drupal_install_profile_name(), drupal_requirements_severity(), drupal_set_message(), drupal_verify_install_file(), and st().

Referenced by install_main().

install_configure_form | ( | &$ | form_state,
 |  | $ | url
 | ) |  |

Form API array definition for site configuration.

Definition at line 984 of file install.php.

References $url, _system_zonelist(), and st().

install_configure_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Form API submit for the site configuration form.

Definition at line 1113 of file install.php.

References $user, drupal_install_modules(), user_authenticate(), user_load(), user_save(), and variable_set().

install_configure_form_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Form API validate for the site configuration form.

Definition at line 1098 of file install.php.

References form_error(), user_validate_mail(), and user_validate_name().

install_find_locales ( $ profilename )

Find all .po files for the current profile.

Definition at line 482 of file install.php.

References file_scan_directory().

Referenced by install_select_locale(), and install_task_list().

install_find_profiles ( )

Find all .profile files.

Definition at line 415 of file install.php.

References file_scan_directory().

Referenced by install_select_profile(), and install_task_list().

install_main ( )

The Drupal installation happens in a series of steps.

We begin by verifying that the current environment meets our minimum requirements. We then go on to verify that settings.php is properly configured. From there we connect to the configured database and verify that it meets our minimum requirements. Finally we can allow the user to select an installation profile and complete the installation process.

Parameters:
$phase The installation phase we should proceed to.

Definition at line 19 of file install.php.

References $conf, $install_locale, $messages, $module_list, $profile, db_set_active(), drupal_bootstrap(), drupal_init_language(), drupal_install_system(), drupal_load(), drupal_maintenance_theme(), drupal_page_header(), drupal_set_message(), drupal_set_title(), drupal_verify_profile(), exit, install_already_done_error(), install_change_settings(), install_check_requirements(), install_goto(), install_no_profile_error(), install_select_locale(), install_select_profile(), install_task_list(), install_tasks(), install_verify_drupal(), install_verify_settings(), module_list(), st(), theme(), and variable_set().

install_no_profile_error ( )

Show an error page when there are no profiles available.

Definition at line 586 of file install.php.

References drupal_set_title(), exit, install_task_list(), st(), and theme().

Referenced by drupal_check_profile(), drupal_verify_profile(), and install_main().

install_reserved_tasks ( )

The list of reserved tasks to run in the installer.

Definition at line 857 of file install.php.

Referenced by install_tasks().

install_select_locale ( $ profilename )

Allow admin to select which locale to use for the current profile.

Returns:
The selected language.

Definition at line 494 of file install.php.

References $output, drupal_get_form(), drupal_set_title(), exit, install_find_locales(), install_task_list(), name, st(), and theme().

Referenced by install_main().

install_select_locale_form | ( | &$ | form_state,
 |  | $ | locales
 | ) |  |

Form API array definition for language selection.

Definition at line 559 of file install.php.

References $name, _locale_get_predefined_list(), name, and st().

install_select_profile ( )

Allow admin to select which profile to install.

Returns:
The selected profile.

Definition at line 425 of file install.php.

References $profile, drupal_get_form(), drupal_set_title(), exit, install_find_profiles(), install_task_list(), name, st(), and theme().

Referenced by install_main().

install_select_profile_form | ( | &$ | form_state,
 |  | $ | profiles
 | ) |  |

Form API array definition for the profile selection form.

Definition at line 453 of file install.php.

References $name, $profile, name, and st().

install_settings_form | ( | &$ | form_state,
 |  | $ | profile,
 |  | $ | install_locale,
 |  | $ | settings_file,
 |  | $ | db_url,
 |  | $ | db_type,
 |  | $ | db_prefix,
 |  | $ | db_user,
 |  | $ | db_pass,
 |  | $ | db_host,
 |  | $ | db_port,
 |  | $ | db_path
 | ) |  |

Form API array definition for install_settings.

Definition at line 210 of file install.php.

References $db_prefix, $db_type, $install_locale, $profile, drupal_detect_database_types(), drupal_install_profile_name(), and st().

install_settings_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Form API submit for install_settings form.

Definition at line 394 of file install.php.

References $install_locale, $profile, drupal_rewrite_settings(), and install_goto().

install_settings_form_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Form API validate for install_settings form.

Definition at line 342 of file install.php.

References $db_url, and _install_settings_form_validate().

install_task_list ( $ active = NULL )

Add the installation task list to the current page.

Definition at line 925 of file install.php.

References $profile, $result, drupal_set_content(), install_find_locales(), install_find_profiles(), st(), and theme_task_list().

Referenced by install_change_settings(), install_main(), install_no_profile_error(), install_select_locale(), install_select_profile(), and install_tasks().

install_tasks | ( | $ | profile,
 |  | $ | task
 | ) |  |

Tasks performed after the database is initialized.

Definition at line 608 of file install.php.

References $base_url, $install_locale, $messages, $output, $profile, $url, _batch_page(), _drupal_flush_css_js(), _user_password_dynamic_validation(), actions_synchronize(), batch_process(), batch_set(), conf_path(), drupal_add_js(), drupal_bootstrap(), drupal_get_form(), drupal_get_path(), drupal_install_profile_name(), drupal_set_message(), drupal_set_title(), drupal_verify_install_file(), install_already_done_error(), install_reserved_tasks(), install_task_list(), locale_add_language(), locale_batch_by_language(), menu_rebuild(), module_rebuild_cache(), st(), theme(), url(), variable_del(), variable_get(), and variable_set().

Referenced by install_main().

install_verify_drupal ( )

Verify if Drupal is installed.

Definition at line 137 of file install.php.

References $result, db_query(), and db_result().

Referenced by install_main().

install_verify_settings ( )

Verify existing settings.php.

Definition at line 148 of file install.php.

References $db_prefix, $db_type, $db_url, $url, _install_settings_form_validate(), conf_path(), and form_get_errors().

Referenced by install_main().

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: update.php File Reference

update.php File Reference

Detailed Description

Administrative page for handling updates from one Drupal version to another.

Point your browser to "http://www.example.com/update.php" and follow the instructions.

If you are not logged in as administrator, you will need to modify the access check statement inside your settings.php file. After finishing the upgrade, be sure to open settings.php again, and change it back to its original state!

Definition in file update.php.

Go to the source code of this file.

Enumerations

  • enum MAINTENANCE_MODE
    Global flag to identify update.php run, and so avoid various unwanted operations, such as hook_init() and hook_exit() invokes, css/js preprocessing and translation, and solve some theming issues. More...

Functions

  • db_add_column (&$ret, $table, $column, $type, $attributes=array())
    Add a column to a database using syntax appropriate for PostgreSQL.
  • db_change_column (&$ret, $table, $column, $column_new, $type, $attributes=array())
    Change a column definition using syntax appropriate for PostgreSQL.
  • update_access_denied_page ()
  • update_batch ()
  • update_check_incompatibility ($name, $type= 'module')
    Helper function to test compatibility of a module or theme.
  • update_check_requirements ()
    Check update requirements and report any errors.
  • update_create_batch_table ()
    Create the batch table.
  • update_do_one ($module, $number, &$context)
    Perform one update and store the results which will later be displayed on the finished page.
  • update_finished ($success, $results, $operations)
  • update_fix_compatibility ()
    Disable anything in the {system} table that is not compatible with the current version of Drupal core.
  • update_fix_d6_requirements ()
    Perform Drupal 5.x to 6.x updates that are required for update.php to function properly.
  • update_info_page ()
  • update_results_page ()
  • update_script_selection_form ()
  • update_selection_page ()
  • update_task_list ($active=NULL)
    Add the update task list to the current page.

Variables

  • $messages = drupal_set_message()
  • $module_list ['filter']['filename'] = 'modules/filter/filter.module'
  • $module_list ['system']['filename'] = 'modules/system/system.module'
  • $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : ''
  • $output = _batch_page()
  • case __pad0__
  • case __pad1__
  • case __pad2__
  • default __pad3__
  • break
  • exit

Enumeration Type Documentation

enum MAINTENANCE_MODE

Global flag to identify update.php run, and so avoid various unwanted operations, such as hook_init() and hook_exit() invokes, css/js preprocessing and translation, and solve some theming issues.

This flag is checked on several places in Drupal code (not just update.php).

Definition at line 22 of file update.php.

Function Documentation

db_add_column | ( | &$ | ret,
 |  | $ | table,
 |  | $ | column,
 |  | $ | type,
 |  | $ | attributes = array()
 | ) |  |

Add a column to a database using syntax appropriate for PostgreSQL.

Save result of SQL commands in $ret array.

Note: when you add a column with NOT NULL and you are not sure if there are already rows in the table, you MUST also add DEFAULT. Otherwise PostgreSQL won't work when the table is not empty, and db_add_column() will fail. To have an empty string as the default, you must use: 'default' => "''" in the $attributes array. If NOT NULL and DEFAULT are set the PostgreSQL version will set values of the added column in old rows to the DEFAULT value.

Parameters:
$ret | Array to which results will be added.
$table | Name of the table, without {}
$column | Name of the column
$type | Type of column
$attributes | Additional optional attributes. Recognized attributes: not null => TRUE|FALSE default => NULL|FALSE|value (the value must be enclosed in '' marks)
Returns:
nothing, but modifies $ret parameter.

Definition at line 51 of file update.php.

References $attributes, and update_sql().

Referenced by system_update_6005(), system_update_6011(), and system_update_6016().

db_change_column | ( | &$ | ret,
 |  | $ | table,
 |  | $ | column,
 |  | $ | column_new,
 |  | $ | type,
 |  | $ | attributes = array()
 | ) |  |

Change a column definition using syntax appropriate for PostgreSQL.

Save result of SQL commands in $ret array.

Remember that changing a column definition involves adding a new column and dropping an old one. This means that any indices, primary keys and sequences from serial-type columns are dropped and might need to be recreated.

Parameters:
$ret | Array to which results will be added.
$table | Name of the table, without {}
$column | Name of the column to change
$column_new | New name for the column (set to the same as $column if you don't want to change the name)
$type | Type of column
$attributes | Additional optional attributes. Recognized attributes: not null => TRUE|FALSE default => NULL|FALSE|value (with or without '', it won't be added)
Returns:
nothing, but modifies $ret parameter.

Definition at line 107 of file update.php.

References $attributes, and update_sql().

Referenced by statistics_update_1000().

update_access_denied_page ( )

Definition at line 385 of file update.php.

References drupal_set_title().

update_batch ( )

Definition at line 259 of file update.php.

References $base_url, batch_process(), batch_set(), drupal_get_schema_versions(), and drupal_set_installed_schema_version().

update_check_incompatibility | ( | $ | name,
 |  | $ | type = 'module'
 | ) |  |

Helper function to test compatibility of a module or theme.

Definition at line 446 of file update.php.

References $name, $type, module_rebuild_cache(), and system_theme_data().

Referenced by update_fix_compatibility(), and update_script_selection_form().

update_check_requirements ( )

Check update requirements and report any errors.

Definition at line 543 of file update.php.

References drupal_requirements_severity(), drupal_set_message(), and module_invoke().

update_create_batch_table ( )

Create the batch table.

This is part of the Drupal 5.x to 6.x migration.

Definition at line 401 of file update.php.

References db_create_table(), and db_table_exists().

update_do_one | ( | $ | module,
 |  | $ | number,
 |  | &$ | context
 | ) |  |

Perform one update and store the results which will later be displayed on the finished page.

An update function can force the current and all later updates for this module to abort by returning a $ret array with an element like: $ret['abort'] = array('success' => FALSE, 'query' => 'What went wrong'); The schema version will not be updated in this case, and all the aborted updates will continue to appear on update.php as updates that have not yet been run.

Parameters:
$module | The module whose update will be run.
$number | The update number to run.
$context | The batch context array

Definition at line 151 of file update.php.

References check_plain(), and drupal_set_installed_schema_version().

update_finished | ( | $ | success,
 |  | $ | results,
 |  | $ | operations
 | ) |  |

Definition at line 287 of file update.php.

References $results, and drupal_flush_all_caches().

update_fix_compatibility ( )

Disable anything in the {system} table that is not compatible with the current version of Drupal core.

Definition at line 428 of file update.php.

References $result, db_fetch_object(), db_query(), name, update_check_incompatibility(), and update_sql().

update_fix_d6_requirements ( )

Perform Drupal 5.x to 6.x updates that are required for update.php to function properly.

This function runs when update.php is run the first time for 6.x, even before updates are selected or performed. It is important that if updates are not ultimately performed that no changes are made which make it impossible to continue using the prior version. Just adding columns is safe. However, renaming the system.description column to owner is not. Therefore, we add the system.owner column and leave it to system_update_6008() to copy the data from description and remove description. The same for renaming locales_target.locale to locales_target.language, which will be finished by locale_update_6002().

Definition at line 485 of file update.php.

References db_add_field(), db_create_table(), db_table_exists(), drupal_get_installed_schema_version(), variable_get(), and variable_set().

update_info_page ( )

Definition at line 362 of file update.php.

References $output, _drupal_flush_css_js(), base_path(), cache_clear_all(), db_table_exists(), drupal_set_title(), and update_task_list().

update_results_page ( )

Definition at line 296 of file update.php.

References $links, $output, $queries, base_path(), drupal_set_title(), module_exists(), theme(), and update_task_list().

update_script_selection_form ( )

Definition at line 199 of file update.php.

References drupal_get_installed_schema_version(), drupal_get_schema_versions(), drupal_map_assoc(), module_invoke(), and update_check_incompatibility().

update_selection_page ( )

Definition at line 187 of file update.php.

References $output, drupal_get_form(), drupal_set_title(), and update_task_list().

update_task_list ( $ active = NULL )

Add the update task list to the current page.

Definition at line 528 of file update.php.

References drupal_set_content(), and theme().

Referenced by update_info_page(), update_results_page(), and update_selection_page().

Variable Documentation

$messages = drupal_set_message()

Definition at line 598 of file update.php.

Referenced by drupal_get_messages(), install_main(), install_tasks(), theme_install_page(), theme_status_messages(), and theme_update_page().

$module_list['filter']['filename'] = 'modules/filter/filter.module'

Definition at line 582 of file update.php.

$module_list['system']['filename'] = 'modules/system/system.module'

Definition at line 581 of file update.php.

Referenced by _drupal_maintenance_theme(), drupal_check_profile(), drupal_get_install_files(), drupal_install_modules(), drupal_verify_profile(), install_main(), module_disable(), and module_enable().

$op = isset($_REQUEST['op']) ? $_REQUEST['op'] : ''

Definition at line 570 of file update.php.

Referenced by _aggregator_page_list(), _batch_page(), _locale_import_one_string(), _locale_import_parse_arithmetic(), _locale_import_read_po(), _menu_overview_tree_form(), _node_access_where_sql(), _node_revision_access(), _trigger_get_hook_actions(), _trigger_get_hook_aids(), _user_mail_notify(), aggregator_block(), aggregator_save_category(), block_block(), block_example_block(), blog_access(), blog_block(), book_block(), book_node_type(), book_nodeapi(), comment_access(), comment_block(), comment_form(), comment_invoke_comment(), comment_node_type(), comment_nodeapi(), comment_reply(), contact_admin_edit(), dblog_filter_form_submit(), dblog_user(), fileupload_access(), filter_example_filter(), filter_filter(), forum_access(), forum_block(), forum_nodeapi(), forum_taxonomy(), hook_access(), hook_block(), hook_comment(), hook_filter(), hook_node_type(), hook_nodeapi(), hook_search(), hook_taxonomy(), hook_user(), locale_block(), locale_locale(), menu_block(), menu_link_maintain(), menu_nodeapi(), node_access(), node_access_example_node_grants(), node_access_example_nodeapi(), node_access_grants(), node_block(), node_content_access(), node_example_access(), node_example_nodeapi(), node_get_types(), node_invoke_nodeapi(), node_node_type(), node_save(), node_search(), node_type_form_submit(), node_user(), nodeapi_example_nodeapi(), openid_user(), path_nodeapi(), php_filter(), poll_access(), poll_block(), poll_user(), profile_block(), statistics_block(), statistics_nodeapi(), statistics_user(), system_block(), system_node_type(), system_settings_form_submit(), taxonomy_node_type(), taxonomy_nodeapi(), taxonomy_term_page(), theme_menu_overview_form(), translation_nodeapi(), trigger_assign(), trigger_assign_form(), trigger_comment(), trigger_forms(), trigger_nodeapi(), trigger_taxonomy(), trigger_unassign(), trigger_user(), update_settings_submit(), upload_nodeapi(), user_admin(), user_block(), user_comment(), user_filter_form_submit(), user_register_submit(), user_save(), and user_search().

$output = _batch_page()

Definition at line 650 of file update.php.

Referenced by _aggregator_page_list(), _batch_page(), _batch_progress_page_js(), _batch_progress_page_nojs(), _color_rewrite_stylesheet(), _filter_autop(), _filter_htmlcorrector(), _locale_export_po(), _locale_export_po_generate(), _locale_translate_language_list(), _locale_translate_seek(), _profile_form_explanation(), _statistics_format_item(), _theme_table_cell(), aggregator_help(), aggregator_page_categories(), aggregator_page_sources(), aggregator_view(), block_help(), blog_help(), blog_page_last(), blog_page_user(), blogapi_help(), book_export_traverse(), book_form_update(), book_help(), chameleon_comment(), chameleon_node(), chameleon_page(), color_help(), comment_delete(), comment_form_add_preview(), comment_help(), comment_render(), comment_reply(), contact_help(), contact_site_page(), contact_user_page(), dblog_event(), dblog_help(), dblog_overview(), dblog_top(), drupal_eval(), drupal_get_css(), drupal_get_html_head(), drupal_get_js(), drupal_html_to_text(), drupal_render_form(), drupal_to_js(), example_profile_tasks(), filter_filter_tips(), filter_help(), filter_tips_long(), format_interval(), format_rss_channel(), format_rss_item(), format_xml_elements(), forum_help(), help_help(), help_links_as_list(), help_main(), help_page(), image_get_available_toolkits(), install_change_settings(), install_select_locale(), install_tasks(), locale_help(), locale_languages_add_screen(), locale_translate_export_screen(), locale_translate_seek_screen(), menu_get_active_help(), menu_help(), menu_tree_output(), mime_header_encode(), node_add(), node_feed(), node_help(), node_page_default(), node_preview(), node_show(), openid_help(), openid_redirect(), openid_user_identities(), path_admin_delete_confirm(), path_admin_edit(), path_admin_overview(), path_help(), php_filter_tips(), php_help(), ping_help(), poll_choice_js(), poll_help(), poll_page(), poll_view(), poll_votes(), profile_block(), profile_browse(), profile_help(), search_view(), statistics_help(), statistics_node_tracker(), statistics_recent_hits(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), statistics_user_tracker(), system_actions_manage(), system_admin_menu_block_page(), system_batch_page(), system_help(), system_logging_overview(), system_settings_overview(), system_sql(), taxonomy_help(), taxonomy_node_update_index(), taxonomy_nodeapi(), taxonomy_render_nodes(), taxonomy_rss_item(), taxonomy_term_page(), template_preprocess_forum_topic_navigation(), theme(), theme_admin_block(), theme_admin_block_content(), theme_admin_page(), theme_aggregator_block_item(), theme_aggregator_categorize_items(), theme_aggregator_page_opml(), theme_aggregator_page_rss(), theme_blocks(), theme_box(), theme_color_scheme_form(), theme_comment_admin_overview(), theme_comment_controls(), theme_comment_view(), theme_dblog_filters(), theme_filter_admin_order(), theme_filter_admin_overview(), theme_filter_tips(), theme_form_element(), theme_indentation(), theme_item_list(), theme_links(), theme_locale_languages_overview_form(), theme_menu_local_tasks(), theme_menu_overview_form(), theme_multipage_form_example(), theme_node_add_list(), theme_node_admin_nodes(), theme_node_example_order_info(), theme_node_filter_form(), theme_node_filters(), theme_node_form(), theme_node_preview(), theme_node_search_admin(), theme_nodeapi_example_rating(), theme_pager_first(), theme_pager_last(), theme_pager_next(), theme_pager_previous(), theme_password(), theme_poll_choices(), theme_profile_admin_overview(), theme_progress_bar(), theme_radio(), theme_status_messages(), theme_status_report(), theme_system_admin_by_module(), theme_system_modules(), theme_system_modules_uninstall(), theme_system_theme_select_form(), theme_system_themes_form(), theme_table(), theme_task_list(), theme_taxonomy_overview_terms(), theme_taxonomy_term_page(), theme_textfield(), theme_trigger_display(), theme_update_report(), theme_update_version(), theme_upload_form_current(), theme_upload_form_new(), theme_user_admin_account(), theme_user_admin_new_role(), theme_user_admin_perm(), theme_user_filter_form(), theme_user_filters(), theme_user_signature(), theme_username(), throttle_help(), tracker_help(), tracker_page(), translation_help(), trigger_assign(), trigger_help(), update_help(), update_info_page(), update_results_page(), update_selection_page(), upload_help(), upload_js(), upload_nodeapi(), user_admin(), user_admin_access_check(), user_admin_access_delete_confirm(), user_block(), and user_help().

case __pad0__

Definition at line 636 of file update.php.

case __pad1__

Definition at line 640 of file update.php.

case __pad2__

Definition at line 644 of file update.php.

default __pad3__

Definition at line 649 of file update.php.

break

Definition at line 633 of file update.php.

exit

Definition at line 602 of file update.php.

Referenced by _db_error_page(), _drupal_bootstrap(), book_form_update(), drupal_goto(), drupal_page_cache_header(), file_transfer(), install_already_done_error(), install_change_settings(), install_goto(), install_main(), install_no_profile_error(), install_select_locale(), install_select_profile(), openid_redirect(), openid_redirect_http(), profile_admin_settings_autocomplete(), system_date_time_lookup(), system_php(), upload_js(), and xmlrpc_server_output().

Generated on Tue Feb 12 15:30:49 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: xmlrpc.php File Reference

xmlrpc.php File Reference

Detailed Description

PHP page for handling incoming XML-RPC requests from clients.

Definition in file xmlrpc.php.

Go to the source code of this file.

Generated on Tue Feb 12 15:30:49 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/example.profile File Reference

docs

example.profile File Reference

Go to the source code of this file.

Functions

  • example_form (&$form_state, $url)
    Form API array definition for the example form.
  • example_form_alter (&$form, $form_state, $form_id)
    Implementation of hook_form_alter().
  • example_form_submit ($form, &$form_state)
    Form API submit for the example form.
  • example_profile_details ()
    Return a description of the profile for the initial installation screen.
  • example_profile_modules ()
    Return an array of the modules to be enabled when this profile is installed.
  • example_profile_task_list ()
    Return a list of tasks that this profile supports.
  • example_profile_tasks (&$task, $url)
    Perform any final installation tasks for this profile.

Function Documentation

example_form | ( | &$ | form_state,
 |  | $ | url
 | ) |  |

Form API array definition for the example form.

Definition at line 274 of file example.profile.

References $url, and st().

example_form_alter | ( | &$ | form,
 |  | $ | form_state,
 |  | $ | form_id
 | ) |  |

Implementation of hook_form_alter().

Allows the profile to alter the site-configuration form. This is called through custom invocation, so $form_state is not populated.

Definition at line 327 of file example.profile.

example_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Form API submit for the example form.

Definition at line 306 of file example.profile.

References variable_set().

example_profile_details ( )

Return a description of the profile for the initial installation screen.

Returns:
An array with keys 'name' and 'description' describing this profile, and optional 'language' to override the language selection for language-specific profiles.

Definition at line 26 of file example.profile.

example_profile_modules ( )

Return an array of the modules to be enabled when this profile is installed.

Returns:
An array of modules to enable.

Definition at line 10 of file example.profile.

example_profile_task_list ( )

Return a list of tasks that this profile supports.

Returns:
A keyed array of tasks the profile will perform during the final stage. The keys of the array will be used internally, while the values will be displayed to the user in the installer task list.

Definition at line 62 of file example.profile.

References st().

example_profile_tasks | ( | &$ | task,
 |  | $ | url
 | ) |  |

Perform any final installation tasks for this profile.

The installer goes through the profile-select -> locale-select -> requirements -> database -> locale-initial-batch -> configure -> locale-remaining-batch -> finished -> done tasks in this order, if you don't implement this function in your profile.

If this function is implemented, you can have any number of custom tasks to perform after 'configure', implementing a state machine here to walk the user through those tasks. First time, this function gets called with $task set to 'profile', and you can advance to further tasks by setting $task to your tasks' identifiers, used as array keys in the hook_profile_task_list() above. You must avoid the reserved tasks listed in install_reserved_tasks(). If you implement your custom tasks, this function will get called in every HTTP request (for form processing, printing your information screens and so on) until you advance to the 'profile-finished' task, with which you hand control back to the installer. Each custom page you return needs to provide a way to continue, such as a form submission or a link. You should also set custom page titles.

You should define the list of custom tasks you implement by returning an array of them in hook_profile_task_list(), as these show up in the list of tasks on the installer user interface.

Remember that the user will be able to reload the pages multiple times, so you might want to use variable_set() and variable_get() to remember your data and control further processing, if $task is insufficient. Should a profile want to display a form here, it can; the form should set 'redirect' to FALSE, and rely on an action in the submit handler, such as variable_set(), to detect submission and proceed to further tasks. See the configuration form handling code in install_tasks() for an example.

Important: Any temporary variables should be removed using variable_del() before advancing to the 'profile-finished' phase.

Parameters:
$task | The current $task of the install system. When hook_profile_tasks() is first called, this is 'profile'.
$url | Complete URL to be used for a link or form action on a custom page, if providing any, to allow the user to proceed with the installation.
Returns:
An optional HTML string to display to the user. Only used if you modify the $task, otherwise discarded.

Definition at line 131 of file example.profile.

References $output, $type, $url, _node_type_set_defaults(), drupal_get_form(), drupal_set_title(), menu_rebuild(), node_type_save(), st(), variable_del(), variable_get(), and variable_set().

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/globals.php File Reference

docs

globals.php File Reference

Detailed Description

These are the global variables that Drupal uses.

Definition in file globals.php.

Go to the source code of this file.

Variables

  • global $active_db
    Active database connection.
  • global $base_path
    The base path of the drupal installation.
  • global $base_root
    The root URL of the host excludes the path.
  • global $base_theme_info
    An array of objects that reperesent the base theme.
  • global $base_url
    The base URL of the drupal installation.
  • global $channel
    An associative array containing title, link, description and other keys.
  • global $conf
    The path to the configuration directory as set by conf_path().
  • global $cookie_domain
    The domain to be used form session cookies.
  • global $custom_theme
    Name of custom theme to override default theme.
  • global $db_prefix
    The prefix to be placed on all database tables.
  • global $db_type
    The type of database being used.
  • global $db_url
    The url of the database.
  • global $element
    Structured array describing the data to be rendered.
  • global $forum_topic_list_header
    An array of topic header information.
  • global $id
    Active statistics record id.
  • global $image
    Current image tag used by aggregator.
  • global $install_locale
    The locale to use durring installation.
  • global $installed_profile
    The name of the profile that has just been installed.
  • global $item
    General string or array.
  • global $items
    Array of items used by aggregator.
  • global $language
    An array containing the information for the active language.
  • global $last_result
    Resource of the query executed.
  • global $menu_admin
    Boolean indicating that a menu administrator is running the menu access check.
  • global $multibyte
    The current multibyte mode.
  • global $nid
    Active blog node id.
  • global $pager_page_array
    Result of pager_query() that is utilized by other functions.
  • global $pager_total
    Array of the total number of pages per pager.
  • global $pager_total_items
    Array of the total number of items per pager.
  • global $profile
    The name of the currently installed profile.
  • global $queries
    Array of queries that have been executed.
  • global $recent_activity
    Recent activity statistics generated by statistics_exit().
  • global $tag
    Active tag name.
  • global $theme
    Name of the active theme.
  • global $theme_engine
    The active theme engine related to the active theme.
  • global $theme_info
    Active theme object.
  • global $theme_key
    Name of the active theme.
  • global $theme_path
    Path to the active theme.
  • global $timers
    Stores timers that have been created by timer_start().
  • global $update_free_access
    Access control for update.php script.
  • global $update_mode
    Disabled caling hook_boot() and hook_exit() during the update process (update.php) since the database is in a largely unknown state.
  • global $user
    Representation of the current user.
  • global $xrds_current_service
    Array used by XRDS XML parser for OpenID to track parsing state.
  • global $xrds_open_elements
    Array used by XRDS XML parser for OpenID to track parsing state.
  • global $xrds_services
    Array used by XRDS XML parser for OpenID to track parsing state.

Variable Documentation

global $active_db

Active database connection.

See also:
db_set_active

Definition at line 126 of file globals.php.

Referenced by _db_query(), db_affected_rows(), db_encode_blob(), db_error(), db_escape_string(), db_is_active(), db_set_active(), and db_version().

global $base_path

The base path of the drupal installation.

At least will default to /.

See also:
conf_init

Definition at line 30 of file globals.php.

Referenced by _drupal_html_to_mail_urls(), _theme_build_registry(), and conf_init().

global $base_root

The root URL of the host excludes the path.

See also:
conf_init

Definition at line 37 of file globals.php.

Referenced by _block_get_cache_id(), conf_init(), page_get_cache(), page_set_cache(), and watchdog().

global $base_theme_info

An array of objects that reperesent the base theme.

For documentation of the theme object see _init_theme().

Definition at line 192 of file globals.php.

Referenced by _init_theme().

global $base_url

The base URL of the drupal installation.

See also:
conf_init

Definition at line 23 of file globals.php.

Referenced by _drupal_html_to_mail_urls(), _update_refresh(), blogapi_rsd(), conf_init(), filter_filter_tips(), hook_watchdog(), install_already_done_error(), install_goto(), install_tasks(), node_feed(), php_filter_tips(), ping_cron(), system_help(), template_preprocess_book_export_html(), update_batch(), url(), user_mail_tokens(), and user_register_submit().

global $channel

An associative array containing title, link, description and other keys.

The link should be an absolute URL.

See also:
aggregator_element_start

Definition at line 244 of file globals.php.

Referenced by aggregator_element_data(), aggregator_element_start(), aggregator_parse_feed(), aggregator_refresh(), blog_feed_last(), blog_feed_user(), node_feed(), and taxonomy_term_page().

global $conf

The path to the configuration directory as set by conf_path().

Definition at line 60 of file globals.php.

Referenced by _drupal_bootstrap(), conf_init(), conf_path(), drupal_eval(), install_main(), variable_del(), variable_get(), variable_init(), and variable_set().

global $cookie_domain

The domain to be used form session cookies.

Cookie domains must contain at least one dot other than the first (RFC 2109). For hosts such as 'localhost' or an IP Addresses the cookie domain will not be set.

Definition at line 55 of file globals.php.

Referenced by conf_init().

global $custom_theme

Name of custom theme to override default theme.

See also:
init_theme

Definition at line 172 of file globals.php.

Referenced by block_admin_display(), block_admin_display_form(), init_theme(), and system_init().

global $db_prefix

The prefix to be placed on all database tables.

Definition at line 47 of file globals.php.

Referenced by _install_settings_form_validate(), conf_init(), db_prefix_tables(), install_change_settings(), install_settings_form(), and install_verify_settings().

global $db_type

The type of database being used.

Example: mysql.

Definition at line 119 of file globals.php.

Referenced by _db_error_page(), _install_settings_form_validate(), db_set_active(), install_change_settings(), install_settings_form(), install_verify_settings(), and system_requirements().

global $db_url

The url of the database.

Thorough documentation provided in default.settings.php.

Definition at line 42 of file globals.php.

Referenced by _install_settings_form_validate(), conf_init(), db_set_active(), install_change_settings(), install_settings_form_validate(), and install_verify_settings().

global $element

Structured array describing the data to be rendered.

See also:
aggregator_element_start

Definition at line 222 of file globals.php.

Referenced by _form_set_class(), aggregator_element_data(), aggregator_element_end(), aggregator_element_start(), element_children(), element_properties(), example_element_phonenumber_expand(), expand_checkboxes(), expand_date(), expand_hidden_array(), expand_password_confirm(), expand_radios(), form_error(), form_expand_ahah(), form_get_error(), form_get_options(), form_select_options(), menu_overview_form_submit(), multipage_form_restore_attributes(), multipage_form_set_attribute(), multipage_form_set_element_visibility(), node_feed(), pager_load_array(), pager_query(), process_weight(), theme_button(), theme_checkbox(), theme_checkboxes(), theme_date(), theme_fieldset(), theme_file(), theme_filter_admin_overview(), theme_form(), theme_form_element(), theme_hidden(), theme_hidden_array(), theme_image_button(), theme_item(), theme_locale_languages_overview_form(), theme_markup(), theme_menu_overview_form(), theme_pager(), theme_pager_first(), theme_pager_last(), theme_pager_link(), theme_pager_next(), theme_pager_previous(), theme_password(), theme_password_confirm(), theme_phonenumber(), theme_radio(), theme_radios(), theme_select(), theme_submit(), theme_taxonomy_term_select(), theme_textarea(), theme_textfield(), theme_token(), and theme_trigger_display().

global $forum_topic_list_header

An array of topic header information.

Definition at line 259 of file globals.php.

Referenced by forum_get_topics(), and template_preprocess_forum_topic_list().

global $id

Active statistics record id.

Definition at line 289 of file globals.php.

Referenced by _filter_tips(), aggregator_block(), color_scheme_form_submit(), dblog_event(), drupal_write_record(), filter_admin_format_form(), filter_admin_format_form_submit(), filter_admin_order(), filter_admin_order_submit(), filter_admin_overview(), form_clean_id(), statistics_link(), template_preprocess_forum_list(), template_preprocess_forum_topic_list(), theme_admin_page(), theme_filter_admin_order(), and theme_system_admin_by_module().

global $image

Current image tag used by aggregator.

Definition at line 249 of file globals.php.

Referenced by _color_render_images(), aggregator_element_data(), aggregator_parse_feed(), aggregator_refresh(), tablesort_header(), theme_aggregator_block_item(), theme_feed_icon(), theme_system_powered_by(), and theme_xml_icon().

global $install_locale

The locale to use durring installation.

See also:
st

Definition at line 143 of file globals.php.

Referenced by install_change_settings(), install_main(), install_settings_form(), install_settings_form_submit(), install_tasks(), and st().

global $installed_profile

The name of the profile that has just been installed.

Definition at line 65 of file globals.php.

Referenced by conf_init().

global $item

General string or array.

See also:
aggregator_element_start

Definition at line 215 of file globals.php.

Referenced by _aggregator_page_list(), _fix_gpc_magic(), _fix_gpc_magic_files(), _menu_check_access(), _menu_delete_item(), _menu_item_localize(), _menu_link_build(), _menu_link_move_children(), _menu_link_parents_set(), _menu_link_translate(), _menu_load_objects(), _menu_navigation_links_rebuild(), _menu_overview_tree_form(), _menu_parent_depth_limit(), _menu_router_build(), _menu_tree_check_access(), _menu_tree_data(), _menu_update_parental_status(), _openid_encode_message(), _openid_parse_message(), aggregator_block(), aggregator_categorize_items(), aggregator_element_data(), aggregator_element_start(), aggregator_feed_items_load(), aggregator_page_categories(), aggregator_page_opml(), aggregator_page_rss(), aggregator_page_sources(), aggregator_parse_feed(), aggregator_remove(), aggregator_save_feed(), blog_form(), book_link_load(), book_menu_subtree_data(), drupal_uninstall_module(), hook_menu_link_alter(), hook_search(), hook_translated_menu_link_alter(), locale_user(), menu_delete_menu_confirm_submit(), menu_edit_item(), menu_edit_item_submit(), menu_edit_item_validate(), menu_edit_menu_validate(), menu_form_alter(), menu_get_active_breadcrumb(), menu_get_active_title(), menu_item_delete_form(), menu_item_delete_form_submit(), menu_item_delete_page(), menu_link_children_relative_depth(), menu_link_load(), menu_link_save(), menu_local_tasks(), menu_navigation_links(), menu_nodeapi(), menu_overview_form_submit(), menu_parent_options(), menu_reset_item(), menu_reset_item_confirm(), menu_reset_item_confirm_submit(), menu_set_active_trail(), menu_tree_all_data(), menu_tree_page_data(), menu_valid_path(), node_add_page(), node_feed(), node_search(), path_admin_form_validate(), system_admin_menu_block(), system_admin_menu_block_page(), system_get_module_admin_tasks(), system_logging_overview(), system_main_admin_page(), system_settings_overview(), system_site_information_settings_validate(), system_update_6021(), template_preprocess_aggregator_item(), template_preprocess_aggregator_summary_item(), theme_admin_block_content(), theme_aggregator_block_item(), theme_item_list(), theme_node_add_list(), theme_task_list(), and xmlrpc_value_get_xml().

global $items

Array of items used by aggregator.

See also:
aggregator_element_start

Definition at line 236 of file globals.php.

Referenced by _aggregator_page_list(), _openid_encode_message(), _openid_parse_message(), aggregator_admin_settings(), aggregator_block(), aggregator_categorize_items(), aggregator_element_data(), aggregator_element_start(), aggregator_feed_items_load(), aggregator_menu(), aggregator_page_categories(), aggregator_page_category(), aggregator_page_last(), aggregator_page_source(), aggregator_page_sources(), aggregator_parse_feed(), aggregator_remove(), aggregator_save_feed(), batch_example_menu(), block_menu(), blog_feed_last(), blog_feed_user(), blog_menu(), blog_page_last(), blog_page_user(), blogapi_menu(), book_menu(), comment_menu(), contact_menu(), dblog_menu(), example_element_menu(), fileupload_menu(), filter_menu(), format_rss_channel(), forum_menu(), help_menu(), hook_menu(), locale_menu(), menu_menu(), menu_tree_output(), multipage_form_example_menu(), node_feed(), node_menu(), node_title_list(), openid_form_alter(), openid_menu(), page_example_menu(), path_menu(), poll_menu(), profile_menu(), search_admin_settings(), statistics_menu(), system_get_module_admin_tasks(), system_menu(), system_modules_confirm_form(), taxonomy_menu(), taxonomy_term_page(), theme_aggregator_page_rss(), theme_comment_block(), theme_item_list(), theme_node_list(), theme_pager(), theme_system_admin_by_module(), theme_task_list(), theme_user_list(), throttle_menu(), tracker_menu(), translation_menu(), trigger_menu(), update_menu(), upload_menu(), upload_menu_alter(), user_block(), user_login_block(), and user_menu().

global $language

An array containing the information for the active language.

Example: array ( 'language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => '' );

Definition at line 99 of file globals.php.

Referenced by _block_get_cache_id(), _color_page_alter(), _locale_export_get_strings(), _locale_export_po(), _locale_export_po_generate(), _locale_languages_common_controls(), _locale_parse_js_file(), _locale_rebuild_js(), _locale_translate_language_list(), _update_message_text(), _user_mail_notify(), _user_mail_text(), chameleon_page(), contact_mail(), contact_mail_page_submit(), contact_mail_user_submit(), drupal_add_css(), drupal_init_language(), drupal_lookup_path(), drupal_mail(), format_rss_channel(), language_default(), language_initialize(), language_url_rewrite(), locale(), locale_block(), locale_get_plural(), locale_language_list(), locale_languages_edit_form(), locale_languages_overview_form(), locale_languages_overview_form_submit(), locale_translate_edit_form(), locale_translate_export_po_form_submit(), locale_translate_overview_screen(), locale_update_js_files(), locale_user(), node_feed(), path_admin_form_validate(), path_nodeapi(), path_set_alias(), phptemplate_get_ie_styles(), system_send_email_action(), t(), template_preprocess_book_export_html(), translation_link(), translation_node_overview(), translation_nodeapi(), translation_path_get_translations(), update_mail(), user_mail(), user_mail_tokens(), and user_pass_submit().

global $last_result

Resource of the query executed.

Definition at line 136 of file globals.php.

Referenced by _db_query(), and db_affected_rows().

global $menu_admin

Boolean indicating that a menu administrator is running the menu access check.

Definition at line 264 of file globals.php.

Referenced by menu_overview_form(), and menu_valid_path().

global $multibyte

The current multibyte mode.

Possible values: UNICODE_ERROR, UNICODE_SINGLEBYTE, UNICODE_MULTIBYTE.

Definition at line 208 of file globals.php.

Referenced by drupal_strlen(), drupal_strtolower(), drupal_strtoupper(), and drupal_substr().

global $nid

Active blog node id.

Definition at line 254 of file globals.php.

Referenced by _book_add_form_elements(), _book_link_defaults(), _comment_update_node_statistics(), _forum_new(), _forum_user_last_visit(), _node_mass_update_batch_process(), _node_mass_update_helper(), batch_example_batch_1(), batch_example_op_1(), blog_form(), book_export(), book_export_html(), comment_num_all(), comment_num_new(), comment_render(), hook_comment(), menu_tree_check_access(), menu_tree_collect_node_links(), multipage_form_example_custom_submit(), node_comment_mode(), node_delete(), node_feed(), node_last_changed(), node_last_viewed(), node_mark(), node_mass_update(), node_multiple_delete_confirm(), node_multiple_delete_confirm_submit(), node_tag_new(), poll_cancel_form(), statistics_get(), and theme_book_admin_table().

global $pager_page_array

Result of pager_query() that is utilized by other functions.

Definition at line 148 of file globals.php.

Referenced by pager_query(), taxonomy_overview_terms(), theme_pager(), theme_pager_first(), theme_pager_last(), theme_pager_next(), and theme_pager_previous().

global $pager_total

Array of the total number of pages per pager.

The key is will be 0 by defualt, but can be specified via the $element parameter of pager_query().

Definition at line 154 of file globals.php.

Referenced by pager_query(), taxonomy_overview_terms(), theme_pager(), theme_pager_last(), and theme_pager_next().

global $pager_total_items

Array of the total number of items per pager.

The key is will be 0 by defualt, but can be specified via the $element parameter of pager_query().

Definition at line 160 of file globals.php.

Referenced by pager_query(), and taxonomy_overview_terms().

global $profile

The name of the currently installed profile.

Definition at line 112 of file globals.php.

Referenced by drupal_check_profile(), drupal_detect_baseurl(), drupal_install_profile_name(), drupal_system_listing(), drupal_verify_profile(), install_change_settings(), install_check_requirements(), install_main(), install_select_profile(), install_select_profile_form(), install_settings_form(), install_settings_form_submit(), install_task_list(), install_tasks(), profile_block(), profile_browse(), and st().

global $queries

Array of queries that have been executed.

Definition at line 131 of file globals.php.

Referenced by _db_query(), and update_results_page().

global $recent_activity

Recent activity statistics generated by statistics_exit().

Definition at line 284 of file globals.php.

Referenced by statistics_exit().

global $tag

Active tag name.

See also:
aggregator_element_start

Definition at line 229 of file globals.php.

Referenced by _filter_autop(), _filter_htmlcorrector(), _locale_import_parse_header(), aggregator_element_data(), aggregator_element_start(), update_xml_parser::data(), drupal_explode_tags(), drupal_html_to_text(), drupal_implode_tags(), filter_filter_tips(), taxonomy_autocomplete(), taxonomy_implode_tags(), theme_update_version(), xmlrpc_message_tag_close(), and xmlrpc_message_tag_open().

global $theme

Name of the active theme.

Definition at line 165 of file globals.php.

Referenced by _block_get_cache_id(), _block_themes_access(), _color_render_images(), _color_rewrite_stylesheet(), _drupal_maintenance_theme(), _init_theme(), _system_theme_data(), _system_themes_access(), _theme_build_registry(), _theme_load_offline_registry(), _theme_load_registry(), _theme_process_registry(), block_add_block_form_submit(), block_admin_display(), block_admin_display_form(), block_menu(), chameleon_theme(), color_form_alter(), color_get_info(), color_get_palette(), color_scheme_form(), color_scheme_form_submit(), drupal_find_theme_templates(), init_theme(), list_themes(), phptemplate_theme(), system_admin_theme_settings(), system_default_region(), system_help(), system_initialize_theme_blocks(), system_menu(), system_theme_data(), system_theme_select_form(), system_themes_form(), system_themes_form_submit(), system_update_6042(), template_preprocess_maintenance_page(), template_preprocess_page(), theme_color_scheme_form(), and theme_system_themes_form().

global $theme_engine

The active theme engine related to the active theme.

Definition at line 197 of file globals.php.

Referenced by _init_theme(), _theme_build_registry(), _theme_load_offline_registry(), _theme_load_registry(), drupal_discover_template(), and theme().

global $theme_info

Active theme object.

For documentation of the theme object see _init_theme().

See also:
_init_theme

Definition at line 186 of file globals.php.

Referenced by _init_theme(), _system_theme_data(), drupal_eval(), and drupal_find_theme_templates().

global $theme_key

Name of the active theme.

See also:
init_theme

Definition at line 179 of file globals.php.

Referenced by _block_compare(), _block_rehash(), _color_page_alter(), _drupal_maintenance_theme(), block_admin_display_form(), block_list(), init_theme(), system_region_list(), system_theme_select_form(), system_themes_form(), template_preprocess_block_admin_display_form(), and theme_get_setting().

global $theme_path

Path to the active theme.

Definition at line 202 of file globals.php.

Referenced by _init_theme(), drupal_eval(), path_to_theme(), theme(), theme_install_page(), and theme_update_page().

global $timers

Stores timers that have been created by timer_start().

See also:
timer_start

timer_read

timer_stop

Definition at line 16 of file globals.php.

Referenced by timer_read(), timer_start(), and timer_stop().

global $update_free_access

Access control for update.php script.

Allows the update.php script to be run when not logged in as and administrator.

Definition at line 71 of file globals.php.

Referenced by conf_init().

global $update_mode

Disabled caling hook_boot() and hook_exit() during the update process (update.php) since the database is in a largely unknown state.

See also:
drupal_goto

Definition at line 107 of file globals.php.

global $user

Representation of the current user.

Stores preferences and other user information.

Definition at line 76 of file globals.php.

Referenced by _block_get_cache_id(), _comment_get_display_setting(), _contact_user_tab_access(), _db_query(), _forum_new(), _forum_user_last_visit(), _locale_export_po_generate(), _upload_file_limits(), _upload_form(), _user_edit_submit(), _user_edit_validate(), _user_password_dynamic_validation(), block_list(), blog_block(), blog_page_last(), blog_page_user(), blog_user(), blogap_mti_publish_post(), blogapi_blogger_delete_post(), blogapi_blogger_edit_post(), blogapi_blogger_get_post(), blogapi_blogger_get_recent_posts(), blogapi_blogger_get_user_info(), blogapi_blogger_get_users_blogs(), blogapi_blogger_new_post(), blogapi_metaweblog_new_media_object(), blogapi_mt_get_post_categories(), blogapi_mt_set_post_categories(), blogapi_validate_user(), cache_clear_all(), cache_get(), comment_access(), comment_controls_submit(), comment_edit(), comment_form(), comment_form_add_preview(), comment_form_validate(), comment_links(), comment_num_new(), comment_render(), comment_save(), comment_user(), comment_validate(), contact_mail(), contact_mail_page(), contact_mail_user(), contact_mail_user_submit(), contact_site_page(), contact_user_page(), custom_url_rewrite_inbound(), custom_url_rewrite_outbound(), dblog_user(), drupal_anonymous_user(), drupal_init_language(), drupal_prepare_form(), drupal_valid_token(), file_save_upload(), file_validate_extensions(), file_validate_size(), fileupload_access(), filter_formats(), format_date(), forum_get_topics(), hook_node_grants(), init_theme(), install_configure_form_submit(), language_initialize(), locale_user(), node_access(), node_add(), node_form(), node_form_submit(), node_last_viewed(), node_mark(), node_object_prepare(), node_preview(), node_save(), node_submit(), node_tag_new(), node_user(), page_get_cache(), page_set_cache(), poll_cancel(), poll_form(), poll_load(), poll_user(), poll_view(), poll_vote(), profile_load_profile(), profile_save_profile(), profile_user(), profile_view_field(), profile_view_profile(), sess_read(), sess_write(), statistics_exit(), statistics_user(), system_admin_compact_mode(), system_admin_compact_page(), system_message_action(), system_send_email_action(), template_preprocess(), template_preprocess_forum_list(), template_preprocess_forums(), theme_aggregator_block_item(), theme_comment_post_forbidden(), theme_mark(), theme_user_list(), upload_node_form_submit(), user_access(), user_authenticate(), user_authenticate_finalize(), user_autocomplete(), user_block(), user_block_user_action(), user_external_load(), user_external_login(), user_external_login_register(), user_help(), user_load(), user_login(), user_login_final_validate(), user_login_submit(), user_logout(), user_module_invoke(), user_multiple_delete_confirm(), user_page(), user_pass_reset(), user_register(), user_save(), valid_email_address(), and watchdog().

global $xrds_current_service

Array used by XRDS XML parser for OpenID to track parsing state.

Definition at line 279 of file globals.php.

Referenced by _xrds_cdata(), and _xrds_element_end().

global $xrds_open_elements

Array used by XRDS XML parser for OpenID to track parsing state.

Definition at line 274 of file globals.php.

Referenced by _xrds_cdata(), _xrds_element_end(), and _xrds_element_start().

global $xrds_services

Array used by XRDS XML parser for OpenID to track parsing state.

Definition at line 269 of file globals.php.

Referenced by _xrds_cdata(), _xrds_element_end(), and xrds_parse().

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/index.php File Reference

docs

index.php File Reference

Go to the source code of this file.

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/batch_example.install File Reference

docs » examples

batch_example.install File Reference

Go to the source code of this file.

Functions

  • batch_test_update_1 (&$sandbox)

Function Documentation

batch_test_update_1 ( &$ sandbox )

Definition at line 13 of file batch_example.install.

References $result, $row, db_fetch_array(), db_query(), db_query_range(), db_result(), and update_sql().

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/batch_example.module File Reference

docs » examples

batch_example.module File Reference

Detailed Description

This is an example outlining how a module can define batches.

Batches allow heavy processing to be spread out over several page requests, thus ensuring that the processing does not get interrupted because of a PHP timeout, while allowing the user to receive feedback on the progress of the ongoing operations.

Definition in file batch_example.module.

Go to the source code of this file.

Functions

  • batch_example_batch_1 ()
    Batch 1 : Load 100 times the node with the lowest nid.
  • batch_example_batch_2 ()
    Batch 2 : load all nodes 5 by 5, 20 times (Multipart operation).
  • batch_example_finished ($success, $results, $operations)
    Batch 'finished' callback used by both batch 1 and batch 2.
  • batch_example_menu ()
    2 'harmless' batches are defined : batch 1 : Load 100 times the node with the lowest nid batch 2 : Load all nodes, 20 times (uses a progressive op : load nodes by groups of 5)
  • batch_example_multistep_form ($form_state=NULL)
    Multistep form.
  • batch_example_multistep_form_submit ($form, &$form_state)
  • batch_example_op_1 ($nid, &$context)
    Batch operation for batch 1 : lode a node.
  • batch_example_op_2 (&$context)
    Batch operation for batch 2 : load all nodes, 5 by five This is a multipart operation, using the.
  • batch_example_page ()
  • batch_example_simple_form ()
    Test 1 : Simple form.
  • batch_example_simple_form_submit ($form, &$form_state)

Function Documentation

batch_example_menu ( )

2 'harmless' batches are defined : batch 1 : Load 100 times the node with the lowest nid batch 2 : Load all nodes, 20 times (uses a progressive op : load nodes by groups of 5)

The module defines the following pages : /batch_example/example_1 : Simple form, lets you pick the batch that should be executed /batch_example/example_2 : Multistep form : perform batch 1 and batch 2 as separate submission steps. /batch_example/example_3 No form - start a batch simply by clicking a link (not really user friendly, should probably be avoided) Implementation of hook_menu().

Definition at line 33 of file batch_example.module.

References $items.

batch_example_multistep_form ( $ form_state = NULL )

Multistep form.

Definition at line 99 of file batch_example.module.

batch_example_multistep_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 117 of file batch_example.module.

References batch_example_batch_1(), batch_example_batch_2(), batch_set(), and drupal_set_message().

batch_example_page ( )

Definition at line 136 of file batch_example.module.

References batch_example_batch_1(), batch_process(), and batch_set().

batch_example_simple_form ( )

Test 1 : Simple form.

Definition at line 68 of file batch_example.module.

batch_example_simple_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 84 of file batch_example.module.

References batch_set().

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/block_example.module File Reference

docs » examples

block_example.module File Reference

Detailed Description

This is an example outlining how a module can define blocks to be displayed on each page.

Definition in file block_example.module.

Go to the source code of this file.

Functions

  • block_example_block ($op= 'list', $delta=0, $edit=array())
    Implementation of hook_block().
  • block_example_contents ($which_block)
    A block content function.

Function Documentation

block_example_block | ( | $ | op = 'list',
 |  | $ | delta = 0,
 |  | $ | edit = array()
 | ) |  |

Implementation of hook_block().

This hook both declares to Drupal what blocks are provided by the module, and generates the contents of the blocks themselves.

Definition at line 16 of file block_example.module.

References $op, block_example_contents(), t(), variable_get(), and variable_set().

block_example_contents ( $ which_block )

A block content function.

Definition at line 87 of file block_example.module.

References t(), and variable_get().

Referenced by block_example_block().

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/example_element.module File Reference

docs » examples

example_element.module File Reference

Detailed Description

This is an example demonstrating how a module can define custom form elements.

Form elements are already familiar to anyone who uses Forms API. Examples of core form elements are 'textfield', 'checkbox' and 'fieldset'. Drupal utilizes hook_elements() to define these FAPI types, and this occurs in the core function system_elements().

Each form element has a type value that determines how it's treated by the Form API and how it's ultimately rendered into HTML. hook_elements() allows modules to define new element types, and tell the Form API what default values they should automatically be populated with.

By implementing hook_elements in your own module, you can create custom form elements with their own properties, validation and theming.

In this example, we will define a phone number field that is expanded into several text fields for area code, phone number and extention, each of which is validated.

Definition in file example_element.module.

Go to the source code of this file.

Functions

  • example_element_demo_form ()
    This is a simple form to demonstrate how to use the phonenumber element we've defined.
  • example_element_elements ()
    Implementation of hook_elements().
  • example_element_menu ()
    Implementation of hook_menu().
  • example_element_phonenumber_expand ($element)
    Our process callback to expand the control.
  • example_element_phonenumber_validate ($form, &$form_state)
    Our element's validation function.
  • example_element_theme ()
    Implementation of hook_theme().
  • theme_phonenumber ($element)
    Theme function to format the output.

Function Documentation

example_element_demo_form ( )

This is a simple form to demonstrate how to use the phonenumber element we've defined.

Definition at line 143 of file example_element.module.

References system_settings_form(), t(), and variable_get().

example_element_elements ( )

Implementation of hook_elements().

Definition at line 46 of file example_element.module.

References $type.

example_element_menu ( )

Implementation of hook_menu().

This just defines a page that we can use to test our form elements.

Definition at line 33 of file example_element.module.

References $items.

example_element_phonenumber_expand ( $ element )

Our process callback to expand the control.

Definition at line 59 of file example_element.module.

References $element, and t().

example_element_phonenumber_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Our element's validation function.

We check that:

  • the area code is a three digit number
  • the number is numeric, with an optional dash

Any problems are attached to the form element using form_error().

Definition at line 101 of file example_element.module.

References form_error(), and t().

example_element_theme ( )

Implementation of hook_theme().

This lets us tell Drupal about our theme functions and their arguments.

Definition at line 121 of file example_element.module.

theme_phonenumber ( $ element )

Theme function to format the output.

We use the container-inline class so that all three of the HTML elements are placed next to each other, rather than on separate lines.

Definition at line 135 of file example_element.module.

References $element, and theme().

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/fileupload.module File Reference

docs » examples

fileupload.module File Reference

Detailed Description

This is an example to demonstrate how to make a Drupal node support file uploads.

definition:

   CREATE TABLE fileupload (
     nid int(10) unsigned NOT NULL default '0',
     filename varchar(255) not null,
     filepath varchar(255) not null,
     filemime varchar(255) not null,
     filesize int(10) unsigned not null
   );

Definition in file fileupload.module.

Go to the source code of this file.

Functions

  • fileupload_access ($op, $node)
    Implementation of hook_access.
  • fileupload_delete ($node)
    Implementation of hook_delete().
  • fileupload_file_download ($file)
    Implementation of hook_file_download.
  • fileupload_form (&$node)
    Implementation of hook_form().
  • fileupload_help ($section)
    Implementation of hook_help.
  • fileupload_insert ($node)
    Implementation of hook_insert().
  • fileupload_load ($node)
    Implementation of hook_load().
  • fileupload_menu ($may_cache)
    Implementation of hook_menu.
  • fileupload_node_info ()
    Implementation of hook_node_info.
  • fileupload_perm ()
    Implementation of hook_perm.
  • fileupload_submit (&$node)
    Implementation of hook_submit().
  • fileupload_update ($node)
    Implementation of hook_update().
  • fileupload_validate (&$node)
    Implementation of hook_validate().
  • fileupload_view (&$node, $teaser=FALSE, $page=FALSE)
    Implementation of hook_view.

Function Documentation

fileupload_access | ( | $ | op,
 |  | $ | node
 | ) |  |

Implementation of hook_access.

Definition at line 64 of file fileupload.module.

References $op, $user, and user_access().

fileupload_delete ( $ node )

Implementation of hook_delete().

The node is being delete, remove the file and any information.

Definition at line 228 of file fileupload.module.

References db_query(), file_delete(), and nid.

fileupload_file_download ( $ file )

Implementation of hook_file_download.

Definition at line 79 of file fileupload.module.

References db_query(), db_result(), file_create_path(), and user_access().

fileupload_form ( &$ node )

Implementation of hook_form().

Return an array of the form elements needed to edit this node.

Definition at line 114 of file fileupload.module.

References nid, and t().

fileupload_help ( $ section )

Implementation of hook_help.

Definition at line 45 of file fileupload.module.

References t().

fileupload_insert ( $ node )

Implementation of hook_insert().

The node is being created, save the file's infomation to the database.

Definition at line 196 of file fileupload.module.

References db_query(), and nid.

fileupload_load ( $ node )

Implementation of hook_load().

The node is being loaded. Load the file's information from the database so it can be added to the node.

Definition at line 185 of file fileupload.module.

References db_fetch_object(), db_query(), and nid.

fileupload_menu ( $ may_cache )

Implementation of hook_menu.

Definition at line 24 of file fileupload.module.

References $items, t(), and user_access().

fileupload_node_info ( )

Implementation of hook_node_info.

Definition at line 57 of file fileupload.module.

References t().

fileupload_perm ( )

Implementation of hook_perm.

Definition at line 38 of file fileupload.module.

fileupload_submit ( &$ node )

Implementation of hook_submit().

If a file was uploaded save it before updating the database.

Definition at line 172 of file fileupload.module.

References file_directory_path(), and file_save_upload().

fileupload_update ( $ node )

Implementation of hook_update().

The node is being updated, save changes to the file infomation to the database.

Definition at line 206 of file fileupload.module.

References db_query(), db_result(), file_delete(), and nid.

fileupload_validate ( &$ node )

Implementation of hook_validate().

Verify that there is a file attached to the node.

Definition at line 155 of file fileupload.module.

References form_set_error(), and t().

fileupload_view | ( | &$ | node,
 |  | $ | teaser = FALSE,
 |  | $ | page = FALSE
 | ) |  |

Implementation of hook_view.

Definition at line 93 of file fileupload.module.

References file_check_location(), file_create_url(), file_directory_path(), format_size(), l(), and theme().

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/filter_example.module File Reference

docs » examples

filter_example.module File Reference

Detailed Description

This is an example outlining how a module can be used to define a filter to be run on user-submitted content before it is output to the browser.

To show all the capabilities of the filter system, we will define two filters in this module. One will substitute the string "foo" with an administratively- defined replacement string. The other will find a custom XML tag, <time>, and replace it by the current time.

Definition in file filter_example.module.

Go to the source code of this file.

Functions

  • filter_example_filter ($op, $delta=0, $format=-1, $text= '')
    Implementation of hook_filter().
  • filter_example_filter_tips ($delta, $format, $long=FALSE)
    Implementation of hook_filter_tips().

Function Documentation

filter_example_filter | ( | $ | op,
 |  | $ | delta = 0,
 |  | $ | format = -1,
 |  | $ | text = ''
 | ) |  |

Implementation of hook_filter().

The bulk of filtering work is done here. This hook is quite complicated, so we'll discuss each operation it defines.

Definition at line 48 of file filter_example.module.

References $op, format_date(), t(), and variable_get().

filter_example_filter_tips | ( | $ | delta,
 |  | $ | format,
 |  | $ | long = FALSE
 | ) |  |

Implementation of hook_filter_tips().

This hook allows filters to provide help text to users during the content editing process. Short tips are provided on the content editing screen, while long tips are provided on a separate linked page. Short tips are optional, but long tips are highly recommended.

Definition at line 23 of file filter_example.module.

References t(), and variable_get().

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/multipage_form_example.module File Reference

docs » examples

multipage_form_example.module File Reference

Go to the source code of this file.

Functions

  • expand_hidden_array ($element)
  • multipage_form_example_access ($op, $node)
    Implementation of hook_access().
  • multipage_form_example_custom_submit ()
  • multipage_form_example_custom_validate ()
    Validate our form.
  • multipage_form_example_delete ($node)
    Implementation of hook_delete().
  • multipage_form_example_elements ()
    Playing around here with a new form element to enable storing hidden values in an array fashion.
  • multipage_form_example_form (&$node)
    Implementation of hook_form() for multipage_form_example.
  • multipage_form_example_form_alter ($form_id, &$form)
    Implementation of hook_form_alter().
  • multipage_form_example_help ($section)
    Implementation of hook_help().
  • multipage_form_example_load ($node)
    Implementation of hook_load().
  • multipage_form_example_menu ($may_cache)
    Implementation of hook_menu().
  • multipage_form_example_node_info ()
    Implementation of hook_node_info().
  • multipage_form_example_pre_render ($form_id, &$form, $next_page=TRUE)
    The pre_render of a form allows us to make changes AFTER validation (unlike hook_form_alter()), but BEFORE the form has actually been displayed.
  • multipage_form_example_view (&$node, $teaser=FALSE, $page=FALSE)
    Implementation of hook_view().
  • multipage_form_restore_attributes (&$element)
    Restore any form attributes which have been set using multipage_form_set_attribute().
  • multipage_form_set_attribute (&$element, $key, $new_value)
    Set an attribute on an element array with storing the previous value which may be reverted to using multipage_form_restore_attributes().
  • multipage_form_set_element_visibility (&$element, $visible, $next_page=TRUE)
    Set an element's visibility.
  • theme_hidden_array ($element)
  • theme_multipage_form_example ($node)
    A custom theme function.
  • theme_multipage_form_example_node_form ($form)

Function Documentation

expand_hidden_array ( $ element )

Definition at line 462 of file multipage_form_example.module.

References $element, and $value.

multipage_form_example_access | ( | $ | op,
 |  | $ | node
 | ) |  |

Implementation of hook_access().

Definition at line 37 of file multipage_form_example.module.

multipage_form_example_custom_submit ( )

Definition at line 286 of file multipage_form_example.module.

References $nid, $value, db_query(), db_result(), and variable_set().

multipage_form_example_custom_validate ( )

Validate our form.

Definition at line 217 of file multipage_form_example.module.

References form_set_error(), and t().

multipage_form_example_delete ( $ node )

Implementation of hook_delete().

Clean up our data in variable table.

Definition at line 323 of file multipage_form_example.module.

References nid, and variable_del().

multipage_form_example_elements ( )

Playing around here with a new form element to enable storing hidden values in an array fashion.

Seems to work fine. Check out $form['test_hidden_array'] above for how to structure the form element

Definition at line 457 of file multipage_form_example.module.

References $type.

multipage_form_example_form ( &$ node )

Implementation of hook_form() for multipage_form_example.

We don't set ANY required attributes here - we leave that up to multipage_form_example_pre_render().

Definition at line 52 of file multipage_form_example.module.

References t().

multipage_form_example_form_alter | ( | $ | form_id,
 |  | &$ | form
 | ) |  |

Implementation of hook_form_alter().

Here, we set up the 'page' field, which keeps track of what stage the form is in.

Definition at line 181 of file multipage_form_example.module.

References multipage_form_example_pre_render(), and t().

multipage_form_example_help ( $ section )

Implementation of hook_help().

Definition at line 8 of file multipage_form_example.module.

References t().

multipage_form_example_load ( $ node )

Implementation of hook_load().

Now that we've defined how to manage the node data in the database, We need to tell Drupal how to get the node back out. This hook is called every time a node is loaded, and allows us to do some loading of our own.

Definition at line 312 of file multipage_form_example.module.

References nid, and variable_get().

multipage_form_example_menu ( $ may_cache )

Implementation of hook_menu().

Definition at line 20 of file multipage_form_example.module.

References $items, and t().

multipage_form_example_node_info ( )

Implementation of hook_node_info().

Definition at line 44 of file multipage_form_example.module.

References t().

multipage_form_example_pre_render | ( | $ | form_id,
 |  | &$ | form,
 |  | $ | next_page = TRUE
 | ) |  |

The pre_render of a form allows us to make changes AFTER validation (unlike hook_form_alter()), but BEFORE the form has actually been displayed.

We use it to control which form elements are shown, which are hidden, and which values to set based on validate elements, not $_POST. This is a necessity for our complicated multipage example form.

Definition at line 232 of file multipage_form_example.module.

References form_get_errors(), multipage_form_set_element_visibility(), and t().

Referenced by multipage_form_example_form_alter().

multipage_form_example_view | ( | &$ | node,
 |  | $ | teaser = FALSE,
 |  | $ | page = FALSE
 | ) |  |

Implementation of hook_view().

This is a typical implementation that simply runs the node text through the output filters.

Definition at line 334 of file multipage_form_example.module.

References node_prepare(), and theme().

multipage_form_restore_attributes ( &$ element )

Restore any form attributes which have been set using multipage_form_set_attribute().

Parameters:
$element The form element array to restore.

Definition at line 446 of file multipage_form_example.module.

References $element.

Referenced by multipage_form_set_element_visibility().

multipage_form_set_attribute | ( | &$ | element,
 |  | $ | key,
 |  | $ | new_value
 | ) |  |

Set an attribute on an element array with storing the previous value which may be reverted to using multipage_form_restore_attributes().

Parameters:
$element | The form element array to modify.
$key | A key of the form element array.
$new_value | The new value for the attribute.

Definition at line 434 of file multipage_form_example.module.

References $element.

Referenced by multipage_form_set_element_visibility().

multipage_form_set_element_visibility | ( | &$ | element,
 |  | $ | visible,
 |  | $ | next_page = TRUE
 | ) |  |

Set an element's visibility.

Elements are gnerally changed to hidden elements. Visibility may be set and reset any number of times.

Parameters:
$element | The form element array to modify.
$visible | The desired visibity of the form element.
$next_page | Boolean value, TRUE if the next page is about to be rendered, FALSE otherwise.

Definition at line 372 of file multipage_form_example.module.

References $element, element_children(), multipage_form_restore_attributes(), and multipage_form_set_attribute().

Referenced by multipage_form_example_pre_render().

theme_hidden_array ( $ element )

Definition at line 471 of file multipage_form_example.module.

References $element.

theme_multipage_form_example ( $ node )

A custom theme function.

By using this function to format our node-specific information, themes can override this presentation if they wish. We also wrap the default presentation in a CSS class that is prefixed by the module name. This way, style sheets can modify the output without requiring theme code.

Definition at line 349 of file multipage_form_example.module.

References $output, check_plain(), and t().

theme_multipage_form_example_node_form ( $ form )

Definition at line 160 of file multipage_form_example.module.

References $content, check_plain(), element_children(), and t().

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/node_access_example.install File Reference

docs » examples

node_access_example.install File Reference

Go to the source code of this file.

Functions

  • node_access_example_install ()
    Implementation of hook_install().
  • node_access_example_schema ()
    Implementation of hook_schema().
  • node_access_example_uninstall ()
    Implementation of hook_uninstall().

Function Documentation

node_access_example_install ( )

Implementation of hook_install().

Definition at line 7 of file node_access_example.install.

References drupal_install_schema().

node_access_example_schema ( )

Implementation of hook_schema().

Definition at line 21 of file node_access_example.install.

node_access_example_uninstall ( )

Implementation of hook_uninstall().

Definition at line 14 of file node_access_example.install.

References drupal_uninstall_schema().

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/node_access_example.module File Reference

docs » examples

node_access_example.module File Reference

Detailed Description

This is an example illustrating how to restrict access to nodes based on some criterion associated with the user.

This example module will simply set a single flag on a node: 'private'. If the flag is set, only users with the 'view private content' flag can see the node, and all users with 'edit private content' can edit (but not delete) the node.

Additionally we will ensure that the node author can always view, edit, and delete the node by providing an additional access realm that grants privileges to the node's author.

Database definition:

   CREATE TABLE node_access_example (
     nid int(10) unsigned NOT NULL default '0' PRIMARY KEY,
     private int,
     KEY `node_example_nid` (nid)
   )

Definition in file node_access_example.module.

Go to the source code of this file.

Functions

  • node_access_example_form_alter (&$form, $form_state)
    Implementation of hook_form_alter().
  • node_access_example_node_access_records ($node)
    Implementation of hook_node_access_records().
  • node_access_example_node_grants ($account, $op)
    Implementation of hook_node_grants().
  • node_access_example_nodeapi (&$node, $op, $arg=0)
    Implementation of hook_nodeapi().
  • node_access_example_perm ()
    Implementation of hook_perm().

Function Documentation

node_access_example_form_alter | ( | &$ | form,
 |  | $ | form_state
 | ) |  |

Implementation of hook_form_alter().

This module adds a simple checkbox to the node form labeled private. If the checkbox is labelled, only the node author and users with 'access private content' privileges may see it.

Definition at line 108 of file node_access_example.module.

References t().

node_access_example_node_access_records ( $ node )

Implementation of hook_node_access_records().

All node access modules must implement this hook. If the module is interested in the privacy of the node passed in, return a list of node access values for each grant ID we offer. Since this example module only offers 1 grant ID, we will only ever be returning one record.

Definition at line 73 of file node_access_example.module.

node_access_example_node_grants | ( | $ | account,
 |  | $ | op
 | ) |  |

Implementation of hook_node_grants().

Tell the node access system what GIDs the user belongs to for each realm. In this example, we are providing two realms: the example realm, which has just one group id (1) and the user is either a member or not depending upon the operation and the access permission set.

We are also setting up a realm for the node author, though, to give it special privileges. That has 1 GID for every UID, and each user is automatically a member of the group where GID == UID.

Definition at line 51 of file node_access_example.module.

References $op, and user_access().

node_access_example_nodeapi | ( | &$ | node,
 |  | $ | op,
 |  | $ | arg = 0
 | ) |  |

Implementation of hook_nodeapi().

  • "delete", "insert", and "update": The module must track the access status of the node.

Definition at line 125 of file node_access_example.module.

References $op, $result, db_fetch_object(), db_query(), and nid.

node_access_example_perm ( )

Implementation of hook_perm().

In this example, we will use a simple permission to determine whether a user has access to "private" content. This permission is defined here.

Definition at line 34 of file node_access_example.module.

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/node_example.install File Reference

docs » examples

node_example.install File Reference

Go to the source code of this file.

Functions

  • node_example_install ()
    Implementation of hook_install().
  • node_example_schema ()
    Implementation of hook_schema().
  • node_example_uninstall ()
    Implementation of hook_uninstall().

Function Documentation

node_example_install ( )

Implementation of hook_install().

Definition at line 7 of file node_example.install.

References drupal_install_schema().

node_example_schema ( )

Implementation of hook_schema().

Definition at line 21 of file node_example.install.

node_example_uninstall ( )

Implementation of hook_uninstall().

Definition at line 14 of file node_example.install.

References drupal_uninstall_schema().

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/node_example.module File Reference

docs » examples

node_example.module File Reference

Detailed Description

This is an example outlining how a module can be used to define a new node type.

Our example node type will allow users to specify a "color" and a "quantity" for their nodes; some kind of rudimentary inventory-tracking system, perhaps? To store this extra information, we need an auxiliary database table.

Database definition:

   CREATE TABLE node_example (
     vid int(10) unsigned NOT NULL default '0',
     nid int(10) unsigned NOT NULL default '0',
     color varchar(255) NOT NULL default '',
     quantity int(10) unsigned NOT NULL default '0',
     PRIMARY KEY (vid, nid),
     KEY `node_example_nid` (nid)
   )

Definition in file node_example.module.

Go to the source code of this file.

Functions

  • node_example_access ($op, $node, $account)
    Implementation of hook_access().
  • node_example_delete ($node)
    Implementation of hook_delete().
  • node_example_form (&$node)
    Implementation of hook_form().
  • node_example_insert ($node)
    Implementation of hook_insert().
  • node_example_load ($node)
    Implementation of hook_load().
  • node_example_node_info ()
    Implementation of hook_node_info().
  • node_example_nodeapi (&$node, $op, $teaser, $page)
    Implementation of hook_nodeapi().
  • node_example_perm ()
    Implementation of hook_perm().
  • node_example_theme ()
    Implementation of hook_theme().
  • node_example_update ($node)
    Implementation of hook_update().
  • node_example_validate (&$node)
    Implementation of hook_validate().
  • node_example_view ($node, $teaser=FALSE, $page=FALSE)
    Implementation of hook_view().
  • theme_node_example_order_info ($node)
    A custom theme function.

Function Documentation

node_example_access | ( | $ | op,
 |  | $ | node,
 |  | $ | account
 | ) |  |

Implementation of hook_access().

Node modules may implement node_access() to determine the operations users may perform on nodes. This example uses a very common access pattern.

Definition at line 71 of file node_example.module.

References $op, and user_access().

node_example_delete ( $ node )

Implementation of hook_delete().

When a node is deleted, we need to remove all related records from out table.

Definition at line 222 of file node_example.module.

References db_query(), and nid.

node_example_form ( &$ node )

Implementation of hook_form().

Now it's time to describe the form for collecting the information specific to this node type. This hook requires us to return an array with a sub array containing information for each element in the form.

Definition at line 113 of file node_example.module.

References $type, check_plain(), node_body_field(), node_get_types(), and t().

node_example_insert ( $ node )

Implementation of hook_insert().

As a new node is being inserted into the database, we need to do our own database inserts.

Definition at line 181 of file node_example.module.

References db_query(), and nid.

Referenced by node_example_update().

node_example_load ( $ node )

Implementation of hook_load().

Now that we've defined how to manage the node data in the database, we need to tell Drupal how to get the node back out. This hook is called every time a node is loaded, and allows us to do some loading of our own.

Definition at line 234 of file node_example.module.

References db_fetch_object(), and db_query().

node_example_node_info ( )

Implementation of hook_node_info().

This function replaces hook_node_name() and hook_node_types() from 4.6. Drupal 5 expands this hook significantly.

This is a required node hook. This function describes the nodes provided by this module.

The required attributes are:

  • "name" provides a human readable name for the node,
  • "module" tells Drupal how the module's functions map to hooks (i.e. if the module is node_example_foo then node_example_foo_insert will be called when inserting the node).
  • "description" provides a brief description of the node type, which is show up when a user accesses the "Create content" page for that node type.

The other optional, attributes:

  • "has_title" boolean that indicates whether or not this node type has a title field.
  • "title_label": the label for the title field of this content type.
  • "has_body": boolean that indicates whether or not this node type has a body field.
  • "body_label": the label for the body field of this content type.
  • "min_word_count": the minimum number of words for the body field to be considered valid for this content type.

Definition at line 51 of file node_example.module.

References t().

node_example_nodeapi | ( | &$ | node,
 |  | $ | op,
 |  | $ | teaser,
 |  | $ | page
 | ) |  |

Implementation of hook_nodeapi().

When a node revision is deleted, we need to remove the corresponding record from our table. The only way to handle revision deletion is by implementing hook_nodeapi().

Definition at line 208 of file node_example.module.

References $op, and db_query().

node_example_perm ( )

Implementation of hook_perm().

Since we are limiting the ability to create new nodes to certain users, we need to define what those permissions are here. We also define a permission to allow users to edit the nodes they created.

Definition at line 96 of file node_example.module.

node_example_theme ( )

Implementation of hook_theme().

This lets us tell Drupal about our theme functions and their arguments.

Definition at line 261 of file node_example.module.

node_example_update ( $ node )

Implementation of hook_update().

As an existing node is being updated in the database, we need to do our own database updates.

Definition at line 191 of file node_example.module.

References db_query(), and node_example_insert().

node_example_validate ( &$ node )

Implementation of hook_validate().

Our "quantity" field requires a number to be entered. This hook lets us ensure that the user entered an appropriate value before we try inserting anything into the database.

Errors should be signaled with form_set_error().

Definition at line 163 of file node_example.module.

References form_set_error(), and t().

node_example_view | ( | $ | node,
 |  | $ | teaser = FALSE,
 |  | $ | page = FALSE
 | ) |  |

Implementation of hook_view().

This is a typical implementation that simply runs the node text through the output filters.

Definition at line 245 of file node_example.module.

References node_prepare(), and theme().

theme_node_example_order_info ( $ node )

A custom theme function.

By using this function to format our node-specific information, themes can override this presentation if they wish. We also wrap the default presentation in a CSS class that is prefixed by the module name. This way, style sheets can modify the output without requiring theme code.

Definition at line 277 of file node_example.module.

References $output, check_plain(), and t().

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/nodeapi_example.install File Reference

docs » examples

nodeapi_example.install File Reference

Go to the source code of this file.

Functions

  • nodeapi_example_install ()
    Implementation of hook_install().
  • nodeapi_example_schema ()
    Implementation of hook_schema().
  • nodeapi_example_uninstall ()
    Implementation of hook_uninstall().
  • nodeapi_example_update_1 ()

Function Documentation

nodeapi_example_install ( )

Implementation of hook_install().

Definition at line 8 of file nodeapi_example.install.

References drupal_install_schema().

nodeapi_example_schema ( )

Implementation of hook_schema().

Definition at line 22 of file nodeapi_example.install.

nodeapi_example_uninstall ( )

Implementation of hook_uninstall().

Definition at line 15 of file nodeapi_example.install.

References drupal_uninstall_schema().

nodeapi_example_update_1 ( )

Definition at line 34 of file nodeapi_example.install.

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/nodeapi_example.module File Reference

docs » examples

nodeapi_example.module File Reference

Detailed Description

This is an example outlining how a module can be used to extend existing content types.

We will add the ability for each node to have a "rating," which will be a number from one to five.

Definition in file nodeapi_example.module.

Go to the source code of this file.

Functions

  • nodeapi_example_form_alter (&$form, $form_state, $form_id)
    Implementation of hook_form_alter().
  • nodeapi_example_nodeapi (&$node, $op, $teaser, $page)
    Implementation of hook_nodeapi().
  • nodeapi_example_theme ()
    Implementation of hook_theme().
  • theme_nodeapi_example_rating ($rating)
    A custom theme function.

Function Documentation

nodeapi_example_form_alter | ( | &$ | form,
 |  | $ | form_state,
 |  | $ | form_id
 | ) |  |

Implementation of hook_form_alter().

By implementing this hook, we're able to modify any form. We'll only make changes to two types: a node's content type configuration and edit forms.

We need to have a way for administrators to indicate which content types should have our rating field added. This is done by inserting a checkbox in the node's content type configuration page.

Definition at line 23 of file nodeapi_example.module.

References t(), and variable_get().

nodeapi_example_nodeapi | ( | &$ | node,
 |  | $ | op,
 |  | $ | teaser,
 |  | $ | page
 | ) |  |

Implementation of hook_nodeapi().

We will implement several node API operations here. This hook allows us to act on all major node operations, so we can manage our additional data appropriately.

Definition at line 61 of file nodeapi_example.module.

References $op, db_query(), db_result(), form_set_error(), nid, t(), theme(), and variable_get().

nodeapi_example_theme ( )

Implementation of hook_theme().

This lets us tell Drupal about our theme functions and their arguments.

Definition at line 129 of file nodeapi_example.module.

theme_nodeapi_example_rating ( $ rating )

A custom theme function.

By using this function to format our rating, themes can override this presentation if they wish; for example, they could provide a star graphic for the rating. We also wrap the default presentation in a CSS class that is prefixed by the module name. This way, style sheets can modify the output without requiring theme code.

Definition at line 145 of file nodeapi_example.module.

References $output, and t().

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/page_example.module File Reference

docs » examples

page_example.module File Reference

Detailed Description

This is an example outlining how a module can be used to display a custom page at a given URL.

Definition in file page_example.module.

Go to the source code of this file.

Functions

  • page_example_baz ($alice, $bob)
    A more complex page callback that takes arguments.
  • page_example_foo ()
    A simple page callback.
  • page_example_help ($path, $arg)
    Implementation of hook_help().
  • page_example_menu ()
    Implementation of hook_menu().
  • page_example_perm ()
    Implementation of hook_perm().

Function Documentation

page_example_baz | ( | $ | alice,
 |  | $ | bob
 | ) |  |

A more complex page callback that takes arguments.

The arguments are passed in from the page URL. The in our hook_menu implementation we instructed the menu system to extract the last two parameters of the path and pass them to this function as arguments.

Definition at line 116 of file page_example.module.

References drupal_access_denied(), t(), and theme().

page_example_foo ( )

A simple page callback.

Page callbacks are required to return the entire page. The content is then usually output via a call to theme('page'), where the theme system will then surround the content in the appropriate blocks, navigation, and styling.

If you do not want to use the theme system (for example for outputting an image or XML), you should print the content yourself and not return anything.

Definition at line 105 of file page_example.module.

References t().

page_example_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Throughout Drupal, hook_help() is used to display help text at the top of pages. Some other parts of Drupal pages get explanatory text from these hooks as well. We use it here to illustrate how to add help text to the pages your module defines.

Definition at line 18 of file page_example.module.

References t().

page_example_menu ( )

Implementation of hook_menu().

You must implement hook_menu() to emit items to place in the main menu. This is a required step for modules wishing to display their own pages, because the process of creating the links also tells Drupal what callback function to use for a given URL. The menu items returned here provide this information to the menu system.

With the below menu definitions, URLs will be interpreted as follows:

If the user accesses http://example.com/?q=foo, then the menu system will first look for a menu item with that path. In this case it will find a match, and execute page_example_foo().

If the user accesses http://example.com/?q=bar, no match will be found, and a 404 page will be displayed.

If the user accesses http://example.com/?q=bar/baz, the menu system will find a match and execute page_example_baz().

If the user accesses http://example.com/?q=bar/baz/1/2, the menu system will first look for bar/baz/1/2. Not finding a match, it will look for bar/baz/1/%. Again not finding a match, it will look for bar/baz//2. Yet again not finding a match, it will look for bar/baz//%. This time it finds a match, and so will execute page_example_baz(1, 2). Note the parameters being passed; this is a very useful technique.

Definition at line 66 of file page_example.module.

References $items.

page_example_perm ( )

Implementation of hook_perm().

Since the access to our new custom pages will be granted based on special permissions, we need to define what those permissions are here. This ensures that they are available to enable on the user role administration pages.

Definition at line 34 of file page_example.module.

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/xmlrpc_example.module File Reference

docs » examples

xmlrpc_example.module File Reference

Detailed Description

This is an example of how to implement XML-RPC callbacks by implementing a validation suite.

Information on the test in this suite can be found at: http://www.xmlrpc.com/validator1Docs

Definition in file xmlrpc_example.module.

Go to the source code of this file.

Functions

  • xmlrpc_example_arrayOfStructsTest ($array)
  • xmlrpc_example_countTheEntities ($string)
  • xmlrpc_example_easyStructTest ($array)
  • xmlrpc_example_echoStructTest ($array)
  • xmlrpc_example_manyTypesTest ($args)
  • xmlrpc_example_moderateSizeArrayCheck ($array)
  • xmlrpc_example_nestedStructTest ($array)
  • xmlrpc_example_simpleStructReturnTest ($number)
  • xmlrpc_example_xmlrpc ()
    Implementation of hook_xmlrpc().

Function Documentation

xmlrpc_example_arrayOfStructsTest ( $ array )

Definition at line 32 of file xmlrpc_example.module.

xmlrpc_example_countTheEntities ( $ string )

Definition at line 40 of file xmlrpc_example.module.

xmlrpc_example_easyStructTest ( $ array )

Definition at line 50 of file xmlrpc_example.module.

xmlrpc_example_echoStructTest ( $ array )

Definition at line 54 of file xmlrpc_example.module.

xmlrpc_example_manyTypesTest ( $ args )

Definition at line 58 of file xmlrpc_example.module.

References xmlrpc_base64(), and xmlrpc_date().

xmlrpc_example_moderateSizeArrayCheck ( $ array )

Definition at line 63 of file xmlrpc_example.module.

xmlrpc_example_nestedStructTest ( $ array )

Definition at line 67 of file xmlrpc_example.module.

xmlrpc_example_simpleStructReturnTest ( $ number )

Definition at line 71 of file xmlrpc_example.module.

xmlrpc_example_xmlrpc ( )

Implementation of hook_xmlrpc().

This function provides Drupal with an array to map XML-RPC callbacks to the functions implemented by this module.

Definition at line 19 of file xmlrpc_example.module.

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/hooks/core.php File Reference

docs » hooks

core.php File Reference

Detailed Description

These are the hooks that are invoked by the Drupal core.

Core hooks are typically called in all modules at once using module_invoke_all().

Definition in file core.php.

Go to the source code of this file.

Functions

  • custom_url_rewrite_inbound (&$result, $path, $path_language)
    custom_url_rewrite_inbound is not a hook, it's a function you can add to settings.php to alter incoming requests so they map to a Drupal path.
  • custom_url_rewrite_outbound (&$path, &$options, $original_path)
    custom_url_rewrite_outbound is not a hook, it's a function you can add to settings.php to alter all links generated by Drupal.
  • hook_block ($op= 'list', $delta=0, $edit=array())
    Declare a block or set of blocks.
  • hook_boot ()
    Perform setup tasks.
  • hook_comment ($a1, $op)
    Act on comments.
  • hook_cron ()
    Perform periodic actions.
  • hook_db_rewrite_sql ($query, $primary_table, $primary_field, $args)
    Rewrite database queries, usually for access control.
  • hook_elements ()
    Allows modules to declare their own form element types and specify their default values.
  • hook_exit ($destination=NULL)
    Perform cleanup tasks.
  • hook_file_download ($file)
    Allow file downloads.
  • hook_filter ($op, $delta=0, $format=-1, $text= '')
    Define content filters.
  • hook_filter_tips ($delta, $format, $long=false)
    Provide tips for using filters.
  • hook_footer ($main=0)
    Insert closing HTML.
  • hook_form_alter (&$form, $form_state, $form_id)
    Perform alterations before a form is rendered.
  • hook_forms ()
    Map form_ids to builder functions.
  • hook_help ($path, $arg)
    Provide online user help.
  • hook_init ()
    Perform setup tasks.
  • hook_link ($type, $object, $teaser=FALSE)
    Define internal Drupal links.
  • hook_link_alter (&$links, $node)
    Perform alterations before links on a node are rendered.
  • hook_mail ($key, &$message, $params)
    Prepare a message based on parameters.
  • hook_mail_alter (&$message)
    Alter any aspect of the emails sent by Drupal.
  • hook_menu ()
    Define menu items and page callbacks.
  • hook_menu_alter (&$callbacks)
    Alter the data being saved to the {menu_router} table after hook_menu is invoked.
  • hook_menu_link_alter (&$item, $menu)
    Alter the data being saved to the {menu_links} table by menu_link_save().
  • hook_node_access_records ($node)
    Set permissions for a node to be written to the database.
  • hook_node_grants ($account, $op)
    Inform the node access system what permissions the user has.
  • hook_node_operations ()
    Add mass node operations.
  • hook_nodeapi (&$node, $op, $a3=NULL, $a4=NULL)
    Act on nodes defined by other modules.
  • hook_perm ()
    Define user permissions.
  • hook_ping ($name= '', $url= '')
    Ping another server.
  • hook_profile_alter (&$fields, $account)
    Perform alterations profile items before they are rendered.
  • hook_search ($op= 'search', $keys=null)
    Define a custom search routine.
  • hook_search_preprocess ($text)
    Preprocess text for the search index.
  • hook_taxonomy ($op, $type, $array=NULL)
    Act on taxonomy changes.
  • hook_theme ()
    Register a module (or theme's) theme implementations.
  • hook_translated_menu_link_alter (&$item, $map)
    Alter a menu link after it's translated, but before it's rendered.
  • hook_update_index ()
    Update Drupal's full-text index for this module.
  • hook_user ($op, &$edit, &$account, $category=NULL)
    Act on user account actions.
  • hook_user_operations ()
    Add mass user operations.
  • hook_watchdog ($log_msg)
    Log an event message.
  • hook_xmlrpc ()
    Register XML-RPC callbacks.
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/hooks/install.php File Reference

docs » hooks

install.php File Reference

Detailed Description

Documentation for the installation and update system.

The update system is used by modules to provide database updates which are run with update.php.

Implementations of these hooks should be placed in a mymodule.install file in the same directory as mymodule.module.

Definition in file install.php.

Go to the source code of this file.

Functions

  • hook_disable ()
    Perform necessary actions before module is disabled.
  • hook_enable ()
    Perform necessary actions after module is enabled.
  • hook_install ()
    Install the current version of the database schema, and any other setup tasks.
  • hook_requirements ($phase)
    Check installation requirements and do status reporting.
  • hook_schema ()
    Define the current version of the database schema.
  • hook_uninstall ()
    Remove any tables or variables that the module sets.
  • hook_update_N ()
    Perform a single update.
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/hooks/node.php File Reference

docs » hooks

node.php File Reference

Detailed Description

These hooks are defined by node modules, modules that define a new kind of node.

If you don't need to make a new node type but rather extend the existing ones, you should instead investigate using hook_nodeapi().

Node hooks are typically called by node.module using node_invoke().

Definition in file node.php.

Go to the source code of this file.

Functions

  • hook_access ($op, $node, $account)
    Define access restrictions.
  • hook_delete (&$node)
    Respond to node deletion.
  • hook_form (&$node, &$param)
    Display a node editing form.
  • hook_insert ($node)
    Respond to node insertion.
  • hook_load ($node)
    Load node-type-specific information.
  • hook_node_info ()
    Define module-provided node types.
  • hook_node_type ($op, $info)
    Act on node type changes.
  • hook_prepare (&$node)
    This is a hook used by node modules.
  • hook_submit (&$node)
    This is a hook used by node modules.
  • hook_update ($node)
    Respond to node updating.
  • hook_validate ($node)
    Verify a node editing form.
  • hook_view ($node, $teaser=FALSE, $page=FALSE)
    Display a node.
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/actions.inc File Reference

includes

actions.inc File Reference

Detailed Description

This is the actions engine for executing stored actions.

Definition in file actions.inc.

Go to the source code of this file.

Functions

  • actions_actions_map ($actions)
    Create an associative array keyed by md5 hashes of function names.
  • actions_delete ($aid)
    Delete a single action from the database.
  • actions_do ($action_ids, &$object, $context=NULL, $a1=NULL, $a2=NULL)
    Perform a given list of actions by executing their callback functions.
  • actions_function_lookup ($hash)
    Given an md5 hash of a function name, return the function name.
  • actions_get_all_actions ()
    Retrieve all action instances from the database.
  • actions_list ($reset=FALSE)
    Discover all action functions by invoking hook_action_info().
  • actions_load ($aid)
    Retrieve a single action from the database.
  • actions_save ($function, $type, $params, $desc, $aid=NULL)
    Save an action and its associated user-supplied parameter values to the database.
  • actions_synchronize ($actions_in_code=array(), $delete_orphans=FALSE)
    Synchronize actions that are provided by modules.

Function Documentation

actions_actions_map ( $ actions )

Create an associative array keyed by md5 hashes of function names.

Hashes are used to prevent actual function names from going out into HTML forms and coming back.

Parameters:
$actions An associative array with function names as keys and associative arrays with keys 'description', 'type', etc. as values. Generally the output of actions_list() or actions_get_all_actions() is given as input to this function.
Returns:
An associative array keyed on md5 hash of function name. The value of each key is an associative array of function, description, and type for the action.

Definition at line 209 of file actions.inc.

Referenced by system_actions_configure(), system_actions_manage(), trigger_assign_form(), and trigger_options().

actions_delete ( $ aid )

Delete a single action from the database.

Parameters:
$aid integer The ID of the action to delete.

Definition at line 362 of file actions.inc.

References db_query(), and module_invoke_all().

Referenced by actions_synchronize(), and system_actions_delete_form_submit().

actions_do | ( | $ | action_ids,
 |  | &$ | object,
 |  | $ | context = NULL,
 |  | $ | a1 = NULL,
 |  | $ | a2 = NULL
 | ) |  |

Perform a given list of actions by executing their callback functions.

Given the IDs of actions to perform, find out what the callbacks for the actions are by querying the database. Then call each callback using the function call $function($object, $context, $a1, $2) where $function is the name of a function written in compliance with the action specification; that is, foo($object, $context).

Parameters:
$action_ids | The ID of the action to perform. Can be a single action ID or an array of IDs. IDs of instances will be numeric; IDs of singletons will be function names.
$object | Parameter that will be passed along to the callback. Typically the object that the action will act on; a node, user or comment object. If the action does not act on an object, pass a dummy object. This is necessary to support PHP 4 object referencing.
$context | Parameter that will be passed along to the callback. $context is a keyed array containing extra information about what is currently happening at the time of the call. Typically $context['hook'] and $context['op'] will tell which hook-op combination resulted in this call to actions_do().
$a1 | Parameter that will be passed along to the callback.
$a2 | Parameter that will be passed along to the callback.
Returns:
An associative array containing the result of the function that performs the action, keyed on action ID.

Definition at line 42 of file actions.inc.

References $result, actions_list(), db_fetch_object(), db_query(), variable_get(), and watchdog().

Referenced by trigger_comment(), trigger_cron(), trigger_nodeapi(), trigger_taxonomy(), and trigger_user().

actions_function_lookup ( $ hash )

Given an md5 hash of a function name, return the function name.

Faster than actions_actions_map() when you only need the function name.

Parameters:
$hash MD5 hash of a function name
Returns:
Function name

Definition at line 232 of file actions.inc.

References actions_list(), db_query(), and db_result().

Referenced by system_actions_configure_submit(), system_actions_configure_validate(), trigger_assign_form_submit(), trigger_assign_form_validate(), trigger_unassign(), and trigger_unassign_submit().

actions_get_all_actions ( )

Retrieve all action instances from the database.

Compare with actions_list() which gathers actions by invoking hook_action_info(). The two are synchronized by visiting /admin/build/actions (when actions.module is enabled) which runs actions_synchronize().

Returns:
Associative array keyed by action ID. Each value is an associative array with keys 'callback', 'description', 'type' and 'configurable'.

Definition at line 178 of file actions.inc.

References $result, db_fetch_object(), and db_query().

Referenced by trigger_assign_form(), trigger_options(), trigger_unassign(), and trigger_unassign_submit().

actions_list ( $ reset = FALSE )

Discover all action functions by invoking hook_action_info().

mymodule_action_info() { return array( 'mymodule_functiondescription_action' => array( 'type' => 'node', 'description' => t('Save node'), 'configurable' => FALSE, 'hooks' => array( 'nodeapi' => array('delete', 'insert', 'update', 'view'), 'comment' => array('delete', 'insert', 'update', 'view'), ) ) ); }

The description is used in presenting possible actions to the user for configuration. The type is used to present these actions in a logical grouping and to denote context. Some types are 'node', 'user', 'comment', and 'system'. If an action is configurable it will provide form, validation and submission functions. The hooks the action supports are declared in the 'hooks' array.

Parameters:
$reset Reset the action info static cache.
Returns:
An associative array keyed on function name. The value of each key is an array containing information about the action, such as type of action and description of the action, e.g.,
   $actions['node_publish_action'] = array(
     'type' => 'node',
     'description' => t('Publish post'),
     'configurable' => FALSE,
     'hooks' => array(
       'nodeapi' => array('presave', 'insert', 'update', 'view'),
       'comment' => array('delete', 'insert', 'update', 'view'),
     ),
   );

Definition at line 154 of file actions.inc.

References drupal_alter(), and module_invoke_all().

Referenced by actions_do(), actions_function_lookup(), actions_synchronize(), system_actions_configure(), system_actions_manage(), system_actions_remove_orphans(), trigger_assign_form(), trigger_assign_form_submit(), and trigger_install().

actions_load ( $ aid )

Retrieve a single action from the database.

Parameters:
$aid integer The ID of the action to retrieve.
Returns:
The appropriate action row from the database as an object.

Definition at line 352 of file actions.inc.

References db_fetch_object(), and db_query().

Referenced by system_actions_delete_form_submit().

actions_save | ( | $ | function,
 |  | $ | type,
 |  | $ | params,
 |  | $ | desc,
 |  | $ | aid = NULL
 | ) |  |

Save an action and its associated user-supplied parameter values to the database.

Parameters:
$function | The name of the function to be called when this action is performed.
$params | An associative array with parameter names as keys and parameter values as values.
$desc | A user-supplied description of this particular action, e.g., 'Send e-mail to Jim'.
$aid | The ID of this action. If omitted, a new action is created.
Returns:
The ID of the action.

Definition at line 325 of file actions.inc.

References $type, db_last_insert_id(), db_query(), and watchdog().

Referenced by system_actions_configure_submit().

actions_synchronize | ( | $ | actions_in_code = array(),
 |  | $ | delete_orphans = FALSE
 | ) |  |

Synchronize actions that are provided by modules.

They are synchronized with actions that are stored in the actions table. This is necessary so that actions that do not require configuration can receive action IDs. This is not necessarily the best approach, but it is the most straightforward.

Definition at line 253 of file actions.inc.

References $result, $results, actions_delete(), actions_list(), db_fetch_object(), db_query(), filter_xss_admin(), format_plural(), l(), t(), and watchdog().

Referenced by install_tasks(), system_actions_manage(), system_actions_remove_orphans(), system_modules_submit(), and trigger_install().

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/batch.inc File Reference

includes

batch.inc File Reference

Detailed Description

Batch processing API for processes to run in multiple HTTP requests.

Definition in file batch.inc.

Go to the source code of this file.

Functions

  • & _batch_current_set ()
    Retrieve the batch set being currently processed.
  • _batch_do ()
    Do one pass of execution and inform back the browser about progression (used for JavaScript-mode only).
  • _batch_finished ()
    End the batch processing: Call the 'finished' callbacks to allow custom handling of results, and resolve page redirection.
  • _batch_next_set ()
    Move execution to the next batch set if any, executing the stored form _submit handlers along the way (thus possibly inserting additional batch sets).
  • _batch_page ()
    State-based dispatcher for the batch processing page.
  • _batch_process ()
    Advance batch processing for 1 second (or process the whole batch if it was not set for progressive execution - e.g forms submitted by drupal_execute).
  • _batch_progress_page_js ()
    Batch processing page with JavaScript support.
  • _batch_progress_page_nojs ()
    Batch processing page without JavaScript support.
  • _batch_shutdown ()
    Shutdown function: store the batch data for next request, or clear the table if the batch is finished.
  • _batch_start ()
    Initiate the batch processing.

Function Documentation

& _batch_current_set ( )

Retrieve the batch set being currently processed.

Definition at line 262 of file batch.inc.

References batch_get().

Referenced by _batch_next_set(), _batch_process(), _batch_progress_page_js(), and _batch_progress_page_nojs().

_batch_do ( )

Do one pass of execution and inform back the browser about progression (used for JavaScript-mode only).

Definition at line 98 of file batch.inc.

References $percentage, _batch_process(), drupal_json(), drupal_set_message(), drupal_set_title(), and t().

Referenced by _batch_page().

_batch_finished ( )

End the batch processing: Call the 'finished' callbacks to allow custom handling of results, and resolve page redirection.

Definition at line 291 of file batch.inc.

References batch_get(), db_query(), drupal_goto(), and drupal_redirect_form().

Referenced by _batch_page(), and _batch_process().

_batch_next_set ( )

Move execution to the next batch set if any, executing the stored form _submit handlers along the way (thus possibly inserting additional batch sets).

Definition at line 272 of file batch.inc.

References _batch_current_set(), and batch_get().

Referenced by _batch_process().

_batch_page ( )

State-based dispatcher for the batch processing page.

Definition at line 12 of file batch.inc.

References $op, $output, _batch_do(), _batch_finished(), _batch_progress_page_nojs(), _batch_start(), batch_get(), db_query(), db_result(), and drupal_get_token().

Referenced by install_tasks(), and system_batch_page().

_batch_process ( )

Advance batch processing for 1 second (or process the whole batch if it was not set for progressive execution - e.g forms submitted by drupal_execute).

Definition at line 166 of file batch.inc.

References $percentage, _batch_current_set(), _batch_finished(), _batch_next_set(), batch_get(), timer_read(), and timer_start().

Referenced by _batch_do(), _batch_progress_page_nojs(), and batch_process().

_batch_progress_page_js ( )

Batch processing page with JavaScript support.

Definition at line 70 of file batch.inc.

References $output, $url, _batch_current_set(), batch_get(), drupal_add_js(), drupal_set_title(), and url().

Referenced by _batch_start().

_batch_progress_page_nojs ( )

Batch processing page without JavaScript support.

Definition at line 115 of file batch.inc.

References $output, $percentage, $url, _batch_current_set(), _batch_process(), batch_get(), drupal_set_html_head(), drupal_set_title(), theme(), and url().

Referenced by _batch_page(), and _batch_start().

_batch_shutdown ( )

Shutdown function: store the batch data for next request, or clear the table if the batch is finished.

Definition at line 351 of file batch.inc.

References batch_get(), and db_query().

_batch_start ( )

Initiate the batch processing.

Definition at line 54 of file batch.inc.

References _batch_progress_page_js(), and _batch_progress_page_nojs().

Referenced by _batch_page().

Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/bootstrap.inc File Reference

includes

bootstrap.inc File Reference

Detailed Description

Functions that need to be loaded on every Drupal request.

Definition in file bootstrap.inc.

Go to the source code of this file.

Enumerations

  • enum CACHE_AGGRESSIVE
    Indicates that page caching is using "aggressive" mode. More...
  • enum CACHE_DISABLED
    Indicates that page caching is disabled. More...
  • enum CACHE_NORMAL
    Indicates that page caching is enabled, using "normal" mode. More...
  • enum CACHE_PERMANENT
    Indicates that the item should never be removed unless explicitly told to using cache_clear_all() with a cache ID. More...
  • enum CACHE_TEMPORARY
    Indicates that the item should be removed at the next general cache wipe. More...
  • enum DRUPAL_ANONYMOUS_RID
    Role ID for anonymous users; should match what's in the "role" table. More...
  • enum DRUPAL_AUTHENTICATED_RID
    Role ID for authenticated users; should match what's in the "role" table. More...
  • enum DRUPAL_BOOTSTRAP_ACCESS
    Fourth bootstrap phase: identify and reject banned hosts. More...
  • enum DRUPAL_BOOTSTRAP_CONFIGURATION
    First bootstrap phase: initialize configuration. More...
  • enum DRUPAL_BOOTSTRAP_DATABASE
    Third bootstrap phase: initialize database layer. More...
  • enum DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE
    Second bootstrap phase: try to call a non-database cache fetch routine. More...
  • enum DRUPAL_BOOTSTRAP_FULL
    Final bootstrap phase: Drupal is fully loaded; validate and fix input data. More...
  • enum DRUPAL_BOOTSTRAP_LANGUAGE
    Seventh bootstrap phase: find out language of the page. More...
  • enum DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE
    Sixth bootstrap phase: load bootstrap.inc and module.inc, start the variable system and try to serve a page from the cache. More...
  • enum DRUPAL_BOOTSTRAP_PATH
    Eighth bootstrap phase: set $_GET['q'] to Drupal path of request. More...
  • enum DRUPAL_BOOTSTRAP_SESSION
    Fifth bootstrap phase: initialize session handling. More...
  • enum LANGUAGE_NEGOTIATION_DOMAIN
    Domain based negotiation with fallback to default language if no language identified by domain. More...
  • enum LANGUAGE_NEGOTIATION_NONE
    No language negotiation. More...
  • enum LANGUAGE_NEGOTIATION_PATH
    Path based negotiation with fallback to user preferences and browser language detection if no defined path prefix identified. More...
  • enum LANGUAGE_NEGOTIATION_PATH_DEFAULT
    Path based negotiation with fallback to default language if no defined path prefix identified. More...
  • enum WATCHDOG_ALERT
  • enum WATCHDOG_CRITICAL
  • enum WATCHDOG_DEBUG
  • enum WATCHDOG_EMERG
    Severity levels, as defined in RFC 3164 http://www.faqs.org/rfcs/rfc3164.html. More...
  • enum WATCHDOG_ERROR
  • enum WATCHDOG_INFO
  • enum WATCHDOG_NOTICE
  • enum WATCHDOG_WARNING

Functions

  • _drupal_bootstrap ($phase)
  • bootstrap_hooks ()
    Define the critical hooks that force modules to always be loaded.
  • bootstrap_invoke_all ($hook)
    Call all init or exit hooks without including all modules.
  • check_plain ($text)
    Encode special characters in a plain-text string for display as HTML.
  • conf_init ()
    Loads the configuration and sets the base URL, cookie domain, and session name correctly.
  • conf_path ($require_settings=TRUE, $reset=FALSE)
    Find the appropriate configuration directory.
  • drupal_anonymous_user ($session= '')
    Generates a default anonymous $user object.
  • drupal_bootstrap ($phase)
    A string describing a phase of Drupal to load.
  • drupal_get_filename ($type, $name, $filename=NULL)
    Returns and optionally sets the filename for a system item (module, theme, etc.
  • drupal_get_messages ($type=NULL, $clear_queue=TRUE)
    Return all messages that have been set.
  • drupal_init_language ()
    Choose a language for the current page, based on site and user preferences.
  • drupal_is_denied ($type, $mask)
    Perform an access check for a given mask and rule type.
  • drupal_load ($type, $name)
    Includes a file with the provided type and name.
  • drupal_maintenance_theme ()
    Enables use of the theme system without requiring database access.
  • drupal_page_cache_header ($cache)
    Set HTTP headers in preparation for a cached page response.
  • drupal_page_header ()
    Set HTTP headers in preparation for a page response.
  • drupal_set_message ($message=NULL, $type= 'status', $repeat=TRUE)
    Set a message which reflects the status of the performed operation.
  • drupal_unpack ($obj, $field= 'data')
    Unserializes and appends elements from a serialized string.
  • drupal_unset_globals ()
    Unsets all disallowed global variables.
  • drupal_validate_utf8 ($text)
    Checks whether a string is valid UTF-8.
  • get_t ()
    Return the name of the localisation function.
  • ip_address ()
    If Drupal is behind a reverse proxy, we use the X-Forwarded-For header instead of $_SERVER['REMOTE_ADDR'], which would be the IP address of the proxy server, and not the client's.
  • language_default ($property=NULL)
    Default language used on the site.
  • language_list ($field= 'language', $reset=FALSE)
    Get a list of languages set up indexed by the specified key.
  • page_get_cache ($status_only=FALSE)
    Retrieve the current page from the cache.
  • referer_uri ()
    Return the URI of the referring page.
  • request_uri ()
    Since $_SERVER['REQUEST_URI'] is only available on Apache, we generate an equivalent using other environment variables.
  • timer_read ($name)
    Read the current timer value without stopping the timer.
  • timer_start ($name)
    Start the timer with the specified name.
  • timer_stop ($name)
    Stop the timer with the specified name.
  • variable_del ($name)
    Unset a persistent variable.
  • variable_get ($name, $default)
    Return a persistent variable.
  • variable_init ($conf=array())
    Load the persistent variable table.
  • variable_set ($name, $value)
    Set a persistent variable.
  • watchdog ($type, $message, $variables=array(), $severity=WATCHDOG_NOTICE, $link=NULL)
    Log a system message.

Enumeration Type Documentation

enum CACHE_AGGRESSIVE

Indicates that page caching is using "aggressive" mode.

This bypasses loading any modules for additional speed, which may break functionality in modules that expect to be run on each page load.

Definition at line 35 of file bootstrap.inc.

enum CACHE_DISABLED

Indicates that page caching is disabled.

Definition at line 23 of file bootstrap.inc.

enum CACHE_NORMAL

Indicates that page caching is enabled, using "normal" mode.

Definition at line 28 of file bootstrap.inc.

enum CACHE_PERMANENT

Indicates that the item should never be removed unless explicitly told to using cache_clear_all() with a cache ID.

Definition at line 13 of file bootstrap.inc.

enum CACHE_TEMPORARY

Indicates that the item should be removed at the next general cache wipe.

Definition at line 18 of file bootstrap.inc.

enum DRUPAL_ANONYMOUS_RID

Role ID for anonymous users; should match what's in the "role" table.

Definition at line 103 of file bootstrap.inc.

enum DRUPAL_AUTHENTICATED_RID

Role ID for authenticated users; should match what's in the "role" table.

Definition at line 108 of file bootstrap.inc.

enum DRUPAL_BOOTSTRAP_ACCESS

Fourth bootstrap phase: identify and reject banned hosts.

Definition at line 71 of file bootstrap.inc.

enum DRUPAL_BOOTSTRAP_CONFIGURATION

First bootstrap phase: initialize configuration.

Definition at line 55 of file bootstrap.inc.

enum DRUPAL_BOOTSTRAP_DATABASE

Third bootstrap phase: initialize database layer.

Definition at line 66 of file bootstrap.inc.

enum DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE

Second bootstrap phase: try to call a non-database cache fetch routine.

Definition at line 61 of file bootstrap.inc.

enum DRUPAL_BOOTSTRAP_FULL

Final bootstrap phase: Drupal is fully loaded; validate and fix input data.

Definition at line 98 of file bootstrap.inc.

enum DRUPAL_BOOTSTRAP_LANGUAGE

Seventh bootstrap phase: find out language of the page.

Definition at line 87 of file bootstrap.inc.

enum DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE

Sixth bootstrap phase: load bootstrap.inc and module.inc, start the variable system and try to serve a page from the cache.

Definition at line 82 of file bootstrap.inc.

enum DRUPAL_BOOTSTRAP_PATH

Eighth bootstrap phase: set $_GET['q'] to Drupal path of request.

Definition at line 92 of file bootstrap.inc.

enum DRUPAL_BOOTSTRAP_SESSION

Fifth bootstrap phase: initialize session handling.

Definition at line 76 of file bootstrap.inc.

enum LANGUAGE_NEGOTIATION_DOMAIN

Domain based negotiation with fallback to default language if no language identified by domain.

Definition at line 132 of file bootstrap.inc.

enum LANGUAGE_NEGOTIATION_NONE

No language negotiation.

The default language is used.

Definition at line 113 of file bootstrap.inc.

enum LANGUAGE_NEGOTIATION_PATH

Path based negotiation with fallback to user preferences and browser language detection if no defined path prefix identified.

Definition at line 126 of file bootstrap.inc.

enum LANGUAGE_NEGOTIATION_PATH_DEFAULT

Path based negotiation with fallback to default language if no defined path prefix identified.

Definition at line 119 of file bootstrap.inc.

enum WATCHDOG_ALERT

Definition at line 44 of file bootstrap.inc.

enum WATCHDOG_CRITICAL

Definition at line 45 of file bootstrap.inc.

enum WATCHDOG_DEBUG

Definition at line 50 of file bootstrap.inc.

enum WATCHDOG_EMERG

Severity levels, as defined in RFC 3164 http://www.faqs.org/rfcs/rfc3164.html.

See also:
watchdog()

watchdog_severity_levels()

Definition at line 43 of file bootstrap.inc.

enum WATCHDOG_ERROR

Definition at line 46 of file bootstrap.inc.

enum WATCHDOG_INFO

Definition at line 49 of file bootstrap.inc.

enum WATCHDOG_NOTICE

Definition at line 48 of file bootstrap.inc.

enum WATCHDOG_WARNING

Definition at line 47 of file bootstrap.inc.

Function Documentation

_drupal_bootstrap ( $ phase )

Definition at line 932 of file bootstrap.inc.

References $conf, _drupal_bootstrap_full(), bootstrap_invoke_all(), check_plain(), conf_init(), db_set_active(), drupal_init_language(), drupal_init_path(), drupal_is_denied(), drupal_page_cache_header(), drupal_page_header(), drupal_unset_globals(), exit, ip_address(), page_get_cache(), timer_start(), variable_get(), and variable_init().

Referenced by drupal_bootstrap().

bootstrap_hooks ( )

Define the critical hooks that force modules to always be loaded.

Definition at line 643 of file bootstrap.inc.

Referenced by module_rebuild_cache().

bootstrap_invoke_all ( $ hook )

Call all init or exit hooks without including all modules.

Parameters:
$hook The name of the bootstrap hook we wish to invoke.

Definition at line 529 of file bootstrap.inc.

References drupal_load(), module_invoke(), and module_list().

Referenced by _drupal_bootstrap().

check_plain ( $ text )

Encode special characters in a plain-text string for display as HTML.

Uses drupal_validate_utf8 to prevent cross site scripting attacks on Internet Explorer 6.

Definition at line 681 of file bootstrap.inc.

References drupal_validate_utf8().

Referenced by _db_query(), _drupal_bootstrap(), _filter_html(), _filter_url_parse_full_links(), _filter_url_parse_partial_links(), _locale_translate_seek(), _node_index_node(), _system_sql(), _upload_form(), aggregator_block(), aggregator_categorize_items(), aggregator_form_feed(), aggregator_page_source(), aggregator_refresh(), block_admin_display_form(), block_list(), block_menu(), block_user(), blog_form(), book_admin_edit(), book_outline(), chameleon_node(), comment_form_add_preview(), comment_multiple_delete_confirm(), comment_nodeapi(), conf_init(), contact_mail_user(), contact_user_page(), db_add_field(), dblog_event(), drupal_access_denied(), drupal_attributes(), drupal_get_title(), drupal_not_found(), expand_radios(), file_check_directory(), filter_filter_tips(), filter_xss_bad_protocol(), form_select_options(), format_rss_channel(), format_rss_item(), format_xml_elements(), forum_form(), hook_form(), l(), locale_languages_overview_form(), locale_translate_edit_form(), menu_block(), menu_path_is_external(), node_admin_nodes(), node_body_field(), node_content_form(), node_example_form(), node_multiple_delete_confirm(), node_overview_types(), node_page_view(), node_perm(), node_search(), openid_user_identities(), path_admin_edit(), path_admin_overview(), poll_form(), poll_results(), poll_teaser(), poll_view_voting(), poll_votes(), profile_admin_overview(), profile_admin_settings_autocomplete(), profile_autocomplete(), profile_block(), profile_browse(), profile_form_profile(), profile_view_field(), profile_view_profile(), st(), statistics_access_log(), statistics_node_tracker(), statistics_user_tracker(), system_actions_delete_form_submit(), system_message_action(), system_theme_settings(), t(), taxonomy_autocomplete(), taxonomy_form(), taxonomy_overview_vocabularies(), taxonomy_rss_item(), taxonomy_term_page(), template_preprocess_aggregator_item(), template_preprocess_aggregator_summary_item(), template_preprocess_aggregator_summary_items(), template_preprocess_book_export_html(), template_preprocess_book_navigation(), template_preprocess_book_node_export_html(), template_preprocess_forum_list(), template_preprocess_forum_topic_list(), template_preprocess_forum_topic_navigation(), template_preprocess_forums(), template_preprocess_node(), template_preprocess_poll_bar(), template_preprocess_poll_results(), template_preprocess_poll_vote(), template_preprocess_profile_block(), template_preprocess_search_result(), template_preprocess_user_profile_category(), theme_aggregator_block_item(), theme_aggregator_page_opml(), theme_button(), theme_filter_admin_overview(), theme_hidden(), theme_image(), theme_image_button(), theme_links(), theme_locale_languages_overview_form(), theme_multipage_form_example(), theme_multipage_form_example_node_form(), theme_node_example_order_info(), theme_placeholder(), theme_radio(), theme_textarea(), theme_textfield(), theme_update_report(), theme_username(), tracker_page(), trigger_unassign_submit(), update_do_one(), update_sql(), url(), user_autocomplete(), user_block(), user_block_user_action(), user_edit(), user_login(), user_multiple_delete_confirm(), user_view(), and xmlrpc_value_get_xml().

conf_init ( )

Loads the configuration and sets the base URL, cookie domain, and session name correctly.

Definition at line 273 of file bootstrap.inc.

References $base_path, $base_root, $base_url, $conf, $cookie_domain, $db_prefix, $db_url, $installed_profile, $update_free_access, check_plain(), and conf_path().

Referenced by _drupal_bootstrap().

conf_path | ( | $ | require_settings = TRUE,
 |  | $ | reset = FALSE
 | ) |  |

Find the appropriate configuration directory.

Try finding a matching configuration directory by stripping the website's hostname from left to right and pathname from right to left. The first configuration file found will be used; the remaining will ignored. If no configuration file is found, return a default value '$confdir/default'.

Example for a fictitious site installed at http://www.drupal.org:8080/mysite/test/ the 'settings.php' is searched in the following directories:

1. $confdir/8080.www.drupal.org.mysite.test 2. $confdir/www.drupal.org.mysite.test 3. $confdir/drupal.org.mysite.test 4. $confdir/org.mysite.test

5. $confdir/8080.www.drupal.org.mysite 6. $confdir/www.drupal.org.mysite 7. $confdir/drupal.org.mysite 8. $confdir/org.mysite

9. $confdir/8080.www.drupal.org 10. $confdir/www.drupal.org 11. $confdir/drupal.org 12. $confdir/org

13. $confdir/default

Parameters:
$require_settings | Only configuration directories with an existing settings.php file will be recognized. Defaults to TRUE. During initial installation, this is set to FALSE so that Drupal can detect a matching directory, then create a new settings.php file in it.
reset | Force a full search for matching directories even if one had been found previously.
Returns:
The path of the matching directory.

Definition at line 232 of file bootstrap.inc.

References $conf.

Referenced by conf_init(), drupal_get_filename(), drupal_rewrite_settings(), drupal_system_listing(), file_directory_path(), install_change_settings(), install_check_requirements(), install_tasks(), install_verify_settings(), and system_requirements().

drupal_anonymous_user ( $ session = '' )

Generates a default anonymous $user object.

Returns:
Object - the user object.

Definition at line 891 of file bootstrap.inc.

References $user, and ip_address().

Referenced by comment_form_alter(), sess_read(), and user_logout().

drupal_bootstrap ( $ phase )

A string describing a phase of Drupal to load.

Each phase adds to the previous one, so invoking a later phase automatically runs the earlier phases too. The most important usage is that if you want to access the Drupal database from a script without loading anything else, you can include bootstrap.inc, and call drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE).

Parameters:
$phase A constant. Allowed values are: DRUPAL_BOOTSTRAP_CONFIGURATION: initialize configuration. DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE: try to call a non-database cache fetch routine. DRUPAL_BOOTSTRAP_DATABASE: initialize database layer. DRUPAL_BOOTSTRAP_ACCESS: identify and reject banned hosts. DRUPAL_BOOTSTRAP_SESSION: initialize session handling. DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE: load bootstrap.inc and module.inc, start the variable system and try to serve a page from the cache. DRUPAL_BOOTSTRAP_LANGUAGE: identify the language used on the page. DRUPAL_BOOTSTRAP_PATH: set $_GET['q'] to Drupal path of request. DRUPAL_BOOTSTRAP_FULL: Drupal is fully loaded, validate and fix input data.

Definition at line 922 of file bootstrap.inc.

References _drupal_bootstrap().

Referenced by drupal_install_system(), init_theme(), install_main(), install_tasks(), and statistics_exit().

drupal_get_filename | ( | $ | type,
 |  | $ | name,
 |  | $ | filename = NULL
 | ) |  |

Returns and optionally sets the filename for a system item (module, theme, etc.

). The filename, whether provided, cached, or retrieved from the database, is only returned if the file exists.

This function plays a key role in allowing Drupal's resources (modules and themes) to be located in different places depending on a site's configuration. For example, a module 'foo' may legally be be located in any of these three places:

modules/foo/foo.module sites/all/modules/foo/foo.module sites/example.com/modules/foo/foo.module

Calling drupal_get_filename('module', 'foo') will give you one of the above, depending on where the module is located.

Parameters:
$type | The type of the item (i.e. theme, theme_engine, module).
$name | The name of the item for which the filename is requested.
$filename | The filename of the item if it is to be set explicitly rather than by consulting the database.
Returns:
The filename of the requested item.

Definition at line 370 of file bootstrap.inc.

References $name, $type, conf_path(), db_is_active(), db_query(), and db_result().

Referenced by drupal_get_path(), drupal_install_system(), drupal_load(), module_list(), and system_modules_uninstall_confirm_form().

drupal_get_messages | ( | $ | type = NULL,
 |  | $ | clear_queue = TRUE
 | ) |  |

Return all messages that have been set.

Parameters:
$type | (optional) Only return messages of this type.
$clear_queue | (optional) Set to FALSE if you do not want to clear the messages queue
Returns:
An associative array, the key is the message type, the value an array of messages. If the $type parameter is passed, you get only that type, or an empty array if there are no such messages. If $type is not passed, all message types are returned, or an empty array if none exist.

Definition at line 838 of file bootstrap.inc.

References $messages, $type, and drupal_set_message().

Referenced by theme_status_messages().

drupal_init_language ( )

Choose a language for the current page, based on site and user preferences.

Definition at line 1050 of file bootstrap.inc.

References $language, $user, language_default(), language_initialize(), and variable_get().

Referenced by _drupal_bootstrap(), and install_main().

drupal_is_denied | ( | $ | type,
 |  | $ | mask
 | ) |  |

Perform an access check for a given mask and rule type.

Rules are usually created via admin/user/rules page.

If any allow rule matches, access is allowed. Otherwise, if any deny rule matches, access is denied. If no rule matches, access is allowed.

Parameters:
$type string Type of access to check: Allowed values are:
  • 'host': host name or IP address
  • 'mail': e-mail address
  • 'user': username
$mask string String or mask to test: '_' matches any character, '' matches any number of characters.
Returns:
bool TRUE if access is denied, FALSE if access is allowed.

Definition at line 876 of file bootstrap.inc.

References $type, db_query_range(), and db_result().

Referenced by _drupal_bootstrap(), _user_edit_validate(), user_admin_access_check_submit(), and user_login_name_validate().

drupal_load | ( | $ | type,
 |  | $ | name
 | ) |  |

Includes a file with the provided type and name.

This prevents including a theme, engine, module, etc., more than once.

Parameters:
$type | The type of item to load (i.e. theme, theme_engine, module).
$name | The name of the item to load.
Returns:
TRUE if the item is loaded or has already been loaded.

Definition at line 548 of file bootstrap.inc.

References $name, $type, and drupal_get_filename().

Referenced by _drupal_maintenance_theme(), bootstrap_invoke_all(), comment_update_6002(), drupal_uninstall_module(), forum_uninstall(), hook_boot(), install_main(), module_enable(), and module_load_all().

drupal_maintenance_theme ( )

Enables use of the theme system without requiring database access.

Loads and initializes the theme system for site installs, updates and when the site is in off-line mode. This also applies when the database fails.

See also:
_drupal_maintenance_theme()

Definition at line 1030 of file bootstrap.inc.

References _drupal_maintenance_theme().

Referenced by _db_error_page(), drupal_site_offline(), and install_main().

drupal_page_cache_header ( $ cache )

Set HTTP headers in preparation for a cached page response.

The general approach here is that anonymous users can keep a local cache of the page, but must revalidate it on every request. Then, they are given a '304 Not Modified' response as long as they stay logged out and the page has not been modified.

Definition at line 592 of file bootstrap.inc.

References $header, exit, and variable_get().

Referenced by _drupal_bootstrap().

drupal_page_header ( )

Set HTTP headers in preparation for a page response.

Authenticated users are always given a 'no-cache' header, and will fetch a fresh page on every request. This prevents authenticated users seeing locally cached pages that show them as logged out.

See also:
page_set_cache()

Definition at line 576 of file bootstrap.inc.

Referenced by _drupal_bootstrap(), and install_main().

drupal_set_message | ( | $ | message = NULL,
 |  | $ | type = 'status',
 |  | $ | repeat = TRUE
 | ) |  |

Set a message which reflects the status of the performed operation.

If the function is called with no arguments, this function returns all set messages without clearing them.

Parameters:
$message | The message should begin with a capital letter and always ends with a period '.'.
$type The type of the message. One of the following values are possible:
  • 'status'
  • 'warning'
  • 'error'
$repeat | If this is FALSE and the message is already set, then the message won't be repeated.

Definition at line 806 of file bootstrap.inc.

References $type.

Referenced by _batch_do(), _block_rehash(), _locale_batch_language_finished(), _locale_batch_system_finished(), _locale_import_message(), _locale_import_parse_plural_forms(), _locale_import_po(), _menu_site_is_offline(), _module_build_dependencies(), _node_access_rebuild_batch_finished(), _node_mass_update_batch_finished(), aggregator_categorize_items_submit(), aggregator_form_category_submit(), aggregator_form_feed_submit(), aggregator_parse_feed(), aggregator_refresh(), aggregator_remove(), batch_example_finished(), batch_example_multistep_form_submit(), block_add_block_form_submit(), block_admin_configure_submit(), block_admin_display_form_submit(), block_box_delete_submit(), blog_page_last(), blog_page_user(), blogapi_update_6000(), book_admin_edit_submit(), book_export(), book_outline_form_submit(), book_remove_form_submit(), color_form_alter(), color_scheme_form_submit(), comment_admin_overview_submit(), comment_confirm_delete_submit(), comment_controls_submit(), comment_delete(), comment_multiple_delete_confirm(), comment_multiple_delete_confirm_submit(), comment_reply(), comment_save(), contact_admin_delete_submit(), contact_admin_edit_submit(), contact_mail_page(), contact_mail_page_submit(), contact_mail_user_submit(), db_check_setup(), drupal_check_module(), drupal_error_handler(), drupal_get_messages(), drupal_mail(), drupal_rewrite_settings(), drupal_test_mysql(), drupal_test_mysqli(), drupal_test_pgsql(), drupal_verify_profile(), file_check_directory(), file_copy(), file_destination(), file_move(), file_munge_filename(), file_save_data(), file_save_upload(), file_validate_image_resolution(), filter_admin_delete(), filter_admin_delete_submit(), filter_admin_format_form_submit(), filter_admin_order_submit(), filter_admin_overview_submit(), form_set_error(), forum_confirm_delete_submit(), forum_form_submit(), hook_nodeapi(), install_check_requirements(), install_main(), install_tasks(), locale_languages_configure_form_submit(), locale_languages_delete_form(), locale_languages_delete_form_submit(), locale_languages_overview_form_submit(), locale_languages_predefined_form_submit(), locale_translate_delete(), locale_translate_edit_form(), locale_translate_edit_form_submit(), locale_translate_import_form_submit(), locale_update_6005(), menu_delete_menu_confirm_submit(), menu_edit_item_submit(), menu_edit_item_validate(), menu_item_delete_form_submit(), menu_nodeapi(), menu_reset_item_confirm_submit(), node_access_rebuild(), node_delete(), node_form_submit(), node_help(), node_mass_update(), node_multiple_delete_confirm_submit(), node_node_type(), node_revision_delete_confirm_submit(), node_revision_revert_confirm_submit(), node_teaser_include_verify(), node_type_delete_confirm_submit(), node_type_form_submit(), openid_authentication(), openid_authentication_page(), openid_user(), openid_user_delete(), openid_user_identities(), page_get_cache(), path_admin_delete(), path_admin_form_submit(), php_disable(), php_install(), poll_vote(), profile_admin_overview_submit(), profile_field_delete_submit(), profile_field_form_submit(), search_admin_settings_validate(), search_wipe_confirm_submit(), system_action_delete_orphans_post(), system_actions_configure_submit(), system_actions_delete_form_submit(), system_clear_cache_submit(), system_main_admin_page(), system_message_action(), system_modules_submit(), system_modules_uninstall_submit(), system_modules_uninstall_validate(), system_requirements(), system_run_cron(), system_settings_form(), system_settings_form_submit(), system_site_information_settings_validate(), system_theme_settings_submit(), system_themes_form_submit(), system_update_6017(), system_update_6026(), system_update_6038(), system_update_6045(), taxonomy_form_term_submit(), taxonomy_form_vocabulary_submit(), taxonomy_term_confirm_delete_submit(), taxonomy_vocabulary_confirm_delete_submit(), taxonomy_vocabulary_confirm_reset_alphabetical_submit(), theme_install_page(), theme_node_preview(), theme_update_page(), trigger_assign_form_submit(), trigger_unassign_submit(), update_check_requirements(), update_help(), update_manual_status(), user_admin_access_add(), user_admin_access_check_submit(), user_admin_access_delete_confirm_submit(), user_admin_access_edit(), user_admin_account_submit(), user_admin_perm_submit(), user_admin_role_submit(), user_confirm_delete_submit(), user_edit_submit(), user_external_login_register(), user_multiple_delete_confirm_submit(), user_pass_reset(), user_pass_submit(), user_profile_form_submit(), and user_register_submit().

drupal_unpack | ( | $ | obj,
 |  | $ | field = 'data'
 | ) |  |

Unserializes and appends elements from a serialized string.

Parameters:
$obj | The object to which the elements are appended.
$field | The attribute of $obj whose value should be unserialized.

Definition at line 655 of file bootstrap.inc.

References $value.

Referenced by comment_edit(), comment_form_add_preview(), comment_render(), comment_reply(), sess_read(), and user_load().

drupal_unset_globals ( )

Unsets all disallowed global variables.

See $allowed for what's allowed.

Definition at line 258 of file bootstrap.inc.

References $value.

Referenced by _drupal_bootstrap().

drupal_validate_utf8 ( $ text )

Checks whether a string is valid UTF-8.

All functions designed to filter input should use drupal_validate_utf8 to ensure they operate on valid UTF-8 strings to prevent bypass of the filter.

When text containing an invalid UTF-8 lead byte (0xC0 - 0xFF) is presented as UTF-8 to Internet Explorer 6, the program may misinterpret subsequent bytes. When these subsequent bytes are HTML control characters such as quotes or angle brackets, parts of the text that were deemed safe by filters end up in locations that are potentially unsafe; An onerror attribute that is outside of a tag, and thus deemed safe by a filter, can be interpreted by the browser as if it were inside the tag.

This function exploits preg_match behaviour (since PHP 4.3.5) when used with the u modifier, as a fast way to find invalid UTF-8. When the matched string contains an invalid byte sequence, it will fail silently.

preg_match may not fail on 4 and 5 octet sequences, even though they are not supported by the specification.

The specific preg_match behaviour is present since PHP 4.3.5.

Parameters:
$text The text to check.
Returns:
TRUE if the text is valid UTF-8, FALSE if not.

Definition at line 714 of file bootstrap.inc.

Referenced by check_plain(), and filter_xss().

get_t ( )

Return the name of the localisation function.

Use in code that needs to run both during installation and normal operation.

Definition at line 1039 of file bootstrap.inc.

Referenced by _form_validate(), _locale_batch_build(), _locale_import_message(), _unicode_check(), batch_process(), batch_set(), db_check_setup(), db_status_report(), hook_requirements(), menu_install(), system_requirements(), theme_form_element(), and unicode_requirements().

ip_address ( )

If Drupal is behind a reverse proxy, we use the X-Forwarded-For header instead of $_SERVER['REMOTE_ADDR'], which would be the IP address of the proxy server, and not the client's.

Returns:
IP address of client machine, adjusted for reverse proxy.

Definition at line 1128 of file bootstrap.inc.

References variable_get().

Referenced by _drupal_bootstrap(), comment_save(), drupal_anonymous_user(), flood_is_allowed(), flood_register_event(), poll_cancel(), poll_load(), poll_vote(), sess_write(), statistics_exit(), user_block_ip_action(), and watchdog().

language_default ( $ property = NULL )

Default language used on the site.

Parameters:
$property Optional property of the language object to return

Definition at line 1115 of file bootstrap.inc.

References $language, and variable_get().

Referenced by _locale_rebuild_js(), _update_cron_notify(), _user_mail_notify(), contact_mail_page_submit(), drupal_init_language(), language_initialize(), language_list(), language_url_rewrite(), locale_form_alter(), locale_languages_delete_form(), locale_languages_edit_form_submit(), locale_languages_edit_form_validate(), locale_languages_overview_form(), locale_languages_overview_form_submit(), locale_translate_edit_form(), theme_locale_languages_overview_form(), and user_preferred_language().

language_list | ( | $ | field = 'language',
 |  | $ | reset = FALSE
 | ) |  |

Get a list of languages set up indexed by the specified key.

Parameters:
$field | The field to index the list with.
$reset | Boolean to request a reset of the list.

Definition at line 1070 of file bootstrap.inc.

References $result, $row, db_fetch_object(), db_query(), language_default(), module_exists(), and variable_get().

Referenced by _locale_invalidate_js(), _locale_prepare_predefined_list(), _locale_rebuild_js(), _locale_translate_language_list(), language_from_browser(), language_initialize(), locale_batch_by_component(), locale_block(), locale_get_plural(), locale_language_list(), locale_languages_delete_form(), locale_languages_delete_form_submit(), locale_languages_overview_form(), locale_languages_overview_form_submit(), locale_translate_edit_form(), locale_translate_export_po_form_submit(), locale_translate_import_form_submit(), locale_translate_overview_screen(), locale_user(), node_admin_nodes(), translation_link(), translation_node_overview(), and user_preferred_language().

page_get_cache ( $ status_only = FALSE )

Retrieve the current page from the cache.

Note: we do not serve cached pages when status messages are waiting (from a redirected form submission which was completed).

Parameters:
$status_only When set to TRUE, retrieve the status of the page cache only (whether it was started in this request or not).

Definition at line 502 of file bootstrap.inc.

References $base_root, $status, $user, cache_get(), drupal_set_message(), and request_uri().

Referenced by _drupal_bootstrap(), and page_set_cache().

referer_uri ( )

Return the URI of the referring page.

Definition at line 669 of file bootstrap.inc.

Referenced by statistics_exit(), and watchdog().

request_uri ( )

Since $_SERVER['REQUEST_URI'] is only available on Apache, we generate an equivalent using other environment variables.

Definition at line 725 of file bootstrap.inc.

Referenced by _block_get_cache_id(), locale(), page_get_cache(), page_set_cache(), system_clean_url_settings(), system_elements(), theme_install_page(), and watchdog().

timer_read ( $ name )

Read the current timer value without stopping the timer.

Parameters:
name The name of the timer.
Returns:
The current timer value in ms.

Definition at line 158 of file bootstrap.inc.

References $name, and $timers.

Referenced by _batch_process(), statistics_exit(), and timer_stop().

timer_start ( $ name )

Start the timer with the specified name.

If you start and stop the same timer multiple times, the measured intervals will be accumulated.

Parameters:
name The name of the timer.

Definition at line 142 of file bootstrap.inc.

References $name, and $timers.

Referenced by _batch_process(), and _drupal_bootstrap().

timer_stop ( $ name )

Stop the timer with the specified name.

Parameters:
name The name of the timer.
Returns:
A timer array. The array contains the number of times the timer has been started and stopped (count) and the accumulated timer value in ms (time).

Definition at line 183 of file bootstrap.inc.

References $name, $timers, and timer_read().

variable_del ( $ name )

Unset a persistent variable.

Parameters:
$name The name of the variable to undefine.

Definition at line 482 of file bootstrap.inc.

References $conf, $name, cache_clear_all(), and db_query().

Referenced by _update_remove_update_status_variables(), aggregator_uninstall(), color_scheme_form_submit(), comment_node_type(), comment_update_6002(), contact_uninstall(), drupal_cron_cleanup(), drupal_cron_run(), example_profile_tasks(), forum_taxonomy(), forum_uninstall(), hook_node_type(), hook_search(), hook_uninstall(), install_tasks(), locale_update_6005(), menu_rebuild(), multipage_form_example_delete(), node_access_needs_rebuild(), node_type_form_submit(), profile_uninstall(), search_uninstall(), statistics_uninstall(), system_settings_form_submit(), system_theme_settings_submit(), system_themes_form_submit(), system_update_6017(), system_update_6021(), system_update_6036(), system_update_6042(), system_update_6044(), update_settings_submit(), and update_uninstall().

variable_get | ( | $ | name,
 |  | $ | default
 | ) |  |

Return a persistent variable.

Parameters:
$name | The name of the variable to return.
$default | The default value to use if this variable has never been set.
Returns:
The value of the variable.

Definition at line 447 of file bootstrap.inc.

References $conf, and $name.

Referenced by _block_get_cache_id(), _block_themes_access(), _blogapi_get_node_types(), _book_parent_select(), _color_page_alter(), _comment_get_display_setting(), _db_query(), _drupal_bootstrap(), _drupal_flush_css_js(), _drupal_maintenance_theme(), _filter_html(), _filter_html_settings(), _filter_url(), _filter_url_settings(), _forum_parent_select(), _locale_export_po_generate(), _locale_invalidate_js(), _locale_rebuild_js(), _menu_site_is_offline(), _system_themes_access(), _system_zonelist(), _update_build_fetch_url(), _update_cron_notify(), _update_refresh(), _update_requirement_check(), _upload_file_limits(), _user_mail_notify(), _user_mail_text(), actions_do(), aggregator_admin_settings(), aggregator_categorize_items(), aggregator_filter_xss(), aggregator_page_categories(), aggregator_page_category(), aggregator_page_last(), aggregator_page_rss(), aggregator_page_sources(), aggregator_parse_feed(), block_admin_display(), block_admin_display_form(), block_example_block(), block_example_contents(), block_menu(), blog_feed_last(), blog_feed_user(), blog_page_last(), blog_page_user(), blogapi_admin_settings(), blogapi_blogger_new_post(), book_admin_settings(), book_block(), book_link(), book_node_type(), book_type_is_allowed(), cache_clear_all(), cache_get(), chameleon_page(), color_form_alter(), color_get_palette(), color_scheme_form(), color_scheme_form_submit(), comment_form(), comment_form_add_preview(), comment_form_alter(), comment_link(), comment_nodeapi(), comment_render(), comment_update_1(), comment_update_6002(), comment_validate(), contact_admin_settings(), contact_mail(), contact_mail_page(), contact_site_page(), contact_user(), contact_user_page(), dblog_admin_settings(), dblog_cron(), default_profile_tasks(), drupal_access_denied(), drupal_cron_cleanup(), drupal_cron_run(), drupal_error_handler(), drupal_get_css(), drupal_get_js(), drupal_get_private_key(), drupal_http_request(), drupal_init_language(), drupal_init_path(), drupal_is_front_page(), drupal_mail(), drupal_mail_send(), drupal_match_path(), drupal_not_found(), drupal_page_cache_header(), drupal_page_footer(), drupal_process_form(), drupal_site_offline(), drupal_system_listing(), drupal_urlencode(), drupal_valid_token(), example_element_demo_form(), example_profile_tasks(), expand_date(), file_create_url(), file_directory_path(), file_directory_temp(), file_munge_filename(), file_save_upload(), filter_access(), filter_admin_delete(), filter_admin_delete_submit(), filter_admin_format_form(), filter_admin_overview(), filter_example_filter(), filter_example_filter_tips(), filter_filter_tips(), filter_form(), filter_formats(), filter_resolve_format(), filter_xss_bad_protocol(), format_date(), forum_admin_settings(), forum_block(), forum_enable(), forum_form(), forum_form_alter(), forum_form_container(), forum_form_forum(), forum_form_submit(), forum_get_forums(), forum_help(), forum_link_alter(), forum_nodeapi(), forum_overview(), forum_page(), forum_taxonomy(), forum_term_load(), forum_uninstall(), forum_update_6000(), hook_block(), hook_footer(), hook_form_alter(), hook_link(), hook_mail(), hook_mail_alter(), hook_node_type(), hook_requirements(), hook_taxonomy(), hook_update_index(), hook_watchdog(), image_gd_close(), image_gd_settings(), image_get_toolkit(), init_theme(), install_tasks(), ip_address(), language_default(), language_initialize(), language_list(), language_url_rewrite(), locale(), locale_add_language(), locale_block(), locale_form_alter(), locale_languages_configure_form(), locale_update_6005(), locale_update_js_files(), locale_user(), menu_configure(), menu_execute_active_handler(), menu_get_ancestors(), menu_nodeapi(), menu_parent_options(), menu_primary_links(), menu_secondary_links(), menu_tree_page_data(), module_list(), multipage_form_example_load(), node_access_needs_rebuild(), node_configure(), node_feed(), node_form(), node_object_prepare(), node_page_default(), node_search(), node_teaser(), node_type_form(), node_update_index(), nodeapi_example_form_alter(), nodeapi_example_nodeapi(), openid_authentication(), openid_form_alter(), openid_user(), page_set_cache(), path_admin_form(), ping_cron(), profile_block(), profile_view_field(), search_admin_settings(), search_admin_settings_validate(), sess_write(), statistics_access_logging_settings(), statistics_block(), statistics_cron(), statistics_exit(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), system_admin_compact_mode(), system_admin_theme_settings(), system_admin_theme_submit(), system_block(), system_clean_url_settings(), system_date_time_settings(), system_error_reporting_settings(), system_file_system_settings(), system_image_toolkit_settings(), system_init(), system_initialize_theme_blocks(), system_mail(), system_message_action(), system_node_type(), system_performance_settings(), system_requirements(), system_rss_feeds_settings(), system_site_information_settings(), system_site_maintenance_settings(), system_theme_select_form(), system_theme_settings(), system_themes_form(), system_themes_form_submit(), system_update_6017(), system_update_6021(), system_update_6041(), system_update_6042(), system_update_6044(), system_update_6046(), system_user(), t(), taxonomy_form_alter(), taxonomy_form_term(), taxonomy_render_nodes(), taxonomy_select_nodes(), taxonomy_term_page(), template_preprocess_aggregator_item(), template_preprocess_comment_wrapper(), template_preprocess_forum_icon(), template_preprocess_forum_topic_navigation(), template_preprocess_forums(), template_preprocess_maintenance_page(), template_preprocess_page(), template_preprocess_user_picture(), theme_aggregator_page_opml(), theme_aggregator_page_rss(), theme_comment_post_forbidden(), theme_get_setting(), theme_get_settings(), theme_update_report(), theme_username(), throttle_admin_settings(), throttle_exit(), throttle_status(), translation_supported_type(), update_cron(), update_fix_d6_requirements(), update_get_available(), update_mail(), update_settings(), upload_admin_settings(), upload_form_alter(), upload_node_form_submit(), upload_nodeapi(), url(), user_admin_settings(), user_block(), user_comment(), user_edit_form(), user_file_download(), user_login(), user_login_block(), user_mail_tokens(), user_register(), user_register_access(), user_register_submit(), and user_validate_picture().

variable_init ( $ conf = array() )

Load the persistent variable table.

The variable table is composed of values that have been saved in the table with variable_set() as well as those explicitly specified in the configuration file.

Definition at line 417 of file bootstrap.inc.

References $conf, $name, $result, $value, cache_get(), cache_set(), db_fetch_object(), and db_query().

Referenced by _drupal_bootstrap().

variable_set | ( | $ | name,
 |  | $ | value
 | ) |  |

Set a persistent variable.

Parameters:
$name | The name of the variable to set.
$value | The value to set. This can be any PHP data type; these functions take care of serialization as necessary.

Definition at line 462 of file bootstrap.inc.

References $conf, $name, $value, cache_clear_all(), db_affected_rows(), and db_query().

Referenced by _book_install_type_create(), _color_render_images(), _drupal_flush_css_js(), _install_locale_initial_batch_finished(), _install_locale_remaining_batch_finished(), _install_profile_batch_finished(), _locale_invalidate_js(), _locale_rebuild_js(), _menu_router_build(), _menu_set_expanded_menus(), _node_index_node(), _update_refresh(), block_example_block(), book_block(), book_node_type(), cache_clear_all(), cache_get(), color_scheme_form_submit(), comment_update_1(), comment_update_6002(), default_profile_tasks(), drupal_clear_js_cache(), drupal_cron_run(), drupal_get_private_key(), example_form_submit(), example_profile_tasks(), file_directory_temp(), filter_admin_overview_submit(), forum_block(), forum_enable(), forum_form_submit(), forum_taxonomy(), forum_update_6000(), hook_block(), hook_node_type(), hook_taxonomy(), hook_update_index(), install_configure_form_submit(), install_main(), install_tasks(), locale_add_language(), locale_languages_configure_form_submit(), locale_languages_edit_form_submit(), locale_languages_overview_form_submit(), locale_update_6000(), locale_update_6005(), locale_update_js_files(), menu_rebuild(), multipage_form_example_custom_submit(), node_access_needs_rebuild(), node_type_form_submit(), node_update_index(), profile_block(), statistics_block(), statistics_cron(), system_block(), system_check_http_request(), system_image_toolkit_settings(), system_node_type(), system_settings_form_submit(), system_theme_settings_submit(), system_themes_form_submit(), system_update_1022(), system_update_6014(), system_update_6017(), system_update_6021(), system_update_6042(), system_update_6043(), system_update_6046(), throttle_exit(), update_fix_d6_requirements(), update_settings_submit(), and user_block().

watchdog | ( | $ | type,
 |  | $ | message,
 |  | $ | variables = array(),
 |  | $ | severity = WATCHDOG_NOTICE,
 |  | $ | link = NULL
 | ) |  |

Log a system message.

Parameters:
$type | The category to which this message belongs.
$message | The message to store in the log. See t() for documentation on how $message and $variables interact. Keep $message translatable by not concatenating dynamic values into it!
$variables | Array of variables to replace in the message on display or NULL if message is already translated or not possible to translate.
$severity | The severity of the message, as per RFC 3164
$link | A link to associate with the message.
See also:
watchdog_severity_levels()

Definition at line 765 of file bootstrap.inc.

References $base_root, $type, $user, ip_address(), module_implements(), module_invoke(), referer_uri(), and request_uri().

Referenced by _comment_delete_thread(), _form_validate(), _locale_export_po(), _locale_import_po(), _locale_rebuild_js(), _update_refresh(), actions_do(), actions_save(), actions_synchronize(), aggregator_form_category_submit(), aggregator_form_feed_submit(), aggregator_parse_feed(), aggregator_refresh(), blogapi_blogger_edit_post(), blogapi_blogger_new_post(), book_admin_edit_submit(), comment_admin_overview_submit(), comment_save(), comment_unpublish_action(), comment_unpublish_by_keyword_action(), contact_admin_delete_submit(), contact_admin_edit_submit(), contact_mail_page_submit(), contact_mail_user_submit(), drupal_access_denied(), drupal_convert_to_utf8(), drupal_cron_cleanup(), drupal_cron_run(), drupal_error_handler(), drupal_mail(), drupal_not_found(), drupal_xml_parser_create(), file_check_directory(), file_copy(), file_save_upload(), filter_form_validate(), forum_confirm_delete_submit(), hook_ping(), image_toolkit_invoke(), locale_add_language(), locale_languages_delete_form_submit(), locale_translate_import_form_submit(), locale_update_js_files(), menu_delete_menu_confirm_submit(), menu_item_delete_form_submit(), node_assign_owner_action(), node_delete(), node_form_submit(), node_make_sticky_action(), node_make_unsticky_action(), node_promote_action(), node_publish_action(), node_revision_delete_confirm_submit(), node_revision_revert_confirm_submit(), node_save_action(), node_type_delete_confirm_submit(), node_type_form_submit(), node_unpromote_action(), node_unpublish_action(), node_unpublish_by_keyword_action(), ping_ping(), profile_field_delete_submit(), profile_field_form_submit(), search_view(), system_actions_delete_form_submit(), system_cron(), system_send_email_action(), taxonomy_form_term_submit(), taxonomy_form_vocabulary_submit(), taxonomy_term_confirm_delete_submit(), taxonomy_vocabulary_confirm_delete_submit(), taxonomy_vocabulary_confirm_reset_alphabetical_submit(), throttle_exit(), trigger_unassign_submit(), user_authenticate_finalize(), user_block_ip_action(), user_block_user_action(), user_delete(), user_edit_validate(), user_external_login_register(), user_login_final_validate(), user_logout(), user_pass_reset(), user_pass_submit(), user_profile_form_validate(), user_register_submit(), and user_user_operations().

Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/cache-install.inc File Reference

includes

cache-install.inc File Reference

Go to the source code of this file.

Functions

  • cache_clear_all ($cid=NULL, $table=NULL, $wildcard=FALSE)
  • cache_get ($key, $table= 'cache')
    A stub cache implementation to be used during the installation process when database access is not yet available.
  • cache_set ($cid, $data, $table= 'cache', $expire=CACHE_PERMANENT, $headers=NULL)

Function Documentation

cache_clear_all | ( | $ | cid = NULL,
 |  | $ | table = NULL,
 |  | $ | wildcard = FALSE
 | ) |  |

Definition at line 22 of file cache-install.inc.

Referenced by _locale_import_po(), _menu_clear_page_cache(), _node_access_rebuild_batch_finished(), aggregator_refresh(), block_add_block_form_submit(), block_admin_configure_submit(), block_admin_display_form_submit(), block_box_delete_submit(), cache_clear_all(), comment_admin_overview_submit(), comment_confirm_delete_submit(), comment_multiple_delete_confirm_submit(), comment_save(), drupal_flush_all_caches(), drupal_process_form(), drupal_rebuild_theme_registry(), filter_admin_configure_submit(), filter_admin_delete_submit(), filter_admin_format_form_submit(), filter_admin_order_submit(), filter_cron(), locale(), locale_languages_delete_form_submit(), locale_languages_overview_form_submit(), locale_translate_delete(), locale_translate_edit_form_submit(), menu_cache_clear(), menu_cache_clear_all(), menu_delete_menu_confirm_submit(), node_access_rebuild(), node_admin_nodes_submit(), node_delete(), node_save(), poll_vote(), profile_admin_overview_submit(), profile_field_delete_submit(), profile_field_form_submit(), system_modules(), system_settings_form_submit(), system_theme_settings_submit(), taxonomy_del_term(), taxonomy_del_vocabulary(), taxonomy_save_term(), taxonomy_save_vocabulary(), throttle_exit(), update_info_page(), update_invalidate_cache(), update_project_cache(), user_admin_perm_submit(), user_edit_submit(), user_profile_form_submit(), variable_del(), and variable_set().

cache_get | ( | $ | key,
 |  | $ | table = 'cache'
 | ) |  |

A stub cache implementation to be used during the installation process when database access is not yet available.

Because Drupal's caching system never requires that cached data be present, these stub functions can short-circuit the process and sidestep the need for any persistent storage. Obviously, using this cache implementation during normal operations would have a negative impact on performance.

Definition at line 14 of file cache-install.inc.

Referenced by _theme_load_registry(), block_list(), book_form_update(), book_menu_subtree_data(), check_markup(), drupal_get_schema(), form_get_cache(), locale(), menu_router_build(), menu_tree_all_data(), menu_tree_page_data(), page_get_cache(), update_get_available(), update_project_cache(), upload_js(), and variable_init().

cache_set | ( | $ | cid,
 |  | $ | data,
 |  | $ | table = 'cache',
 |  | $ | expire = CACHE_PERMANENT,
 |  | $ | headers = NULL
 | ) |  |

Definition at line 18 of file cache-install.inc.

Referenced by _theme_save_registry(), _update_refresh(), block_list(), book_form_update(), book_menu_subtree_data(), check_markup(), drupal_get_schema(), form_set_cache(), locale(), menu_router_build(), menu_tree_all_data(), menu_tree_page_data(), page_set_cache(), update_calculate_project_data(), update_get_projects(), upload_js(), and variable_init().

Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/cache.inc File Reference

includes

cache.inc File Reference

Go to the source code of this file.

Functions

  • cache_clear_all ($cid=NULL, $table=NULL, $wildcard=FALSE)
    Expire data from the cache.
  • cache_get ($cid, $table= 'cache')
    Return data from the persistent cache.
  • cache_set ($cid, $data, $table= 'cache', $expire=CACHE_PERMANENT, $headers=NULL)
    Store data in the persistent cache.

Function Documentation

cache_clear_all | ( | $ | cid = NULL,
 |  | $ | table = NULL,
 |  | $ | wildcard = FALSE
 | ) |  |

Expire data from the cache.

If called without arguments, expirable entries will be cleared from the cache_page and cache_block tables.

Parameters:
$cid | If set, the cache ID to delete. Otherwise, all cache entries that can expire are deleted.
$table | If set, the table $table to delete from. Mandatory argument if $cid is set.
$wildcard | If set to TRUE, the $cid is treated as a substring to match rather than a complete ID. The match is a right hand match. If '*' is given as $cid, the table $table will be emptied.

Definition at line 133 of file cache.inc.

References $user, cache_clear_all(), db_query(), variable_get(), and variable_set().

cache_get | ( | $ | cid,
 |  | $ | table = 'cache'
 | ) |  |

Return data from the persistent cache.

Data may be stored as either plain text or as serialized data. cache_get will automatically return unserialized objects and arrays.

Parameters:
$cid | The cache ID of the data to retrieve.
$table | The table $table to store the data in. Valid core values are 'cache_filter', 'cache_menu', 'cache_page', or 'cache' for the default cache.

Definition at line 14 of file cache.inc.

References $user, db_decode_blob(), db_fetch_object(), db_query(), variable_get(), and variable_set().

cache_set | ( | $ | cid,
 |  | $ | data,
 |  | $ | table = 'cache',
 |  | $ | expire = CACHE_PERMANENT,
 |  | $ | headers = NULL
 | ) |  |

Store data in the persistent cache.

The persistent cache is split up into four database tables. Contributed modules can add additional tables.

'cache_page': This table stores generated pages for anonymous users. This is the only table affected by the page cache setting on the administrator panel.

'cache_menu': Stores the cachable part of the users' menus.

'cache_filter': Stores filtered pieces of content. This table is periodically cleared of stale entries by cron.

'cache': Generic cache storage table.

The reasons for having several tables are as follows:

  • smaller tables allow for faster selects and inserts
  • we try to put fast changing cache items and rather static ones into different tables. The effect is that only the fast changing tables will need a lot of writes to disk. The more static tables will also be better cachable with MySQL's query cache

Parameters:
$cid | The cache ID of the data to store.
$data | The data to store in the cache. Complex data types will be automatically serialized before insertion. Strings will be stored as plain text and not serialized.
$table | The table $table to store the data in. Valid core values are 'cache_filter', 'cache_menu', 'cache_page', or 'cache'.
$expire One of the following values:
  • CACHE_PERMANENT: Indicates that the item should never be removed unless explicitly told to using cache_clear_all() with a cache ID.
  • CACHE_TEMPORARY: Indicates that the item should be removed at the next general cache wipe.
  • A Unix timestamp: Indicates that the item should be kept at least until the given time, after which it behaves like CACHE_TEMPORARY.
$headers | A string containing HTTP header information for cached pages.

Definition at line 102 of file cache.inc.

References db_affected_rows(), and db_query().

Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/common.inc File Reference

includes

common.inc File Reference

Detailed Description

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.

Definition in file common.inc.

Go to the source code of this file.

Enumerations

  • enum SAVED_DELETED
    Return status for saving which deleted an existing item. More...
  • enum SAVED_NEW
    Return status for saving which involved creating a new item. More...
  • enum SAVED_UPDATED
    Return status for saving which involved an update to an existing item. More...

Functions

  • _drupal_bootstrap_full ()
  • _drupal_build_css_path ($matches, $base=NULL)
    Helper function for drupal_build_css_cache().
  • _drupal_flush_css_js ()
    Helper function to change query-strings on css/js files.
  • _drupal_load_stylesheet ($matches)
    Loads stylesheets recursively and returns contents with corrected paths.
  • _fix_gpc_magic (&$item)
  • _fix_gpc_magic_files (&$item, $key)
    Helper function to strip slashes from $_FILES skipping over the tmp_name keys since PHP generates single backslashes for file paths on Windows systems.
  • base_path ()
    Returns the base URL path of the Drupal installation.
  • check_file ($filename)
  • check_url ($uri)
    Prepare a URL for use in an HTML attribute.
  • drupal_add_css ($path=NULL, $type= 'module', $media= 'all', $preprocess=TRUE)
    Adds a CSS file to the stylesheet queue.
  • drupal_add_feed ($url=NULL, $title= '')
    Add a feed URL for the current page.
  • drupal_add_js ($data=NULL, $type= 'module', $scope= 'header', $defer=FALSE, $cache=TRUE, $preprocess=TRUE)
    Add a JavaScript file, setting or inline code to the page.
  • drupal_add_link ($attributes)
    Add a <link> tag to the page's HEAD.
  • drupal_add_tabledrag ($table_id, $action, $relationship, $group, $subgroup=NULL, $source=NULL, $hidden=TRUE, $limit=0)
    Assist in adding the tableDrag JavaScript behavior to a themed table.
  • drupal_alter ($type, &$data)
    This dispatch function hands off structured Drupal arrays to type-specific *_alter implementations.
  • drupal_attributes ($attributes=array())
    Format an attribute string to insert in a tag.
  • drupal_build_css_cache ($types, $filename)
    Aggregate and optimize CSS files, putting them in the files directory.
  • drupal_build_js_cache ($files, $filename)
    Aggregate JS files, putting them in the files directory.
  • drupal_clear_css_cache ()
    Delete all cached CSS files.
  • drupal_clear_js_cache ()
    Delete all cached JS files.
  • drupal_clear_path_cache ()
    Reset the static variable which holds the aliases mapped for this request.
  • drupal_clone ($object)
    Provide a substitute clone() function for PHP4.
  • drupal_common_theme ()
    Provide theme registration for themes across .inc files.
  • drupal_cron_cleanup ()
    Shutdown function for cron cleanup.
  • drupal_cron_run ()
    Executes a cron run when called.
  • drupal_error_handler ($errno, $message, $filename, $line, $context)
    End of "HTTP handling".
  • drupal_eval ($code)
    Evaluate a string of PHP code.
  • drupal_explode_tags ($tags)
    Explode a string of given tags into an array.
  • drupal_flush_all_caches ()
    Flush all cached data on the site.
  • drupal_get_breadcrumb ()
    Get the breadcrumb trail for the current page.
  • drupal_get_content ($region=NULL, $delimiter= ' ')
    Get assigned content.
  • drupal_get_css ($css=NULL)
    Returns a themed representation of all stylesheets that should be attached to the page.
  • drupal_get_feeds ($delimiter="\n")
    Get the feed URLs for the current page.
  • drupal_get_headers ()
    Get the HTTP response headers for the current page.
  • drupal_get_html_head ()
    Retrieve output to be displayed in the head tag of the HTML page.
  • drupal_get_js ($scope= 'header', $javascript=NULL)
    Returns a themed presentation of all JavaScript code for the current page.
  • drupal_get_path ($type, $name)
    Returns the path to a system item (module, theme, etc.
  • drupal_get_private_key ()
    Ensure the private key variable used to generate tokens is set.
  • drupal_get_token ($value= '')
    Generate a token based on $value, the current user session and private key.
  • drupal_implode_tags ($tags)
    Implode an array of tags into a string.
  • drupal_json ($var=NULL)
    Return data in JSON format.
  • drupal_load_stylesheet ($file, $optimize=NULL)
    Loads the stylesheet and resolves all commands.
  • drupal_map_assoc ($array, $function=NULL)
    Form an associative array from a linear array.
  • drupal_page_footer ()
    Perform end-of-request tasks.
  • drupal_parse_info_file ($filename)
    End of "ingroup schemaapi".
  • drupal_render (&$elements)
    Renders HTML given a structured array tree.
  • drupal_set_breadcrumb ($breadcrumb=NULL)
    Set the breadcrumb trail for the current page.
  • drupal_set_content ($region=NULL, $data=NULL)
    Set content for a specified region.
  • drupal_set_header ($header=NULL)
    Set an HTTP response header for the current page.
  • drupal_set_html_head ($data=NULL)
    Add output to the head tag of the HTML page.
  • drupal_system_listing ($mask, $directory, $key= 'name', $min_depth=1)
    Return an array of system file objects.
  • drupal_to_js ($var)
    Converts a PHP variable into its Javascript equivalent.
  • drupal_urlencode ($text)
    Wrapper around urlencode() which avoids Apache quirks.
  • drupal_valid_token ($token, $value= '', $skip_anonymous=FALSE)
    Validate a token based on $value, the current user session and private key.
  • element_child ($key)
    Check if the key is a child.
  • element_children ($element)
    Get keys of a structured array tree element that are not properties (i.e., do not begin with '#').
  • element_properties ($element)
    Get properties of a structured array element.
  • element_property ($key)
    Check if the key is a property.
  • element_sort ($a, $b)
    Function used by uasort to sort structured arrays by weight.
  • fix_gpc_magic ()
    Fix double-escaping problems caused by "magic quotes" in some PHP installations.
  • flood_is_allowed ($name, $threshold)
    Check if the current visitor (hostname/IP) is allowed to proceed with the specified event.
  • flood_register_event ($name)
    End of "defgroup validation".
  • format_date ($timestamp, $type= 'medium', $format= '', $timezone=NULL, $langcode=NULL)
    Format a date with the given configured format or a custom format string.
  • format_interval ($timestamp, $granularity=2, $langcode=NULL)
    Format a time interval with the requested granularity.
  • format_plural ($count, $singular, $plural, $args=array(), $langcode=NULL)
    Format a string containing a count of items.
  • format_rss_channel ($title, $link, $description, $items, $langcode=NULL, $args=array())
    Formats an RSS channel.
  • format_rss_item ($title, $link, $description, $args=array())
    Format a single RSS item.
  • format_size ($size, $langcode=NULL)
    Generate a string representation for the given byte count.
  • format_xml_elements ($array)
    Format XML elements.
  • l ($text, $path, $options=array())
    Format an internal Drupal link.
  • page_set_cache ()
    Store the current page in the cache.
  • parse_size ($size)
    Parse a given byte count.
  • t ($string, $args=array(), $langcode=NULL)
    Translate strings to the page language or a given language.
  • url ($path=NULL, $options=array())
    End of "defgroup format".
  • valid_email_address ($mail)
    Verify the syntax of the given e-mail address.
  • valid_url ($url, $absolute=FALSE)
    Verify the syntax of the given URL.
  • watchdog_severity_levels ()
  • xmlrpc ($url)
    Performs one or more XML-RPC request(s).
  • _drupal_initialize_schema ($module, &$schema)
    Fill in required default values for table definitions returned by hook_schema().
  • drupal_get_schema ($table=NULL, $rebuild=FALSE)
    Get the schema definition of a table, or the whole database schema.
  • drupal_get_schema_unprocessed ($module, $table=NULL)
    Returns the unprocessed and unaltered version of a module's schema.
  • drupal_install_schema ($module)
    Create all tables that a module defines in its hook_schema().
  • drupal_schema_fields_sql ($table, $prefix=NULL)
    Retrieve a list of fields from a table schema.
  • drupal_uninstall_schema ($module)
    Remove all tables that a module defines in its hook_schema().
  • drupal_write_record ($table, &$object, $update=array())
    Save a record to the database based upon the schema.
HTTP handling
Functions to properly handle HTTP responses.

  • drupal_access_denied ()
    Generates a 403 error if the request is not allowed.
  • drupal_get_destination ()
    Prepare a destination query string for use in combination with drupal_goto().
  • drupal_goto ($path= '', $query=NULL, $fragment=NULL, $http_response_code=302)
    Send the user to a different Drupal page.
  • drupal_http_request ($url, $headers=array(), $method= 'GET', $data=NULL, $retry=3)
    Perform an HTTP request.
  • drupal_not_found ()
    Generates a 404 error if the request can not be handled.
  • drupal_query_string_encode ($query, $exclude=array(), $parent= '')
    Parse an array into a valid urlencoded query string.
  • drupal_site_offline ()
    Generates a site off-line message.

Enumeration Type Documentation

enum SAVED_DELETED

Return status for saving which deleted an existing item.

Definition at line 25 of file common.inc.

enum SAVED_NEW

Return status for saving which involved creating a new item.

Definition at line 15 of file common.inc.

enum SAVED_UPDATED

Return status for saving which involved an update to an existing item.

Definition at line 20 of file common.inc.

Function Documentation

_drupal_bootstrap_full ( )

Definition at line 2429 of file common.inc.

References drupal_set_header(), fix_gpc_magic(), module_invoke_all(), module_load_all(), and unicode_check().

Referenced by _drupal_bootstrap().

_drupal_build_css_path | ( | $ | matches,
 |  | $ | base = NULL
 | ) |  |

Helper function for drupal_build_css_cache().

This function will prefix all paths within a CSS file.

Definition at line 1807 of file common.inc.

Referenced by color_scheme_form_submit(), and drupal_build_css_cache().

_drupal_flush_css_js ( )

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.

Definition at line 3550 of file common.inc.

References variable_get(), and variable_set().

Referenced by drupal_flush_all_caches(), install_tasks(), and update_info_page().

_drupal_initialize_schema | ( | $ | module,
 |  | &$ | schema
 | ) |  |

Fill in required default values for table definitions returned by hook_schema().

Parameters:
$module | The module for which hook_schema() was invoked.
$schema | The schema definition array as it was returned by the module's hook_schema().

Definition at line 3173 of file common.inc.

References $name.

Referenced by drupal_get_schema(), drupal_install_schema(), and drupal_uninstall_schema().

_drupal_load_stylesheet ( $ matches )

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.

Definition at line 1886 of file common.inc.

References drupal_load_stylesheet().

_fix_gpc_magic ( &$ item )

Definition at line 613 of file common.inc.

References $item.

_fix_gpc_magic_files | ( | &$ | item,
 |  | $ | key
 | ) |  |

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

Definition at line 629 of file common.inc.

References $item.

base_path ( )

Returns the base URL path of the Drupal installation.

At the very least, this will always default to /.

Definition at line 1566 of file common.inc.

Referenced by _color_page_alter(), _color_rewrite_stylesheet(), color_scheme_form_submit(), drupal_add_js(), drupal_build_css_cache(), drupal_get_css(), drupal_get_js(), phptemplate_get_ie_styles(), system_clean_url_settings(), system_requirements(), template_preprocess_maintenance_page(), template_preprocess_page(), theme_color_scheme_form(), theme_get_setting(), theme_image(), theme_image_button(), update_info_page(), update_results_page(), and url().

check_file ( $ filename )

Definition at line 880 of file common.inc.

check_url ( $ uri )

Prepare a URL for use in an HTML attribute.

Strips harmful protocols.

Definition at line 887 of file common.inc.

References filter_xss_bad_protocol().

Referenced by _filter_url_parse_full_links(), aggregator_refresh(), blog_form(), chameleon_page(), format_rss_channel(), format_rss_item(), l(), profile_view_field(), template_preprocess_aggregator_feed_source(), template_preprocess_aggregator_item(), template_preprocess_aggregator_summary_item(), template_preprocess_maintenance_page(), template_preprocess_page(), template_preprocess_search_result(), theme_aggregator_block_item(), theme_aggregator_page_opml(), theme_aggregator_page_rss(), theme_feed_icon(), theme_form(), theme_image(), theme_more_help_link(), theme_more_link(), theme_textfield(), and theme_xml_icon().

drupal_access_denied ( )

Generates a 403 error if the request is not allowed.

Definition at line 371 of file common.inc.

References $return, check_plain(), drupal_get_normal_path(), drupal_set_header(), drupal_set_title(), menu_execute_active_handler(), menu_set_active_item(), t(), theme(), variable_get(), and watchdog().

Referenced by book_export_html(), comment_edit(), file_download(), menu_delete_menu_page(), menu_item_delete_page(), page_example_baz(), profile_browse(), system_batch_page(), and user_pass_reset().

drupal_add_css | ( | $ | path = NULL,
 |  | $ | type = 'module',
 |  | $ | media = 'all',
 |  | $ | preprocess = TRUE
 | ) |  |

Adds a CSS file to the stylesheet queue.

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.

Parameters:
$path (optional) The path to the CSS file relative to the base_path(), e.g., /modules/devel/devel.css.
Modules should always prefix the names of their CSS files with the module name, for example: system-menus.css rather than simply menus.css. Themes can override module-supplied CSS files based on their filenames, and this prefixing helps prevent confusing name collisions for theme developers.

If the direction of the current language is right-to-left (Hebrew, Arabic, etc.), the function will also look for an RTL CSS file and append it to the list. The name of this file should have an '-rtl.css' suffix. For example a CSS file called 'name.css' will have a 'name-rtl.css' file added to the list, if exists in the same directory. This CSS file should contain overrides for properties which should be reversed or otherwise different in a right-to-left display.

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.

Parameters:
$type | (optional) The type of stylesheet that is being added. Types are: module or theme.
$media | (optional) The media type for the stylesheet, e.g., all, print, screen.
$preprocess | (optional) Should this CSS file be aggregated and compressed if this feature has been turned on under the performance section?
What does this actually mean? CSS preprocessing is the process of aggregating a bunch of separate CSS files into one file that is then compressed by removing all extraneous white space.

The reason for merging the CSS files is outlined quite thoroughly here: http://www.die.net/musings/page_load_time/ "Load fewer external objects. Due to request overhead, one bigger file just loads faster than two smaller ones half its size."

However, you should *not* preprocess every file as this can lead to redundant caches. You should set $preprocess = FALSE when:

  • Your styles are only used rarely on the site. This could be a special admin page, the homepage, or a handful of pages that does not represent the majority of the pages on your site.

Typical candidates for caching are for example styles for nodes across the site, or used in the theme.

Returns:
An array of CSS files.

Definition at line 1643 of file common.inc.

References $language, and $type.

Referenced by _drupal_maintenance_theme(), _init_theme(), _locale_translate_language_list(), aggregator_init(), block_admin_display_form(), book_init(), color_scheme_form(), comment_render(), dblog_init(), drupal_get_css(), forum_init(), help_main(), hook_init(), node_init(), openid_form_alter(), openid_user_identities(), poll_init(), system_init(), template_preprocess_maintenance_page(), template_preprocess_page(), theme_color_scheme_form(), theme_profile_admin_overview(), theme_taxonomy_overview_terms(), theme_taxonomy_term_page(), theme_update_report(), tracker_page(), and user_init().

drupal_add_feed | ( | $ | url = NULL,
 |  | $ | title = ''
 | ) |  |

Add a feed URL for the current page.

Parameters:
$url | A url for the feed.
$title | The title of the feed.

Definition at line 162 of file common.inc.

References $title, $url, drupal_add_link(), and theme().

Referenced by aggregator_page_category(), aggregator_page_last(), blog_page_last(), blog_page_user(), drupal_get_feeds(), node_page_default(), taxonomy_term_page(), and template_preprocess_forums().

drupal_add_js | ( | $ | data = NULL,
 |  | $ | type = 'module',
 |  | $ | scope = 'header',
 |  | $ | defer = FALSE,
 |  | $ | cache = TRUE,
 |  | $ | preprocess = TRUE
 | ) |  |

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.

Parameters:
$data (optional) If given, the value depends on the $type parameter:
  • 'core', 'module' or 'theme': Path to the file relative to base_path().
  • 'inline': The JavaScript code that should be placed in the given scope.
  • 'setting': An array with configuration options as associative array. The array is directly placed in Drupal.settings. You might want to wrap your actual configuration settings in another variable to prevent the pollution of the Drupal.settings namespace.
$type | (optional) The type of JavaScript that should be added to the page. Allowed values are 'core', 'module', 'theme', 'inline' and 'setting'. You can, however, specify any value. It is treated as a reference to a JavaScript file. Defaults to 'module'.
$scope | (optional) The location in which you want to place the script. Possible values are 'header' and 'footer' by default. If your theme implements different locations, however, you can also use these.
$defer | (optional) If set to TRUE, the defer attribute is set on the <script> tag. Defaults to FALSE. This parameter is not used with $type == 'setting'.
$cache | (optional) If set to FALSE, the JavaScript file is loaded anew on every page call, that means, it is not cached. Defaults to TRUE. Used only when $type references a JavaScript file.
$preprocess | (optional) Should this JS file be aggregated if this feature has been turned on under the performance section?
Returns:
If the first parameter is NULL, the JavaScript array that has been built so far for $scope is returned. If the first three parameters are NULL, an array with all scopes is returned.

Definition at line 1957 of file common.inc.

References $type, and base_path().

Referenced by _batch_progress_page_js(), _book_add_form_elements(), _init_theme(), _user_password_dynamic_validation(), color_scheme_form(), comment_form(), drupal_add_tabledrag(), drupal_get_js(), form_expand_ahah(), install_tasks(), locale_update_js_files(), node_filter_form(), openid_form_alter(), system_clean_url_settings(), system_date_time_settings(), theme_fieldset(), theme_poll_choices(), theme_profile_admin_overview(), theme_table(), theme_table_select_header_cell(), theme_taxonomy_overview_terms(), theme_textarea(), theme_textfield(), user_admin_settings(), user_filter_form(), and user_register().

drupal_add_link ( $ attributes )

Add a <link> tag to the page's HEAD.

Definition at line 1580 of file common.inc.

References $attributes, drupal_attributes(), and drupal_set_html_head().

Referenced by blogapi_init(), drupal_add_feed(), and template_preprocess_book_navigation().

drupal_add_tabledrag | ( | $ | table_id,
 |  | $ | action,
 |  | $ | relationship,
 |  | $ | group,
 |  | $ | subgroup = NULL,
 |  | $ | source = NULL,
 |  | $ | hidden = TRUE,
 |  | $ | limit = 0
 | ) |  |

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:

 $output = theme('table', $header, $rows, array('id' => 'my-module-table'));
 return $output;

In the theme function for the form, a special class must be added to each form element within the same column, "grouping" them together.

In a situation where a single weight column is being sorted in the table, the classes could be added like this (in the theme function):

 $form['my_elements'][$delta]['weight']['#attributes']['class'] = "my-elements-weight";

Each row of the table must also have a class of "draggable" in order to enable the drag handles:

 $row = array(...);
 $rows[] = array(
   'data' => $row,
   'class' => 'draggable',
 );

When tree relationships are present, the two additional classes 'tabledrag-leaf' and 'tabledrag-root' can be used to refine the behavior:

  • Rows with the 'tabledrag-leaf' class cannot have child rows.
  • Rows with the 'tabledrag-root' class cannot be nested under a parent row.

Calling drupal_add_tabledrag() would then be written as such:

 drupal_add_tabledrag('my-module-table', 'order', 'sibling', 'my-elements-weight');

In a more complex case where there are several groups in one column (such as the block regions on the admin/build/block page), a separate subgroup class must also be added to differentiate the groups.

 $form['my_elements'][$region][$delta]['weight']['#attributes']['class'] = "my-elements-weight my-elements-weight-". $region;

$group is still 'my-element-weight', and the additional $subgroup variable will be passed in as 'my-elements-weight-'. $region. This also means that you'll need to call drupal_add_tabledrag() once for every region added.

 foreach ($regions as $region) {
   drupal_add_tabledrag('my-module-table', 'order', 'sibling', 'my-elements-weight', 'my-elements-weight-'. $region);
 }

In a situation where tree relationships are present, adding multiple subgroups is not necessary, because the table will contain indentations that provide enough information about the sibling and parent relationships. See theme_menu_overview_form() for an example creating a table containing parent relationships.

Please note that this function should be called from the theme layer, such as in a .tpl.php file, theme_ function, or in a template_preprocess function, not in a form declartion. Though the same JavaScript could be added to the page using drupal_add_js() directly, this function helps keep template files clean and readable. It also prevents tabledrag.js from being added twice accidentally.

Parameters:
$table_id String containing the target table's id attribute. If the table does not have an id, one will need to be set, such as
$action | String describing the action to be done on the form item. Either 'match' 'depth', or 'order'. Match is typically used for parent relationships. Order is typically used to set weights on other form elements with the same group. Depth updates the target element with the current indentation.
$relationship | String describing where the $action variable should be performed. Either 'parent', 'sibling', 'group', or 'self'. Parent will only look for fields up the tree. Sibling will look for fields in the same group in rows above and below it. Self affects the dragged row itself. Group affects the dragged row, plus any children below it (the entire dragged group).
$group | A class name applied on all related form elements for this action.
$subgroup | (optional) If the group has several subgroups within it, this string should contain the class name identifying fields in the same subgroup.
$source | (optional) If the $action is 'match', this string should contain the class name identifying what field will be used as the source value when matching the value in $subgroup.
$hidden | (optional) The column containing the field elements may be entirely hidden from view dynamically when the JavaScript is loaded. Set to FALSE if the column should not be hidden.
$limit | (optional) Limit the maximum amount of parenting in this table.
See also:
block-admin-display-form.tpl.php

theme_menu_overview_form()

Definition at line 2208 of file common.inc.

References drupal_add_js().

Referenced by theme_book_admin_table(), theme_filter_admin_order(), theme_menu_overview_form(), theme_profile_admin_overview(), theme_taxonomy_overview_terms(), theme_taxonomy_overview_vocabularies(), theme_upload_form_current(), and theme_upload_form_new().

drupal_alter | ( | $ | type,
 |  | &$ | data
 | ) |  |

This dispatch function hands off structured Drupal arrays to type-specific *_alter implementations.

It ensures a consistent interface for all altering operations.

Parameters:
$type | The data type of the structured array. 'form', 'links', 'node_content', and so on are several examples.
$data | The structured array to be altered.
... Any additional params will be passed on to the called hook_$type_alter functions.

Definition at line 2646 of file common.inc.

References $type, and module_implements().

Referenced by _menu_link_translate(), _system_theme_data(), _theme_build_registry(), actions_list(), comment_render(), drupal_get_schema(), drupal_mail(), drupal_prepare_form(), locale_block(), menu_link_save(), menu_router_build(), module_rebuild_cache(), node_view(), poll_choice_js(), taxonomy_link(), update_calculate_project_data(), upload_js(), and user_build_content().

drupal_attributes ( $ attributes = array() )

Format an attribute string to insert in a tag.

Parameters:
$attributes An associative array of HTML attributes.
Returns:
An HTML string ready for insertion in a tag.

Definition at line 1377 of file common.inc.

References $attributes, $value, and check_plain().

Referenced by _theme_table_cell(), drupal_add_link(), format_xml_elements(), l(), node_feed(), template_preprocess_user_profile_category(), template_preprocess_user_profile_item(), theme_button(), theme_checkbox(), theme_fieldset(), theme_file(), theme_form(), theme_hidden(), theme_image(), theme_image_button(), theme_item_list(), theme_links(), theme_password(), theme_radio(), theme_select(), theme_table(), theme_textarea(), and theme_textfield().

drupal_build_css_cache | ( | $ | types,
 |  | $ | filename
 | ) |  |

Aggregate and optimize CSS files, putting them in the files directory.

Parameters:
$types | An array of types of CSS files (e.g., screen, print) to aggregate and compress into one file.
$filename | The name of the aggregate CSS file.
Returns:
The name of the CSS file.

Definition at line 1767 of file common.inc.

References $type, _drupal_build_css_path(), base_path(), drupal_load_stylesheet(), file_check_directory(), file_create_path(), and file_save_data().

Referenced by drupal_get_css().

drupal_build_js_cache | ( | $ | files,
 |  | $ | filename
 | ) |  |

Aggregate JS files, putting them in the files directory.

Parameters:
$files | An array of JS files to aggregate and compress into one file.
$filename | The name of the aggregate JS file.
Returns:
The name of the JS file.

Definition at line 2239 of file common.inc.

References file_check_directory(), file_create_path(), and file_save_data().

Referenced by drupal_get_js().

drupal_clear_css_cache ( )

Delete all cached CSS files.

Definition at line 1897 of file common.inc.

References file_create_path(), and file_scan_directory().

Referenced by drupal_flush_all_caches(), system_modules_submit(), and system_themes_form().

drupal_clear_js_cache ( )

Delete all cached JS files.

Definition at line 2265 of file common.inc.

References file_create_path(), file_scan_directory(), and variable_set().

Referenced by drupal_flush_all_caches(), and system_modules_submit().

drupal_clear_path_cache ( )

Reset the static variable which holds the aliases mapped for this request.

Definition at line 124 of file common.inc.

References drupal_lookup_path().

Referenced by path_set_alias().

drupal_clone ( $ object )

Provide a substitute clone() function for PHP4.

Definition at line 1573 of file common.inc.

Referenced by node_load(), node_preview(), node_unpublish_by_keyword_action(), taxonomy_get_tree(), and theme_node_preview().

drupal_common_theme ( )

Provide theme registration for themes across .inc files.

Definition at line 2827 of file common.inc.

Referenced by system_theme().

drupal_cron_cleanup ( )

Shutdown function for cron cleanup.

Definition at line 2556 of file common.inc.

References variable_del(), variable_get(), and watchdog().

drupal_cron_run ( )

Executes a cron run when called.

Returns:
Returns TRUE if ran successfully

Definition at line 2508 of file common.inc.

References module_invoke_all(), variable_del(), variable_get(), variable_set(), and watchdog().

Referenced by system_run_cron().

drupal_error_handler | ( | $ | errno,
 |  | $ | message,
 |  | $ | filename,
 |  | $ | line,
 |  | $ | context
 | ) |  |

End of "HTTP handling".

Log errors as defined by administrator.

Error levels:

  • 0 = Log errors to database.
  • 1 = Log errors to database and to screen.

Definition at line 573 of file common.inc.

References drupal_set_message(), variable_get(), and watchdog().

drupal_eval ( $ code )

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.

Parameters:
$code The code to evaluate.
Returns:
A string containing the printed output of the code, followed by the returned output of the code.

Definition at line 1520 of file common.inc.

References $conf, $output, $theme_info, $theme_path, and drupal_get_path().

Referenced by block_list(), and php_filter().

drupal_explode_tags ( $ tags )

Explode a string of given tags into an array.

Definition at line 3480 of file common.inc.

References $tag.

Referenced by comment_unpublish_by_keyword_action_submit(), node_unpublish_by_keyword_action_submit(), taxonomy_autocomplete(), taxonomy_link(), and taxonomy_node_save().

drupal_flush_all_caches ( )

Flush all cached data on the site.

Empties cache tables, rebuilds the menu cache and theme registries, and exposes a hook for other modules to clear their own cache data as well.

Definition at line 3523 of file common.inc.

References _drupal_flush_css_js(), cache_clear_all(), drupal_clear_css_cache(), drupal_clear_js_cache(), drupal_rebuild_theme_registry(), menu_rebuild(), module_invoke_all(), and node_types_rebuild().

Referenced by system_clear_cache_submit(), and update_finished().

drupal_get_breadcrumb ( )

Get the breadcrumb trail for the current page.

Definition at line 89 of file common.inc.

References drupal_set_breadcrumb(), and menu_get_active_breadcrumb().

Referenced by aggregator_page_category(), chameleon_page(), and template_preprocess_page().

drupal_get_content | ( | $ | region = NULL,
 |  | $ | delimiter = ' '
 | ) |  |

Get assigned content.

Parameters:
$region | A specified region to fetch content for. If NULL, all regions will be returned.
$delimiter | Content to be inserted between exploded array elements.

Definition at line 53 of file common.inc.

References $content, and drupal_set_content().

Referenced by template_preprocess_maintenance_page(), and theme_blocks().

drupal_get_css ( $ css = NULL )

Returns a themed representation of all stylesheets that should be attached to the page.

It loads the CSS in order, with 'core' CSS first, then 'module' CSS, then 'theme' CSS files. This ensures proper cascading of styles for easy overriding in modules and themes.

Parameters:
$css (optional) An array of CSS files. If no array is provided, the default stylesheets array is used instead.
Returns:
A string of XHTML CSS tags.

Definition at line 1705 of file common.inc.

References $output, $type, base_path(), drupal_add_css(), drupal_build_css_cache(), file_directory_path(), and variable_get().

Referenced by _color_page_alter(), chameleon_page(), template_preprocess_maintenance_page(), and template_preprocess_page().

drupal_get_destination ( )

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.

See also:
drupal_goto()

Definition at line 240 of file common.inc.

References drupal_query_string_encode().

Referenced by _update_no_data(), comment_admin_overview(), hook_translated_menu_link_alter(), node_admin_nodes(), node_form_delete_submit(), openid_authentication(), openid_form_alter(), path_admin_overview(), statistics_top_visitors(), taxonomy_overview_terms(), taxonomy_term_confirm_parents(), template_preprocess_forums(), theme_book_admin_table(), user_admin_account(), user_edit_delete_submit(), and user_login_block().

drupal_get_feeds ( $ delimiter = "\n" )

Get the feed URLs for the current page.

Parameters:
$delimiter A delimiter to split feeds by.

Definition at line 182 of file common.inc.

References drupal_add_feed().

Referenced by chameleon_page(), and template_preprocess_page().

drupal_get_headers ( )

Get the HTTP response headers for the current page.

Definition at line 150 of file common.inc.

References drupal_set_header().

Referenced by page_set_cache().

drupal_get_html_head ( )

Retrieve output to be displayed in the head tag of the HTML page.

Definition at line 116 of file common.inc.

References $output, and drupal_set_html_head().

Referenced by chameleon_page(), template_preprocess_book_export_html(), template_preprocess_maintenance_page(), and template_preprocess_page().

drupal_get_js | ( | $ | scope = 'header',
 |  | $ | javascript = NULL
 | ) |  |

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.

$scope (optional) The scope for which the JavaScript rules should be returned. Defaults to 'header'. $javascript (optional) An array with all JavaScript code. Defaults to the default JavaScript array for the given scope.

Returns:
All JavaScript code segments and includes for the scope as HTML tags.

Definition at line 2031 of file common.inc.

References $output, $type, base_path(), drupal_add_js(), drupal_build_js_cache(), drupal_to_js(), file_directory_path(), locale_update_js_files(), and variable_get().

Referenced by chameleon_page(), template_preprocess_maintenance_page(), template_preprocess_page(), and theme_closure().

drupal_get_path | ( | $ | type,
 |  | $ | name
 | ) |  |

Returns the path to a system item (module, theme, etc.

).

Parameters:
$type | The type of the item (i.e. theme, theme_engine, module).
$name | The name of the item for which the path is requested.
Returns:
The path to the requested item.

Definition at line 1558 of file common.inc.

References $name, $type, and drupal_get_filename().

Referenced by _drupal_maintenance_theme(), _locale_translate_language_list(), _menu_router_build(), _menu_site_is_offline(), _theme_build_registry(), _user_password_dynamic_validation(), aggregator_init(), block_admin_display_form(), book_init(), color_get_info(), color_scheme_form(), color_scheme_form_submit(), comment_form(), comment_render(), dblog_init(), drupal_eval(), forum_init(), help_main(), help_page(), hook_init(), install_tasks(), module_load_include(), node_init(), node_mass_update(), openid_form_alter(), openid_user_identities(), poll_init(), system_clean_url_settings(), system_date_time_settings(), system_init(), theme_color_scheme_form(), theme_profile_admin_overview(), theme_taxonomy_overview_terms(), theme_taxonomy_term_page(), theme_update_report(), tracker_page(), user_admin_settings(), user_init(), and user_menu().

drupal_get_private_key ( )

Ensure the private key variable used to generate tokens is set.

Returns:
The private key.

Definition at line 2364 of file common.inc.

References variable_get(), and variable_set().

Referenced by _update_refresh(), and drupal_get_token().

drupal_get_schema_unprocessed | ( | $ | module,
 |  | $ | table = NULL
 | ) |  |

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().

Parameters:
$module | The module to which the table belongs.
$table | The name of the table. If not given, the module's complete schema is returned.

Definition at line 3151 of file common.inc.

References module_invoke(), and module_load_include().

Referenced by block_schema(), drupal_install_schema(), drupal_uninstall_schema(), filter_schema(), and update_schema().

drupal_get_token ( $ value = '' )

Generate a token based on $value, the current user session and private key.

Parameters:
$value An additional value to base the token on.

Definition at line 2378 of file common.inc.

References $value, and drupal_get_private_key().

Referenced by _batch_page(), batch_process(), and drupal_prepare_form().

drupal_goto | ( | $ | path = '',
 |  | $ | query = NULL,
 |  | $ | fragment = NULL,
 |  | $ | http_response_code = 302
 | ) |  |

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.

Parameters:
$path | A Drupal path or a full URL.
$query | A query string component, if any.
$fragment | A destination fragment identifier (named anchor).
$http_response_code Valid values for an actual "goto" as per RFC 2616 section 10.3 are:
  • 301 Moved Permanently (the recommended value for most redirects)
  • 302 Found (default in Drupal and PHP, sometimes used for spamming search engines)
  • 303 See Other
  • 304 Not Modified
  • 305 Use Proxy
  • 307 Temporary Redirect (alternative to "503 Site Down for Maintenance") Note: Other values are defined by RFC 2616, but are rarely used and poorly supported.
See also:
drupal_get_destination()

Definition at line 296 of file common.inc.

References $url, exit, module_invoke_all(), and url().

Referenced by _batch_finished(), aggregator_admin_refresh_feed(), batch_process(), comment_admin_overview_validate(), comment_multiple_delete_confirm(), comment_reply(), drupal_redirect_form(), filter_admin_delete(), locale_languages_delete_form(), locale_translate_delete(), locale_translate_edit_form(), node_configure_validate(), openid_authentication(), openid_authentication_page(), openid_user_delete(), search_admin_settings_validate(), search_view(), system_actions_configure(), system_actions_remove_orphans(), system_admin_compact_page(), system_goto_action(), system_modules_uninstall_validate(), system_run_cron(), trigger_assign(), trigger_unassign(), trigger_unassign_submit(), update_manual_status(), user_admin_access_add(), user_admin_access_edit(), user_admin_role(), user_login(), user_logout(), user_pass_reset(), and user_register().

drupal_http_request | ( | $ | url,
 |  | $ | headers = array(),
 |  | $ | method = 'GET',
 |  | $ | data = NULL,
 |  | $ | retry = 3
 | ) |  |

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.

Parameters:
$url | A string containing a fully qualified URI.
$headers | An array containing an HTTP header => value pair.
$method | A string defining the HTTP request to use.
$data | A string containing data to include in the request.
$retry | An integer representing how many times to retry the request in case of a redirect.
Returns:
An object containing the HTTP request headers, response code, headers, data and redirect status.

Definition at line 416 of file common.inc.

References $header, $result, $url, $value, module_invoke(), t(), and variable_get().

Referenced by _update_refresh(), _xmlrpc(), aggregator_refresh(), openid_association(), openid_discovery(), openid_verify_assertion(), and system_check_http_request().

drupal_implode_tags ( $ tags )

Implode an array of tags into a string.

Definition at line 3504 of file common.inc.

References $tag.

Referenced by comment_unpublish_by_keyword_action_form(), and node_unpublish_by_keyword_action_form().

drupal_install_schema ( $ module )

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.

Parameters:
$module The module for which the tables will be created.
Returns:
An array of arrays with the following key/value pairs: success: a boolean indicating whether the query succeeded query: the SQL query(s) executed, passed through check_plain()

Definition at line 3091 of file common.inc.

References $name, _drupal_initialize_schema(), db_create_table(), and drupal_get_schema_unprocessed().

Referenced by aggregator_install(), book_install(), contact_install(), dblog_install(), forum_install(), hook_install(), locale_install(), menu_install(), node_access_example_install(), node_example_install(), nodeapi_example_install(), openid_install(), poll_install(), profile_install(), search_install(), statistics_install(), system_install(), trigger_install(), update_install(), and upload_install().

drupal_json ( $ var = NULL )

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.

Parameters:
$var (optional) If set, the variable will be converted to JSON and output.

Definition at line 2319 of file common.inc.

References drupal_set_header(), and drupal_to_js().

Referenced by _batch_do(), book_form_update(), poll_choice_js(), profile_autocomplete(), taxonomy_autocomplete(), and user_autocomplete().

drupal_load_stylesheet | ( | $ | file,
 |  | $ | optimize = NULL
 | ) |  |

Loads the stylesheet and resolves all commands.

Loads a stylesheet and replaces 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.

Parameters:
$file | Name of the stylesheet to be processed.
$optimize | Defines if CSS contents should be compressed or not.
Returns:
Contents of the stylesheet including the imported stylesheets.

Definition at line 1842 of file common.inc.

Referenced by _drupal_load_stylesheet(), color_scheme_form_submit(), and drupal_build_css_cache().

drupal_map_assoc | ( | $ | array,
 |  | $ | function = NULL
 | ) |  |

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.

Parameters:
$array | A linear array.
$function | A name of a function to apply to all values before output.
Returns:
An associative array.

Definition at line 1486 of file common.inc.

References $result, and $value.

Referenced by _comment_per_page(), _filter_htmlcorrector(), aggregator_admin_settings(), aggregator_block(), aggregator_form_feed(), contact_admin_settings(), dblog_admin_settings(), expand_date(), form_type_select_value(), forum_admin_settings(), forum_block(), node_configure(), node_search(), node_type_form(), poll_form(), search_admin_settings(), statistics_access_logging_settings(), statistics_block(), system_performance_settings(), system_rss_feeds_settings(), system_themes_form(), taxonomy_form_term(), update_script_selection_form(), and user_block().

drupal_not_found ( )

Generates a 404 error if the request can not be handled.

Definition at line 341 of file common.inc.

References $return, check_plain(), drupal_get_normal_path(), drupal_set_header(), drupal_set_title(), menu_execute_active_handler(), menu_set_active_item(), t(), theme(), variable_get(), and watchdog().

Referenced by book_export(), file_download(), file_transfer(), filter_admin_delete(), locale_languages_delete_form(), locale_languages_edit_form(), profile_browse(), profile_field_delete(), profile_field_form(), statistics_access_log(), statistics_node_tracker(), statistics_user_tracker(), system_main_admin_page(), taxonomy_admin_term_edit(), and taxonomy_term_page().

drupal_page_footer ( )

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().

Definition at line 1462 of file common.inc.

References module_invoke_all(), page_set_cache(), and variable_get().

drupal_parse_info_file ( $ filename )

End of "ingroup schemaapi".

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.

 *   key = value
 *   key = "value"
 *   key = 'value'
 *   key = "multi-line
 *
 *   value"
 *   key = 'multi-line
 *
 *   value'
 *   key
 *   =
 *   'value'
 *

Arrays are created using a GET-like syntax:

 *   key[] = "numeric array"
 *   key[index] = "associative array"
 *   key[index][] = "nested numeric array"
 *   key[index][index] = "nested associative array"
 *

PHP constants are substituted in, but only when used as the entire value:

Comments should start with a semi-colon at the beginning of a line.

This function is NOT for placing arbitrary module-specific settings. Use variable_get() and variable_set() for that.

Information stored in the module.info file:

  • name: The real name of the module for display purposes.
  • description: A brief description of the module.
  • dependencies: An array of shortnames of other modules this module depends on.
  • package: The name of the package of modules this module belongs to.

Example of .info file:

 *   name = Forum
 *   description = Enables threaded discussions about general topics.
 *   dependencies[] = taxonomy
 *   dependencies[] = comment
 *   package = Core - optional
 *   version = VERSION
 *

Parameters:
$filename The file we are parsing. Accepts file with relative or absolute path.
Returns:
The info array.

Definition at line 3396 of file common.inc.

References $value.

Referenced by _system_theme_data(), help_page(), module_rebuild_cache(), and system_modules_uninstall_confirm_form().

drupal_query_string_encode | ( | $ | query,
 |  | $ | exclude = array(),
 |  | $ | parent = ''
 | ) |  |

Parse an array into a valid urlencoded query string.

Parameters:
$query | The array to be processed e.g. $_GET.
$exclude | The array filled with keys to be excluded. Use parent[child] to exclude nested items.
$parent | Should not be passed, only used in recursive calls.
Returns:
An urlencoded string which can be appended to/as the URL query string.

Definition at line 206 of file common.inc.

References $value, and drupal_urlencode().

Referenced by drupal_get_destination(), pager_get_querystring(), tablesort_get_querystring(), theme_pager_link(), and url().

drupal_render ( &$ elements )

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 a another function, like drupal_get_form() or node_view().

Parameters:
$elements The structured array describing the data to be rendered.
Returns:
The rendered HTML.

Definition at line 2693 of file common.inc.

References $children, $content, _element_info(), element_children(), and theme().

Referenced by _node_index_node(), book_form_update(), book_node_export(), drupal_render_form(), node_search(), node_view(), poll_block(), poll_choice_js(), template_preprocess_block_admin_display_form(), template_preprocess_poll_vote(), template_preprocess_user_profile(), theme_aggregator_categorize_items(), theme_book_admin_table(), theme_color_scheme_form(), theme_comment_admin_overview(), theme_comment_controls(), theme_dblog_filters(), theme_filter_admin_order(), theme_filter_admin_overview(), theme_locale_languages_overview_form(), theme_menu_overview_form(), theme_node_admin_nodes(), theme_node_filter_form(), theme_node_filters(), theme_node_form(), theme_node_search_admin(), theme_poll_choices(), theme_profile_admin_overview(), theme_system_modules(), theme_system_modules_uninstall(), theme_system_theme_select_form(), theme_system_themes_form(), theme_taxonomy_overview_terms(), theme_taxonomy_overview_vocabularies(), theme_trigger_display(), theme_upload_form_current(), theme_upload_form_new(), theme_user_admin_account(), theme_user_admin_new_role(), theme_user_admin_perm(), theme_user_filter_form(), theme_user_filters(), and upload_js().

drupal_schema_fields_sql | ( | $ | table,
 |  | $ | prefix = NULL
 | ) |  |

Retrieve a list of fields from a table schema.

The list is suitable for use in a SQL query.

Parameters:
$table | The name of the table from which to retrieve fields.
An | optional prefix to to all fields.
Returns:
An array of fields.

Definition at line 3195 of file common.inc.

References drupal_get_schema().

Referenced by node_load().

drupal_set_breadcrumb ( $ breadcrumb = NULL )

Set the breadcrumb trail for the current page.

Parameters:
$breadcrumb Array of links, starting with "home" and proceeding up to but not including the current page.

Definition at line 77 of file common.inc.

Referenced by aggregator_page_category(), blog_view(), comment_reply(), drupal_get_breadcrumb(), forum_nodeapi(), taxonomy_term_page(), and template_preprocess_forums().

drupal_set_content | ( | $ | region = NULL,
 |  | $ | data = NULL
 | ) |  |

Set content for a specified region.

Parameters:
$region | Page region the content is assigned to.
$data | Content to be set.

Definition at line 35 of file common.inc.

References $content.

Referenced by drupal_get_content(), install_task_list(), template_preprocess_block_admin_display_form(), and update_task_list().

drupal_set_header ( $ header = NULL )

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).

Definition at line 134 of file common.inc.

References $header.

Referenced by _db_error_page(), _drupal_bootstrap_full(), blogapi_rsd(), drupal_access_denied(), drupal_get_headers(), drupal_json(), drupal_not_found(), drupal_site_offline(), file_transfer(), node_feed(), theme_aggregator_page_opml(), theme_aggregator_page_rss(), theme_install_page(), and theme_update_page().

drupal_set_html_head ( $ data = NULL )

Add output to the head tag of the HTML page.

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

Definition at line 104 of file common.inc.

Referenced by _batch_progress_page_nojs(), chameleon_page(), drupal_add_link(), drupal_get_html_head(), template_preprocess_maintenance_page(), and template_preprocess_page().

drupal_site_offline ( )

Generates a site off-line message.

Definition at line 330 of file common.inc.

References drupal_maintenance_theme(), drupal_set_header(), drupal_set_title(), filter_xss_admin(), t(), theme(), and variable_get().

drupal_system_listing | ( | $ | mask,
 |  | $ | directory,
 |  | $ | key = 'name',
 |  | $ | min_depth = 1
 | ) |  |

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.

Parameters:
$mask | The regular expression of the files to find.
$directory | The subdirectory name in which the files are found. For example, 'modules' will search in both modules/ and sites/somesite/modules/.
$key | The key to be passed to file_scan_directory().
$min_depth | Minimum depth of directories to return files from.
Returns:
An array of file objects of the specified type.

Definition at line 2593 of file common.inc.

References $profile, conf_path(), file_scan_directory(), and variable_get().

Referenced by _system_theme_data(), drupal_find_theme_templates(), drupal_get_install_files(), drupal_verify_profile(), and module_rebuild_cache().

drupal_to_js ( $ var )

Converts a PHP variable into its Javascript equivalent.

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

Definition at line 2275 of file common.inc.

References $output.

Referenced by _locale_rebuild_js(), drupal_get_js(), drupal_json(), profile_admin_settings_autocomplete(), system_date_time_lookup(), and upload_js().

drupal_uninstall_schema ( $ module )

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.

Parameters:
$module The module for which the tables will be removed.
Returns:
An array of arrays with the following key/value pairs: success: a boolean indicating whether the query succeeded query: the SQL query(s) executed, passed through check_plain()

Definition at line 3116 of file common.inc.

References _drupal_initialize_schema(), db_drop_table(), and drupal_get_schema_unprocessed().

Referenced by aggregator_uninstall(), book_uninstall(), contact_uninstall(), dblog_uninstall(), hook_uninstall(), locale_uninstall(), menu_uninstall(), node_access_example_uninstall(), node_example_uninstall(), nodeapi_example_uninstall(), openid_uninstall(), poll_uninstall(), profile_uninstall(), search_uninstall(), statistics_uninstall(), trigger_uninstall(), update_uninstall(), and upload_uninstall().

drupal_urlencode ( $ text )

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.

Parameters:
$text String to encode

Definition at line 2347 of file common.inc.

References variable_get().

Referenced by _update_build_fetch_url(), drupal_query_string_encode(), theme_comment_post_forbidden(), and url().

drupal_valid_token | ( | $ | token,
 |  | $ | value = '',
 |  | $ | skip_anonymous = FALSE
 | ) |  |

Validate a token based on $value, the current user session and private key.

Parameters:
$token | The token to be validated.
$value | An additional value to base the token on.
$skip_anonymous | Set to true to skip token validation for anonymous users.
Returns:
True for a valid token, false for an invalid token. When $skip_anonymous is true, the return value will always be true for anonymous users.

Definition at line 2396 of file common.inc.

References $user, $value, and variable_get().

Referenced by drupal_validate_form().

drupal_write_record | ( | $ | table,
 |  | &$ | object,
 |  | $ | update = array()
 | ) |  |

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.

Parameters:
$table | The name of the table; this must exist in schema API.
$object | The object to write. This is a reference, as defaults according to the schema may be filled in on the object, as well as ID on the serial type(s). Both array an object types may be passed.
$update | If this is an update, specify the primary keys' field names. It is the caller's responsibility to know if a record for this object already exists in the database. If there is only 1 key, you may pass a simple string.
Returns:
Failure to write a record will return FALSE. Otherwise SAVED_NEW or SAVED_UPDATED is returned depending on the operation performed. The $object parameter contains values for any serial fields defined by the $table. For example, $object->nid will be populated after inserting a new node.

Definition at line 3233 of file common.inc.

References $id, $return, db_last_insert_id(), db_query(), db_type_placeholder(), and drupal_get_schema().

Referenced by _block_rehash(), _node_save_revision(), contact_admin_edit_submit(), file_save_upload(), node_save(), taxonomy_save_term(), and taxonomy_save_vocabulary().

element_child ( $ key )

Check if the key is a child.

Definition at line 2813 of file common.inc.

Referenced by theme_locale_languages_overview_form().

element_children ( $ element )

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

Definition at line 2820 of file common.inc.

References $element.

Referenced by _form_validate(), book_admin_edit_submit(), color_form_alter(), drupal_render(), filter_form_validate(), form_builder(), forum_overview(), menu_overview_form(), menu_overview_form_submit(), multipage_form_set_element_visibility(), profile_admin_overview_submit(), system_theme_settings(), taxonomy_term_confirm_parents(), template_preprocess_block_admin_display_form(), template_preprocess_user_profile(), theme_aggregator_categorize_items(), theme_book_admin_table(), theme_color_scheme_form(), theme_comment_admin_overview(), theme_dblog_filters(), theme_filter_admin_order(), theme_menu_overview_form(), theme_multipage_form_example_node_form(), theme_node_admin_nodes(), theme_node_filters(), theme_node_search_admin(), theme_poll_choices(), theme_profile_admin_overview(), theme_system_modules_uninstall(), theme_system_theme_select_form(), theme_system_themes_form(), theme_taxonomy_overview_terms(), theme_taxonomy_overview_vocabularies(), theme_upload_form_current(), theme_user_admin_account(), theme_user_admin_perm(), and theme_user_filters().

element_properties ( $ element )

Get properties of a structured array element.

Properties begin with '#'.

Definition at line 2806 of file common.inc.

References $element.

element_property ( $ key )

Check if the key is a property.

Definition at line 2799 of file common.inc.

element_sort | ( | $ | a,
 |  | $ | b
 | ) |  |

Function used by uasort to sort structured arrays by weight.

Definition at line 2787 of file common.inc.

fix_gpc_magic ( )

Fix double-escaping problems caused by "magic quotes" in some PHP installations.

Definition at line 643 of file common.inc.

Referenced by _drupal_bootstrap_full().

flood_is_allowed | ( | $ | name,
 |  | $ | threshold
 | ) |  |

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.

Parameters:
$name | The name of the event.
$number | The maximum number of the specified event per hour (per visitor).
Returns:
True if the user did not exceed the hourly threshold. False otherwise.

Definition at line 875 of file common.inc.

References $name, db_query(), db_result(), and ip_address().

Referenced by contact_site_page(), and contact_user_page().

flood_register_event ( $ name )

End of "defgroup validation".

Register an event for the current visitor (hostname/IP) to the flood control mechanism.

Parameters:
$name The name of an event.

Definition at line 858 of file common.inc.

References $name, db_query(), and ip_address().

Referenced by contact_mail_page_submit(), and contact_mail_user_submit().

l | ( | $ | text,
 |  | $ | path,
 |  | $ | options = array()
 | ) |  |

Format an internal Drupal link.

This function correctly handles aliased paths, and allows themes to highlight links to the current page correctly, so all internal links output by modules should be generated by this function if possible.

Parameters:
$text | The text to be enclosed with the anchor tag.
$path The Drupal path being linked to, such as "admin/content/node". Can be an external or internal URL.
  • If you provide the full URL, it will be considered an external URL.
  • If you provide only the path (e.g. "admin/content/node"), it is considered an internal link. In this case, it must be a system URL as the url() function will generate the alias.
  • If you provide '<front>', it generates a link to the site's base URL (again via the url() function).
  • If you provide a path, and 'alias' is set to TRUE (see below), it is used as is.
$options | An associative array of additional options, with the following keys: 'attributes' An associative array of HTML attributes to apply to the anchor tag. 'query' A query string to append to the link, or an array of query key/value properties. 'fragment' A fragment identifier (named anchor) to append to the link. Do not include the '#' character. 'absolute' (default FALSE) Whether to force the output to be an absolute link (beginning with http:). Useful for links that will be displayed outside the site, such as in an RSS feed. 'html' (default FALSE) Whether the title is HTML, or just plain-text. For example for making an image a link, this must be set to TRUE, or else you will see the escaped HTML. 'alias' (default FALSE) Whether the given path is an alias already.
Returns:
an HTML string containing a link to the given path.

Definition at line 1430 of file common.inc.

References check_plain(), check_url(), drupal_attributes(), drupal_is_front_page(), and url().

Referenced by _locale_translate_seek(), _menu_overview_tree_form(), _node_mass_update_batch_process(), _statistics_link(), _update_refresh(), _update_requirement_check(), actions_synchronize(), aggregator_form_category_submit(), aggregator_form_feed_submit(), aggregator_page_category(), aggregator_view(), block_admin_display_form(), blog_form(), blog_page_last(), blog_page_user(), blog_user(), blog_view(), blogapi_blogger_edit_post(), blogapi_blogger_new_post(), book_admin_edit_submit(), book_admin_overview(), book_render(), chameleon_comment(), chameleon_node(), chameleon_page(), comment_admin_overview(), comment_admin_overview_submit(), comment_reply(), comment_save(), confirm_form(), contact_admin_categories(), contact_admin_edit_submit(), db_status_report(), dblog_event(), dblog_overview(), fileupload_view(), filter_admin_format_form(), filter_admin_overview(), forum_nodeapi(), forum_overview(), help_links_as_list(), hook_requirements(), locale_update_6005(), menu_edit_item(), menu_get_active_breadcrumb(), node_admin_nodes(), node_feed(), node_form_submit(), node_overview_types(), node_revision_overview(), node_title_list(), node_type_form_submit(), openid_form_alter(), openid_user_identities(), path_admin_overview(), php_install(), poll_page(), profile_admin_overview(), profile_block(), profile_field_delete_submit(), profile_field_form_submit(), profile_view_field(), search_view(), statistics_access_log(), statistics_node_tracker(), statistics_recent_hits(), statistics_top_visitors(), statistics_user_tracker(), system_actions_manage(), system_admin_by_module(), system_get_module_admin_tasks(), system_requirements(), system_themes_form(), tablesort_header(), taxonomy_form_term_submit(), taxonomy_form_vocabulary_submit(), taxonomy_overview_terms(), taxonomy_overview_vocabularies(), taxonomy_term_page(), template_preprocess_aggregator_feed_source(), template_preprocess_aggregator_item(), template_preprocess_comment(), template_preprocess_comment_folded(), template_preprocess_forum_topic_list(), template_preprocess_forums(), template_preprocess_user_picture(), theme_admin_block_content(), theme_admin_page(), theme_aggregator_block_item(), theme_book_admin_table(), theme_book_title_link(), theme_comment_block(), theme_filter_tips_more_info(), theme_links(), theme_locale_languages_overview_form(), theme_menu_item_link(), theme_node_add_list(), theme_pager_link(), theme_system_powered_by(), theme_update_report(), theme_update_version(), theme_upload_attachments(), theme_user_admin_new_role(), theme_username(), tracker_page(), translation_node_overview(), trigger_assign_form(), user_admin_access(), user_admin_account(), user_external_login_register(), user_login_block(), and user_register_submit().

page_set_cache ( )

Store the current page in the cache.

We try to store a gzipped version of the cache. This requires the PHP zlib extension (http://php.net/manual/en/ref.zlib.php). Presence of the extension is checked by testing for the function gzencode. There are two compression algorithms: gzip and deflate. The majority of all modern browsers support gzip or both of them. We thus only deal with the gzip variant and unzip the cache in case the browser does not accept gzip encoding.

See also:
drupal_page_header

Definition at line 2476 of file common.inc.

References $base_root, $user, cache_set(), drupal_get_headers(), page_get_cache(), request_uri(), and variable_get().

Referenced by drupal_page_footer().

t | ( | $ | string,
 |  | $ | args = array(),
 |  | $ | langcode = NULL
 | ) |  |

Translate strings to the page language or a given language.

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

Examples:

   if (!$info || !$info['extension']) {
     form_set_error('picture_upload', t('The uploaded file was not an image.'));
   }

   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Log in'),
   );

Any text within t() can be extracted by translators and changed into the equivalent text in their native language.

Special variables called "placeholders" are used to signal dynamic information in a string which should not be translated. Placeholders can also be used for text that may change from time to time (such as link paths) to be changed without requiring updates to translations.

For example:

   $output = t('There are currently %members and %visitors online.', array(
     '%members' => format_plural($total_users, '1 user', '@count users'),
     '%visitors' => format_plural($guests->count, '1 guest', '@count guests')));

There are three styles of placeholders:

  • !variable, which indicates that the text should be inserted as-is. This is useful for inserting variables into things like e-mail.
         $message[] = t("If you don't want to receive such e-mails, you can change your settings at !url.", array('!url' => url("user/$account->uid", array('absolute' => TRUE))));

  • , which indicates that the text should be run through check_plain, to escape HTML characters. Use this for any output that's displayed within a Drupal page.
         drupal_set_title($title = t("@name's blog", array('@name' => $account->name)));

  • variable, which indicates that the string should be HTML escaped and highlighted with theme_placeholder() which shows up by default as emphasized.
         $message = t('%name-from sent %name-to an e-mail.', array('%name-from' => $user->name, '%name-to' => $account->name));

When using t(), try to put entire sentences and strings in one t() call. This makes it easier for translators, as it provides context as to what each word refers to. HTML markup within translation strings is allowed, but should be avoided if possible. The exception are embedded links; link titles add a context for translators, so should be kept in the main string.

Here is an example of incorrect usage of t():

   $output .= t('<p>Go to the @contact-page.</p>', array('@contact-page' => l(t('contact page'), 'contact')));

Here is an example of t() used correctly:

   $output .= '<p>'. t('Go to the <a href="@contact-page">contact page</a>.', array('@contact-page' => url('contact'))) .'</p>';

Also avoid escaping quotation marks wherever possible.

Incorrect:

   $output .= t('Don\'t click me.');

Correct:

   $output .= t("Don't click me.");

Parameters:
$string | A string containing the English string to translate.
$args An associative array of replacements to make after translation. Incidences of any key in this array are replaced with the corresponding value. Based on the first character of the key, the value is escaped and/or themed:
  • !variable: inserted as is
  • : escape plain text to HTML (check_plain)
  • variable: escape text and theme as a placeholder for user-submitted content (check_plain + theme_placeholder)
$langcode | Optional language code to translate to a language other than what is used to display the page.
Returns:
The translated string.

Definition at line 753 of file common.inc.

References $language, $value, check_plain(), locale(), theme(), and variable_get().

Referenced by _batch_do(), _block_rehash(), _blogapi_validate_blogid(), _book_add_form_elements(), _book_install_type_create(), _book_parent_select(), _comment_form_submit(), _comment_get_modes(), _comment_get_orders(), _dblog_format_message(), _filter_html_settings(), _filter_url_settings(), _forum_parent_select(), _locale_import_parse_plural_forms(), _locale_import_po(), _locale_languages_common_controls(), _locale_prepare_predefined_list(), _locale_rebuild_js(), _locale_translate_seek(), _menu_item_localize(), _menu_overview_tree_form(), _menu_parents_recurse(), _menu_site_is_offline(), _module_build_dependencies(), _node_access_rebuild_batch_finished(), _node_mass_update_batch_finished(), _node_type_set_defaults(), _poll_choice_form(), _profile_field_types(), _profile_form_explanation(), _system_sql(), _update_message_text(), _update_no_data(), _update_requirement_check(), _upload_form(), _user_edit_validate(), _user_mail_text(), _user_password_dynamic_validation(), _xmlrpc(), actions_synchronize(), aggregator_admin_remove_feed(), aggregator_admin_settings(), aggregator_block(), aggregator_categorize_items(), aggregator_categorize_items_submit(), aggregator_categorize_items_validate(), aggregator_form_category(), aggregator_form_category_submit(), aggregator_form_category_validate(), aggregator_form_feed(), aggregator_form_feed_submit(), aggregator_form_feed_validate(), aggregator_help(), aggregator_page_category(), aggregator_page_last(), aggregator_page_sources(), aggregator_parse_feed(), aggregator_refresh(), aggregator_remove(), aggregator_schema(), aggregator_view(), batch_example_batch_2(), block_add_block_form_submit(), block_add_block_form_validate(), block_admin_configure(), block_admin_configure_submit(), block_admin_configure_validate(), block_admin_display_form(), block_admin_display_form_submit(), block_box_delete(), block_box_delete_submit(), block_box_form(), block_example_block(), block_example_contents(), block_help(), block_schema(), block_user(), blog_block(), blog_help(), blog_link(), blog_node_info(), blog_page_last(), blog_page_user(), blog_user(), blog_view(), blogap_mti_publish_post(), blogapi_admin_settings(), blogapi_blogger_edit_post(), blogapi_blogger_new_post(), blogapi_help(), blogapi_init(), blogapi_metaweblog_new_media_object(), blogapi_validate_user(), blogapi_xmlrpc(), book_admin_edit(), book_admin_edit_submit(), book_admin_overview(), book_admin_settings(), book_admin_settings_validate(), book_block(), book_build_active_trail(), book_export(), book_form_alter(), book_form_node_delete_confirm_alter(), book_help(), book_link(), book_outline_form(), book_outline_form_submit(), book_remove_form(), book_remove_form_submit(), book_schema(), chameleon_comment(), chameleon_node(), chameleon_page(), check_markup(), color_form_alter(), color_help(), color_requirements(), color_scheme_form(), color_scheme_form_submit(), comment_action_info(), comment_admin_overview(), comment_admin_overview_submit(), comment_admin_overview_validate(), comment_block(), comment_confirm_delete(), comment_confirm_delete_submit(), comment_controls(), comment_controls_submit(), comment_delete(), comment_form(), comment_form_add_preview(), comment_form_alter(), comment_help(), comment_hook_info(), comment_link(), comment_links(), comment_multiple_delete_confirm(), comment_multiple_delete_confirm_submit(), comment_operations(), comment_render(), comment_reply(), comment_save(), comment_schema(), comment_unpublish_by_keyword_action_form(), comment_validate(), confirm_form(), contact_admin_categories(), contact_admin_delete(), contact_admin_delete_submit(), contact_admin_edit(), contact_admin_edit_submit(), contact_admin_edit_validate(), contact_admin_settings(), contact_help(), contact_mail(), contact_mail_page(), contact_mail_page_submit(), contact_mail_page_validate(), contact_mail_user(), contact_mail_user_submit(), contact_schema(), contact_site_page(), contact_user(), contact_user_page(), date_validate(), dblog_admin_settings(), dblog_event(), dblog_filter_form(), dblog_filter_form_submit(), dblog_filter_form_validate(), dblog_filters(), dblog_help(), dblog_overview(), dblog_schema(), dblog_top(), drupal_access_denied(), drupal_check_module(), drupal_http_request(), drupal_mail(), drupal_not_found(), drupal_site_offline(), drupal_validate_form(), example_element_demo_form(), example_element_phonenumber_expand(), example_element_phonenumber_validate(), expand_password_confirm(), file_check_directory(), file_copy(), file_destination(), file_move(), file_munge_filename(), file_save_data(), file_save_upload(), file_validate_extensions(), file_validate_image_resolution(), file_validate_is_image(), file_validate_name_length(), file_validate_size(), fileupload_form(), fileupload_help(), fileupload_menu(), fileupload_node_info(), fileupload_validate(), filter_admin_configure(), filter_admin_configure_page(), filter_admin_delete(), filter_admin_delete_submit(), filter_admin_format_form(), filter_admin_format_form_submit(), filter_admin_format_form_validate(), filter_admin_format_page(), filter_admin_order(), filter_admin_order_page(), filter_admin_order_submit(), filter_admin_overview(), filter_admin_overview_submit(), filter_example_filter(), filter_example_filter_tips(), filter_filter(), filter_filter_tips(), filter_form(), filter_form_validate(), filter_help(), filter_schema(), format_date(), format_interval(), format_plural(), format_size(), forum_admin_settings(), forum_block(), forum_confirm_delete(), forum_confirm_delete_submit(), forum_enable(), forum_form(), forum_form_alter(), forum_form_container(), forum_form_forum(), forum_form_main(), forum_form_submit(), forum_get_topics(), forum_help(), forum_node_info(), forum_nodeapi(), forum_overview(), forum_schema(), forum_update_6000(), help_help(), help_main(), help_page(), hook_block(), hook_filter(), hook_filter_tips(), hook_form(), hook_form_alter(), hook_help(), hook_link(), hook_mail_alter(), hook_menu(), hook_node_info(), hook_node_operations(), hook_nodeapi(), hook_prepare(), hook_requirements(), hook_search(), hook_user(), hook_user_operations(), hook_validate(), hook_view(), hook_watchdog(), hook_xmlrpc(), image_gd_info(), image_gd_settings(), image_gd_settings_validate(), locale_block(), locale_form_alter(), locale_help(), locale_language_list(), locale_language_name(), locale_languages_configure_form(), locale_languages_configure_form_submit(), locale_languages_custom_form(), locale_languages_delete_form(), locale_languages_delete_form_submit(), locale_languages_edit_form(), locale_languages_edit_form_validate(), locale_languages_overview_form(), locale_languages_overview_form_submit(), locale_languages_predefined_form(), locale_languages_predefined_form_submit(), locale_languages_predefined_form_validate(), locale_locale(), locale_schema(), locale_translate_delete(), locale_translate_edit_form(), locale_translate_edit_form_submit(), locale_translate_export_po_form(), locale_translate_export_pot_form(), locale_translate_import_form(), locale_translate_import_form_submit(), locale_translate_overview_screen(), locale_translate_seek_form(), locale_user(), menu_configure(), menu_delete_menu_confirm(), menu_delete_menu_confirm_submit(), menu_edit_item(), menu_edit_item_submit(), menu_edit_item_validate(), menu_edit_menu(), menu_edit_menu_validate(), menu_form_alter(), menu_help(), menu_item_delete_form(), menu_item_delete_form_submit(), menu_nodeapi(), menu_overview_form(), menu_reset_item_confirm(), menu_reset_item_confirm_submit(), menu_schema(), menu_set_active_trail(), multipage_form_example_custom_validate(), multipage_form_example_form(), multipage_form_example_form_alter(), multipage_form_example_help(), multipage_form_example_menu(), multipage_form_example_node_info(), multipage_form_example_pre_render(), node_access_example_form_alter(), node_access_rebuild(), node_action_info(), node_add(), node_admin_nodes(), node_admin_nodes_validate(), node_assign_owner_action_form(), node_assign_owner_action_validate(), node_block(), node_body_field(), node_configure(), node_configure_rebuild_confirm(), node_configure_validate(), node_delete(), node_delete_confirm(), node_example_form(), node_example_node_info(), node_example_validate(), node_feed(), node_filter_form(), node_filter_form_submit(), node_filters(), node_form(), node_form_alter(), node_form_submit(), node_help(), node_hook_info(), node_link(), node_mass_update(), node_multiple_delete_confirm(), node_multiple_delete_confirm_submit(), node_node_operations(), node_overview_types(), node_page_default(), node_preview(), node_revision_delete_confirm(), node_revision_delete_confirm_submit(), node_revision_overview(), node_revision_revert_confirm(), node_revision_revert_confirm_submit(), node_schema(), node_search(), node_show(), node_teaser_include_verify(), node_type_delete_confirm(), node_type_delete_confirm_submit(), node_type_form(), node_type_form_submit(), node_type_form_validate(), node_unpublish_by_keyword_action_form(), node_validate(), nodeapi_example_form_alter(), nodeapi_example_nodeapi(), openid_authentication(), openid_authentication_page(), openid_begin(), openid_form_alter(), openid_help(), openid_redirect(), openid_redirect_form(), openid_schema(), openid_user(), openid_user_add(), openid_user_add_validate(), openid_user_delete(), openid_user_identities(), page_example_baz(), page_example_foo(), page_example_help(), password_confirm_validate(), path_admin_delete(), path_admin_delete_confirm(), path_admin_filter_form(), path_admin_form(), path_admin_form_submit(), path_admin_form_validate(), path_admin_overview(), path_form_alter(), path_help(), path_nodeapi(), php_disable(), php_filter(), php_filter_tips(), php_help(), php_install(), phptemplate_comment_submitted(), phptemplate_comment_wrapper(), phptemplate_node_submitted(), ping_help(), poll_block(), poll_cancel_form(), poll_form(), poll_help(), poll_node_info(), poll_page(), poll_schema(), poll_validate(), poll_view(), poll_view_voting(), poll_view_voting_validate(), poll_vote(), poll_votes(), profile_admin_overview(), profile_admin_overview_submit(), profile_block(), profile_browse(), profile_field_delete(), profile_field_delete_submit(), profile_field_form(), profile_field_form_submit(), profile_field_form_validate(), profile_help(), profile_schema(), profile_validate_profile(), search_admin_settings(), search_admin_settings_validate(), search_form_submit(), search_schema(), search_view(), search_wipe_confirm(), search_wipe_confirm_submit(), statistics_access_log(), statistics_access_logging_settings(), statistics_block(), statistics_help(), statistics_node_tracker(), statistics_recent_hits(), statistics_schema(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), statistics_user_tracker(), system_action_delete_orphans_post(), system_action_info(), system_actions_configure(), system_actions_configure_submit(), system_actions_delete_form(), system_actions_delete_form_submit(), system_actions_manage(), system_actions_manage_form(), system_admin_by_module(), system_admin_menu_block_page(), system_admin_theme_settings(), system_block(), system_clean_url_settings(), system_date_time_settings(), system_error_reporting_settings(), system_file_system_settings(), system_get_module_admin_tasks(), system_goto_action_form(), system_help(), system_hook_info(), system_image_toolkit_settings(), system_main_admin_page(), system_message_action(), system_message_action_form(), system_modules(), system_modules_confirm_form(), system_modules_submit(), system_modules_uninstall(), system_modules_uninstall_confirm_form(), system_modules_uninstall_submit(), system_modules_uninstall_validate(), system_performance_settings(), system_rss_feeds_settings(), system_run_cron(), system_schema(), system_send_email_action_form(), system_send_email_action_validate(), system_settings_form(), system_settings_form_submit(), system_site_information_settings(), system_site_information_settings_validate(), system_site_maintenance_settings(), system_sql(), system_theme_select_form(), system_theme_settings(), system_theme_settings_submit(), system_themes_form(), system_themes_form_submit(), system_user(), tablesort_header(), taxonomy_add_term_page(), taxonomy_admin_vocabulary_edit(), taxonomy_form(), taxonomy_form_alter(), taxonomy_form_term(), taxonomy_form_term_submit(), taxonomy_form_term_validate(), taxonomy_form_vocabulary(), taxonomy_form_vocabulary_submit(), taxonomy_help(), taxonomy_hook_info(), taxonomy_node_validate(), taxonomy_overview_terms(), taxonomy_overview_terms_submit(), taxonomy_overview_vocabularies(), taxonomy_render_nodes(), taxonomy_schema(), taxonomy_term_confirm_delete(), taxonomy_term_confirm_delete_submit(), taxonomy_term_confirm_parents(), taxonomy_term_page(), taxonomy_vocabulary_confirm_delete(), taxonomy_vocabulary_confirm_delete_submit(), taxonomy_vocabulary_confirm_reset_alphabetical(), taxonomy_vocabulary_confirm_reset_alphabetical_submit(), template_preprocess_aggregator_feed_source(), template_preprocess_aggregator_item(), template_preprocess_aggregator_summary_item(), template_preprocess_block_admin_display_form(), template_preprocess_comment(), template_preprocess_comment_folded(), template_preprocess_forum_topic_list(), template_preprocess_forums(), template_preprocess_user_picture(), theme_admin_page(), theme_aggregator_block_item(), theme_aggregator_categorize_items(), theme_aggregator_page_rss(), theme_book_admin_table(), theme_color_scheme_form(), theme_comment_admin_overview(), theme_comment_block(), theme_comment_controls(), theme_comment_post_forbidden(), theme_comment_submitted(), theme_feed_icon(), theme_filter_admin_order(), theme_filter_admin_overview(), theme_filter_tips(), theme_filter_tips_more_info(), theme_locale_languages_overview_form(), theme_mark(), theme_menu_overview_form(), theme_more_help_link(), theme_more_link(), theme_multipage_form_example(), theme_multipage_form_example_node_form(), theme_node_admin_nodes(), theme_node_example_order_info(), theme_node_filters(), theme_node_log_message(), theme_node_preview(), theme_node_search_admin(), theme_node_submitted(), theme_nodeapi_example_rating(), theme_pager(), theme_pager_link(), theme_poll_choices(), theme_profile_admin_overview(), theme_system_admin_by_module(), theme_system_modules(), theme_system_modules_uninstall(), theme_system_powered_by(), theme_system_theme_select_form(), theme_system_themes_form(), theme_tablesort_indicator(), theme_taxonomy_overview_terms(), theme_taxonomy_overview_vocabularies(), theme_trigger_display(), theme_update_report(), theme_update_version(), theme_upload_attachments(), theme_upload_form_current(), theme_user_admin_account(), theme_user_admin_new_role(), theme_user_admin_perm(), theme_user_filters(), theme_username(), theme_xml_icon(), throttle_admin_settings(), throttle_admin_settings_validate(), throttle_help(), tracker_help(), tracker_page(), translation_form_alter(), translation_help(), translation_node_overview(), trigger_assign_form(), trigger_assign_form_submit(), trigger_assign_form_validate(), trigger_help(), trigger_options(), trigger_schema(), trigger_unassign(), trigger_unassign_submit(), update_calculate_project_data(), update_help(), update_mail(), update_manual_status(), update_process_project_info(), update_requirements(), update_schema(), update_settings(), update_settings_submit(), update_settings_validate(), upload_admin_settings(), upload_admin_settings_validate(), upload_form_alter(), upload_help(), upload_link(), upload_schema(), user_action_info(), user_admin(), user_admin_access(), user_admin_access_add(), user_admin_access_check_submit(), user_admin_access_check_validate(), user_admin_access_delete_confirm(), user_admin_access_delete_confirm_submit(), user_admin_access_edit(), user_admin_access_form(), user_admin_account(), user_admin_account_submit(), user_admin_account_validate(), user_admin_check_host(), user_admin_check_mail(), user_admin_check_user(), user_admin_perm(), user_admin_perm_submit(), user_admin_role(), user_admin_role_submit(), user_admin_role_validate(), user_admin_settings(), user_block(), user_confirm_delete(), user_confirm_delete_submit(), user_edit_form(), user_edit_submit(), user_edit_validate(), user_external_login_register(), user_filter_form(), user_filter_form_submit(), user_filters(), user_help(), user_hook_info(), user_login(), user_login_block(), user_login_final_validate(), user_login_name_validate(), user_multiple_delete_confirm(), user_multiple_delete_confirm_submit(), user_page_title(), user_pass(), user_pass_reset(), user_pass_submit(), user_pass_validate(), user_profile_form(), user_profile_form_submit(), user_profile_form_validate(), user_register(), user_register_submit(), user_roles(), user_schema(), user_search(), user_user(), user_user_operations(), user_validate_mail(), user_validate_name(), user_validate_picture(), watchdog_severity_levels(), xmlrpc_server(), xmlrpc_server_call(), xmlrpc_server_method_signature(), and xmlrpc_server_multicall().

url | ( | $ | path = NULL,
 |  | $ | options = array()
 | ) |  |

End of "defgroup format".

Generate a URL from a Drupal menu path. Will also pass-through existing URLs.

Parameters:
$path | The Drupal path being linked to, such as "admin/content/node", or an existing URL like "http://drupal.org/". The special path '<front>' may also be given and will generate the site's base URL.
$options | An associative array of additional options, with the following keys: 'query' A query string to append to the link, or an array of query key/value properties. 'fragment' A fragment identifier (or named anchor) to append to the link. Do not include the '#' character. 'absolute' (default FALSE) Whether to force the output to be an absolute link (beginning with http:). Useful for links that will be displayed outside the site, such as in an RSS feed. 'alias' (default FALSE) Whether the given path is an alias already. 'external' Whether the given path is an external URL. 'language' An optional language object. Used to build the URL to link to and look up the proper alias for the link. 'base_url' Only used internally, to modify the base URL when a language dependent URL requires so. 'prefix' Only used internally, to modify the path when a language dependent URL requires so.
Returns:
A string containing a URL to the given path.
When creating links in modules, consider whether l() could be a better alternative than url().

Definition at line 1257 of file common.inc.

References $base_url, base_path(), check_plain(), custom_url_rewrite_outbound(), drupal_get_path_alias(), drupal_query_string_encode(), drupal_urlencode(), filter_xss_bad_protocol(), language, language_url_rewrite(), and variable_get().

Referenced by _batch_progress_page_js(), _batch_progress_page_nojs(), _blogapi_get_post(), _update_message_text(), _update_no_data(), _user_edit_validate(), aggregator_admin_settings(), aggregator_block(), aggregator_form_feed(), aggregator_form_feed_validate(), aggregator_help(), aggregator_page_categories(), aggregator_page_category(), aggregator_page_last(), aggregator_page_sources(), batch_process(), block_admin_display_form(), block_box_form(), block_help(), blog_block(), blog_feed_last(), blog_feed_user(), blog_help(), blog_page_last(), blog_page_user(), blogapi_blogger_get_user_info(), blogapi_blogger_get_users_blogs(), blogapi_help(), blogapi_init(), blogapi_rsd(), blogapi_update_6000(), book_help(), chameleon_page(), color_form_alter(), color_help(), comment_form(), comment_form_alter(), comment_help(), comment_nodeapi(), contact_admin_settings(), contact_help(), contact_mail(), contact_mail_page(), contact_user(), contact_user_page(), dblog_admin_settings(), drupal_goto(), file_create_url(), filter_help(), form_expand_ahah(), forum_block(), forum_confirm_delete(), forum_help(), forum_overview(), hook_help(), hook_mail(), hook_ping(), hook_requirements(), hook_search(), install_tasks(), l(), locale_form_alter(), locale_help(), locale_languages_predefined_form_submit(), menu_get_active_help(), menu_help(), node_block(), node_feed(), node_help(), node_page_default(), node_search(), openid_authentication(), openid_authentication_request(), openid_form_alter(), openid_help(), openid_login_validate(), openid_user_add_validate(), path_admin_form(), php_filter_tips(), php_help(), ping_help(), poll_help(), profile_block(), profile_field_delete(), search_admin_settings(), statistics_access_log(), statistics_access_logging_settings(), statistics_help(), statistics_node_tracker(), statistics_top_referrers(), system_check_http_request(), system_date_time_settings(), system_error_reporting_settings(), system_help(), system_mail(), system_main_admin_page(), system_message_action(), system_modules(), system_modules_uninstall(), system_requirements(), system_site_information_settings(), system_site_maintenance_settings(), system_themes_form_submit(), system_update_6017(), system_update_6026(), system_update_6045(), taxonomy_rss_item(), taxonomy_term_page(), template_preprocess_aggregator_feed_source(), template_preprocess_aggregator_item(), template_preprocess_book_navigation(), template_preprocess_forum_list(), template_preprocess_forum_topic_list(), template_preprocess_forum_topic_navigation(), template_preprocess_forums(), template_preprocess_node(), template_preprocess_page(), theme_aggregator_page_opml(), theme_aggregator_page_rss(), theme_comment_post_forbidden(), theme_image(), theme_textfield(), translation_form_alter(), translation_help(), trigger_help(), update_help(), update_mail(), update_settings(), upload_admin_settings(), upload_form_alter(), upload_help(), user_help(), user_login_block(), user_login_final_validate(), user_mail_tokens(), user_pass_reset(), user_pass_reset_url(), user_register_submit(), and user_search().

watchdog_severity_levels ( )

Returns:
Array of the possible severity levels for log messages.
See also:
watchdog

Definition at line 3463 of file common.inc.

References t().

Referenced by dblog_event(), and dblog_filters().

xmlrpc ( $ url )

Performs one or more XML-RPC request(s).

Parameters:
$url An absolute URL of the XML-RPC endpoint. Example: http://www.example.com/xmlrpc.php
... For one request: The method name followed by a variable number of arguments to the method. For multiple requests (system.multicall): An array of call arrays. Each call array follows the pattern of the single request: method name followed by the arguments to the method.
Returns:
For one request: Either the return value of the method on success, or FALSE. If FALSE is returned, see xmlrpc_errno() and xmlrpc_error_msg(). For multiple requests: An array of results. Each result will either be the result returned by the method called, or an xmlrpc_error object if the call failed. See xmlrpc_error().

Definition at line 2423 of file common.inc.

Referenced by ping_ping().

Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/database.inc File Reference

includes

database.inc File Reference

Detailed Description

Wrapper for database interface code.

Definition in file database.inc.

Go to the source code of this file.

Enumerations

  • enum DB_ERROR
    A hash value to check when outputting database errors, md5('DB_ERROR'). More...
  • enum DB_QUERY_REGEXP
    Indicates the place holders that should be replaced in _db_query_callback(). More...

Functions

  • _db_error_page ($error= '')
    Helper function to show fatal database errors.
  • _db_query_callback ($match, $init=FALSE)
    Helper function for db_query().
  • _db_rewrite_sql ($query= '', $primary_table= 'n', $primary_field= 'nid', $args=array())
    Helper function for db_rewrite_sql.
  • db_create_table (&$ret, $name, $table)
    Create a new table from a Drupal table definition.
  • db_escape_table ($string)
    Restrict a dynamic table, column or constraint name to safe characters.
  • db_field_names ($fields)
    Return an array of field names from an array of key/index column specifiers.
  • db_is_active ()
    Returns a boolean depending on the availability of the database.
  • db_placeholders ($arguments, $type= 'int')
    Generate placeholders for an array of query arguments of a single type.
  • db_prefix_tables ($sql)
    Append a database prefix to all tables in a query.
  • db_rewrite_sql ($query, $primary_table= 'n', $primary_field= 'nid', $args=array())
    Rewrites node, taxonomy and comment queries.
  • db_set_active ($name= 'default')
    Activate a database for future queries.
  • db_type_placeholder ($type)
    Given a Schema API field type, return the correct -placeholder.
  • update_sql ($sql)
    Perform an SQL query and return success or failure.

Enumeration Type Documentation

enum DB_ERROR

A hash value to check when outputting database errors, md5('DB_ERROR').

See also:
drupal_error_handler()

Definition at line 14 of file database.inc.

Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/database.mysql-common.inc File Reference

includes

database.mysql-common.inc File Reference

Detailed Description

Functions shared between mysql and mysqli database engines.

Definition in file database.mysql-common.inc.

Go to the source code of this file.

Functions

  • db_query ($query)
    Runs a basic query in the active database.
  • _db_create_field_sql ($name, $spec)
    Create an SQL string for a field to be used in table creation or alteration.
  • _db_create_key_sql ($fields)
  • _db_create_keys_sql ($spec)
  • _db_process_field ($field)
    Set database-engine specific properties for a field.
  • db_add_field (&$ret, $table, $field, $spec, $keys_new=array())
    Add a new field to a table.
  • db_add_index (&$ret, $table, $name, $fields)
    Add an index.
  • db_add_primary_key (&$ret, $table, $fields)
    Add a primary key.
  • db_add_unique_key (&$ret, $table, $name, $fields)
    Add a unique key.
  • db_change_field (&$ret, $table, $field, $field_new, $spec, $keys_new=array())
    Change a field definition.
  • db_create_table_sql ($name, $table)
    Generate SQL to create a new table from a Drupal schema definition.
  • db_drop_field (&$ret, $table, $field)
    Drop a field.
  • db_drop_index (&$ret, $table, $name)
    Drop an index.
  • db_drop_primary_key (&$ret, $table)
    Drop the primary key.
  • db_drop_table (&$ret, $table)
    Drop a table.
  • db_drop_unique_key (&$ret, $table, $name)
    Drop a unique key.
  • db_field_set_default (&$ret, $table, $field, $default)
    Set the default value for a field.
  • db_field_set_no_default (&$ret, $table, $field)
    Set a field to have no default value.
  • db_last_insert_id ($table, $field)
    Returns the last insert id.
  • db_rename_table (&$ret, $table, $new_name)
    Rename a table.
  • db_type_map ()
    This maps a generic data type in combination with its data size to the engine-specific data type.

Function Documentation

_db_create_field_sql | ( | $ | name,
 |  | $ | spec
 | ) |  |

Create an SQL string for a field to be used in table creation or alteration.

Before passing a field out of a schema definition into this function it has to be processed by _db_process_field().

Parameters:
$name | Name of the field.
$spec | The field specification, as per the schema data structure format.

Definition at line 156 of file database.mysql-common.inc.

References $name.

Referenced by db_add_field(), db_change_field(), and db_create_table_sql().

_db_create_key_sql ( $ fields )

Definition at line 107 of file database.mysql-common.inc.

Referenced by _db_create_index_sql(), _db_create_keys_sql(), db_add_index(), db_add_primary_key(), and db_add_unique_key().

_db_create_keys_sql ( $ spec )

Definition at line 87 of file database.mysql-common.inc.

References _db_create_key_sql().

Referenced by db_add_field(), db_change_field(), and db_create_table_sql().

_db_process_field ( $ field )

Set database-engine specific properties for a field.

Parameters:
$field A field description array, as specified in the schema documentation.

Definition at line 126 of file database.mysql-common.inc.

References db_type_map().

Referenced by db_add_field(), db_change_field(), and db_create_table_sql().

db_add_field | ( | &$ | ret,
 |  | $ | table,
 |  | $ | field,
 |  | $ | spec,
 |  | $ | keys_new = array()
 | ) |  |

Add a new field to a table.

Parameters:
$ret | Array to which query results will be added.
$table | Name of the table to be altered.
$field | Name of the field to be added.
$spec | The field specification array, as taken from a schema definition. The specification may also contain the key 'initial', the newly created field will be set to the value of the key in all rows. This is most useful for creating NOT NULL columns with no default value in existing tables.
$keys_new | Optional keys and indexes specification to be created on the table along with adding the field. The format is the same as a table specification but without the 'fields' element. If you are adding a type 'serial' field, you MUST specify at least one key or index including it in this array.
See also:
db_change_field for more explanation why.

Definition at line 287 of file database.mysql-common.inc.

References $result, _db_create_field_sql(), _db_create_keys_sql(), _db_process_field(), check_plain(), db_change_field(), db_query(), db_type_placeholder(), and update_sql().

Referenced by db_change_field(), hook_update_N(), system_update_6001(), system_update_6010(), system_update_6021(), system_update_6022(), system_update_6024(), system_update_6027(), system_update_6036(), system_update_6040(), and update_fix_d6_requirements().

db_add_index | ( | &$ | ret,
 |  | $ | table,
 |  | $ | name,
 |  | $ | fields
 | ) |  |

Add an index.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.
$name | The name of the index.
$fields | An array of field names.

Definition at line 432 of file database.mysql-common.inc.

References $name, _db_create_key_sql(), and update_sql().

Referenced by _db_create_keys(), comment_update_6003(), locale_update_6004(), system_update_1022(), system_update_6001(), system_update_6003(), system_update_6019(), system_update_6022(), system_update_6023(), system_update_6024(), system_update_6025(), system_update_6035(), system_update_6043(), and system_update_6044().

db_add_primary_key | ( | &$ | ret,
 |  | $ | table,
 |  | $ | fields
 | ) |  |

Add a primary key.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.
$fields | Fields for the primary key.

Definition at line 372 of file database.mysql-common.inc.

References _db_create_key_sql(), and update_sql().

Referenced by _db_create_keys(), system_update_6001(), system_update_6002(), system_update_6019(), system_update_6022(), system_update_6033(), and system_update_6043().

db_add_unique_key | ( | &$ | ret,
 |  | $ | table,
 |  | $ | name,
 |  | $ | fields
 | ) |  |

Add a unique key.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.
$name | The name of the key.
$fields | An array of field names.

Definition at line 401 of file database.mysql-common.inc.

References $name, _db_create_key_sql(), and update_sql().

Referenced by _db_create_keys(), system_update_6019(), system_update_6032(), system_update_6036(), and system_update_6043().

db_change_field | ( | &$ | ret,
 |  | $ | table,
 |  | $ | field,
 |  | $ | field_new,
 |  | $ | spec,
 |  | $ | keys_new = array()
 | ) |  |

Change a field definition.

IMPORTANT NOTE: To maintain database portability, you have to explicitly recreate all indices and primary keys that are using the changed field.

That means that you have to drop all affected keys and indexes with db_drop_{primary_key,unique_key,index}() before calling db_change_field(). To recreate the keys and indices, pass the key definitions as the optional $keys_new argument directly to db_change_field().

For example, suppose you have:

 $schema['foo'] = array(
   'fields' => array(
     'bar' => array('type' => 'int', 'not null' => TRUE)
   ),
   'primary key' => array('bar')
 );
and you want to change foo.bar to be type serial, leaving it as the primary key. The correct sequence is:
 db_drop_primary_key($ret, 'foo');
 db_change_field($ret, 'foo', 'bar', 'bar',
   array('type' => 'serial', 'not null' => TRUE),
   array('primary key' => array('bar')));

The reasons for this are due to the different database engines:

On PostgreSQL, changing a field definition involves adding a new field and dropping an old one which* causes any indices, primary keys and sequences (from serial-type fields) that use the changed field to be dropped.

On MySQL, all type 'serial' fields must be part of at least one key or index as soon as they are created. You cannot use db_add_{primary_key,unique_key,index}() for this purpose because the ALTER TABLE command will fail to add the column without a key or index specification. The solution is to use the optional $keys_new argument to create the key or index at the same time as field.

You could use db_add_{primary_key,unique_key,index}() in all cases unless you are converting a field to be type serial. You can use the $keys_new argument in all cases.

Parameters:
$ret | Array to which query results will be added.
$table | Name of the table.
$field | Name of the field to change.
$field_new | New name for the field (set to the same as $field if you don't want to change the name).
$spec | The field specification for the new field.
$keys_new | Optional keys and indexes specification to be created on the table along with changing the field. The format is the same as a table specification but without the 'fields' element.

Definition at line 514 of file database.mysql-common.inc.

References _db_create_field_sql(), _db_create_keys_sql(), _db_process_field(), and update_sql().

Referenced by db_add_field(), system_update_6002(), system_update_6019(), system_update_6022(), system_update_6023(), system_update_6025(), system_update_6032(), system_update_6033(), system_update_6037(), and system_update_6043().

db_drop_field | ( | &$ | ret,
 |  | $ | table,
 |  | $ | field
 | ) |  |

Drop a field.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.
$field | The field to be dropped.

Definition at line 321 of file database.mysql-common.inc.

References update_sql().

Referenced by db_change_field(), locale_update_6001(), system_update_6008(), and system_update_6036().

db_drop_index | ( | &$ | ret,
 |  | $ | table,
 |  | $ | name
 | ) |  |

Drop an index.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.
$name | The name of the index.

Definition at line 447 of file database.mysql-common.inc.

References $name, and update_sql().

Referenced by locale_update_6004(), system_update_6019(), system_update_6022(), system_update_6023(), system_update_6025(), system_update_6035(), system_update_6036(), and system_update_6043().

db_drop_primary_key | ( | &$ | ret,
 |  | $ | table
 | ) |  |

Drop the primary key.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.

Definition at line 385 of file database.mysql-common.inc.

References update_sql().

Referenced by system_update_6001(), system_update_6002(), system_update_6019(), system_update_6022(), and system_update_6043().

db_drop_table | ( | &$ | ret,
 |  | $ | table
 | ) |  |

Drop a table.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be dropped.

Definition at line 260 of file database.mysql-common.inc.

References update_sql().

Referenced by drupal_uninstall_schema().

db_drop_unique_key | ( | &$ | ret,
 |  | $ | table,
 |  | $ | name
 | ) |  |

Drop a unique key.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.
$name | The name of the key.

Definition at line 416 of file database.mysql-common.inc.

References $name, and update_sql().

Referenced by system_update_6005(), system_update_6019(), system_update_6032(), system_update_6043(), and system_update_6044().

db_field_set_default | ( | &$ | ret,
 |  | $ | table,
 |  | $ | field,
 |  | $ | default
 | ) |  |

Set the default value for a field.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.
$field | The field to be altered.
$default | Default value to be set. NULL for 'default NULL'.

Definition at line 337 of file database.mysql-common.inc.

References update_sql().

db_field_set_no_default | ( | &$ | ret,
 |  | $ | table,
 |  | $ | field
 | ) |  |

Set a field to have no default value.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.
$field | The field to be altered.

Definition at line 358 of file database.mysql-common.inc.

References update_sql().

Referenced by system_update_6019().

db_last_insert_id | ( | $ | table,
 |  | $ | field
 | ) |  |

Returns the last insert id.

Parameters:
$table | The name of the table you inserted into.
$field | The name of the autoincrement field.

Definition at line 531 of file database.mysql-common.inc.

References db_query(), and db_result().

Referenced by actions_save(), aggregator_save_category(), aggregator_save_feed(), aggregator_save_item(), batch_process(), block_add_block_form_submit(), comment_save(), drupal_write_record(), menu_link_save(), user_admin_access_add(), and user_save().

db_query ( $ query )

Runs a basic query in the active database.

User-supplied arguments to the query should be passed in as separate parameters so that they can be properly escaped to avoid SQL injection attacks.

Parameters:
$query A string containing an SQL query.
... A variable number of arguments which are substituted into the query using printf() syntax. Instead of a variable number of query arguments, you may also pass a single array containing the query arguments.
Valid -modifiers are: s, d, f, b (binary data, do not enclose in '') and %%.

NOTE: using this syntax will cast NULL and FALSE values to decimal 0, and TRUE values to decimal 1.

Returns:
A database query result resource, or FALSE if the query was not executed correctly.

Definition at line 33 of file database.mysql-common.inc.

References _db_query(), _db_query_callback(), and db_prefix_tables().

Referenced by _aggregator_has_categories(), _batch_finished(), _batch_page(), _batch_shutdown(), _block_rehash(), _book_update_outline(), _comment_delete_thread(), _comment_load(), _comment_update_node_statistics(), _dblog_get_message_types(), _filter_tips(), _forum_topics_unread(), _forum_user_last_visit(), _locale_export_get_strings(), _locale_import_one_string(), _locale_import_one_string_db(), _locale_import_po(), _locale_parse_js_file(), _locale_rebuild_js(), _menu_delete_item(), _menu_link_move_children(), _menu_navigation_links_rebuild(), _menu_router_build(), _menu_set_expanded_menus(), _menu_update_parental_status(), _node_access_rebuild_batch_operation(), _node_revision_access(), _node_types_build(), _profile_get_fields(), _taxonomy_term_children(), _trigger_get_hook_actions(), _trigger_get_hook_aids(), _user_edit_validate(), actions_delete(), actions_do(), actions_function_lookup(), actions_get_all_actions(), actions_load(), actions_save(), actions_synchronize(), aggregator_block(), aggregator_categorize_items(), aggregator_categorize_items_submit(), aggregator_category_load(), aggregator_cron(), aggregator_feed_items_load(), aggregator_feed_load(), aggregator_form_category_validate(), aggregator_form_feed(), aggregator_form_feed_validate(), aggregator_page_categories(), aggregator_page_opml(), aggregator_page_rss(), aggregator_page_sources(), aggregator_parse_feed(), aggregator_refresh(), aggregator_remove(), aggregator_save_category(), aggregator_save_feed(), aggregator_save_item(), aggregator_view(), batch_example_op_2(), batch_process(), batch_test_update_1(), block_add_block_form_submit(), block_add_block_form_validate(), block_admin_configure(), block_admin_configure_submit(), block_admin_configure_validate(), block_admin_display_form_submit(), block_block(), block_box_delete_submit(), block_box_get(), block_box_save(), block_list(), block_user(), blog_form(), book_block(), book_get_books(), book_link_load(), book_menu_subtree_data(), book_nodeapi(), book_remove_form_submit(), book_uninstall(), book_update_6000(), book_update_bid(), cache_clear_all(), cache_get(), cache_set(), comment_admin_overview_submit(), comment_delete(), comment_edit(), comment_enable(), comment_form_add_preview(), comment_multiple_delete_confirm(), comment_new_page_count(), comment_nodeapi(), comment_num_all(), comment_num_new(), comment_num_replies(), comment_render(), comment_reply(), comment_save(), comment_unpublish_action(), comment_unpublish_by_keyword_action(), comment_update_1(), comment_user(), comment_validate(), contact_admin_categories(), contact_admin_delete_submit(), contact_admin_edit_submit(), contact_load(), contact_mail_page(), db_add_field(), db_check_setup(), db_column_exists(), db_last_insert_id(), db_lock_table(), db_table_exists(), db_unlock_tables(), db_version(), dblog_cron(), dblog_event(), dblog_user(), dblog_watchdog(), drupal_get_filename(), drupal_get_installed_schema_version(), drupal_install_system(), drupal_lookup_path(), drupal_set_installed_schema_version(), drupal_uninstall_module(), drupal_write_record(), file_set_status(), file_space_used(), fileupload_delete(), fileupload_file_download(), fileupload_insert(), fileupload_load(), fileupload_update(), filter_admin_delete(), filter_admin_delete_submit(), filter_admin_format_form_submit(), filter_admin_format_form_validate(), filter_admin_order_submit(), filter_format_allowcache(), filter_formats(), filter_list_format(), flood_is_allowed(), flood_register_event(), forum_get_forums(), forum_install(), forum_load(), forum_nodeapi(), forum_taxonomy(), forum_term_load(), forum_uninstall(), hook_cron(), hook_delete(), hook_exit(), hook_file_download(), hook_insert(), hook_load(), hook_update(), install_verify_drupal(), language_list(), list_themes(), locale(), locale_add_language(), locale_batch_by_component(), locale_batch_by_language(), locale_install(), locale_languages_delete_form_submit(), locale_languages_edit_form(), locale_languages_edit_form_submit(), locale_languages_edit_form_validate(), locale_languages_overview_form_submit(), locale_languages_predefined_form_validate(), locale_translate_delete(), locale_translate_edit_form(), locale_translate_edit_form_submit(), locale_translate_overview_screen(), locale_uninstall(), locale_update_6000(), locale_update_6005(), menu_delete_menu_confirm(), menu_delete_menu_confirm_submit(), menu_edit_menu_submit(), menu_edit_menu_validate(), menu_enable(), menu_get_menus(), menu_get_names(), menu_install(), menu_link_delete(), menu_link_load(), menu_link_maintain(), menu_link_save(), menu_load(), menu_local_tasks(), menu_nodeapi(), menu_overview_form(), menu_overview_page(), menu_router_build(), menu_tree_all_data(), menu_tree_check_access(), menu_tree_page_data(), menu_valid_path(), module_disable(), module_enable(), module_list(), module_rebuild_cache(), multipage_form_example_custom_submit(), node_access(), node_access_example_nodeapi(), node_access_rebuild(), node_access_view_all_nodes(), node_access_write_grants(), node_admin_nodes(), node_assign_owner_action(), node_assign_owner_action_form(), node_assign_owner_action_submit(), node_assign_owner_action_validate(), node_comment_mode(), node_configure(), node_cron(), node_delete(), node_example_delete(), node_example_insert(), node_example_load(), node_example_nodeapi(), node_example_update(), node_last_changed(), node_last_viewed(), node_load(), node_multiple_delete_confirm(), node_revision_delete_confirm_submit(), node_revision_list(), node_save(), node_search(), node_tag_new(), node_type_delete(), node_type_delete_confirm(), node_type_save(), node_type_update_nodes(), node_update_index(), node_user(), nodeapi_example_nodeapi(), openid_association(), openid_user_add_validate(), openid_user_delete(), openid_user_identities(), openid_verify_assertion(), pager_query(), path_admin_delete(), path_admin_form_validate(), path_admin_overview(), path_form_alter(), path_load(), path_nodeapi(), path_set_alias(), php_install(), ping_cron(), poll_block(), poll_cancel(), poll_cron(), poll_delete(), poll_insert(), poll_load(), poll_update(), poll_user(), poll_vote(), profile_admin_overview(), profile_admin_overview_submit(), profile_autocomplete(), profile_block(), profile_browse(), profile_categories(), profile_category_access(), profile_field_delete(), profile_field_delete_submit(), profile_field_form(), profile_field_form_submit(), profile_field_form_validate(), profile_load_profile(), profile_save_profile(), profile_user(), profile_view_profile(), sess_count(), sess_destroy_sid(), sess_destroy_uid(), sess_gc(), sess_read(), sess_regenerate(), sess_write(), statistics_access_log(), statistics_cron(), statistics_exit(), statistics_get(), statistics_nodeapi(), statistics_user(), system_actions_configure(), system_actions_manage(), system_admin_menu_block(), system_admin_theme_submit(), system_cron(), system_get_files_database(), system_get_module_admin_tasks(), system_initialize_theme_blocks(), system_install(), system_main_admin_page(), system_modules_submit(), system_modules_uninstall(), system_region_list(), system_sql(), system_status(), system_theme_data(), system_themes_form_submit(), system_update_6000(), system_update_6001(), system_update_6009(), system_update_6018(), system_update_6019(), system_update_6021(), system_update_6027(), system_update_6034(), system_update_6036(), system_update_6039(), system_update_6041(), system_update_6045(), taxonomy_del_term(), taxonomy_del_vocabulary(), taxonomy_form_alter(), taxonomy_get_children(), taxonomy_get_parents(), taxonomy_get_related(), taxonomy_get_synonym_root(), taxonomy_get_synonyms(), taxonomy_get_term(), taxonomy_get_term_by_name(), taxonomy_get_tree(), taxonomy_get_vocabularies(), taxonomy_node_delete(), taxonomy_node_delete_revision(), taxonomy_node_get_terms(), taxonomy_node_get_terms_by_vocabulary(), taxonomy_node_save(), taxonomy_node_type(), taxonomy_overview_terms(), taxonomy_save_term(), taxonomy_save_vocabulary(), taxonomy_term_count_nodes(), taxonomy_term_page(), taxonomy_vocabulary_confirm_reset_alphabetical_submit(), taxonomy_vocabulary_load(), template_preprocess_forum_topic_navigation(), translation_node_get_translations(), translation_nodeapi(), translation_remove_from_set(), trigger_actions_delete(), trigger_assign_form_submit(), trigger_assign_form_validate(), trigger_menu(), trigger_unassign_submit(), update_fix_compatibility(), update_sql(), upload_delete(), upload_delete_revision(), upload_file_download(), upload_load(), upload_save(), upload_total_space_used(), user_access(), user_admin_access(), user_admin_access_add(), user_admin_access_delete_confirm(), user_admin_access_delete_confirm_submit(), user_admin_access_edit(), user_admin_account(), user_admin_perm(), user_admin_perm_submit(), user_admin_role(), user_admin_role_submit(), user_admin_role_validate(), user_authenticate_finalize(), user_block(), user_block_ip_action(), user_block_user_action(), user_delete(), user_external_load(), user_fields(), user_get_authmaps(), user_is_blocked(), user_load(), user_multiple_delete_confirm(), user_multiple_role_edit(), user_roles(), user_save(), user_set_authmaps(), variable_del(), variable_init(), and variable_set().

db_rename_table | ( | &$ | ret,
 |  | $ | table,
 |  | $ | new_name
 | ) |  |

Rename a table.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be renamed.
$new_name | The new name for the table.

Definition at line 248 of file database.mysql-common.inc.

References update_sql().

Referenced by system_update_6022(), and system_update_6030().

db_type_map ( )

This maps a generic data type in combination with its data size to the engine-specific data type.

Definition at line 196 of file database.mysql-common.inc.

Referenced by _db_process_field().

Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/database.mysql.inc File Reference

includes

database.mysql.inc File Reference

Detailed Description

Database interface code for MySQL database servers.

Definition in file database.mysql.inc.

Go to the source code of this file.

Functions

  • _db_query ($query, $debug=0)
    Helper function for db_query().
  • db_affected_rows ()
    Determine the number of rows changed by the preceding query.
  • db_column_exists ($table, $column)
    Check if a column exists in the given table.
  • db_connect ($url)
    Initialize a database connection.
  • db_decode_blob ($data)
    Returns text from a Binary Large Object value.
  • db_distinct_field ($table, $field, $query)
    Wraps the given table.field entry with a DISTINCT().
  • db_encode_blob ($data)
    Returns a properly formatted Binary Large OBject value.
  • db_error ()
    Determine whether the previous query caused an error.
  • db_escape_string ($text)
    Prepare user input for use in a database query, preventing SQL injection attacks.
  • db_fetch_array ($result)
    Fetch one result row from the previous query as an array.
  • db_fetch_object ($result)
    Fetch one result row from the previous query as an object.
  • db_lock_table ($table)
    Lock a table.
  • db_query_range ($query)
    Runs a limited-range query in the active database.
  • db_query_temporary ($query)
    Runs a SELECT query and stores its results in a temporary table.
  • db_result ($result)
    Return an individual result field from the previous query.
  • db_status_report ($phase)
    Report database status.
  • db_table_exists ($table)
    Check if a table exists.
  • db_unlock_tables ()
    Unlock all locked tables.
  • db_version ()
    Returns the version of the database server currently in use.

Function Documentation

_db_query | ( | $ | query,
 |  | $ | debug = 0
 | ) |  |

Helper function for db_query().

Definition at line 91 of file database.mysql.inc.

References $active_db, $name, $queries, $result, $user, check_plain(), and variable_get().

Referenced by db_query(), db_query_range(), and db_query_temporary().

db_affected_rows ( )

Determine the number of rows changed by the preceding query.

Definition at line 196 of file database.mysql.inc.

References $active_db.

Referenced by cache_set(), node_type_update_nodes(), openid_user_delete(), statistics_exit(), system_update_6038(), user_set_authmaps(), and variable_set().

db_column_exists | ( | $ | table,
 |  | $ | column
 | ) |  |

Check if a column exists in the given table.

Definition at line 348 of file database.mysql.inc.

References db_escape_table(), db_fetch_object(), and db_query().

db_connect ( $ url )

Initialize a database connection.

Definition at line 51 of file database.mysql.inc.

References $url, and _db_error_page().

Referenced by db_set_active().

db_decode_blob ( $ data )

Returns text from a Binary Large Object value.

Parameters:
$data Data to decode.
Returns:
Decoded data.

Definition at line 312 of file database.mysql.inc.

Referenced by cache_get().

db_distinct_field | ( | $ | table,
 |  | $ | field,
 |  | $ | query
 | ) |  |

Wraps the given table.field entry with a DISTINCT().

The wrapper is added to the SELECT list entry of the given query and the resulting query is returned. This function only applies the wrapper if a DISTINCT doesn't already exist in the query.

Parameters:
$table | Table containing the field to set as DISTINCT
$field | Field to set as DISTINCT
$query | Query to apply the wrapper to
Returns:
SQL query with the DISTINCT wrapper surrounding the given table.field.

Definition at line 363 of file database.mysql.inc.

Referenced by db_rewrite_sql().

db_encode_blob ( $ data )

Returns a properly formatted Binary Large OBject value.

Parameters:
$data Data to encode.
Returns:
Encoded data.

Definition at line 299 of file database.mysql.inc.

References $active_db.

Referenced by _db_query_callback().

db_error ( )

Determine whether the previous query caused an error.

Definition at line 188 of file database.mysql.inc.

References $active_db.

db_escape_string ( $ text )

Prepare user input for use in a database query, preventing SQL injection attacks.

Definition at line 319 of file database.mysql.inc.

References $active_db.

Referenced by _db_query_callback(), and node_load().

db_fetch_array ( $ result )

Fetch one result row from the previous query as an array.

Parameters:
$result A database query result resource, as returned from db_query().
Returns:
An associative array representing the next row of the result, or FALSE. The keys of this object are the names of the table fields selected by the query, and the values are the field values for this result row.

Definition at line 158 of file database.mysql.inc.

References $result.

Referenced by _block_rehash(), _book_update_outline(), _menu_delete_item(), _menu_navigation_links_rebuild(), _menu_set_expanded_menus(), _menu_tree_data(), _node_access_rebuild_batch_operation(), aggregator_category_load(), aggregator_cron(), aggregator_feed_load(), batch_example_op_2(), batch_test_update_1(), block_admin_configure(), block_box_get(), book_get_books(), book_link_load(), book_nodeapi(), book_update_6000(), book_update_bid(), comment_nodeapi(), contact_load(), drupal_uninstall_module(), forum_nodeapi(), forum_term_load(), hook_cron(), menu_delete_menu_confirm_submit(), menu_edit_menu_submit(), menu_enable(), menu_get_item(), menu_get_menus(), menu_get_names(), menu_link_delete(), menu_link_load(), menu_link_save(), menu_load(), menu_local_tasks(), menu_nodeapi(), menu_overview_page(), menu_tree_check_access(), menu_tree_page_data(), menu_valid_path(), path_load(), poll_load(), profile_field_form(), statistics_get(), system_admin_menu_block(), system_get_module_admin_tasks(), system_initialize_theme_blocks(), system_main_admin_page(), system_update_6021(), taxonomy_get_synonyms(), user_admin_access_edit(), user_external_load(), and user_fields().

db_fetch_object ( $ result )

Fetch one result row from the previous query as an object.

Parameters:
$result A database query result resource, as returned from db_query().
Returns:
An object representing the next row of the result, or FALSE. The attributes of this object are the table fields selected by the query.

Definition at line 142 of file database.mysql.inc.

References $result.

Referenced by _comment_delete_thread(), _comment_load(), _comment_update_node_statistics(), _dblog_get_message_types(), _filter_tips(), _forum_user_last_visit(), _locale_export_get_strings(), _locale_import_po(), _locale_parse_js_file(), _locale_rebuild_js(), _locale_translate_seek(), _node_types_build(), _taxonomy_term_children(), _trigger_get_hook_actions(), _trigger_get_hook_aids(), actions_do(), actions_get_all_actions(), actions_load(), actions_synchronize(), aggregator_block(), aggregator_categorize_items(), aggregator_feed_items_load(), aggregator_form_category_validate(), aggregator_form_feed(), aggregator_form_feed_validate(), aggregator_page_categories(), aggregator_page_opml(), aggregator_page_rss(), aggregator_page_sources(), aggregator_parse_feed(), aggregator_remove(), aggregator_save_feed(), aggregator_save_item(), aggregator_view(), block_admin_configure(), block_block(), block_list(), block_user(), blog_feed_last(), blog_feed_user(), blog_form(), blog_page_last(), blog_page_user(), blogapi_blogger_get_recent_posts(), book_update_6000(), cache_get(), comment_admin_overview(), comment_delete(), comment_edit(), comment_form_add_preview(), comment_get_recent(), comment_nodeapi(), comment_render(), comment_reply(), contact_admin_categories(), contact_mail_page(), db_column_exists(), db_table_exists(), dblog_event(), dblog_overview(), dblog_top(), drupal_get_installed_schema_version(), fileupload_load(), filter_admin_delete(), filter_admin_format_form_validate(), filter_formats(), filter_list_format(), forum_get_forums(), forum_get_topics(), forum_load(), forum_taxonomy(), hook_load(), hook_update_index(), language_list(), list_themes(), locale(), locale_batch_by_component(), locale_batch_by_language(), locale_languages_edit_form(), locale_languages_edit_form_validate(), locale_translate_edit_form(), locale_translate_overview_screen(), locale_uninstall(), locale_update_6000(), module_enable(), module_list(), node_access_example_nodeapi(), node_access_rebuild(), node_admin_nodes(), node_assign_owner_action_form(), node_example_load(), node_feed(), node_last_changed(), node_last_viewed(), node_load(), node_page_default(), node_revision_list(), node_title_list(), node_update_index(), openid_user_identities(), openid_verify_assertion(), path_admin_overview(), poll_cron(), poll_load(), poll_page(), poll_votes(), profile_admin_overview(), profile_admin_settings_autocomplete(), profile_autocomplete(), profile_block(), profile_browse(), profile_categories(), profile_field_delete(), profile_form_profile(), profile_load_profile(), profile_save_profile(), profile_validate_profile(), profile_view_profile(), sess_read(), statistics_access_log(), statistics_node_tracker(), statistics_recent_hits(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), statistics_user_tracker(), system_actions_configure(), system_actions_manage(), system_cron(), system_get_files_database(), system_modules_uninstall(), system_sql(), system_update_6018(), system_update_6034(), system_update_6039(), system_update_6045(), taxonomy_autocomplete(), taxonomy_del_vocabulary(), taxonomy_form_alter(), taxonomy_get_children(), taxonomy_get_parents(), taxonomy_get_related(), taxonomy_get_synonym_root(), taxonomy_get_term(), taxonomy_get_term_by_name(), taxonomy_get_tree(), taxonomy_get_vocabularies(), taxonomy_node_get_terms(), taxonomy_node_get_terms_by_vocabulary(), taxonomy_overview_terms(), taxonomy_render_nodes(), taxonomy_term_count_nodes(), taxonomy_term_page(), taxonomy_vocabulary_load(), template_preprocess_forum_topic_navigation(), tracker_page(), translation_node_get_translations(), update_fix_compatibility(), upload_delete(), upload_file_download(), upload_load(), user_access(), user_admin_access(), user_admin_access_delete_confirm(), user_admin_account(), user_admin_perm(), user_admin_perm_submit(), user_admin_role(), user_autocomplete(), user_block(), user_get_authmaps(), user_is_blocked(), user_load(), user_roles(), user_search(), and variable_init().

db_lock_table ( $ table )

Lock a table.

Definition at line 327 of file database.mysql.inc.

References db_escape_table(), and db_query().

db_query_range ( $ query )

Runs a limited-range query in the active database.

Use this as a substitute for db_query() when a subset of the query is to be returned. User-supplied arguments to the query should be passed in as separate parameters so that they can be properly escaped to avoid SQL injection attacks.

Parameters:
$query A string containing an SQL query.
... A variable number of arguments which are substituted into the query using printf() syntax. The query arguments can be enclosed in one array instead. Valid -modifiers are: s, d, f, b (binary data, do not enclose in '') and %%.
NOTE: using this syntax will cast NULL and FALSE values to decimal 0, and TRUE values to decimal 1.

Parameters:
$from | The first result row to return.
$count | The maximum number of result rows to return.
Returns:
A database query result resource, or FALSE if the query was not executed correctly.

Definition at line 229 of file database.mysql.inc.

References _db_query(), _db_query_callback(), and db_prefix_tables().

Referenced by _comment_update_node_statistics(), _forum_new(), _menu_update_parental_status(), _node_access_rebuild_batch_operation(), aggregator_block(), aggregator_page_categories(), aggregator_page_rss(), aggregator_page_sources(), batch_example_batch_1(), batch_example_op_2(), batch_test_update_1(), blog_block(), blog_feed_last(), blog_feed_user(), blogapi_blogger_get_recent_posts(), book_update_6000(), comment_get_recent(), drupal_is_denied(), forum_block(), forum_get_forums(), forum_nodeapi(), hook_update_index(), menu_edit_menu_validate(), menu_get_item(), menu_link_children_relative_depth(), menu_nodeapi(), node_feed(), node_update_index(), pager_query(), profile_admin_settings_autocomplete(), profile_autocomplete(), statistics_title_list(), system_update_6021(), taxonomy_autocomplete(), taxonomy_select_nodes(), user_autocomplete(), and user_block().

db_query_temporary ( $ query )

Runs a SELECT query and stores its results in a temporary table.

Use this as a substitute for db_query() when the results need to stored in a temporary table. Temporary tables exist for the duration of the page request. User-supplied arguments to the query should be passed in as separate parameters so that they can be properly escaped to avoid SQL injection attacks.

Note that if you need to know how many results were returned, you should do a SELECT COUNT(*) on the temporary table afterwards. db_affected_rows() does not give consistent result across different database types in this case.

Parameters:
$query A string containing a normal SELECT SQL query.
... A variable number of arguments which are substituted into the query using printf() syntax. The query arguments can be enclosed in one array instead. Valid -modifiers are: s, d, f, b (binary data, do not enclose in '') and %%.
NOTE: using this syntax will cast NULL and FALSE values to decimal 0, and TRUE values to decimal 1.

Parameters:
$table The name of the temporary table to select into. This name will not be prefixed as there is no risk of collision.
Returns:
A database query result resource, or FALSE if the query was not executed correctly.

Definition at line 277 of file database.mysql.inc.

References _db_query(), _db_query_callback(), and db_prefix_tables().

db_result ( $ result )

Return an individual result field from the previous query.

Only use this function if exactly one field is being selected; otherwise, use db_fetch_object() or db_fetch_array().

Parameters:
$result A database query result resource, as returned from db_query().
Returns:
The resulting field or FALSE.

Definition at line 175 of file database.mysql.inc.

References $result.

Referenced by _aggregator_has_categories(), _batch_page(), _book_update_outline(), _comment_update_node_statistics(), _forum_new(), _forum_topics_unread(), _locale_import_one_string_db(), _menu_update_parental_status(), _node_access_rebuild_batch_operation(), _node_revision_access(), _user_edit_validate(), actions_function_lookup(), aggregator_block(), batch_example_batch_1(), batch_example_op_2(), batch_test_update_1(), block_add_block_form_validate(), block_admin_configure_validate(), book_block(), book_update_6000(), comment_multiple_delete_confirm(), comment_new_page_count(), comment_nodeapi(), comment_num_all(), comment_num_new(), comment_num_replies(), comment_save(), comment_unpublish_action(), comment_validate(), db_check_setup(), db_column_exists(), db_last_insert_id(), db_table_exists(), db_version(), dblog_cron(), drupal_get_filename(), drupal_is_denied(), drupal_lookup_path(), file_space_used(), fileupload_file_download(), fileupload_update(), filter_admin_format_form_submit(), filter_format_allowcache(), flood_is_allowed(), forum_nodeapi(), hook_file_download(), install_verify_drupal(), locale_languages_predefined_form_validate(), locale_translate_edit_form_submit(), locale_update_6000(), locale_update_6005(), menu_delete_menu_confirm(), menu_delete_menu_confirm_submit(), menu_edit_menu_submit(), menu_edit_menu_validate(), menu_enable(), menu_link_children_relative_depth(), menu_link_save(), menu_nodeapi(), multipage_form_example_custom_submit(), node_access(), node_access_view_all_nodes(), node_admin_nodes(), node_assign_owner_action(), node_assign_owner_action_form(), node_assign_owner_action_submit(), node_assign_owner_action_validate(), node_comment_mode(), node_configure(), node_multiple_delete_confirm(), node_revision_delete_confirm_submit(), node_search(), node_type_delete_confirm(), node_type_save(), node_update_index(), nodeapi_example_nodeapi(), openid_association(), openid_user_add_validate(), pager_query(), path_admin_form_validate(), path_admin_overview(), path_form_alter(), path_nodeapi(), php_install(), ping_cron(), poll_block(), profile_autocomplete(), profile_category_access(), profile_field_form_validate(), sess_count(), sess_write(), system_admin_theme_submit(), system_initialize_theme_blocks(), system_install(), system_region_list(), system_update_6000(), system_update_6009(), system_update_6018(), system_update_6019(), system_update_6021(), system_update_6036(), system_update_6041(), translation_remove_from_set(), trigger_assign_form_submit(), trigger_assign_form_validate(), trigger_menu(), upload_delete_revision(), upload_save(), upload_total_space_used(), user_admin_role_validate(), user_multiple_delete_confirm(), user_multiple_role_edit(), and user_save().

db_status_report ( $ phase )

Report database status.

Definition at line 20 of file database.mysql.inc.

References db_version(), get_t(), and l().

Referenced by system_requirements().

db_table_exists ( $ table )

Check if a table exists.

Definition at line 341 of file database.mysql.inc.

References db_escape_table(), db_fetch_object(), and db_query().

Referenced by system_update_6019(), system_update_6030(), system_update_6032(), system_update_6033(), system_update_6036(), system_update_6038(), system_update_6040(), system_update_6041(), system_update_6043(), system_update_6044(), update_create_batch_table(), update_fix_d6_requirements(), update_info_page(), and upload_install().

db_unlock_tables ( )

Unlock all locked tables.

Definition at line 334 of file database.mysql.inc.

References db_query().

db_version ( )

Returns the version of the database server currently in use.

Returns:
Database server version

Definition at line 43 of file database.mysql.inc.

Referenced by db_status_report().

Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/database.mysqli.inc File Reference

includes

database.mysqli.inc File Reference

Detailed Description

Database interface code for MySQL database servers using the mysqli client libraries.

mysqli is included in PHP 5 by default and allows developers to use the advanced features of MySQL 4.1.x, 5.0.x and beyond.

Definition in file database.mysqli.inc.

Go to the source code of this file.

Functions

  • _db_query ($query, $debug=0)
    Helper function for db_query().
  • db_affected_rows ()
    Determine the number of rows changed by the preceding query.
  • db_column_exists ($table, $column)
    Check if a column exists in the given table.
  • db_connect ($url)
    Initialise a database connection.
  • db_decode_blob ($data)
    Returns text from a Binary Large OBject value.
  • db_distinct_field ($table, $field, $query)
    Wraps the given table.field entry with a DISTINCT().
  • db_encode_blob ($data)
    Returns a properly formatted Binary Large Object value.
  • db_error ()
    Determine whether the previous query caused an error.
  • db_escape_string ($text)
    Prepare user input for use in a database query, preventing SQL injection attacks.
  • db_fetch_array ($result)
    Fetch one result row from the previous query as an array.
  • db_fetch_object ($result)
    Fetch one result row from the previous query as an object.
  • db_lock_table ($table)
    Lock a table.
  • db_query_range ($query)
    Runs a limited-range query in the active database.
  • db_query_temporary ($query)
    Runs a SELECT query and stores its results in a temporary table.
  • db_result ($result)
    Return an individual result field from the previous query.
  • db_status_report ($phase)
    Report database status.
  • db_table_exists ($table)
    Check if a table exists.
  • db_unlock_tables ()
    Unlock all locked tables.
  • db_version ()
    Returns the version of the database server currently in use.

Function Documentation

_db_query | ( | $ | query,
 |  | $ | debug = 0
 | ) |  |

Helper function for db_query().

Definition at line 91 of file database.mysqli.inc.

References $active_db, $name, $queries, $result, $user, check_plain(), and variable_get().

db_affected_rows ( )

Determine the number of rows changed by the preceding query.

Definition at line 198 of file database.mysqli.inc.

References $active_db.

db_column_exists | ( | $ | table,
 |  | $ | column
 | ) |  |

Check if a column exists in the given table.

Definition at line 350 of file database.mysqli.inc.

References db_escape_table(), db_fetch_object(), and db_query().

db_connect ( $ url )

Initialise a database connection.

Note that mysqli does not support persistent connections.

Definition at line 57 of file database.mysqli.inc.

References $url, and _db_error_page().

db_decode_blob ( $ data )

Returns text from a Binary Large OBject value.

Parameters:
$data Data to decode.
Returns:
Decoded data.

Definition at line 314 of file database.mysqli.inc.

db_distinct_field | ( | $ | table,
 |  | $ | field,
 |  | $ | query
 | ) |  |

Wraps the given table.field entry with a DISTINCT().

The wrapper is added to the SELECT list entry of the given query and the resulting query is returned. This function only applies the wrapper if a DISTINCT doesn't already exist in the query.

Parameters:
$table | Table containing the field to set as DISTINCT
$field | Field to set as DISTINCT
$query | Query to apply the wrapper to
Returns:
SQL query with the DISTINCT wrapper surrounding the given table.field.

Definition at line 365 of file database.mysqli.inc.

db_encode_blob ( $ data )

Returns a properly formatted Binary Large Object value.

Parameters:
$data Data to encode.
Returns:
Encoded data.

Definition at line 301 of file database.mysqli.inc.

References $active_db.

db_error ( )

Determine whether the previous query caused an error.

Definition at line 190 of file database.mysqli.inc.

References $active_db.

db_escape_string ( $ text )

Prepare user input for use in a database query, preventing SQL injection attacks.

Definition at line 321 of file database.mysqli.inc.

References $active_db.

db_fetch_array ( $ result )

Fetch one result row from the previous query as an array.

Parameters:
$result A database query result resource, as returned from db_query().
Returns:
An associative array representing the next row of the result, or FALSE. The keys of this object are the names of the table fields selected by the query, and the values are the field values for this result row.

Definition at line 159 of file database.mysqli.inc.

References $result.

db_fetch_object ( $ result )

Fetch one result row from the previous query as an object.

Parameters:
$result A database query result resource, as returned from db_query().
Returns:
An object representing the next row of the result, or FALSE. The attributes of this object are the table fields selected by the query.

Definition at line 142 of file database.mysqli.inc.

References $result.

db_lock_table ( $ table )

Lock a table.

Definition at line 329 of file database.mysqli.inc.

References db_escape_table(), and db_query().

db_query_range ( $ query )

Runs a limited-range query in the active database.

Use this as a substitute for db_query() when a subset of the query is to be returned. User-supplied arguments to the query should be passed in as separate parameters so that they can be properly escaped to avoid SQL injection attacks.

Parameters:
$query A string containing an SQL query.
... A variable number of arguments which are substituted into the query using printf() syntax. The query arguments can be enclosed in one array instead. Valid -modifiers are: s, d, f, b (binary data, do not enclose in '') and %%.
NOTE: using this syntax will cast NULL and FALSE values to decimal 0, and TRUE values to decimal 1.

Parameters:
$from | The first result row to return.
$count | The maximum number of result rows to return.
Returns:
A database query result resource, or FALSE if the query was not executed correctly.

Definition at line 231 of file database.mysqli.inc.

References _db_query(), _db_query_callback(), and db_prefix_tables().

db_query_temporary ( $ query )

Runs a SELECT query and stores its results in a temporary table.

Use this as a substitute for db_query() when the results need to stored in a temporary table. Temporary tables exist for the duration of the page request. User-supplied arguments to the query should be passed in as separate parameters so that they can be properly escaped to avoid SQL injection attacks.

Note that if you need to know how many results were returned, you should do a SELECT COUNT(*) on the temporary table afterwards. db_affected_rows() does not give consistent result across different database types in this case.

Parameters:
$query A string containing a normal SELECT SQL query.
... A variable number of arguments which are substituted into the query using printf() syntax. The query arguments can be enclosed in one array instead. Valid -modifiers are: s, d, f, b (binary data, do not enclose in '') and %%.
NOTE: using this syntax will cast NULL and FALSE values to decimal 0, and TRUE values to decimal 1.

Parameters:
$table The name of the temporary table to select into. This name will not be prefixed as there is no risk of collision.
Returns:
A database query result resource, or FALSE if the query was not executed correctly.

Definition at line 279 of file database.mysqli.inc.

References _db_query(), _db_query_callback(), and db_prefix_tables().

db_result ( $ result )

Return an individual result field from the previous query.

Only use this function if exactly one field is being selected; otherwise, use db_fetch_object() or db_fetch_array().

Parameters:
$result A database query result resource, as returned from db_query().
Returns:
The resulting field or FALSE.

Definition at line 177 of file database.mysqli.inc.

References $result.

db_status_report ( $ phase )

Report database status.

Definition at line 23 of file database.mysqli.inc.

References db_version(), get_t(), and l().

db_table_exists ( $ table )

Check if a table exists.

Definition at line 343 of file database.mysqli.inc.

References db_escape_table(), db_fetch_object(), and db_query().

db_unlock_tables ( )

Unlock all locked tables.

Definition at line 336 of file database.mysqli.inc.

References db_query().

db_version ( )

Returns the version of the database server currently in use.

Returns:
Database server version

Definition at line 46 of file database.mysqli.inc.

References $active_db.

Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/database.pgsql.inc File Reference

includes

database.pgsql.inc File Reference

Detailed Description

Database interface code for PostgreSQL database servers.

Definition in file database.pgsql.inc.

Go to the source code of this file.

Functions

  • _db_create_field_sql ($name, $spec)
    Create an SQL string for a field to be used in table creation or alteration.
  • _db_create_index_sql ($table, $name, $fields)
  • _db_create_key_sql ($fields)
  • _db_create_keys (&$ret, $table, $new_keys)
  • _db_process_field ($field)
    Set database-engine specific properties for a field.
  • db_add_field (&$ret, $table, $field, $spec, $new_keys=array())
    Add a new field to a table.
  • db_add_index (&$ret, $table, $name, $fields)
    Add an index.
  • db_add_primary_key (&$ret, $table, $fields)
    Add a primary key.
  • db_add_unique_key (&$ret, $table, $name, $fields)
    Add a unique key.
  • db_change_field (&$ret, $table, $field, $field_new, $spec, $new_keys=array())
    Change a field definition.
  • db_create_table_sql ($name, $table)
    Generate SQL to create a new table from a Drupal schema definition.
  • db_drop_field (&$ret, $table, $field)
    Drop a field.
  • db_drop_index (&$ret, $table, $name)
    Drop an index.
  • db_drop_primary_key (&$ret, $table)
    Drop the primary key.
  • db_drop_table (&$ret, $table)
    Drop a table.
  • db_drop_unique_key (&$ret, $table, $name)
    Drop a unique key.
  • db_field_set_default (&$ret, $table, $field, $default)
    Set the default value for a field.
  • db_field_set_no_default (&$ret, $table, $field)
    Set a field to have no default value.
  • db_rename_table (&$ret, $table, $new_name)
    Rename a table.
  • db_type_map ()
    End of "ingroup database".
  • _db_query ($query, $debug=0)
    Helper function for db_query().
  • db_affected_rows ()
    Determine the number of rows changed by the preceding query.
  • db_check_setup ()
    Verify if the database is set up correctly.
  • db_column_exists ($table, $column)
    Check if a column exists in the given table.
  • db_connect ($url)
    Initialize a database connection.
  • db_decode_blob ($data)
    Returns text from a Binary Large OBject value.
  • db_distinct_field ($table, $field, $query)
    Wraps the given table.field entry with a DISTINCT().
  • db_encode_blob ($data)
    Returns a properly formatted Binary Large OBject value.
  • db_error ()
    Determine whether the previous query caused an error.
  • db_escape_string ($text)
    Prepare user input for use in a database query, preventing SQL injection attacks.
  • db_fetch_array ($result)
    Fetch one result row from the previous query as an array.
  • db_fetch_object ($result)
    Fetch one result row from the previous query as an object.
  • db_last_insert_id ($table, $field)
    Returns the last insert id.
  • db_lock_table ($table)
    Lock a table.
  • db_query ($query)
    Runs a basic query in the active database.
  • db_query_range ($query)
    Runs a limited-range query in the active database.
  • db_query_temporary ($query)
    Runs a SELECT query and stores its results in a temporary table.
  • db_result ($result)
    Return an individual result field from the previous query.
  • db_status_report ()
    Report database status.
  • db_table_exists ($table)
    Check if a table exists.
  • db_unlock_tables ()
    Unlock all locked tables.
  • db_version ()
    Returns the version of the database server currently in use.

Function Documentation

_db_create_field_sql | ( | $ | name,
 |  | $ | spec
 | ) |  |

Create an SQL string for a field to be used in table creation or alteration.

Before passing a field out of a schema definition into this function it has to be processed by _db_process_field().

Parameters:
$name | Name of the field.
$spec | The field specification, as per the schema data structure format.

Definition at line 594 of file database.pgsql.inc.

References $name.

_db_create_index_sql | ( | $ | table,
 |  | $ | name,
 |  | $ | fields
 | ) |  |

Definition at line 527 of file database.pgsql.inc.

References $name, and _db_create_key_sql().

Referenced by db_add_index(), and db_create_table_sql().

_db_create_key_sql ( $ fields )

Definition at line 533 of file database.pgsql.inc.

_db_create_keys | ( | &$ | ret,
 |  | $ | table,
 |  | $ | new_keys
 | ) |  |

Definition at line 546 of file database.pgsql.inc.

References $name, db_add_index(), db_add_primary_key(), and db_add_unique_key().

Referenced by db_add_field(), and db_change_field().

_db_process_field ( $ field )

Set database-engine specific properties for a field.

Parameters:
$field A field description array, as specified in the schema documentation.

Definition at line 568 of file database.pgsql.inc.

References db_type_map().

_db_query | ( | $ | query,
 |  | $ | debug = 0
 | ) |  |

Helper function for db_query().

Definition at line 130 of file database.pgsql.inc.

References $active_db, $last_result, $queries, check_plain(), and variable_get().

db_add_field | ( | &$ | ret,
 |  | $ | table,
 |  | $ | field,
 |  | $ | spec,
 |  | $ | new_keys = array()
 | ) |  |

Add a new field to a table.

Parameters:
$ret | Array to which query results will be added.
$table | Name of the table to be altered.
$field | Name of the field to be added.
$spec | The field specification array, as taken from a schema definition. The specification may also contain the key 'initial', the newly created field will be set to the value of the key in all rows. This is most useful for creating NOT NULL columns with no default value in existing tables.
$keys_new | Optional keys and indexes specification to be created on the table along with adding the field. The format is the same as a table specification but without the 'fields' element. If you are adding a type 'serial' field, you MUST specify at least one key or index including it in this array.
See also:
db_change_field for more explanation why.

Definition at line 676 of file database.pgsql.inc.

References $result, _db_create_field_sql(), _db_create_keys(), _db_process_field(), check_plain(), db_query(), db_type_placeholder(), and update_sql().

db_add_index | ( | &$ | ret,
 |  | $ | table,
 |  | $ | name,
 |  | $ | fields
 | ) |  |

Add an index.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.
$name | The name of the index.
$fields | An array of field names.

Definition at line 822 of file database.pgsql.inc.

References $name, _db_create_index_sql(), and update_sql().

db_add_primary_key | ( | &$ | ret,
 |  | $ | table,
 |  | $ | fields
 | ) |  |

Add a primary key.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.
$fields | Fields for the primary key.

Definition at line 760 of file database.pgsql.inc.

References update_sql().

db_add_unique_key | ( | &$ | ret,
 |  | $ | table,
 |  | $ | name,
 |  | $ | fields
 | ) |  |

Add a unique key.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.
$name | The name of the key.
$fields | An array of field names.

Definition at line 789 of file database.pgsql.inc.

References $name, and update_sql().

db_affected_rows ( )

Determine the number of rows changed by the preceding query.

Definition at line 237 of file database.pgsql.inc.

References $last_result.

db_change_field | ( | &$ | ret,
 |  | $ | table,
 |  | $ | field,
 |  | $ | field_new,
 |  | $ | spec,
 |  | $ | new_keys = array()
 | ) |  |

Change a field definition.

IMPORTANT NOTE: To maintain database portability, you have to explicitly recreate all indices and primary keys that are using the changed field.

That means that you have to drop all affected keys and indexes with db_drop_{primary_key,unique_key,index}() before calling db_change_field(). To recreate the keys and indices, pass the key definitions as the optional $new_keys argument directly to db_change_field().

For example, suppose you have:

 $schema['foo'] = array(
   'fields' => array(
     'bar' => array('type' => 'int', 'not null' => TRUE)
   ),
   'primary key' => array('bar')
 );
and you want to change foo.bar to be type serial, leaving it as the primary key. The correct sequence is:
 db_drop_primary_key($ret, 'foo');
 db_change_field($ret, 'foo', 'bar', 'bar',
   array('type' => 'serial', 'not null' => TRUE),
   array('primary key' => array('bar')));

The reasons for this are due to the different database engines:

On PostgreSQL, changing a field definition involves adding a new field and dropping an old one which* causes any indices, primary keys and sequences (from serial-type fields) that use the changed field to be dropped.

On MySQL, all type 'serial' fields must be part of at least one key or index as soon as they are created. You cannot use db_add_{primary_key,unique_key,index}() for this purpose because the ALTER TABLE command will fail to add the column without a key or index specification. The solution is to use the optional $new_keys argument to create the key or index at the same time as field.

You could use db_add_{primary_key,unique_key,index}() in all cases unless you are converting a field to be type serial. You can use the $new_keys argument in all cases.

Parameters:
$ret | Array to which query results will be added.
$table | Name of the table.
$field | Name of the field to change.
$field_new | New name for the field (set to the same as $field if you don't want to change the name).
$spec | The field specification for the new field.
$new_keys | Optional keys and indexes specification to be created on the table along with changing the field. The format is the same as a table specification but without the 'fields' element.

Definition at line 903 of file database.pgsql.inc.

References _db_create_keys(), db_add_field(), db_drop_field(), and update_sql().

db_check_setup ( )

Verify if the database is set up correctly.

Definition at line 400 of file database.pgsql.inc.

References db_query(), db_result(), drupal_set_message(), and get_t().

Referenced by system_settings_overview().

db_column_exists | ( | $ | table,
 |  | $ | column
 | ) |  |

Check if a column exists in the given table.

Definition at line 393 of file database.pgsql.inc.

References db_escape_table(), db_query(), and db_result().

db_connect ( $ url )

Initialize a database connection.

Definition at line 47 of file database.pgsql.inc.

References $url, _db_error_page(), and decode_entities().

db_create_table_sql | ( | $ | name,
 |  | $ | table
 | ) |  |

Generate SQL to create a new table from a Drupal schema definition.

Parameters:
$name | The name of the table to create.
$table | A Schema API table definition array.
Returns:
An array of SQL statements to create the table.

Definition at line 493 of file database.pgsql.inc.

References $name, _db_create_field_sql(), _db_create_index_sql(), and _db_process_field().

db_decode_blob ( $ data )

Returns text from a Binary Large OBject value.

In case of PostgreSQL decodes data after select from bytea field.

Parameters:
$data Data to decode.
Returns:
Decoded data.

Definition at line 355 of file database.pgsql.inc.

db_distinct_field | ( | $ | table,
 |  | $ | field,
 |  | $ | query
 | ) |  |

Wraps the given table.field entry with a DISTINCT().

The wrapper is added to the SELECT list entry of the given query and the resulting query is returned. This function only applies the wrapper if a DISTINCT doesn't already exist in the query.

Parameters:
$table | Table containing the field to set as DISTINCT
$field | Field to set as DISTINCT
$query | Query to apply the wrapper to
Returns:
SQL query with the DISTINCT wrapper surrounding the given table.field.

Definition at line 420 of file database.pgsql.inc.

db_drop_field | ( | &$ | ret,
 |  | $ | table,
 |  | $ | field
 | ) |  |

Drop a field.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.
$field | The field to be dropped.

Definition at line 709 of file database.pgsql.inc.

References update_sql().

db_drop_index | ( | &$ | ret,
 |  | $ | table,
 |  | $ | name
 | ) |  |

Drop an index.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.
$name | The name of the index.

Definition at line 836 of file database.pgsql.inc.

References $name, and update_sql().

db_drop_primary_key | ( | &$ | ret,
 |  | $ | table
 | ) |  |

Drop the primary key.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.

Definition at line 773 of file database.pgsql.inc.

References update_sql().

db_drop_table | ( | &$ | ret,
 |  | $ | table
 | ) |  |

Drop a table.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be dropped.

Definition at line 649 of file database.pgsql.inc.

References update_sql().

db_drop_unique_key | ( | &$ | ret,
 |  | $ | table,
 |  | $ | name
 | ) |  |

Drop a unique key.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.
$name | The name of the key.

Definition at line 805 of file database.pgsql.inc.

References $name, and update_sql().

db_encode_blob ( $ data )

Returns a properly formatted Binary Large OBject value.

In case of PostgreSQL encodes data for insert into bytea field.

Parameters:
$data Data to encode.
Returns:
Encoded data.

Definition at line 342 of file database.pgsql.inc.

db_error ( )

Determine whether the previous query caused an error.

Definition at line 217 of file database.pgsql.inc.

References $active_db.

db_escape_string ( $ text )

Prepare user input for use in a database query, preventing SQL injection attacks.

Note: This function requires PostgreSQL 7.2 or later.

Definition at line 363 of file database.pgsql.inc.

db_fetch_array ( $ result )

Fetch one result row from the previous query as an array.

Parameters:
$result A database query result resource, as returned from db_query().
Returns:
An associative array representing the next row of the result, or FALSE. The keys of this object are the names of the table fields selected by the query, and the values are the field values for this result row.

Definition at line 189 of file database.pgsql.inc.

References $result.

db_fetch_object ( $ result )

Fetch one result row from the previous query as an object.

Parameters:
$result A database query result resource, as returned from db_query().
Returns:
An object representing the next row of the result, or FALSE. The attributes of this object are the table fields selected by the query.

Definition at line 173 of file database.pgsql.inc.

References $result.

db_field_set_default | ( | &$ | ret,
 |  | $ | table,
 |  | $ | field,
 |  | $ | default
 | ) |  |

Set the default value for a field.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.
$field | The field to be altered.
$default | Default value to be set. NULL for 'default NULL'.

Definition at line 725 of file database.pgsql.inc.

References update_sql().

db_field_set_no_default | ( | &$ | ret,
 |  | $ | table,
 |  | $ | field
 | ) |  |

Set a field to have no default value.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be altered.
$field | The field to be altered.

Definition at line 746 of file database.pgsql.inc.

References update_sql().

db_last_insert_id | ( | $ | table,
 |  | $ | field
 | ) |  |

Returns the last insert id.

This function is thread safe.

Parameters:
$table | The name of the table you inserted into.
$field | The name of the autoincrement field.

Definition at line 230 of file database.pgsql.inc.

References db_escape_table(), db_query(), and db_result().

db_lock_table ( $ table )

Lock a table.

This function automatically starts a transaction.

Definition at line 371 of file database.pgsql.inc.

References db_escape_table(), and db_query().

db_query ( $ query )

Runs a basic query in the active database.

User-supplied arguments to the query should be passed in as separate parameters so that they can be properly escaped to avoid SQL injection attacks.

Parameters:
$query A string containing an SQL query.
... A variable number of arguments which are substituted into the query using printf() syntax. Instead of a variable number of query arguments, you may also pass a single array containing the query arguments.
Valid -modifiers are: s, d, f, b (binary data, do not enclose in '') and %%.

NOTE: using this syntax will cast NULL and FALSE values to decimal 0, and TRUE values to decimal 1.

Returns:
A database query result resource, or FALSE if the query was not executed correctly.

Definition at line 115 of file database.pgsql.inc.

References _db_query(), _db_query_callback(), and db_prefix_tables().

db_query_range ( $ query )

Runs a limited-range query in the active database.

Use this as a substitute for db_query() when a subset of the query is to be returned. User-supplied arguments to the query should be passed in as separate parameters so that they can be properly escaped to avoid SQL injection attacks.

Parameters:
$query A string containing an SQL query.
... A variable number of arguments which are substituted into the query using printf() syntax. Instead of a variable number of query arguments, you may also pass a single array containing the query arguments. Valid -modifiers are: s, d, f, b (binary data, do not enclose in '') and %%.
NOTE: using this syntax will cast NULL and FALSE values to decimal 0, and TRUE values to decimal 1.

Parameters:
$from | The first result row to return.
$count | The maximum number of result rows to return.
Returns:
A database query result resource, or FALSE if the query was not executed correctly.

Definition at line 271 of file database.pgsql.inc.

References _db_query(), _db_query_callback(), and db_prefix_tables().

db_query_temporary ( $ query )

Runs a SELECT query and stores its results in a temporary table.

Use this as a substitute for db_query() when the results need to stored in a temporary table. Temporary tables exist for the duration of the page request. User-supplied arguments to the query should be passed in as separate parameters so that they can be properly escaped to avoid SQL injection attacks.

Note that if you need to know how many results were returned, you should do a SELECT COUNT(*) on the temporary table afterwards. db_affected_rows() does not give consistent result across different database types in this case.

Parameters:
$query A string containing a normal SELECT SQL query.
... A variable number of arguments which are substituted into the query using printf() syntax. The query arguments can be enclosed in one array instead. Valid -modifiers are: s, d, f, b (binary data, do not enclose in '') and %%.
NOTE: using this syntax will cast NULL and FALSE values to decimal 0, and TRUE values to decimal 1.

Parameters:
$table The name of the temporary table to select into. This name will not be prefixed as there is no risk of collision.
Returns:
A database query result resource, or FALSE if the query was not executed correctly.

Definition at line 319 of file database.pgsql.inc.

References _db_query(), _db_query_callback(), and db_prefix_tables().

db_rename_table | ( | &$ | ret,
 |  | $ | table,
 |  | $ | new_name
 | ) |  |

Rename a table.

Parameters:
$ret | Array to which query results will be added.
$table | The table to be renamed.
$new_name | The new name for the table.

Definition at line 637 of file database.pgsql.inc.

References update_sql().

db_result ( $ result )

Return an individual result field from the previous query.

Only use this function if exactly one field is being selected; otherwise, use db_fetch_object() or db_fetch_array().

Parameters:
$result A database query result resource, as returned from db_query().
Returns:
The resulting field or FALSE.

Definition at line 206 of file database.pgsql.inc.

References $result.

db_table_exists ( $ table )

Check if a table exists.

Definition at line 386 of file database.pgsql.inc.

References db_escape_table(), db_query(), and db_result().

db_unlock_tables ( )

Unlock all locked tables.

This function automatically commits a transaction.

Definition at line 379 of file database.pgsql.inc.

References db_query().

db_version ( )

Returns the version of the database server currently in use.

Returns:
Database server version

Definition at line 40 of file database.pgsql.inc.

References db_query(), and db_result().

Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/file.inc File Reference

includes

file.inc File Reference

Detailed Description

API for handling file uploads and server file management.

Definition in file file.inc.

Go to the source code of this file.

Enumerations

  • enum FILE_CREATE_DIRECTORY
  • enum FILE_DOWNLOADS_PRIVATE
  • enum FILE_DOWNLOADS_PUBLIC
  • enum FILE_EXISTS_ERROR
  • enum FILE_EXISTS_RENAME
  • enum FILE_EXISTS_REPLACE
  • enum FILE_MODIFY_PERMISSIONS
  • enum FILE_STATUS_PERMANENT
  • enum FILE_STATUS_TEMPORARY
    A files status can be one of two values: temporary or permanent. More...

Functions

  • file_check_directory (&$directory, $mode=0, $form_item=NULL)
    Check that the directory exists and is writable.
  • file_check_location ($source, $directory= '')
    Check if a file is really located inside $directory.
  • file_check_path (&$path)
    Checks path to see if it is a directory, or a dir/file.
  • file_copy (&$source, $dest=0, $replace=FILE_EXISTS_RENAME)
    Copies a file to a new location.
  • file_create_filename ($basename, $directory)
    Create a full file path from a directory and filename.
  • file_create_path ($dest=0)
    Make sure the destination is a complete path and resides in the file system directory, if it is not prepend the file system directory.
  • file_create_url ($path)
    Create the download path to a file.
  • file_delete ($path)
    Delete a file.
  • file_destination ($destination, $replace)
    Determines the destination path for a file depending on how replacement of existing files should be handled.
  • file_directory_path ()
    Determine the default 'files' directory.
  • file_directory_temp ()
    Determine the default temporary directory.
  • file_download ()
    Call modules that implement hook_file_download() to find out if a file is accessible and what headers it should be transferred with.
  • file_move (&$source, $dest=0, $replace=FILE_EXISTS_RENAME)
    Moves a file to a new location.
  • file_munge_filename ($filename, $extensions, $alerts=TRUE)
    Munge the filename as needed for security purposes.
  • file_save_data ($data, $dest, $replace=FILE_EXISTS_RENAME)
    Save a string to the specified destination.
  • file_save_upload ($source, $validators=array(), $dest=FALSE, $replace=FILE_EXISTS_RENAME)
    Saves a file upload to a new location.
  • file_scan_directory ($dir, $mask, $nomask=array('.', '..', 'CVS'), $callback=0, $recurse=TRUE, $key= 'filename', $min_depth=0, $depth=0)
    Finds all files that match a given mask in a given directory.
  • file_set_status (&$file, $status)
    Set the status of a file.
  • file_space_used ($uid=NULL)
    Determine total disk space used by a single user or the whole filesystem.
  • file_transfer ($source, $headers)
    Transfer file using http to client.
  • file_unmunge_filename ($filename)
    Undo the effect of upload_munge_filename().
  • file_upload_max_size ()
    Determine the maximum file upload size by querying the PHP settings.
  • file_validate_extensions ($file, $extensions)
    Check that the filename ends with an allowed extension.
  • file_validate_image_resolution (&$file, $maximum_dimensions=0, $minimum_dimensions=0)
    If the file is an image verify that its dimensions are within the specified maximum and minimum dimensions.
  • file_validate_is_image (&$file)
    Check that the file is recognized by image_get_info() as an image.
  • file_validate_name_length ($file)
    Check for files with names longer than we can store in the database.
  • file_validate_size ($file, $file_limit=0, $user_limit=0)
    Check that the file's size is below certain limits.
Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/form.inc File Reference

includes

form.inc File Reference

Go to the source code of this file.

Functions

  • _element_info ($type, $refresh=NULL)
    Retrieve the default properties for the defined element type.
  • _form_builder_handle_input_element ($form_id, &$form, &$form_state, $complete_form)
    Populate the value and name properties of input elements so they can be processed and rendered.
  • _form_builder_ie_cleanup ($form, &$form_state)
    In IE, if only one submit button is present, AND the enter key is used to submit the form, no form value is sent for it and our normal button detection code will never detect a match.
  • _form_button_was_clicked ($form)
    Helper function to handle the sometimes-convoluted logic of button click detection.
  • _form_set_class (&$element, $class=array())
    Sets a form element's class attribute.
  • _form_set_value (&$form_values, $form, $parents, $value)
    Helper function for form_set_value().
  • _form_validate ($elements, &$form_state, $form_id=NULL)
    Performs validation on form elements.
  • & batch_get ()
    Retrieve the current batch.
  • batch_process ($redirect=NULL, $url=NULL)
    Process the batch.
  • batch_set ($batch_definition)
    Open a new batch.
  • date_validate ($form)
    Validates the date type to stop dates like February 30, 2006.
  • drupal_execute ($form_id, &$form_state)
    Retrieves a form using a form_id, populates it with $form_state['values'], processes it, and returns any validation errors encountered.
  • drupal_get_form ($form_id)
    Retrieves a form from a constructor function, or from the cache if the form was built in a previous page-load.
  • drupal_prepare_form ($form_id, &$form, &$form_state)
    Prepares a structured form array by adding required elements, executing any hook_form_alter functions, and optionally inserting a validation token to prevent tampering.
  • drupal_process_form ($form_id, &$form, &$form_state)
    This function is the heart of form API.
  • drupal_rebuild_form ($form_id, &$form_state, $args, $form_build_id=NULL)
    Retrieves a form, caches it and processes it with an empty $_POST.
  • drupal_redirect_form ($form, $redirect=NULL)
    Redirect the user to a URL after a form has been processed.
  • drupal_render_form ($form_id, &$form)
    Renders a structured form array into themed HTML.
  • drupal_retrieve_form ($form_id, &$form_state)
    Retrieves the structured array that defines a given form.
  • drupal_validate_form ($form_id, $form, &$form_state)
    Validates user-submitted form data from the $form_state using the validate functions defined in a structured form array.
  • expand_checkboxes ($element)
  • expand_date ($element)
    Roll out a single date element.
  • expand_password_confirm ($element)
    Expand a password_confirm field into two text boxes.
  • expand_radios ($element)
    Roll out a single radios element to a list of radios, using the options array as index.
  • form_builder ($form_id, $form, &$form_state)
    Walk through the structured form array, adding any required properties to each element and mapping the incoming $_POST data to the proper elements.
  • form_clean_id ($id=NULL, $flush=FALSE)
    Prepare an HTML ID attribute string for a form item.
  • form_error (&$element, $message= '')
    Flag an element as having an error.
  • form_execute_handlers ($type, &$form, &$form_state)
    A helper function used to execute custom validation and submission handlers for a given form.
  • form_expand_ahah ($element)
    Add AHAH information about a form element to the page to communicate with javascript.
  • form_get_cache ($form_build_id, &$form_state)
    Fetch a form from cache.
  • form_get_error ($element)
    Return the error message filed against the form with the specified name.
  • form_get_errors ()
    Return an associative array of all errors.
  • form_get_options ($element, $key)
    Traverses a select element's option array looking for any values that hold the given key.
  • form_options_flatten ($array, $reset=TRUE)
  • form_select_options ($element, $choices=NULL)
  • form_set_cache ($form_build_id, $form, $form_state)
    Store a form in the cache.
  • form_set_error ($name=NULL, $message= '')
    File an error against a form element.
  • form_set_value ($form, $value, &$form_state)
    Use this function to make changes to form values in the form validate phase, so they will be available in the submit phase in $form_state.
  • form_type_checkbox_value ($form, $edit=FALSE)
    Helper function to determine the value for a checkbox form element.
  • form_type_checkboxes_value ($form, $edit=FALSE)
    Helper function to determine the value for a checkboxes form element.
  • form_type_image_button_value ($form, $edit=FALSE)
    Helper function to determine the value for an image button form element.
  • form_type_password_confirm_value ($form, $edit=FALSE)
    Helper function to determine the value for a password_confirm form element.
  • form_type_select_value ($form, $edit=FALSE)
    Helper function to determine the value for a select form element.
  • form_type_textfield_value ($form, $edit=FALSE)
    Helper function to determine the value for a textfield form element.
  • form_type_token_value ($form, $edit=FALSE)
    Helper function to determine the value for form's token value.
  • map_month ($month)
    Helper function for usage with drupal_map_assoc to display month names.
  • password_confirm_validate ($form, &$form_state)
    Validate password_confirm element.
  • process_weight ($element)
    Expand weight elements into selects.
  • theme_button ($element)
    Theme a form button.
  • theme_checkbox ($element)
    Format a checkbox.
  • theme_checkboxes ($element)
    Format a set of checkboxes.
  • theme_date ($element)
    Format a date selection element.
  • theme_fieldset ($element)
    Format a group of form items.
  • theme_file ($element)
    Format a file upload field.
  • theme_form ($element)
    Format a form.
  • theme_form_element ($element, $value)
    Return a themed form element.
  • theme_hidden ($element)
    Format a hidden form field.
  • theme_image_button ($element)
    Theme a form image button.
  • theme_item ($element)
    Format a form item.
  • theme_markup ($element)
    Format HTML markup for use in forms.
  • theme_password ($element)
    Format a password field.
  • theme_password_confirm ($element)
    Format a password_confirm item.
  • theme_radio ($element)
    Format a radio button.
  • theme_radios ($element)
    Format a set of radio buttons.
  • theme_select ($element)
    Format a dropdown menu or scrolling selection box.
  • theme_submit ($element)
    Theme a form submit button.
  • theme_textarea ($element)
    Format a textarea.
  • theme_textfield ($element)
    Format a textfield.
  • theme_token ($element)
    Format a form token.
  • weight_value (&$form)
    If no default value is set for weight select boxes, use 0.
Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/image.gd.inc File Reference

includes

image.gd.inc File Reference

Detailed Description

GD2 toolkit for image manipulation within Drupal.

Definition in file image.gd.inc.

Go to the source code of this file.

Functions

  • image_gd_check_settings ()
    Verify GD2 settings (that the right version is actually installed).
  • image_gd_close ($res, $destination, $extension)
    GD helper to write an image resource to a destination file.
  • image_gd_crop ($source, $destination, $x, $y, $width, $height)
    Crop an image using the GD toolkit.
  • image_gd_info ()
    Retrieve information about the toolkit.
  • image_gd_open ($file, $extension)
    GD helper function to create an image resource from a file.
  • image_gd_resize ($source, $destination, $width, $height)
    Scale an image to the specified size using GD.
  • image_gd_rotate ($source, $destination, $degrees, $background=0x000000)
    Rotate an image the given number of degrees.
  • image_gd_settings ()
    Retrieve settings for the GD2 toolkit.
  • image_gd_settings_validate ($form, &$form_state)
    Validate the submitted GD settings.

Function Documentation

image_gd_check_settings ( )

Verify GD2 settings (that the right version is actually installed).

Returns:
A boolean indicating if the GD toolkit is avaiable on this machine.

Definition at line 67 of file image.gd.inc.

Referenced by image_gd_settings(), and image_get_toolkit().

image_gd_close | ( | $ | res,
 |  | $ | destination,
 |  | $ | extension
 | ) |  |

GD helper to write an image resource to a destination file.

Parameters:
$res | An image resource created with image_gd_open().
$destination | A string file path where the iamge should be saved.
$extension | A string containing one of the following extensions: gif, jpg, jpeg, png.
Returns:
Boolean indicating success.

Definition at line 205 of file image.gd.inc.

References variable_get().

Referenced by image_gd_crop(), image_gd_resize(), and image_gd_rotate().

image_gd_crop | ( | $ | source,
 |  | $ | destination,
 |  | $ | x,
 |  | $ | y,
 |  | $ | width,
 |  | $ | height
 | ) |  |

Crop an image using the GD toolkit.

Definition at line 157 of file image.gd.inc.

References $result, image_gd_close(), image_gd_open(), and image_get_info().

image_gd_open | ( | $ | file,
 |  | $ | extension
 | ) |  |

GD helper function to create an image resource from a file.

Parameters:
$file | A string file path where the iamge should be saved.
$extension | A string containing one of the following extensions: gif, jpg, jpeg, png.
Returns:
An image resource, or FALSE on error.

Definition at line 184 of file image.gd.inc.

Referenced by image_gd_crop(), image_gd_resize(), and image_gd_rotate().

image_gd_resize | ( | $ | source,
 |  | $ | destination,
 |  | $ | width,
 |  | $ | height
 | ) |  |

Scale an image to the specified size using GD.

Definition at line 80 of file image.gd.inc.

References $result, image_gd_close(), image_gd_open(), and image_get_info().

image_gd_rotate | ( | $ | source,
 |  | $ | destination,
 |  | $ | degrees,
 |  | $ | background = 0x000000
 | ) |  |

Rotate an image the given number of degrees.

Definition at line 133 of file image.gd.inc.

References $result, image_gd_close(), image_gd_open(), and image_get_info().

image_gd_settings ( )

Retrieve settings for the GD2 toolkit.

Definition at line 24 of file image.gd.inc.

References form_set_error(), image_gd_check_settings(), t(), and variable_get().

image_gd_settings_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate the submitted GD settings.

Definition at line 53 of file image.gd.inc.

References $value, form_set_error(), and t().

Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/image.inc File Reference

includes

image.inc File Reference

Detailed Description

API for manipulating images.

Definition in file image.inc.

Go to the source code of this file.

Functions

  • image_crop ($source, $destination, $x, $y, $width, $height)
    Crop an image to the rectangle specified by the given rectangle.
  • image_get_available_toolkits ()
    Return a list of available toolkits.
  • image_get_info ($file)
    Get details about an image.
  • image_get_toolkit ()
    Retrieve the name of the currently used toolkit.
  • image_resize ($source, $destination, $width, $height)
    Resize an image to the given dimensions (ignoring aspect ratio).
  • image_rotate ($source, $destination, $degrees, $background=0x000000)
    Rotate an image by the given number of degrees.
  • image_scale ($source, $destination, $width, $height)
    Scales an image to the given width and height while maintaining aspect ratio.
  • image_scale_and_crop ($source, $destination, $width, $height)
    Scales an image to the exact width and height given.
  • image_toolkit_invoke ($method, $params=array())
    Invokes the given method using the currently selected toolkit.
Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/install.inc File Reference

includes

install.inc File Reference

Go to the source code of this file.

Enumerations

  • enum FILE_EXECUTABLE
  • enum FILE_EXIST
  • enum FILE_NOT_EXECUTABLE
  • enum FILE_NOT_EXIST
  • enum FILE_NOT_READABLE
  • enum FILE_NOT_WRITABLE
  • enum FILE_READABLE
  • enum FILE_WRITABLE
  • enum REQUIREMENT_ERROR
  • enum REQUIREMENT_INFO
  • enum REQUIREMENT_OK
  • enum REQUIREMENT_WARNING
  • enum SCHEMA_INSTALLED
  • enum SCHEMA_UNINSTALLED

Functions

  • _drupal_install_module ($module)
    Callback to install an individual profile module.
  • drupal_check_module ($module)
    Check a module's requirements.
  • drupal_check_profile ($profile)
    Check a profile's requirements.
  • drupal_detect_baseurl ($file= 'install.php')
    Auto detect the base_url with PHP predefined variables.
  • drupal_detect_database_types ()
    Detect all databases supported by Drupal that are compiled into the current PHP installation.
  • drupal_get_install_files ($module_list=array())
    Get list of all .install files.
  • drupal_get_installed_schema_version ($module, $reset=FALSE, $array=FALSE)
    Returns the currently installed schema version for a module.
  • drupal_get_schema_versions ($module)
    Returns an array of available schema versions for a module.
  • drupal_install_fix_file ($file, $mask, $message=TRUE)
    Attempt to fix file permissions.
  • drupal_install_mkdir ($file, $mask, $message=TRUE)
    Create a directory with specified permissions.
  • drupal_install_modules ($module_list=array())
    Calls the install function and updates the system table for a given list of modules.
  • drupal_install_profile_name ()
    Loads the profile definition, extracting the profile's defined name.
  • drupal_install_system ()
    Callback to install the system module.
  • drupal_load_updates ()
    Initialize the update system by loading all installed module's .install files.
  • drupal_requirements_severity (&$requirements)
    Extract highest severity from requirements array.
  • drupal_rewrite_settings ($settings=array(), $prefix= '')
    Read settings.php into a buffer line by line, changing values specified in $settings array, then over-writing the old settings.php file.
  • drupal_set_installed_schema_version ($module, $version)
    Update the installed version information for a module.
  • drupal_uninstall_module ($module)
    Calls the uninstall function and updates the system table for a given module.
  • drupal_verify_install_file ($file, $mask=NULL, $type= 'file')
    Verify the state of the specified file.
  • drupal_verify_profile ($profile, $locale)
    Verify a profile for installation.
  • install_goto ($path)
    Send the user to a different installer page.
  • st ($string, $args=array())
    Hardcoded function for doing the equivalent of t() during the install process, when database, theme, and localization system is possibly not yet available.

Enumeration Type Documentation

enum FILE_EXECUTABLE

Definition at line 15 of file install.inc.

enum FILE_EXIST

Definition at line 12 of file install.inc.

enum FILE_NOT_EXECUTABLE

Definition at line 19 of file install.inc.

enum FILE_NOT_EXIST

Definition at line 16 of file install.inc.

enum FILE_NOT_READABLE

Definition at line 17 of file install.inc.

enum FILE_NOT_WRITABLE

Definition at line 18 of file install.inc.

enum FILE_READABLE

Definition at line 13 of file install.inc.

enum FILE_WRITABLE

Definition at line 14 of file install.inc.

enum REQUIREMENT_ERROR

Definition at line 10 of file install.inc.

enum REQUIREMENT_INFO

Definition at line 7 of file install.inc.

enum REQUIREMENT_OK

Definition at line 8 of file install.inc.

enum REQUIREMENT_WARNING

Definition at line 9 of file install.inc.

enum SCHEMA_INSTALLED

Definition at line 5 of file install.inc.

enum SCHEMA_UNINSTALLED

Definition at line 4 of file install.inc.

Function Documentation

_drupal_install_module ( $ module )

Callback to install an individual profile module.

Used during installation to install modules one at a time and then enable them, or to install a number of modules at one time from admin/build/modules.

Definition at line 340 of file install.inc.

References drupal_get_installed_schema_version(), drupal_get_schema_versions(), drupal_set_installed_schema_version(), module_invoke(), and module_load_install().

Referenced by _install_module_batch().

drupal_check_module ( $ module )

Check a module's requirements.

Definition at line 713 of file install.inc.

References drupal_get_install_files(), drupal_requirements_severity(), drupal_set_message(), module_invoke(), and t().

Referenced by system_modules_submit().

drupal_check_profile ( $ profile )

Check a profile's requirements.

Parameters:
profile Name of profile to check.

Definition at line 668 of file install.inc.

References $module_list, $profile, drupal_get_install_files(), drupal_required_modules(), install_no_profile_error(), module_hook(), module_invoke(), and name.

Referenced by install_check_requirements().

drupal_detect_baseurl ( $ file = 'install.php' )

Auto detect the base_url with PHP predefined variables.

Parameters:
$file The name of the file calling this function so we can strip it out of the URI when generating the base_url.
Returns:
The auto-detected $base_url that should be configured in settings.php

Definition at line 133 of file install.inc.

References $profile.

drupal_detect_database_types ( )

Detect all databases supported by Drupal that are compiled into the current PHP installation.

Returns:
An array of database types compiled into PHP.

Definition at line 151 of file install.inc.

References $type.

Referenced by _install_settings_form_validate(), and install_settings_form().

drupal_get_install_files ( $ module_list = array() )

Get list of all .install files.

Parameters:
$module_list An array of modules to search for their .install files.

Definition at line 251 of file install.inc.

References $module_list, and drupal_system_listing().

Referenced by drupal_check_module(), and drupal_check_profile().

drupal_get_installed_schema_version | ( | $ | module,
 |  | $ | reset = FALSE,
 |  | $ | array = FALSE
 | ) |  |

Returns the currently installed schema version for a module.

Parameters:
$module | A module name.
$reset | Set to TRUE after modifying the system table.
$array | Set to TRUE if you want to get information about all modules in the system.
Returns:
The currently installed schema version.

Definition at line 71 of file install.inc.

References $result, $row, db_fetch_object(), and db_query().

Referenced by _drupal_install_module(), drupal_load_updates(), system_modules_submit(), system_requirements(), update_fix_d6_requirements(), and update_script_selection_form().

drupal_get_schema_versions ( $ module )

Returns an array of available schema versions for a module.

Parameters:
$module A module name.
Returns:
If the module has updates, an array of available updates. Otherwise, FALSE.

Definition at line 41 of file install.inc.

Referenced by _drupal_install_module(), drupal_install_system(), system_requirements(), update_batch(), and update_script_selection_form().

drupal_install_fix_file | ( | $ | file,
 |  | $ | mask,
 |  | $ | message = TRUE
 | ) |  |

Attempt to fix file permissions.

The general approach here is that, because we do not know the security setup of the webserver, we apply our permission changes to all three digits of the file permission (i.e. user, group and all).

To ensure that the values behave as expected (and numbers don't carry from one digit to the next) we do the calculation on the octal value using bitwise operations. This lets us remove, for example, 0222 from 0700 and get the correct value of 0500.

Parameters:
$file | The name of the file with permissions to fix.
$mask | The desired permissions for the file.
$message | (optional) Whether to output messages. Defaults to TRUE.
Returns:
TRUE/FALSE whether or not we were able to fix the file's permissions.

Definition at line 551 of file install.inc.

Referenced by drupal_verify_install_file().

drupal_install_mkdir | ( | $ | file,
 |  | $ | mask,
 |  | $ | message = TRUE
 | ) |  |

Create a directory with specified permissions.

Parameters:
file | The name of the directory to create;
mask | The permissions of the directory to create.
$message | (optional) Whether to output messages. Defaults to TRUE.
Returns:
TRUE/FALSE whether or not the directory was successfully created.

Definition at line 502 of file install.inc.

Referenced by drupal_verify_install_file().

drupal_install_modules ( $ module_list = array() )

Calls the install function and updates the system table for a given list of modules.

Parameters:
module_list The modules to install.

Definition at line 310 of file install.inc.

References $module_list, module_enable(), and module_rebuild_cache().

Referenced by install_configure_form_submit(), and system_modules_submit().

drupal_install_profile_name ( )

Loads the profile definition, extracting the profile's defined name.

Returns:
The name defined in the profile's _profile_details() hook.

Definition at line 107 of file install.inc.

References $name, and $profile.

Referenced by _install_settings_form_validate(), install_check_requirements(), install_settings_form(), and install_tasks().

drupal_install_system ( )

Callback to install the system module.

Separated from the installation of other modules so core system functions can be made available while other modules are installed.

Definition at line 356 of file install.inc.

References db_query(), drupal_bootstrap(), drupal_get_filename(), drupal_get_schema_versions(), module_invoke(), and module_rebuild_cache().

Referenced by install_main().

drupal_load_updates ( )

Initialize the update system by loading all installed module's .install files.

Definition at line 24 of file install.inc.

References drupal_get_installed_schema_version(), and module_load_install().

Referenced by system_status().

drupal_requirements_severity ( &$ requirements )

Extract highest severity from requirements array.

Definition at line 700 of file install.inc.

Referenced by drupal_check_module(), install_check_requirements(), system_status(), and update_check_requirements().

drupal_rewrite_settings | ( | $ | settings = array(),
 |  | $ | prefix = ''
 | ) |  |

Read settings.php into a buffer line by line, changing values specified in $settings array, then over-writing the old settings.php file.

Parameters:
$settings An array of settings that need to be updated.

Definition at line 174 of file install.inc.

References conf_path(), drupal_set_message(), and st().

Referenced by install_settings_form_submit().

drupal_set_installed_schema_version | ( | $ | module,
 |  | $ | version
 | ) |  |

Update the installed version information for a module.

Parameters:
$module | A module name.
$version | The new schema version.

Definition at line 97 of file install.inc.

References db_query().

Referenced by _drupal_install_module(), drupal_uninstall_module(), system_update_6029(), update_batch(), and update_do_one().

drupal_uninstall_module ( $ module )

Calls the uninstall function and updates the system table for a given module.

Parameters:
$module The module to uninstall.

Definition at line 375 of file install.inc.

References $item, $result, _menu_delete_item(), db_fetch_array(), db_query(), drupal_load(), drupal_set_installed_schema_version(), module_invoke(), and module_load_install().

Referenced by system_modules_uninstall_submit().

drupal_verify_install_file | ( | $ | file,
 |  | $ | mask = NULL,
 |  | $ | type = 'file'
 | ) |  |

Verify the state of the specified file.

Parameters:
$file | The file to check for.
$mask | An optional bitmask created from various FILE_* constants.
$type | The type of file. Can be file (default), dir, or link.
Returns:
TRUE on success or FALSE on failure. A message is set for the latter.

Definition at line 422 of file install.inc.

References $return, $type, drupal_install_fix_file(), and drupal_install_mkdir().

Referenced by install_check_requirements(), install_tasks(), and system_requirements().

drupal_verify_profile | ( | $ | profile,
 |  | $ | locale
 | ) |  |

Verify a profile for installation.

Parameters:
profile | Name of profile to verify.
locale | Name of locale used (if any).
Returns:
The list of modules to install.

Definition at line 269 of file install.inc.

References $module_list, $profile, drupal_required_modules(), drupal_set_message(), drupal_system_listing(), install_no_profile_error(), and st().

Referenced by install_main().

install_goto ( $ path )

Send the user to a different installer page.

This issues an on-site HTTP redirect. Messages (and errors) are erased.

Parameters:
$path An installer path.

Definition at line 615 of file install.inc.

References $base_url, and exit.

Referenced by db_set_active(), install_main(), and install_settings_form_submit().

st | ( | $ | string,
 |  | $ | args = array()
 | ) |  |

Hardcoded function for doing the equivalent of t() during the install process, when database, theme, and localization system is possibly not yet available.

Definition at line 627 of file install.inc.

References $install_locale, $profile, $value, _locale_import_one_string(), _locale_import_read_po(), and check_plain().

Referenced by _install_settings_form_validate(), default_profile_tasks(), drupal_rewrite_settings(), drupal_test_mysql(), drupal_test_mysqli(), drupal_test_pgsql(), drupal_verify_profile(), example_form(), example_profile_task_list(), example_profile_tasks(), install_already_done_error(), install_change_settings(), install_check_requirements(), install_configure_form(), install_main(), install_no_profile_error(), install_select_locale(), install_select_locale_form(), install_select_profile(), install_select_profile_form(), install_settings_form(), install_task_list(), install_tasks(), and theme_install_page().

Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/install.mysql.inc File Reference

includes

install.mysql.inc File Reference

Go to the source code of this file.

Functions

  • drupal_test_mysql ($url, &$success)
    Check if we can connect to MySQL.
  • mysql_is_available ()
    Check if MySQL is available.

Function Documentation

drupal_test_mysql | ( | $ | url,
 |  | &$ | success
 | ) |  |

Check if we can connect to MySQL.

Returns:
TRUE/FALSE

Definition at line 22 of file install.mysql.inc.

References $result, $url, drupal_set_message(), mysql_is_available(), and st().

mysql_is_available ( )

Check if MySQL is available.

Returns:
TRUE/FALSE

Definition at line 12 of file install.mysql.inc.

Referenced by drupal_test_mysql().

Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/install.mysqli.inc File Reference

includes

install.mysqli.inc File Reference

Go to the source code of this file.

Functions

  • drupal_test_mysqli ($url, &$success)
    Check if we can connect to MySQL.
  • mysqli_is_available ()
    Check if MySQLi is available.

Function Documentation

drupal_test_mysqli | ( | $ | url,
 |  | &$ | success
 | ) |  |

Check if we can connect to MySQL.

Returns:
TRUE/FALSE

Definition at line 22 of file install.mysqli.inc.

References $result, $url, drupal_set_message(), mysqli_is_available(), and st().

mysqli_is_available ( )

Check if MySQLi is available.

Returns:
TRUE/FALSE

Definition at line 12 of file install.mysqli.inc.

Referenced by drupal_test_mysqli().

Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/install.pgsql.inc File Reference

includes

install.pgsql.inc File Reference

Go to the source code of this file.

Functions

  • drupal_test_pgsql ($url, &$success)
    Check if we can connect to PostgreSQL.
  • pgsql_is_available ()
    Check if PostgreSQL is available.

Function Documentation

drupal_test_pgsql | ( | $ | url,
 |  | &$ | success
 | ) |  |

Check if we can connect to PostgreSQL.

Returns:
TRUE/FALSE

Definition at line 22 of file install.pgsql.inc.

References $result, $url, drupal_set_message(), pgsql_is_available(), and st().

pgsql_is_available ( )

Check if PostgreSQL is available.

Returns:
TRUE/FALSE

Definition at line 12 of file install.pgsql.inc.

Referenced by drupal_test_pgsql().

Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/language.inc File Reference

includes

language.inc File Reference

Detailed Description

Multiple language handling functionality.

Definition in file language.inc.

Go to the source code of this file.

Functions

  • language_from_browser ()
    Identify language from the Accept-language HTTP header we got.
  • language_initialize ()
    Choose a language for the page, based on language negotiation settings.
  • language_url_rewrite (&$path, &$options)
    Rewrite URL's with language based prefix.

Function Documentation

language_from_browser ( )

Identify language from the Accept-language HTTP header we got.

Definition at line 72 of file language.inc.

References language_list().

Referenced by language_initialize().

language_initialize ( )

Choose a language for the page, based on language negotiation settings.

Definition at line 12 of file language.inc.

References $language, $user, language, language_default(), language_from_browser(), language_list(), and variable_get().

Referenced by drupal_init_language().

language_url_rewrite | ( | &$ | path,
 |  | &$ | options
 | ) |  |

Rewrite URL's with language based prefix.

Parameters are the same as those of the url() function.

Definition at line 105 of file language.inc.

References $language, language, language_default(), and variable_get().

Referenced by url().

Generated on Tue Feb 12 15:30:43 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/locale.inc File Reference

includes

locale.inc File Reference

Detailed Description

Administration functions for locale.module.

Definition in file locale.inc.

Go to the source code of this file.

Enumerations

  • enum LOCALE_IMPORT_KEEP
    Translation import mode keeping existing translations and only inserting new strings. More...
  • enum LOCALE_IMPORT_OVERWRITE
    Translation import mode overwriting all existing translations if new translated version available. More...
  • enum LOCALE_JS_STRING

Functions

  • _locale_parse_js_file ($filepath)
    End of "Translation import API".
Automatic interface translation import
End of "List of predefined languages"

  • _locale_batch_build ($files, $finished=NULL, $components=array())
    Build a locale batch from an array of files.
  • _locale_batch_import ($filepath, &$context)
    Perform interface translation import as a batch step.
  • _locale_batch_language_finished ($success, $results)
    Finished callback of language addition locale import batch.
  • _locale_batch_system_finished ($success, $results)
    Finished callback of system page locale import batch.
  • locale_batch_by_component ($components, $finished= '_locale_batch_system_finished')
    Prepare a batch to run when installing modules or enabling themes.
  • locale_batch_by_language ($langcode, $finished=NULL, $skip=array())
    Prepare a batch to import translations for all enabled modules in a given language.
Translation (template) export API
  • _locale_export_get_strings ($language=NULL, $group= 'default')
    Generates a structured array of all strings with translations in $language, if given.
  • _locale_export_po ($language=NULL, $output=NULL)
    Write a generated PO or POT file to the output.
  • _locale_export_po_generate ($language=NULL, $strings=array(), $header=NULL)
    Generates the PO(T) file contents for given strings.
  • _locale_export_remove_plural ($entry)
    Removes plural index information from a string.
  • _locale_export_string ($str)
    Print out a string on multiple lines.
  • _locale_export_wrap ($str, $len)
    Custom word wrapping for Portable Object (Template) files.
List of predefined languages
End of "String search functions"

  • _locale_get_predefined_list ()
    Some of the common languages with their English and native names.
  • _locale_prepare_predefined_list ()
    Prepares the language code list for a select form item with only the unsupported ones.
Translation import API
End of "Language addition API"

  • _locale_import_append_plural ($entry, $key)
    Modify a string to contain proper count indices.
  • _locale_import_message ($message, $file, $lineno=NULL)
    Sets an error message occurred during locale file parsing.
  • _locale_import_one_string ($op, $value=NULL, $mode=NULL, $lang=NULL, $file=NULL, $group= 'default')
    Imports a string into the database.
  • _locale_import_one_string_db (&$report, $langcode, $source, $translation, $textgroup, $location, $mode, $plid=NULL, $plural=NULL)
    Import one string into the database.
  • _locale_import_parse_arithmetic ($string)
    Parses and sanitizes an arithmetic formula into a PHP expression.
  • _locale_import_parse_header ($header)
    Parses a Gettext Portable Object file header.
  • _locale_import_parse_plural_forms ($pluralforms, $filename)
    Parses a Plural-Forms entry from a Gettext Portable Object file header.
  • _locale_import_parse_quoted ($string)
    Parses a string in quotes.
  • _locale_import_po ($file, $langcode, $mode, $group=NULL)
    Parses Gettext Portable Object file information and inserts into database.
  • _locale_import_read_po ($op, $file, $mode=NULL, $lang=NULL, $group= 'default')
    Parses Gettext Portable Object file into an array.
  • _locale_import_shorten_comments ($comment)
    Generate a short, one string version of the passed comment array.
  • _locale_import_tokenize_formula ($formula)
    Backward compatible implementation of token_get_all() for formula parsing.
String search functions
End of "Translation (template) export API"

  • _locale_invalidate_js ($langcode=NULL)
    Force the JavaScript translation file(s) to be refreshed.
  • _locale_rebuild_js ($langcode=NULL)
    (Re-)Creates the JavaScript translation file for a language.
  • _locale_translate_language_list ($translation, $limit_language)
    List languages in search result table.
  • _locale_translate_seek ()
    Perform a string search and display results in a table.
  • _locale_translate_seek_query ()
    Build array out of search criteria specified in request variables.
Language addition and editing functionality
End of "Language overview functionality"

  • _locale_languages_common_controls (&$form, $language=NULL)
    Common elements of the language addition and editing form.
  • locale_languages_add_screen ()
    User interface for the language addition screen.
  • locale_languages_custom_form ()
    Custom language addition form.
  • locale_languages_edit_form (&$form_state, $langcode)
    Editing screen for a particular language.
  • locale_languages_edit_form_submit ($form, &$form_state)
    Process the language editing form submission.
  • locale_languages_edit_form_validate ($form, &$form_state)
    Validate the language editing form.
  • locale_languages_predefined_form ()
    Predefined language setup form.
  • locale_languages_predefined_form_submit ($form, &$form_state)
    Process the language addition form submission.
  • locale_languages_predefined_form_validate ($form, &$form_state)
    Validate the language addition form.
Language addition API
End of "Translation delete interface"

  • locale_add_language ($langcode, $name=NULL, $native=NULL, $direction=LANGUAGE_LTR, $domain= '', $prefix= '', $enabled=TRUE, $default=FALSE)
    API function to add a language.
Language negotiation options screen
End of "Language deletion functionality"

  • locale_languages_configure_form ()
    Setting for language negotiation options.
  • locale_languages_configure_form_submit ($form, &$form_state)
    Submit function for language negotiation settings.
Language deletion functionality
End of "Language addition and editing functionality"

  • locale_languages_delete_form (&$form_state, $langcode)
    User interface for the language deletion confirmation screen.
  • locale_languages_delete_form_submit ($form, &$form_state)
    Process language deletion submissions.
Language overview functionality
  • locale_languages_overview_form ()
    User interface for the language overview screen.
  • locale_languages_overview_form_submit ($form, &$form_state)
    Process language overview form submissions, updating existing languages.
  • theme_locale_languages_overview_form ($form)
    Theme the language overview form.
Translation delete interface
End of "Translation text editing"

  • locale_translate_delete ($lid)
    Delete a language string.
Translation text editing
End of "Translation export screen"

  • locale_translate_edit_form (&$form_state, $lid)
    User interface for string editing.
  • locale_translate_edit_form_submit ($form, &$form_state)
    Process string editing form submissions.
Translation export screen
End of "Translation import screen"

  • locale_translate_export_po_form (&$form_state, $names)
    Form to export PO files for the languages provided.
  • locale_translate_export_po_form_submit ($form, &$form_state)
    Process a translation (or template) export form submission.
  • locale_translate_export_pot_form ()
    Translation template export form.
  • locale_translate_export_screen ()
    User interface for the translation export screen.
Translation import screen
End of "Translation search screen"

  • locale_translate_import_form ()
    User interface for the translation import screen.
  • locale_translate_import_form_submit ($form, &$form_state)
    Process the locale import form submission.
Translation overview screen
End of "Language negotiation options screen"

  • locale_translate_overview_screen ()
    Overview screen for translations.
Translation search screen
End of "Translation overview screen"

  • locale_translate_seek_form ()
    User interface for the string search screen.
  • locale_translate_seek_screen ()
    String search screen.

Enumeration Type Documentation

enum LOCALE_IMPORT_KEEP

Translation import mode keeping existing translations and only inserting new strings.

Definition at line 21 of file locale.inc.

enum LOCALE_IMPORT_OVERWRITE

Translation import mode overwriting all existing translations if new translated version available.

Definition at line 15 of file locale.inc.

enum LOCALE_JS_STRING

Definition at line 9 of file locale.inc.

Function Documentation

_locale_batch_build | ( | $ | files,
 |  | $ | finished = NULL,
 |  | $ | components = array()
 | ) |  |

Build a locale batch from an array of files.

Parameters:
$files | Array of files to import
$finished | Optional finished callback for the batch.
$components | Optional list of component names the batch covers. Used in the installer.
Returns:
A batch structure

Definition at line 2505 of file locale.inc.

References get_t().

Referenced by locale_batch_by_component(), and locale_batch_by_language().

_locale_batch_import | ( | $ | filepath,
 |  | &$ | context
 | ) |  |

Perform interface translation import as a batch step.

Parameters:
$filepath | Path to a file to import.
$results | Contains a list of files imported.

Definition at line 2538 of file locale.inc.

References _locale_import_read_po().

_locale_batch_language_finished | ( | $ | success,
 |  | $ | results
 | ) |  |

Finished callback of language addition locale import batch.

Inform the user of translation files imported.

Definition at line 2562 of file locale.inc.

References $results, drupal_set_message(), and format_plural().

_locale_batch_system_finished | ( | $ | success,
 |  | $ | results
 | ) |  |

Finished callback of system page locale import batch.

Inform the user of translation files imported.

Definition at line 2552 of file locale.inc.

References $results, drupal_set_message(), and format_plural().

_locale_export_get_strings | ( | $ | language = NULL,
 |  | $ | group = 'default'
 | ) |  |

Generates a structured array of all strings with translations in $language, if given.

This array can be used to generate an export of the string in the database.

Parameters:
$language | Language object to generate the output for, or NULL if generating translation template.
$group | Text group to export PO file from (eg. 'default' for interface translations)

Definition at line 1683 of file locale.inc.

References $language, $result, db_fetch_object(), db_query(), and language.

Referenced by locale_translate_export_po_form_submit().

_locale_export_po | ( | $ | language = NULL,
 |  | $ | output = NULL
 | ) |  |

Write a generated PO or POT file to the output.

Parameters:
$language | Language object to generate the output for, or NULL if generating translation template.
$output | The PO(T) file to output as a string. See _locale_export_generate_po() on how it can be generated.

Definition at line 1812 of file locale.inc.

References $language, $output, name, and watchdog().

Referenced by locale_translate_export_po_form_submit().

_locale_export_po_generate | ( | $ | language = NULL,
 |  | $ | strings = array(),
 |  | $ | header = NULL
 | ) |  |

Generates the PO(T) file contents for given strings.

Parameters:
$language | Language object to generate the output for, or NULL if generating translation template.
$strings | Array of strings to export. See _locale_export_get_strings() on how it should be formatted.
$header | The header portion to use for the output file. Defaults are provided for PO and POT files.

Definition at line 1723 of file locale.inc.

References $header, $language, $output, $user, _locale_export_remove_plural(), _locale_export_string(), and variable_get().

Referenced by locale_translate_export_po_form_submit().

_locale_export_remove_plural ( $ entry )

Removes plural index information from a string.

Definition at line 1896 of file locale.inc.

Referenced by _locale_export_po_generate().

_locale_export_string ( $ str )

Print out a string on multiple lines.

Definition at line 1832 of file locale.inc.

References _locale_export_wrap().

Referenced by _locale_export_po_generate().

_locale_export_wrap | ( | $ | str,
 |  | $ | len
 | ) |  |

Custom word wrapping for Portable Object (Template) files.

Definition at line 1868 of file locale.inc.

Referenced by _locale_export_string().

_locale_get_predefined_list ( )

Some of the common languages with their English and native names.

Based on ISO 639 and http://people.w3.org/rishida/names/languages.html

Definition at line 2234 of file locale.inc.

Referenced by _locale_prepare_predefined_list(), install_select_locale_form(), locale_add_language(), locale_languages_predefined_form_submit(), locale_languages_predefined_form_validate(), and locale_translate_import_form_submit().

_locale_import_append_plural | ( | $ | entry,
 |  | $ | key
 | ) |  |

Modify a string to contain proper count indices.

This is a callback function used via array_map()

Parameters:
$entry | An array element
$key | Index of the array element

Definition at line 1553 of file locale.inc.

_locale_import_message | ( | $ | message,
 |  | $ | file,
 |  | $ | lineno = NULL
 | ) |  |

Sets an error message occurred during locale file parsing.

Parameters:
$message | The message to be translated
$file | Drupal file object corresponding to the PO file to import
$lineno | An optional line number argument

Definition at line 1163 of file locale.inc.

References drupal_set_message(), and get_t().

Referenced by _locale_import_read_po().

_locale_import_one_string | ( | $ | op,
 |  | $ | value = NULL,
 |  | $ | mode = NULL,
 |  | $ | lang = NULL,
 |  | $ | file = NULL,
 |  | $ | group = 'default'
 | ) |  |

Imports a string into the database.

Parameters:
$op | Operation to perform: 'db-store', 'db-report', 'mem-store' or 'mem-report'
$value | Details of the string stored
$mode | Should existing translations be replaced LOCALE_IMPORT_KEEP or LOCALE_IMPORT_OVERWRITE
$lang | Language to store the string in
$file | Object representation of file being imported, only required when op is 'db-store'
$group | Text group to import PO file into (eg. 'default' for interface translations)

Definition at line 1188 of file locale.inc.

References $header, $op, $value, _locale_import_one_string_db(), _locale_import_parse_header(), _locale_import_parse_plural_forms(), _locale_import_shorten_comments(), and db_query().

Referenced by _locale_import_po(), _locale_import_read_po(), and st().

_locale_import_one_string_db | ( | &$ | report,
 |  | $ | langcode,
 |  | $ | source,
 |  | $ | translation,
 |  | $ | textgroup,
 |  | $ | location,
 |  | $ | mode,
 |  | $ | plid = NULL,
 |  | $ | plural = NULL
 | ) |  |

Import one string into the database.

Parameters:
$report | Report array summarizing the number of changes done in the form: array(inserts, updates, deletes).
$langcode | Language code to import string into.
$source | Source string.
$translation | Translation to language specified in $langcode.
$textgroup | Name of textgroup to store translation in.
$location | Location value to save with source string.
$mode | Import mode to use, LOCALE_IMPORT_KEEP or LOCALE_IMPORT_OVERWRITE.
$plid | Optional plural ID to use.
$plural | Optional plural value to use.
Returns:
The string ID of the existing string modified or the new string added.

Definition at line 1280 of file locale.inc.

References db_query(), and db_result().

Referenced by _locale_import_one_string().

_locale_import_parse_arithmetic ( $ string )

Parses and sanitizes an arithmetic formula into a PHP expression.

While parsing, we ensure, that the operators have the right precedence and associativity.

Parameters:
$string A string containing the arithmetic formula
Returns:
The PHP version of the formula

Definition at line 1390 of file locale.inc.

References $op, and _locale_import_tokenize_formula().

Referenced by _locale_import_parse_plural_forms().

_locale_import_parse_header ( $ header )

Parses a Gettext Portable Object file header.

Parameters:
$header A string containing the complete header
Returns:
An associative array of key-value pairs

Definition at line 1324 of file locale.inc.

References $header, and $tag.

Referenced by _locale_import_one_string().

_locale_import_parse_plural_forms | ( | $ | pluralforms,
 |  | $ | filename
 | ) |  |

Parses a Plural-Forms entry from a Gettext Portable Object file header.

Parameters:
$pluralforms | A string containing the Plural-Forms entry
$filename | A string containing the filename
Returns:
An array containing the number of plurals and a formula in PHP for computing the plural form

Definition at line 1347 of file locale.inc.

References _locale_import_parse_arithmetic(), drupal_set_message(), and t().

Referenced by _locale_import_one_string().

_locale_import_parse_quoted ( $ string )

Parses a string in quotes.

Parameters:
$string A string specified with enclosing quotes
Returns:
The string parsed from inside the quotes

Definition at line 1594 of file locale.inc.

Referenced by _locale_import_read_po().

_locale_import_po | ( | $ | file,
 |  | $ | langcode,
 |  | $ | mode,
 |  | $ | group = NULL
 | ) |  |

Parses Gettext Portable Object file information and inserts into database.

Parameters:
$file | Drupal file object corresponding to the PO file to import
$langcode | Language code
$mode | Should existing translations be replaced LOCALE_IMPORT_KEEP or LOCALE_IMPORT_OVERWRITE
$group | Text group to import PO file into (eg. 'default' for interface translations)

Definition at line 965 of file locale.inc.

References $status, _locale_import_one_string(), _locale_import_read_po(), _locale_invalidate_js(), cache_clear_all(), db_fetch_object(), db_query(), drupal_set_message(), menu_rebuild(), t(), and watchdog().

Referenced by locale_translate_import_form_submit().

_locale_import_read_po | ( | $ | op,
 |  | $ | file,
 |  | $ | mode = NULL,
 |  | $ | lang = NULL,
 |  | $ | group = 'default'
 | ) |  |

Parses Gettext Portable Object file into an array.

Parameters:
$op | Storage operation type: db-store or mem-store
$file | Drupal file object corresponding to the PO file to import
$mode | Should existing translations be replaced LOCALE_IMPORT_KEEP or LOCALE_IMPORT_OVERWRITE
$lang | Language code
$group | Text group to import PO file into (eg. 'default' for interface translations)

Definition at line 1017 of file locale.inc.

References $op, _locale_import_message(), _locale_import_one_string(), and _locale_import_parse_quoted().

Referenced by _locale_batch_import(), _locale_import_po(), and st().

_locale_import_shorten_comments ( $ comment )

Generate a short, one string version of the passed comment array.

Parameters:
$comment An array of strings containing a comment
Returns:
Short one string version of the comment

Definition at line 1572 of file locale.inc.

Referenced by _locale_import_one_string().

_locale_import_tokenize_formula ( $ formula )

Backward compatible implementation of token_get_all() for formula parsing.

Parameters:
$string A string containing the arithmetic formula
Returns:
The PHP version of the formula

Definition at line 1487 of file locale.inc.

Referenced by _locale_import_parse_arithmetic().

_locale_invalidate_js ( $ langcode = NULL )

Force the JavaScript translation file(s) to be refreshed.

This function sets a refresh flag for a specified language, or all languages except English, if none specified. JavaScript translation files are rebuilt (with locale_update_js_files()) the next time a request is served in that language.

Parameters:
$langcode The language code for which the file needs to be refreshed.
Returns:
New content of the 'javascript_parsed' variable.

Definition at line 2033 of file locale.inc.

References language_list(), variable_get(), and variable_set().

Referenced by _locale_import_po(), locale_add_language(), locale_translate_delete(), and locale_translate_edit_form_submit().

_locale_languages_common_controls | ( | &$ | form,
 |  | $ | language = NULL
 | ) |  |

Common elements of the language addition and editing form.

Parameters:
$form | A parent form item (or empty array) to add items below.
$language | Language object to edit.

Definition at line 222 of file locale.inc.

References $language, language, name, and t().

Referenced by locale_languages_custom_form(), and locale_languages_edit_form().

_locale_parse_js_file ( $ filepath )

End of "Translation import API".

Parses a JavaScript file, extracts strings wrapped in Drupal.t() and Drupal.formatPlural() and inserts them into the database.

Definition at line 1618 of file locale.inc.

References $language, $result, db_fetch_object(), and db_query().

_locale_prepare_predefined_list ( )

Prepares the language code list for a select form item with only the unsupported ones.

Definition at line 2208 of file locale.inc.

References $value, _locale_get_predefined_list(), language_list(), and t().

Referenced by locale_languages_predefined_form(), and locale_translate_import_form().

_locale_rebuild_js ( $ langcode = NULL )

(Re-)Creates the JavaScript translation file for a language.

Parameters:
$language The language, the translation file should be (re)created for.

Definition at line 2059 of file locale.inc.

References $language, $result, $status, db_fetch_object(), db_query(), drupal_to_js(), file_check_directory(), file_create_path(), file_delete(), file_save_data(), language, language_default(), language_list(), name, t(), variable_get(), variable_set(), and watchdog().

Referenced by locale_languages_delete_form_submit().

_locale_translate_language_list | ( | $ | translation,
 |  | $ | limit_language
 | ) |  |

List languages in search result table.

Definition at line 2181 of file locale.inc.

References $language, $output, drupal_add_css(), drupal_get_path(), and language_list().

Referenced by _locale_translate_seek().

_locale_translate_seek ( )

Perform a string search and display results in a table.

Definition at line 1911 of file locale.inc.

References $header, $output, $pager, $result, $value, _locale_translate_language_list(), _locale_translate_seek_query(), check_plain(), db_fetch_object(), l(), module_invoke_all(), pager_query(), t(), theme(), and truncate_utf8().

Referenced by locale_translate_seek_screen().

_locale_translate_seek_query ( )

Build array out of search criteria specified in request variables.

Definition at line 2006 of file locale.inc.

Referenced by _locale_translate_seek(), and locale_translate_seek_form().

locale_add_language | ( | $ | langcode,
 |  | $ | name = NULL,
 |  | $ | native = NULL,
 |  | $ | direction = LANGUAGE_LTR,
 |  | $ | domain = '',
 |  | $ | prefix = '',
 |  | $ | enabled = TRUE,
 |  | $ | default = FALSE
 | ) |  |

API function to add a language.

Parameters:
$langcode | Language code.
$name | English name of the language
$native | Native name of the language
$direction | LANGUAGE_LTR or LANGUAGE_RTL
$domain | Optional custom domain name with protocol, without trailing slash (eg. http://de.example.com).
$prefix | Optional path prefix for the language. Defaults to the language code if omitted.
$enabled | Optionally TRUE to enable the language when created or FALSE to disable.
$default | Optionally set this language to be the default.

Definition at line 913 of file locale.inc.

References $name, _locale_get_predefined_list(), _locale_invalidate_js(), db_query(), variable_get(), variable_set(), and watchdog().

Referenced by install_tasks(), locale_languages_predefined_form_submit(), and locale_translate_import_form_submit().

locale_batch_by_component | ( | $ | components,
 |  | $ | finished = '_locale_batch_system_finished'
 | ) |  |

Prepare a batch to run when installing modules or enabling themes.

This batch will import translations for the newly added components in all the languages already set up on the site.

Parameters:
$components | An array of component (theme and/or module) names to import translations for.
$finished | Optional finished callback for the batch.

Definition at line 2471 of file locale.inc.

References $result, _locale_batch_build(), db_fetch_object(), db_query(), file_scan_directory(), language_list(), and name.

Referenced by locale_system_update().

locale_batch_by_language | ( | $ | langcode,
 |  | $ | finished = NULL,
 |  | $ | skip = array()
 | ) |  |

Prepare a batch to import translations for all enabled modules in a given language.

Parameters:
$langcode | Language code to import translations for.
$finished | Optional finished callback for the batch.
$skip | Array of component names to skip. Used in the installer for the second pass import, when most components are already imported.
Returns:
A batch structure or FALSE if no files found.

Definition at line 2439 of file locale.inc.

References $result, _locale_batch_build(), db_fetch_object(), db_placeholders(), db_query(), and file_scan_directory().

Referenced by install_tasks(), and locale_languages_predefined_form_submit().

locale_languages_add_screen ( )

User interface for the language addition screen.

Definition at line 144 of file locale.inc.

References $output, and drupal_get_form().

locale_languages_configure_form ( )

Setting for language negotiation options.

Definition at line 444 of file locale.inc.

References t(), and variable_get().

locale_languages_configure_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit function for language negotiation settings.

Definition at line 466 of file locale.inc.

References drupal_set_message(), t(), and variable_set().

locale_languages_custom_form ( )

Custom language addition form.

Definition at line 173 of file locale.inc.

References _locale_languages_common_controls(), and t().

locale_languages_delete_form | ( | &$ | form_state,
 |  | $ | langcode
 | ) |  |

User interface for the language deletion confirmation screen.

Definition at line 382 of file locale.inc.

References confirm_form(), drupal_goto(), drupal_not_found(), drupal_set_message(), language_default(), language_list(), name, and t().

locale_languages_delete_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process language deletion submissions.

Definition at line 410 of file locale.inc.

References _locale_rebuild_js(), cache_clear_all(), db_query(), drupal_set_message(), language_list(), name, t(), and watchdog().

locale_languages_edit_form | ( | &$ | form_state,
 |  | $ | langcode
 | ) |  |

Editing screen for a particular language.

Parameters:
$langcode Language code of the language to edit.

Definition at line 197 of file locale.inc.

References $language, _locale_languages_common_controls(), db_fetch_object(), db_query(), drupal_not_found(), and t().

locale_languages_edit_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process the language editing form submission.

Definition at line 355 of file locale.inc.

References db_query(), language, language_default(), and variable_set().

locale_languages_edit_form_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate the language editing form.

Reused for custom language addition too.

Definition at line 337 of file locale.inc.

References db_fetch_object(), db_query(), form_set_error(), language, language_default(), and t().

Referenced by locale_languages_predefined_form_validate().

locale_languages_overview_form ( )

User interface for the language overview screen.

Definition at line 31 of file locale.inc.

References $language, check_plain(), language_default(), language_list(), name, and t().

locale_languages_overview_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process language overview form submissions, updating existing languages.

Definition at line 100 of file locale.inc.

References $language, cache_clear_all(), db_query(), drupal_set_message(), language, language_default(), language_list(), t(), and variable_set().

locale_languages_predefined_form ( )

Predefined language setup form.

Definition at line 153 of file locale.inc.

References _locale_prepare_predefined_list(), and t().

locale_languages_predefined_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process the language addition form submission.

Definition at line 310 of file locale.inc.

References _locale_get_predefined_list(), batch_set(), drupal_set_message(), locale_add_language(), locale_batch_by_language(), t(), and url().

locale_languages_predefined_form_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate the language addition form.

Definition at line 287 of file locale.inc.

References _locale_get_predefined_list(), db_query(), db_result(), form_set_error(), locale_languages_edit_form_validate(), and t().

locale_translate_delete ( $ lid )

Delete a language string.

Definition at line 873 of file locale.inc.

References _locale_invalidate_js(), cache_clear_all(), db_query(), drupal_goto(), drupal_set_message(), and t().

locale_translate_edit_form | ( | &$ | form_state,
 |  | $ | lid
 | ) |  |

User interface for string editing.

Definition at line 769 of file locale.inc.

References $language, $result, check_plain(), db_fetch_object(), db_query(), drupal_goto(), drupal_set_message(), language_default(), language_list(), name, and t().

locale_translate_edit_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process string editing form submissions.

Saves all translations of one string submitted from a form.

Definition at line 831 of file locale.inc.

References $value, _locale_invalidate_js(), cache_clear_all(), db_query(), db_result(), drupal_set_message(), and t().

locale_translate_export_po_form | ( | &$ | form_state,
 |  | $ | names
 | ) |  |

Form to export PO files for the languages provided.

Parameters:
$names An associate array with localized language names

Definition at line 704 of file locale.inc.

References module_invoke_all(), and t().

locale_translate_export_po_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process a translation (or template) export form submission.

Definition at line 748 of file locale.inc.

References $language, _locale_export_get_strings(), _locale_export_po(), _locale_export_po_generate(), and language_list().

locale_translate_export_pot_form ( )

Translation template export form.

Definition at line 726 of file locale.inc.

References module_invoke_all(), and t().

locale_translate_export_screen ( )

User interface for the translation export screen.

Definition at line 685 of file locale.inc.

References $output, drupal_get_form(), and locale_language_list().

locale_translate_import_form ( )

User interface for the translation import screen.

Definition at line 590 of file locale.inc.

References _locale_prepare_predefined_list(), locale_language_list(), module_invoke_all(), and t().

locale_translate_import_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process the locale import form submission.

Definition at line 645 of file locale.inc.

References _locale_get_predefined_list(), _locale_import_po(), drupal_set_message(), file_save_upload(), language_list(), locale_add_language(), t(), and watchdog().

locale_translate_overview_screen ( )

Overview screen for translations.

Definition at line 484 of file locale.inc.

References $language, $name, db_fetch_object(), db_query(), language_list(), module_invoke_all(), name, t(), and theme().

locale_translate_seek_form ( )

User interface for the string search screen.

Definition at line 537 of file locale.inc.

References _locale_translate_seek_query(), locale_language_list(), module_invoke_all(), and t().

locale_translate_seek_screen ( )

String search screen.

Definition at line 528 of file locale.inc.

References $output, _locale_translate_seek(), and drupal_get_form().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/mail.inc File Reference

includes

mail.inc File Reference

Go to the source code of this file.

Functions

  • _drupal_html_to_mail_urls ($match=NULL, $reset=FALSE)
    Helper function for drupal_html_to_text().
  • _drupal_html_to_text_clean ($indent)
    Helper function for drupal_wrap_mail() and drupal_html_to_text().
  • _drupal_html_to_text_pad ($text, $pad, $prefix= '')
    Helper function for drupal_html_to_text().
  • _drupal_wrap_mail_line (&$line, $key, $values)
    Helper function for array_walk in drupal_wrap_mail().
  • drupal_html_to_text ($string, $allowed_tags=NULL)
    Transform an HTML string into plain text, preserving the structure of the markup.
  • drupal_mail ($module, $key, $to, $language, $params=array(), $from=NULL, $send=TRUE)
    Compose and optionally send an e-mail message.
  • drupal_mail_send ($message)
    Send an e-mail message, using Drupal variables and default settings.
  • drupal_wrap_mail ($text, $indent= '')
    Perform format=flowed soft wrapping for mail (RFC 3676).

Function Documentation

_drupal_html_to_mail_urls | ( | $ | match = NULL,
 |  | $ | reset = FALSE
 | ) |  |

Helper function for drupal_html_to_text().

Keeps track of URLs and replaces them with placeholder tokens.

Definition at line 433 of file mail.inc.

References $base_path, $base_url, and $url.

Referenced by drupal_html_to_text().

_drupal_html_to_text_clean ( $ indent )

Helper function for drupal_wrap_mail() and drupal_html_to_text().

Replace all non-quotation markers from a given piece of indentation with spaces.

Definition at line 460 of file mail.inc.

Referenced by drupal_wrap_mail().

_drupal_html_to_text_pad | ( | $ | text,
 |  | $ | pad,
 |  | $ | prefix = ''
 | ) |  |

Helper function for drupal_html_to_text().

Pad the last line with the given character.

Definition at line 469 of file mail.inc.

Referenced by drupal_html_to_text().

_drupal_wrap_mail_line | ( | &$ | line,
 |  | $ | key,
 |  | $ | values
 | ) |  |

Helper function for array_walk in drupal_wrap_mail().

Wraps words on a single line.

Definition at line 421 of file mail.inc.

Referenced by drupal_wrap_mail().

drupal_html_to_text | ( | $ | string,
 |  | $ | allowed_tags = NULL
 | ) |  |

Transform an HTML string into plain text, preserving the structure of the markup.

Useful for preparing the body of a node to be sent by e-mail.

The output will be suitable for use as 'format=flowed; delsp=yes' text (RFC 3676) and can be passed directly to drupal_mail() for sending.

We deliberately use LF rather than CRLF, see drupal_mail().

This function provides suitable alternatives for the following tags:

<blockquote>

  1. $string The string to be transformed. $allowed_tags (optional) If supplied, a list of tags that will be transformed. If omitted, all all supported tags are transformed. The transformed string.

Definition at line 259 of file mail.inc.

References $output, $tag, $value, _drupal_html_to_mail_urls(), _drupal_html_to_text_pad(), _filter_htmlcorrector(), decode_entities(), drupal_wrap_mail(), and filter_xss().

Referenced by hook_mail(), and system_mail().

drupal_mail | ( | $ | module,
 |  | $ | key,
 |  | $ | to,
 |  | $ | language,
 |  | $ | params = array(),
 |  | $ | from = NULL,
 |  | $ | send = TRUE
 | ) |  |

Compose and optionally send an e-mail message.

Sending an e-mail works with defining an e-mail template (subject, text and possibly e-mail headers) and the replacement values to use in the appropriate places in the template. Processed e-mail templates are requested from hook_mail() from the module sending the e-mail. Any module can modify the composed e-mail message array using hook_mail_alter(). Finally drupal_mail_send() sends the e-mail, which can be reused if the exact same composed e-mail is to be sent to multiple recipients.

Finding out what language to send the e-mail with needs some consideration. If you send e-mail to a user, her preferred language should be fine, so use user_preferred_language(). If you send email based on form values filled on the page, there are two additional choices if you are not sending the e-mail to a user on the site. You can either use the language used to generate the page ($language global variable) or the site default language. See language_default(). The former is good if sending e-mail to the person filling the form, the later is good if you send e-mail to an address previously set up (like contact addresses in a contact form).

Taking care of always using the proper language is even more important when sending e-mails in a row to multiple users. Hook_mail() abstracts whether the mail text comes from an administrator setting or is static in the source code. It should also deal with common mail tokens, only receiving $params which are unique to the actual e-mail at hand.

An example:

   function example_notify($accounts) {
     foreach ($accounts as $account) {
       $params['account'] = $account;
       // example_mail() will be called based on the first drupal_mail() parameter.
       drupal_mail('example', 'notify', $account->mail, user_preferred_language($account), $params);
     }
   }

   function example_mail($key, &$message, $params) {
     $language = $message['language'];
     $variables = user_mail_tokens($params['account'], $language);
     switch($key) {
       case 'notice':
         $message['subject'] = t('Notification from !site', $variables, $language->language);
         $message['body'] = t("Dear !username\n\nThere is new content available on the site.", $variables, $language->language);
         break;
     }
   }

Parameters:
$module | A module name to invoke hook_mail() on. The {$module}_mail() hook will be called to complete the $message structure which will already contain common defaults.
$key | A key to identify the e-mail sent. The final e-mail id for e-mail altering will be {$module}_{$key}.
$to | The e-mail address or addresses where the message will be sent to. The formatting of this string must comply with RFC 2822. Some examples are: user@example.com user@example.com, anotheruser@example.com User <user@example.com> User <user@example.com>, Another User <anotheruser@example.com>
$language | Language object to use to compose the e-mail.
$params | Optional parameters to build the e-mail.
$from | Sets From, Reply-To, Return-Path and Error-To to this value, if given.
$send | Send the message directly, without calling drupal_mail_send() manually.
Returns:
The $message array structure containing all details of the message. If already sent ($send = TRUE), then the 'result' element will contain the success indicator of the e-mail, failure being already written to the watchdog. (Success means nothing more than the message being accepted at php-level, which still doesn't guarantee it to be delivered.)

Definition at line 83 of file mail.inc.

References $language, drupal_alter(), drupal_mail_send(), drupal_set_message(), drupal_wrap_mail(), t(), variable_get(), and watchdog().

Referenced by _update_cron_notify(), _user_mail_notify(), contact_mail_page_submit(), contact_mail_user_submit(), hook_watchdog(), and system_send_email_action().

drupal_mail_send ( $ message )

Send an e-mail message, using Drupal variables and default settings.

More information in the PHP function reference for mail(). See drupal_mail() for information on how $message is composed.

Parameters:
$message Message array with at least the following elements:
  • id A unique identifier of the e-mail type. Examples: 'contact_user_copy', 'user_password_reset'.
  • to The mail address or addresses where the message will be sent to. The formatting of this string must comply with RFC 2822. Some examples are: user@example.com user@example.com, anotheruser@example.com User <user@example.com> User <user@example.com>, Another User <anotheruser@example.com>
  • subject Subject of the e-mail to be sent. This must not contain any newline characters, or the mail may not be sent properly.
  • body Message to be sent. Accepts both CRLF and LF line-endings. E-mail bodies must be wrapped. You can use drupal_wrap_mail() for smart plain text wrapping.
  • headers Associative array containing all mail headers.
Returns:
Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

Definition at line 173 of file mail.inc.

References $name, $value, mime_header_encode(), and variable_get().

Referenced by drupal_mail().

drupal_wrap_mail | ( | $ | text,
 |  | $ | indent = ''
 | ) |  |

Perform format=flowed soft wrapping for mail (RFC 3676).

We use delsp=yes wrapping, but only break non-spaced languages when absolutely necessary to avoid compatibility issues.

We deliberately use LF rather than CRLF, see drupal_mail().

Parameters:
$text | The plain text to process.
$indent | (optional) A string to indent the text with. Only '>' characters are repeated on subsequent wrapped lines. Others are replaced by spaces.

Definition at line 209 of file mail.inc.

References _drupal_html_to_text_clean(), and _drupal_wrap_mail_line().

Referenced by drupal_html_to_text(), and drupal_mail().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/menu.inc File Reference

includes

menu.inc File Reference

Detailed Description

API for the Drupal menu system.

Definition in file menu.inc.

Go to the source code of this file.

Enumerations

Menu status codes
End of "Menu item types".

Status codes for menu callbacks.

  • enum MENU_ACCESS_DENIED
  • enum MENU_FOUND
  • enum MENU_NOT_FOUND
  • enum MENU_SITE_OFFLINE
Menu item types
End of "Menu flags".

Menu item definitions provide one of these constants, which are shortcuts for combinations of the above flags.

  • enum MENU_CALLBACK
    Callbacks simply register a path so that the correct function is fired when the URL is accessed. More...
  • enum MENU_DEFAULT_LOCAL_TASK
    Every set of local tasks should provide one "default" task, that links to the same path as its parent when clicked. More...
  • enum MENU_LOCAL_TASK
    Local tasks are rendered as tabs by default. More...
  • enum MENU_NORMAL_ITEM
    Normal menu items show up in the menu tree and can be moved/hidden by the administrator. More...
  • enum MENU_SUGGESTED_ITEM
    Modules may "suggest" menu items that the administrator may enable. More...
Menu flags
Flags for use in the "type" attribute of menu items.

  • enum MENU_CREATED_BY_ADMIN
  • enum MENU_IS_LOCAL_TASK
  • enum MENU_IS_ROOT
  • enum MENU_LINKS_TO_PARENT
  • enum MENU_MODIFIED_BY_ADMIN
  • enum MENU_VISIBLE_IN_BREADCRUMB
  • enum MENU_VISIBLE_IN_TREE
  • enum MENU_MAX_DEPTH
    The maximum depth of a menu links tree - matches the number of p columns. More...
  • enum MENU_MAX_PARTS
    End of "Menu status codes". More...

Functions

  • _menu_check_access (&$item, $map)
    Check access to a menu item using the access callback.
  • _menu_clear_page_cache ()
    Helper function to clear the page and block caches at most twice per page load.
  • _menu_delete_item ($item, $force=FALSE)
    Helper function for menu_link_delete; deletes a single menu link.
  • _menu_find_router_path ($menu, $link_path)
    Find the router path which will serve this path.
  • _menu_item_localize (&$item, $map, $link_translate=FALSE)
    Localize the router item title using t() or another callback.
  • _menu_link_build ($item)
    Builds a link from a router item.
  • _menu_link_map_translate (&$map, $to_arg_functions)
    This function translates the path elements in the map using any to_arg helper function.
  • _menu_link_move_children ($item, $existing_item)
    Update the children of a menu link that's being moved.
  • _menu_link_parents_set (&$item, $parent)
    Helper function that sets the p1.
  • _menu_link_translate (&$item)
    This function is similar to _menu_translate() but does link-specific preparation such as always calling to_arg functions.
  • _menu_load_objects (&$item, &$map)
    Loads objects into the map as defined in the $item['load_functions'].
  • _menu_navigation_links_rebuild ($menu)
    Helper function to build menu links for the items in the menu router.
  • _menu_router_build ($callbacks)
    Helper function to build the router table based on the data from hook_menu.
  • _menu_set_expanded_menus ()
    Helper function to update a list of menus with expanded items.
  • _menu_site_is_offline ()
    Checks whether the site is off-line for maintenance.
  • _menu_translate (&$router_item, $map, $to_arg=FALSE)
    Handles dynamic path translation and menu access control.
  • _menu_tree_check_access (&$tree)
    Recursive helper function for menu_tree_check_access().
  • _menu_tree_data ($result, $parents, $depth, $previous_element= '')
    Recursive helper function to build the data representing a menu tree.
  • _menu_update_parental_status ($item, $exclude=FALSE)
    Check and update the has_children status for the parent of a link.
  • drupal_help_arg ($arg=array())
    Generates elements for the $arg array in the help hook.
  • menu_cache_clear ($menu_name= 'navigation')
    Clears the cached cached data for a single named menu.
  • menu_cache_clear_all ()
    Clears all cached menu data.
  • menu_execute_active_handler ($path=NULL)
    Execute the page callback associated with the current path.
  • menu_get_active_breadcrumb ()
    Get the breadcrumb for the current page, as determined by the active trail.
  • menu_get_active_help ()
    Returns the help associated with the active menu item.
  • menu_get_active_menu_name ()
    Get the active menu for the current page - determines the active trail.
  • menu_get_active_title ()
    Get the title of the current page, as determined by the active trail.
  • menu_get_active_trail ()
    Get the active trail for the current page - the path to root in the menu tree.
  • menu_get_ancestors ($parts)
    End of "Menu tree parameters".
  • menu_get_item ($path=NULL, $router_item=NULL)
    Get a router item.
  • menu_get_names ($reset=FALSE)
    Build a list of named menus.
  • menu_get_object ($type= 'node', $position=1, $path=NULL)
    Get a loaded object from a router item.
  • menu_link_children_relative_depth ($item)
    Find the depth of an item's children relative to its depth.
  • menu_link_delete ($mlid, $path=NULL)
    Delete one or several menu links.
  • menu_link_load ($mlid)
    Get a menu link by its mlid, access checked and link translated for rendering.
  • menu_link_maintain ($module, $op, $link_path, $link_title)
    Insert, update or delete an uncustomized menu link related to a module.
  • menu_link_save (&$item)
    Save a menu link.
  • menu_list_system_menus ()
    Return an array containing the names of system-defined (default) menus.
  • menu_local_tasks ($level=0, $return_root=FALSE)
    Collects the local tasks (tabs) for a given level.
  • menu_navigation_links ($menu_name, $level=0)
    Return an array of links for a navigation menu.
  • menu_path_is_external ($path)
    Returns TRUE if a path is external (e.g.
  • menu_primary_links ()
    Return an array of links to be rendered as the Primary links.
  • menu_primary_local_tasks ()
    Returns the rendered local tasks at the top level.
  • menu_rebuild ()
    (Re)populate the database tables used by various menu functions.
  • menu_router_build ($reset=FALSE)
    Collect, alter and store the menu definitions.
  • menu_secondary_links ()
    Return an array of links to be rendered as the Secondary links.
  • menu_secondary_local_tasks ()
    Returns the rendered local tasks at the second level.
  • menu_set_active_item ($path)
    Set the active path, which determines which page is loaded.
  • menu_set_active_menu_name ($menu_name=NULL)
    Set (or get) the active menu for the current page - determines the active trail.
  • menu_set_active_trail ($new_trail=NULL)
    Set (or get) the active trail for the current page - the path to root in the menu tree.
  • menu_set_item ($path, $router_item)
    Replaces the statically cached item for a given path.
  • menu_tab_root_path ()
    Returns the router path, or the path of the parent tab of a default local task.
  • menu_tail_to_arg ($arg, $map, $index)
  • menu_tree ($menu_name= 'navigation')
    Render a menu tree based on the current path.
  • menu_tree_all_data ($menu_name= 'navigation', $item=NULL)
    Get the data structure representing a named menu tree.
  • menu_tree_check_access (&$tree, $node_links=array())
    Check access and perform other dynamic operations for each link in the tree.
  • menu_tree_collect_node_links (&$tree, &$node_links)
    Recursive helper function - collect node links.
  • menu_tree_data ($result=NULL, $parents=array(), $depth=1)
    Build the data representing a menu tree.
  • menu_tree_output ($tree)
    Returns a rendered menu tree.
  • menu_tree_page_data ($menu_name= 'navigation')
    Get the data structure representing a named menu tree, based on the current page.
  • menu_unserialize ($data, $map)
    The menu system uses serialized arrays stored in the database for arguments.
  • menu_valid_path ($form_item)
    Validates the path of a menu link being created or edited.
  • theme_menu_item ($link, $has_children, $menu= '', $in_active_trail=FALSE, $extra_class=NULL)
    Generate the HTML output for a menu item and submenu.
  • theme_menu_item_link ($link)
    Generate the HTML output for a single menu link.
  • theme_menu_local_task ($link, $active=FALSE)
    Generate the HTML output for a single local task link.
  • theme_menu_local_tasks ()
    Returns the rendered local tasks.
  • theme_menu_tree ($tree)
    Generate the HTML output for a menu tree.
Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/module.inc File Reference

includes

module.inc File Reference

Detailed Description

API for loading and interacting with Drupal modules.

Definition in file module.inc.

Go to the source code of this file.

Functions

  • _module_build_dependencies ($files)
    Find dependencies any level deep and fill in dependents information too.
  • drupal_required_modules ()
    End of "defgroup hooks".
  • module_disable ($module_list)
    Disable a given set of modules.
  • module_enable ($module_list)
    Enable a given list of modules.
  • module_exists ($module)
    Determine whether a given module exists.
  • module_hook ($module, $hook)
    Determine whether a module implements a hook.
  • module_implements ($hook, $sort=FALSE, $refresh=FALSE)
    Determine which modules are implementing a hook.
  • module_invoke ()
    Invoke a hook in a particular module.
  • module_invoke_all ()
    Invoke a hook in all enabled modules that implement it.
  • module_iterate ($function, $argument= '')
    Call a function repeatedly with each module in turn as an argument.
  • module_list ($refresh=FALSE, $bootstrap=TRUE, $sort=FALSE, $fixed_list=NULL)
    Collect a list of all loaded modules.
  • module_load_all ()
    Load all the modules that have been enabled in the system table.
  • module_load_all_includes ($type, $name=NULL)
    Load an include file for each of the modules that have been enabled in the system table.
  • module_load_include ($type, $module, $name=NULL)
    Load a module include file.
  • module_load_install ($module)
    Load a module's installation hooks.
  • module_rebuild_cache ()
    Rebuild the database cache of module files.

Function Documentation

_module_build_dependencies ( $ files )

Find dependencies any level deep and fill in dependents information too.

If module A depends on B which in turn depends on C then this function will add C to the list of modules A depends on. This will be repeated until module A has a list of all modules it depends on. If it depends on itself, called a circular dependency, that's marked by adding a nonexistent module, called -circular- to this list of modules. Because this does not exist, it'll be impossible to switch module A on.

Also we fill in a dependents array in $file->info. Using the names above, the dependents array of module B lists A.

Parameters:
$files The array of filesystem objects used to rebuild the cache.
Returns:
The same array with dependencies and dependents added where applicable.

Definition at line 172 of file module.inc.

References drupal_set_message(), and t().

Referenced by module_rebuild_cache().

drupal_required_modules ( )

End of "defgroup hooks".

Array of modules required by core.

Definition at line 490 of file module.inc.

Referenced by drupal_check_profile(), drupal_verify_profile(), and system_modules().

module_disable ( $ module_list )

Disable a given set of modules.

Parameters:
$module_list An array of module names.

Definition at line 323 of file module.inc.

References $module_list, db_query(), module_exists(), module_hook(), module_implements(), module_invoke(), module_list(), module_load_install(), node_access_needs_rebuild(), and node_access_rebuild().

Referenced by system_modules_submit(), and system_update_6018().

module_enable ( $ module_list )

Enable a given list of modules.

Parameters:
$module_list An array of module names.

Definition at line 286 of file module.inc.

References $module_list, db_fetch_object(), db_query(), drupal_load(), module_hook(), module_implements(), module_invoke(), module_list(), module_load_install(), and node_access_needs_rebuild().

Referenced by _install_module_batch(), drupal_install_modules(), system_modules_submit(), and system_update_6029().

module_exists ( $ module )

Determine whether a given module exists.

Parameters:
$module The name of the module (without the .module extension).
Returns:
TRUE if the module is both installed and enabled.

Definition at line 229 of file module.inc.

References module_list().

Referenced by _block_get_cache_id(), block_admin_display_form(), block_help(), chameleon_node(), contact_help(), language_list(), menu_get_active_help(), module_disable(), node_admin_nodes(), node_filters(), node_revision_revert_confirm_submit(), node_search(), path_admin_overview(), phptemplate_preprocess_page(), system_admin_by_module(), system_help(), system_modules(), system_requirements(), system_theme_settings(), system_update_6018(), template_preprocess_block_admin_display_form(), template_preprocess_node(), theme_aggregator_block_item(), theme_get_settings(), theme_system_modules(), trigger_access_check(), update_results_page(), and user_edit_form().

module_iterate | ( | $ | function,
 |  | $ | argument = ''
 | ) |  |

Call a function repeatedly with each module in turn as an argument.

Definition at line 21 of file module.inc.

References $name, and module_list().

module_list | ( | $ | refresh = FALSE,
 |  | $ | bootstrap = TRUE,
 |  | $ | sort = FALSE,
 |  | $ | fixed_list = NULL
 | ) |  |

Collect a list of all loaded modules.

During the bootstrap, return only vital modules. See bootstrap.inc

Parameters:
$refresh | Whether to force the module list to be regenerated (such as after the administrator has changed the system settings).
$bootstrap | Whether to return the reduced set of modules loaded in "bootstrap mode" for cached pages. See bootstrap.inc.
$sort | By default, modules are ordered by weight and filename, settings this option to TRUE, module list will be ordered by module name.
$fixed_list | (Optional) Override the module list with the given modules. Stays until the next call with $refresh = TRUE.
Returns:
An associative array whose keys and values are the names of all loaded modules.

Definition at line 47 of file module.inc.

References $name, $result, db_fetch_object(), db_query(), drupal_get_filename(), name, and variable_get().

Referenced by _block_rehash(), _drupal_maintenance_theme(), _theme_process_registry(), _user_categories(), _user_forms(), bootstrap_invoke_all(), filter_list_all(), install_main(), menu_get_active_help(), module_disable(), module_enable(), module_exists(), module_implements(), module_iterate(), module_load_all(), module_load_all_includes(), search_admin_settings(), system_modules_submit(), system_requirements(), system_update_6027(), user_admin_perm(), user_filters(), and user_module_invoke().

module_load_all ( )

Load all the modules that have been enabled in the system table.

Definition at line 12 of file module.inc.

References drupal_load(), and module_list().

Referenced by _drupal_bootstrap_full().

module_load_all_includes | ( | $ | type,
 |  | $ | name = NULL
 | ) |  |

Load an include file for each of the modules that have been enabled in the system table.

Definition at line 273 of file module.inc.

References $name, $type, module_list(), and module_load_include().

Referenced by drupal_get_schema().

module_load_include | ( | $ | type,
 |  | $ | module,
 |  | $ | name = NULL
 | ) |  |

Load a module include file.

Parameters:
$type | The include file's type (file extension).
$module | The module to which the include file belongs.
$name | Optionally, specify the file name. If not set, the module's name is used.

Definition at line 254 of file module.inc.

References $name, and drupal_get_path().

Referenced by _update_refresh(), drupal_get_schema_unprocessed(), forum_overview(), module_load_all_includes(), module_load_install(), openid_association(), openid_association_request(), openid_authentication(), openid_authentication_request(), openid_begin(), openid_complete(), openid_discovery(), openid_verify_assertion(), update_get_available(), update_refresh(), update_requirements(), and update_status().

module_load_install ( $ module )

Load a module's installation hooks.

Definition at line 237 of file module.inc.

References module_load_include().

Referenced by _drupal_install_module(), drupal_load_updates(), drupal_uninstall_module(), module_disable(), module_enable(), and system_modules_uninstall().

module_rebuild_cache ( )

Rebuild the database cache of module files.

Returns:
The array of filesystem objects used to rebuild the cache.

Definition at line 96 of file module.inc.

References _module_build_dependencies(), bootstrap_hooks(), db_query(), drupal_alter(), drupal_parse_info_file(), drupal_system_listing(), module_hook(), name, and system_get_files_database().

Referenced by drupal_install_modules(), drupal_install_system(), help_links_as_list(), install_tasks(), system_admin_by_module(), system_modules(), system_update_6008(), system_update_6013(), update_check_incompatibility(), and update_get_projects().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/pager.inc File Reference

includes

pager.inc File Reference

Detailed Description

Functions to aid in presenting database results as a set of pages.

Definition in file pager.inc.

Go to the source code of this file.

Functions

  • pager_get_querystring ()
    Compose a query string to append to pager requests.
  • pager_load_array ($value, $element, $old_array)
    End of "Pager pieces".
  • pager_query ($query, $limit=10, $element=0, $count_query=NULL)
    Perform a paged database query.
  • theme_pager ($tags=array(), $limit=10, $element=0, $parameters=array(), $quantity=9)
    Format a query pager.
Pager pieces
Use these pieces to construct your own custom pagers in your theme.

Note that you should NOT modify this file to customize your pager.

  • theme_pager_first ($text, $limit, $element=0, $parameters=array())
    Format a "first page" link.
  • theme_pager_last ($text, $limit, $element=0, $parameters=array())
    Format a "last page" link.
  • theme_pager_link ($text, $page_new, $element, $parameters=array(), $attributes=array())
    Format a link to a specific query result page.
  • theme_pager_next ($text, $limit, $element=0, $interval=1, $parameters=array())
    Format a "next page" link.
  • theme_pager_previous ($text, $limit, $element=0, $interval=1, $parameters=array())
    Format a "previous page" link.

Function Documentation

pager_get_querystring ( )

Compose a query string to append to pager requests.

Returns:
A query string that consists of all components of the current page request except for those pertaining to paging.

Definition at line 85 of file pager.inc.

References drupal_query_string_encode().

Referenced by theme_pager_link().

pager_load_array | ( | $ | value,
 |  | $ | element,
 |  | $ | old_array
 | ) |  |

End of "Pager pieces".

Helper function Copies $old_array to $new_array and sets $new_array[$element] = $value Fills in $new_array[0 .. $element - 1] = 0

Definition at line 422 of file pager.inc.

References $element, and $value.

Referenced by theme_pager_first(), theme_pager_last(), theme_pager_link(), theme_pager_next(), and theme_pager_previous().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/path.inc File Reference

includes

path.inc File Reference

Detailed Description

Functions to handle paths in Drupal, including path aliasing.

These functions are not loaded for cached pages, but modules that need to use them in hook_init() or hook exit() can make them available, by executing "drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);".

Definition in file path.inc.

Go to the source code of this file.

Functions

  • arg ($index=NULL, $path=NULL)
    Return a component of the current Drupal path.
  • drupal_get_normal_path ($path, $path_language= '')
    Given a path alias, return the internal path it represents.
  • drupal_get_path_alias ($path, $path_language= '')
    Given an internal Drupal path, return the alias set by the administrator.
  • drupal_get_title ()
    Get the title of the current page, for display on the page and in the title bar.
  • drupal_init_path ()
    Initialize the $_GET['q'] variable to the proper normal path.
  • drupal_is_front_page ()
    Check if the current page is the front page.
  • drupal_lookup_path ($action, $path= '', $path_language= '')
    Given an alias, return its Drupal system URL if one exists.
  • drupal_match_path ($path, $patterns)
    Check if a path matches any pattern in a set of patterns.
  • drupal_set_title ($title=NULL)
    Set the title of the current page, for display on the page and in the title bar.

Function Documentation

arg | ( | $ | index = NULL,
 |  | $ | path = NULL
 | ) |  |

Return a component of the current Drupal path.

When viewing a page at the path "admin/content/types", for example, arg(0) would return "admin", arg(1) would return "content", and arg(2) would return "types".

Avoid use of this function where possible, as resulting code is hard to read. Instead, attempt to use named arguments in menu callback functions. See the explanation in menu.inc for how to construct callbacks that take arguments.

Parameters:
$index The index of the component, where each component is separated by a '/' (forward-slash), and where the first component has an index of 0 (zero).
Returns:
The component specified by $index, or NULL if the specified component was not found.

Definition at line 159 of file path.inc.

Referenced by _trigger_normalize_user_context(), aggregator_form_category_submit(), aggregator_form_feed_submit(), aggregator_page_category(), aggregator_page_last(), aggregator_page_rss(), aggregator_page_source(), block_admin_display_form(), blog_link(), color_form_alter(), color_scheme_form(), comment_admin(), comment_node_url(), comment_render(), dblog_init(), filter_admin_delete(), filter_tips_long(), forum_nodeapi(), menu_get_active_help(), menu_get_item(), menu_local_tasks(), menu_set_active_trail(), openid_user_add_validate(), profile_block(), profile_field_form(), statistics_exit(), statistics_node_tracker(), statistics_user_tracker(), system_init(), template_preprocess_page(), template_preprocess_profile_wrapper(), update_help(), user_admin_role(), user_block(), and user_user().

drupal_get_normal_path | ( | $ | path,
 |  | $ | path_language = ''
 | ) |  |

Given a path alias, return the internal path it represents.

Parameters:
$path | A Drupal path alias.
$path_language | An optional language code to look up the path in.
Returns:
The internal path represented by the alias, or the original alias if no internal path was found.

Definition at line 128 of file path.inc.

References $result, custom_url_rewrite_inbound(), and drupal_lookup_path().

Referenced by _menu_site_is_offline(), drupal_access_denied(), drupal_init_path(), drupal_is_front_page(), drupal_not_found(), menu_edit_item_validate(), system_site_information_settings_validate(), and system_update_6021().

drupal_get_path_alias | ( | $ | path,
 |  | $ | path_language = ''
 | ) |  |

Given an internal Drupal path, return the alias set by the administrator.

Parameters:
$path | An internal Drupal path.
$path_language | An optional language code to look up the path in.
Returns:
An aliased path if one was found, or the original path if no alias was found.

Definition at line 108 of file path.inc.

References $result, and drupal_lookup_path().

Referenced by _statistics_link(), block_list(), path_nodeapi(), path_set_alias(), and url().

drupal_get_title ( )

Get the title of the current page, for display on the page and in the title bar.

Returns:
The current page's title.

Definition at line 182 of file path.inc.

References $title, check_plain(), drupal_set_title(), and menu_get_active_title().

Referenced by chameleon_page(), statistics_exit(), template_preprocess_maintenance_page(), and template_preprocess_page().

drupal_init_path ( )

Initialize the $_GET['q'] variable to the proper normal path.

Definition at line 16 of file path.inc.

References drupal_get_normal_path(), and variable_get().

Referenced by _drupal_bootstrap().

drupal_is_front_page ( )

Check if the current page is the front page.

Returns:
Boolean value: TRUE if the current page is the front page; FALSE if otherwise.

Definition at line 218 of file path.inc.

References drupal_get_normal_path(), and variable_get().

Referenced by blogapi_init(), l(), menu_get_active_breadcrumb(), menu_set_active_trail(), menu_tree_page_data(), template_preprocess(), and template_preprocess_page().

drupal_lookup_path | ( | $ | action,
 |  | $ | path = '',
 |  | $ | path_language = ''
 | ) |  |

Given an alias, return its Drupal system URL if one exists.

Given a Drupal system URL return one of its aliases if such a one exists. Otherwise, return FALSE.

Parameters:
$action One of the following values:
  • wipe: delete the alias cache.
  • alias: return an alias for a given Drupal system path (if one exists).
  • source: return the Drupal system URL for a path alias (if one exists).
$path | The path to investigate for corresponding aliases or system URLs.
$path_language | Optional language code to search the path with. Defaults to the page language. If there's no path defined for that language it will search paths without language.
Returns:
Either a Drupal system path, an aliased path, or FALSE if no path was found.

Definition at line 46 of file path.inc.

References $language, db_query(), and db_result().

Referenced by drupal_clear_path_cache(), drupal_get_normal_path(), and drupal_get_path_alias().

drupal_match_path | ( | $ | path,
 |  | $ | patterns
 | ) |  |

Check if a path matches any pattern in a set of patterns.

Parameters:
$path The path to match.
$patterns String containing a set of patterns separated by
, or
.
Returns:
Boolean value: TRUE if the path matches a pattern, FALSE otherwise.

Definition at line 235 of file path.inc.

References variable_get().

Referenced by block_list().

drupal_set_title ( $ title = NULL )

Set the title of the current page, for display on the page and in the title bar.

Parameters:
$title Optional string value to assign to the page title; or if set to NULL (default), leaves the current title unchanged.
Returns:
The updated title of the current page.

Definition at line 203 of file path.inc.

References $title.

Referenced by _batch_do(), _batch_progress_page_js(), _batch_progress_page_nojs(), _db_error_page(), aggregator_page_source(), block_admin_configure(), blog_page_user(), book_admin_edit(), book_outline(), comment_form_add_preview(), confirm_form(), contact_user_page(), drupal_access_denied(), drupal_get_title(), drupal_not_found(), drupal_site_offline(), example_profile_tasks(), filter_admin_configure_page(), filter_admin_format_page(), filter_admin_order_page(), forum_overview(), help_page(), install_already_done_error(), install_change_settings(), install_main(), install_no_profile_error(), install_select_locale(), install_select_profile(), install_tasks(), node_add(), node_page_default(), node_page_edit(), node_page_view(), node_preview(), node_revision_overview(), node_show(), openid_user_identities(), path_admin_edit(), poll_results(), poll_votes(), profile_browse(), profile_field_form(), statistics_node_tracker(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), statistics_user_tracker(), taxonomy_add_term_page(), taxonomy_overview_terms(), taxonomy_term_page(), template_preprocess_forums(), tracker_page(), translation_node_overview(), update_access_denied_page(), update_info_page(), update_results_page(), update_selection_page(), user_edit(), and user_view().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/session.inc File Reference

includes

session.inc File Reference

Detailed Description

User session handling functions.

Definition in file session.inc.

Go to the source code of this file.

Functions

  • sess_close ()
  • sess_count ($timestamp=0, $anonymous=true)
    Counts how many users have sessions.
  • sess_destroy_sid ($sid)
    Called by PHP session handling with the PHP session ID to end a user's session.
  • sess_destroy_uid ($uid)
    End a specific user's session.
  • sess_gc ($lifetime)
  • sess_open ($save_path, $session_name)
  • sess_read ($key)
  • sess_regenerate ()
    Called when an anonymous user becomes authenticated or vice-versa.
  • sess_write ($key, $value)
  • session_save_session ($status=NULL)
    Determine whether to save session data of the current request.

Function Documentation

sess_close ( )

Definition at line 13 of file session.inc.

sess_count | ( | $ | timestamp = 0,
 |  | $ | anonymous = true
 | ) |  |

Counts how many users have sessions.

Can count either anonymous sessions, authenticated sessions, or both.

Parameters:
int | $timestamp A Unix timestamp representing a point of time in the past. The default is 0, which counts all existing sessions.
int | $anonymous TRUE counts only anonymous users. FALSE counts only authenticated users. Any other value will return the count of both authenticated and anonymous users.
Returns:
int The number of users with sessions.

Definition at line 122 of file session.inc.

References db_query(), and db_result().

Referenced by throttle_exit(), and user_block().

sess_destroy_sid ( $ sid )

Called by PHP session handling with the PHP session ID to end a user's session.

Parameters:
string $sid the session id

Definition at line 133 of file session.inc.

References db_query().

sess_destroy_uid ( $ uid )

End a specific user's session.

Parameters:
string $uid the user id

Definition at line 143 of file session.inc.

References db_query().

Referenced by user_block_user_action(), user_delete(), and user_save().

sess_gc ( $ lifetime )

Definition at line 147 of file session.inc.

References db_query().

sess_open | ( | $ | save_path,
 |  | $ | session_name
 | ) |  |

Definition at line 9 of file session.inc.

sess_read ( $ key )

Definition at line 17 of file session.inc.

References $result, $user, db_fetch_object(), db_query(), drupal_anonymous_user(), and drupal_unpack().

sess_regenerate ( )

Called when an anonymous user becomes authenticated or vice-versa.

Definition at line 92 of file session.inc.

References db_query().

Referenced by user_authenticate_finalize(), and user_save().

sess_write | ( | $ | key,
 |  | $ | value
 | ) |  |

Definition at line 56 of file session.inc.

References $result, $user, $value, db_query(), db_result(), ip_address(), session_save_session(), and variable_get().

session_save_session ( $ status = NULL )

Determine whether to save session data of the current request.

This function allows the caller to temporarily disable writing of session data, should the request end while performing potentially dangerous operations, such as manipulating the global $user object. See http://drupal.org/node/218104 for usage

Parameters:
$status Disables writing of session data when FALSE, (re-)enables writing when TRUE.
Returns:
FALSE if writing session data has been disabled. Otherwise, TRUE.

Definition at line 170 of file session.inc.

References $status.

Referenced by sess_write().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/tablesort.inc File Reference

includes

tablesort.inc File Reference

Detailed Description

Functions to aid in the creation of sortable tables.

All tables created with a call to theme('table') have the option of having column headers that the user can click on to sort the table by that column.

Definition in file tablesort.inc.

Go to the source code of this file.

Functions

  • tablesort_cell ($cell, $header, $ts, $i)
    Format a table cell.
  • tablesort_get_order ($headers)
    Determine the current sort criterion.
  • tablesort_get_querystring ()
    Compose a query string to append to table sorting requests.
  • tablesort_get_sort ($headers)
    Determine the current sort direction.
  • tablesort_header ($cell, $header, $ts)
    Format a column header.
  • tablesort_init ($header)
    Initialize the table sort context.
  • tablesort_sql ($header, $before= '')
    Create an SQL sort clause.

Function Documentation

tablesort_cell | ( | $ | cell,
 |  | $ | header,
 |  | $ | ts,
 |  | $ | i
 | ) |  |

Format a table cell.

Adds a class attribute to all cells in the currently active column.

Parameters:
$cell | The cell to format.
$header | An array of column headers in the format described in theme_table().
$ts | The current table sort context as returned from tablesort_init().
$i | The index of the cell's table column.
Returns:
A properly formatted cell, ready for _theme_table_cell().

Definition at line 114 of file tablesort.inc.

References $header.

Referenced by theme_table().

tablesort_get_order ( $ headers )

Determine the current sort criterion.

Parameters:
$headers An array of column headers in the format described in theme_table().
Returns:
An associative array describing the criterion, containing the keys:
  • "name": The localized title of the table column.
  • "sql": The name of the database field to sort on.

Definition at line 152 of file tablesort.inc.

References $header.

Referenced by tablesort_init().

tablesort_get_querystring ( )

Compose a query string to append to table sorting requests.

Returns:
A query string that consists of all components of the current page request except for those pertaining to table sorting.

Definition at line 138 of file tablesort.inc.

References drupal_query_string_encode().

Referenced by tablesort_init().

tablesort_get_sort ( $ headers )

Determine the current sort direction.

Parameters:
$headers An array of column headers in the format described in theme_table().
Returns:
The current sort direction ("asc" or "desc").

Definition at line 187 of file tablesort.inc.

References $header.

Referenced by tablesort_init().

tablesort_header | ( | $ | cell,
 |  | $ | header,
 |  | $ | ts
 | ) |  |

Format a column header.

If the cell in question is the column header for the current sort criterion, it gets special formatting. All possible sort criteria become links.

Parameters:
$cell | The cell to format.
$header | An array of column headers in the format described in theme_table().
$ts | The current table sort context as returned from tablesort_init().
Returns:
A properly formatted cell, ready for _theme_table_cell().

Definition at line 68 of file tablesort.inc.

References $image, $title, l(), t(), and theme().

Referenced by template_preprocess_forum_topic_list(), and theme_table().

tablesort_init ( $ header )

Initialize the table sort context.

Definition at line 15 of file tablesort.inc.

References $header, tablesort_get_order(), tablesort_get_querystring(), and tablesort_get_sort().

Referenced by tablesort_sql(), template_preprocess_forum_topic_list(), and theme_table().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/theme.inc File Reference

includes

theme.inc File Reference

Detailed Description

The theme system, which controls the output of Drupal.

The theme system allows for nearly all output of the Drupal system to be customized by user themes.

See also:
Theme developer's guide

Default theme implementations

Definition in file theme.inc.

Go to the source code of this file.

Enumerations

Content markers
Markers used by theme_mark() and node_mark() to designate content.

See also:
theme_mark(), node_mark()

  • enum MARK_NEW
  • enum MARK_READ
  • enum MARK_UPDATED

Functions

  • _init_theme ($theme, $base_theme=array(), $registry_callback= '_theme_load_registry')
    Initialize the theme system given already loaded information.
  • _theme_build_registry ($theme, $base_theme, $theme_engine)
    Rebuild the hook theme_registry cache.
  • _theme_load_registry ($theme, $base_theme=NULL, $theme_engine=NULL)
    Get the theme_registry cache from the database; if it doesn't exist, build it.
  • _theme_process_registry (&$cache, $name, $type, $theme, $path)
    Process a single invocation of the theme hook.
  • _theme_save_registry ($theme, $registry)
    Write the theme_registry cache into the database.
  • _theme_set_registry ($registry)
    Store the theme registry in memory.
  • _theme_table_cell ($cell, $header=FALSE)
    End of "defgroup themeable".
  • drupal_discover_template ($paths, $suggestions, $extension= '.tpl.php')
    Choose which template file to actually render.
  • drupal_find_theme_functions ($cache, $prefixes)
    Find overridden theme functions.
  • drupal_find_theme_templates ($cache, $extension, $path)
    Find overridden theme templates.
  • drupal_rebuild_theme_registry ()
    Force the system to rebuild the theme registry; this should be called when modules are added to the system, or when a dynamic system needs to add more theme hooks.
  • init_theme ()
    End of "Content markers".
  • list_themes ($refresh=FALSE)
    Provides a list of currently available themes.
  • path_to_theme ()
    Return the path to the currently selected theme.
  • template_preprocess (&$variables, $hook)
    Adds a default set of helper variables for preprocess functions and templates.
  • template_preprocess_block (&$variables)
    Process variables for block.tpl.php.
  • template_preprocess_node (&$variables)
    Process variables for node.tpl.php.
  • template_preprocess_page (&$variables)
    Process variables for page.tpl.php.
  • theme ()
    Generate the themed output.
  • theme_blocks ($region)
    Return a set of blocks available for the current user.
  • theme_box ($title, $content, $region= 'main')
    Return a themed box.
  • theme_breadcrumb ($breadcrumb)
    Return a themed breadcrumb trail.
  • theme_closure ($main=0)
    Execute hook_footer() which is run at the end of the page right before the close of the body tag.
  • theme_feed_icon ($url, $title)
    Return code that emits an feed icon.
  • theme_get_registry ($registry=NULL)
    Retrieve the stored theme registry.
  • theme_get_setting ($setting_name, $refresh=FALSE)
    Retrieve a setting for the current theme.
  • theme_get_settings ($key=NULL)
    Retrieve an associative array containing the settings for a theme.
  • theme_help ()
    Return a themed help message.
  • theme_image ($path, $alt= '', $title= '', $attributes=NULL, $getsize=TRUE)
    Return a themed image.
  • theme_indentation ($size=1)
    Create a standard indentation div.
  • theme_item_list ($items=array(), $title=NULL, $type= 'ul', $attributes=NULL)
    Return a themed list of items.
  • theme_links ($links, $attributes=array('class'=> 'links'))
    Return a themed set of links.
  • theme_mark ($type=MARK_NEW)
    Return a themed marker, useful for marking new or updated content.
  • theme_more_help_link ($url)
    Returns code that emits the 'more help'-link.
  • theme_more_link ($url, $title)
    Returns code that emits the 'more' link used on blocks.
  • theme_placeholder ($text)
    Formats text for emphasized display in a placeholder inside a sentence.
  • theme_progress_bar ($percent, $message)
    Return a themed progress bar.
  • theme_render_template ($file, $variables)
    Render a system default template, which is essentially a PHP template.
  • theme_status_messages ($display=NULL)
    Return a themed set of status and/or error messages.
  • theme_submenu ($links)
    Return a themed submenu, typically displayed under the tabs.
  • theme_table ($header, $rows, $attributes=array(), $caption=NULL)
    Return a themed table.
  • theme_table_select_header_cell ()
    Returns a header cell for tables that have a select all functionality.
  • theme_tablesort_indicator ($style)
    Return a themed sort icon.
  • theme_username ($object)
    Format a username.
  • theme_xml_icon ($url)
    Return code that emits an XML icon.

Enumeration Type Documentation

enum MARK_NEW

Definition at line 22 of file theme.inc.

enum MARK_READ

Definition at line 21 of file theme.inc.

enum MARK_UPDATED

Definition at line 23 of file theme.inc.

Function Documentation

_init_theme | ( | $ | theme,
 |  | $ | base_theme = array(),
 |  | $ | registry_callback = '_theme_load_registry'
 | ) |  |

Initialize the theme system given already loaded information.

This function is useful to initialize a theme when no database is present.

Parameters:
$theme | An object with the following information: filename The .info file for this theme. The 'path' to the theme will be in this file's directory. (Required) owner The path to the .theme file or the .engine file to load for the theme. (Required) stylesheet The primary stylesheet for the theme. (Optional) engine The name of theme engine to use. (Optional)
$base_theme | An optional array of objects that represent the 'base theme' if the theme is meant to be derivative of another theme. It requires the same information as the $theme object. It should be in 'oldest first' order, meaning the top level of the chain will be first.
$registry_callback | The callback to invoke to set the theme registry.

Definition at line 88 of file theme.inc.

References $base_theme_info, $name, $theme, $theme_engine, $theme_info, $theme_path, drupal_add_css(), and drupal_add_js().

Referenced by _drupal_maintenance_theme(), and init_theme().

_theme_build_registry | ( | $ | theme,
 |  | $ | base_theme,
 |  | $ | theme_engine
 | ) |  |

Rebuild the hook theme_registry cache.

Parameters:
$theme | The loaded $theme object.
$base_theme | An array of loaded $theme objects representing the ancestor themes in oldest first order.
theme_engine | The name of the theme engine.

Definition at line 366 of file theme.inc.

References $base_path, $theme, $theme_engine, _theme_process_registry(), drupal_alter(), drupal_get_path(), module_implements(), and name.

Referenced by _theme_load_offline_registry(), and _theme_load_registry().

_theme_load_registry | ( | $ | theme,
 |  | $ | base_theme = NULL,
 |  | $ | theme_engine = NULL
 | ) |  |

Get the theme_registry cache from the database; if it doesn't exist, build it.

Parameters:
$theme | The loaded $theme object.
$base_theme | An array of loaded $theme objects representing the ancestor themes in oldest first order.
theme_engine | The name of the theme engine.

Definition at line 218 of file theme.inc.

References $theme, $theme_engine, _theme_build_registry(), _theme_save_registry(), _theme_set_registry(), and cache_get().

_theme_process_registry | ( | &$ | cache,
 |  | $ | name,
 |  | $ | type,
 |  | $ | theme,
 |  | $ | path
 | ) |  |

Process a single invocation of the theme hook.

$type will be one of 'module', 'theme_engine' or 'theme' and it tells us some important information.

Because $cache is a reference, the cache will be continually expanded upon; new entries will replace old entries in the array_merge, but we are careful to ensure some data is carried forward, such as the arguments a theme hook needs.

An override flag can be set for preprocess functions. When detected the cached preprocessors for the hook will not be merged with the newly set. This can be useful to themes and theme engines by giving them more control over how and when the preprocess functions are run.

Definition at line 263 of file theme.inc.

References $name, $result, $theme, $type, and module_list().

Referenced by _theme_build_registry().

_theme_save_registry | ( | $ | theme,
 |  | $ | registry
 | ) |  |

Write the theme_registry cache into the database.

Definition at line 235 of file theme.inc.

References cache_set().

Referenced by _theme_load_registry().

_theme_set_registry ( $ registry )

Store the theme registry in memory.

Definition at line 201 of file theme.inc.

References theme_get_registry().

Referenced by _theme_load_offline_registry(), and _theme_load_registry().

_theme_table_cell | ( | $ | cell,
 |  | $ | header = FALSE
 | ) |  |

End of "defgroup themeable".

Definition at line 1622 of file theme.inc.

References $attributes, $header, $output, and drupal_attributes().

Referenced by template_preprocess_forum_topic_list(), and theme_table().

drupal_discover_template | ( | $ | paths,
 |  | $ | suggestions,
 |  | $ | extension = '.tpl.php'
 | ) |  |

Choose which template file to actually render.

These are all suggested templates from themes and modules. Theming implementations can occur on multiple levels. All paths are checked to account for this.

Definition at line 672 of file theme.inc.

References $theme_engine.

Referenced by theme().

drupal_find_theme_functions | ( | $ | cache,
 |  | $ | prefixes
 | ) |  |

Find overridden theme functions.

Called by themes and/or theme engines to easily discover theme functions.

Parameters:
$cache | The existing cache of theme hooks to test against.
$prefixes | An array of prefixes to test, in reverse order of importance.
Returns:
$templates The functions found, suitable for returning from hook_theme;

Definition at line 714 of file theme.inc.

Referenced by chameleon_theme(), and phptemplate_theme().

drupal_find_theme_templates | ( | $ | cache,
 |  | $ | extension,
 |  | $ | path
 | ) |  |

Find overridden theme templates.

Called by themes and/or theme engines to easily discover templates.

Parameters:
$cache | The existing cache of theme hooks to test against.
$extension | The extension that these templates will have.
$path | The path to search.

Definition at line 754 of file theme.inc.

References $theme, $theme_info, drupal_system_listing(), and list_themes().

Referenced by phptemplate_theme().

drupal_rebuild_theme_registry ( )

Force the system to rebuild the theme registry; this should be called when modules are added to the system, or when a dynamic system needs to add more theme hooks.

Definition at line 244 of file theme.inc.

References cache_clear_all().

Referenced by drupal_flush_all_caches(), system_modules(), system_settings_form_submit(), and system_themes_form_submit().

init_theme ( )

End of "Content markers".

Initialize the theme system by loading the theme.

Definition at line 31 of file theme.inc.

References $custom_theme, $theme, $theme_key, $user, _init_theme(), drupal_bootstrap(), list_themes(), theme(), and variable_get().

Referenced by _block_rehash(), block_admin_display_form(), drupal_render_form(), path_to_theme(), and theme().

list_themes ( $ refresh = FALSE )

Provides a list of currently available themes.

If the database is active then it will be retrieved from the database. Otherwise it will retrieve a new list.

Parameters:
$refresh Whether to reload the list of themes from the database.
Returns:
An array of the currently available themes.

Definition at line 408 of file theme.inc.

References $result, $theme, _system_theme_data(), db_fetch_object(), db_is_active(), and db_query().

Referenced by _color_rewrite_stylesheet(), _drupal_maintenance_theme(), block_add_block_form_submit(), block_menu(), color_form_alter(), drupal_find_theme_templates(), init_theme(), system_menu(), system_theme_select_form(), system_themes_form_submit(), system_update_6042(), and theme_get_setting().

path_to_theme ( )

Return the path to the currently selected theme.

Definition at line 692 of file theme.inc.

References $theme_path, and init_theme().

Referenced by phptemplate_get_ie_styles(), and template_preprocess().

template_preprocess | ( | &$ | variables,
 |  | $ | hook
 | ) |  |

Adds a default set of helper variables for preprocess functions and templates.

This comes in before any other preprocess function which makes it possible to be used in default theme implementations (non-overriden theme functions).

Definition at line 1652 of file theme.inc.

References $user, db_is_active(), drupal_is_front_page(), path_to_theme(), and user_access().

template_preprocess_block ( &$ variables )

Process variables for block.tpl.php.

Prepare the values passed to the theme_block function to be passed into a pluggable template engine. Uses block properties to generate a series of template file suggestions. If none are found, the default block.tpl.php is used.

Most themes utilize their own copy of block.tpl.php. The default is located inside "modules/system/block.tpl.php". Look in there for the full list of variables.

The $variables array contains the following arguments:

  • $block

See also:
block.tpl.php

Definition at line 1908 of file theme.inc.

template_preprocess_node ( &$ variables )

Process variables for node.tpl.php.

Most themes utilize their own copy of node.tpl.php. The default is located inside "modules/node/node.tpl.php". Look in there for the full list of variables.

The $variables array contains the following arguments:

  • $node
  • $teaser
  • $page

See also:
node.tpl.php

Definition at line 1849 of file theme.inc.

References check_plain(), format_date(), module_exists(), nid, taxonomy_link(), theme(), theme_get_setting(), and url().

template_preprocess_page ( &$ variables )

Process variables for page.tpl.php.

Most themes utilize their own copy of page.tpl.php. The default is located inside "modules/system/page.tpl.php". Look in there for the full list of variables.

Uses the arg() function to generate a series of page template suggestions based on the current path.

Any changes to variables in this preprocessor should also be changed inside template_preprocess_maintenance_page() to keep all them consistent.

The $variables array contains the following arguments:

  • $content
  • $show_blocks

See also:
page.tpl.php

Definition at line 1702 of file theme.inc.

References $body_classes, $head_title, $theme, arg(), base_path(), check_url(), drupal_add_css(), drupal_get_breadcrumb(), drupal_get_css(), drupal_get_feeds(), drupal_get_form(), drupal_get_html_head(), drupal_get_js(), drupal_get_title(), drupal_is_front_page(), drupal_set_html_head(), drupal_strtolower(), filter_xss_admin(), form_clean_id(), menu_get_object(), menu_primary_links(), menu_secondary_links(), system_region_list(), theme(), theme_get_setting(), url(), and variable_get().

theme ( )

Generate the themed output.

All requests for theme hooks must go through this function. It examines the request and routes it to the appropriate theme function. The theme registry is checked to determine which implementation to use, which may be a function or a template.

If the implementation is a function, it is executed and its return value passed along.

If the implementation is a template, the arguments are converted to a $variables array. This array is then modified by the module implementing the hook, theme engine (if applicable) and the theme. The following functions may be used to modify the $variables array. They are processed in this order when available:

  • template_preprocess(&$variables) This sets a default set of variables for all template implementations.

  • template_preprocess_HOOK(&$variables) This is the first preprocessor called specific to the hook; it should be implemented by the module that registers it.

  • MODULE_preprocess(&$variables) This will be called for all templates; it should only be used if there is a real need. It's purpose is similar to template_preprocess().

  • MODULE_preprocess_HOOK(&$variables) This is for modules that want to alter or provide extra variables for theming hooks not registered to itself. For example, if a module named "foo" wanted to alter the $submitted variable for the hook "node" a preprocess function of foo_preprocess_node() can be created to intercept and alter the variable.

  • ENGINE_engine_preprocess(&$variables) This function should only be implemented by theme engines and exists so that it can set necessary variables for all hooks.

  • ENGINE_engine_preprocess_HOOK(&$variables) This is the same as the previous function, but it is called for a single theming hook.

  • ENGINE_preprocess(&$variables) This is meant to be used by themes that utilize a theme engine. It is provided so that the preprocessor is not locked into a specific theme. This makes it easy to share and transport code but theme authors must be careful to prevent fatal re-declaration errors when using sub-themes that have their own preprocessor named exactly the same as its base theme. In the default theme engine (PHPTemplate), sub-themes will load their own template.php file in addition to the one used for its parent theme. This increases the risk for these errors. A good practice is to use the engine name for the base theme and the theme name for the sub-themes to minimize this possibility.

  • ENGINE_preprocess_HOOK(&$variables) The same applies from the previous function, but it is called for a specific hook.

  • THEME_preprocess(&$variables) These functions are based upon the raw theme; they should primarily be used by themes that do not use an engine or by sub-themes. It serves the same purpose as ENGINE_preprocess().

  • THEME_preprocess_HOOK(&$variables) The same applies from the previous function, but it is called for a specific hook.

There are two special variables that these hooks can set: 'template_file' and 'template_files'. These will be merged together to form a list of 'suggested' alternate template files to use, in reverse order of priority. template_file will always be a higher priority than items in template_files. theme() will then look for these files, one at a time, and use the first one that exists.

Parameters:
$hook The name of the theme function to call. May be an array, in which case the first hook that actually has an implementation registered will be used. This can be used to choose 'fallback' theme implementations, so that if the specific theme hook isn't implemented anywhere, a more generic one will be used. This can allow themes to create specific theme implementations for named objects.
... Additional arguments to pass along to the theme function.
Returns:
An HTML string that generates the themed output.

Definition at line 552 of file theme.inc.

References $name, $output, $theme_engine, $theme_path, drupal_discover_template(), init_theme(), and theme_get_registry().

Referenced by _aggregator_page_list(), _batch_progress_page_nojs(), _db_error_page(), _locale_translate_seek(), _node_mass_update_batch_finished(), _system_sql(), aggregator_block(), aggregator_categorize_items(), aggregator_page_categories(), aggregator_page_opml(), aggregator_page_rss(), aggregator_page_source(), aggregator_page_sources(), aggregator_view(), blog_block(), blog_page_last(), blog_page_user(), book_admin_overview(), book_block(), book_export_html(), book_node_export(), book_nodeapi(), book_render(), chameleon_comment(), chameleon_node(), chameleon_page(), color_form_alter(), comment_admin_overview(), comment_block(), comment_form(), comment_form_add_preview(), comment_form_box(), comment_link(), comment_links(), comment_render(), comment_reply(), contact_admin_categories(), dblog_event(), dblog_overview(), dblog_top(), drupal_access_denied(), drupal_add_feed(), drupal_not_found(), drupal_render(), drupal_site_offline(), fileupload_view(), filter_admin_format_form(), filter_filter_tips(), filter_form(), filter_tips_long(), forum_block(), forum_nodeapi(), forum_page(), help_page(), hook_nodeapi(), hook_search(), hook_view(), init_theme(), install_already_done_error(), install_change_settings(), install_main(), install_no_profile_error(), install_select_locale(), install_select_profile(), install_tasks(), locale_block(), locale_translate_overview_screen(), menu_get_active_help(), menu_local_tasks(), menu_overview_page(), menu_tree_output(), multipage_form_example_view(), node_add_page(), node_admin_nodes(), node_block(), node_example_view(), node_overview_types(), node_page_default(), node_preview(), node_revision_overview(), node_search(), node_title_list(), node_type_form(), node_view(), nodeapi_example_nodeapi(), openid_form_alter(), openid_user_identities(), page_example_baz(), path_admin_overview(), phptemplate_comment_submitted(), phptemplate_node_submitted(), poll_choice_js(), poll_page(), poll_view_results(), poll_votes(), profile_block(), profile_browse(), search_view(), statistics_access_log(), statistics_node_tracker(), statistics_recent_hits(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), statistics_user_tracker(), system_actions_manage(), system_admin_by_module(), system_admin_menu_block_page(), system_batch_page(), system_block(), system_logging_overview(), system_main_admin_page(), system_modules_confirm_form(), system_modules_uninstall_confirm_form(), system_settings_overview(), system_status(), system_theme_select_form(), system_themes_form(), t(), tablesort_header(), taxonomy_render_nodes(), taxonomy_term_page(), template_preprocess_aggregator_feed_source(), template_preprocess_aggregator_summary_items(), template_preprocess_aggregator_wrapper(), template_preprocess_comment(), template_preprocess_comment_folded(), template_preprocess_forum_list(), template_preprocess_forum_submitted(), template_preprocess_forum_topic_list(), template_preprocess_forums(), template_preprocess_maintenance_page(), template_preprocess_node(), template_preprocess_page(), template_preprocess_poll_results(), template_preprocess_profile_block(), template_preprocess_profile_listing(), template_preprocess_search_results(), template_preprocess_user_picture(), theme_admin_page(), theme_aggregator_block_item(), theme_aggregator_categorize_items(), theme_blocks(), theme_book_admin_table(), theme_checkbox(), theme_checkboxes(), theme_comment_admin_overview(), theme_comment_block(), theme_comment_controls(), theme_comment_flat_collapsed(), theme_comment_flat_expanded(), theme_comment_submitted(), theme_comment_thread_collapsed(), theme_comment_thread_expanded(), theme_comment_view(), theme_date(), theme_feed_icon(), theme_file(), theme_filter_admin_order(), theme_filter_admin_overview(), theme_install_page(), theme_item(), theme_locale_languages_overview_form(), theme_menu_overview_form(), theme_node_admin_nodes(), theme_node_list(), theme_node_search_admin(), theme_node_submitted(), theme_pager(), theme_pager_first(), theme_pager_last(), theme_pager_next(), theme_pager_previous(), theme_password(), theme_password_confirm(), theme_phonenumber(), theme_poll_choices(), theme_profile_admin_overview(), theme_radio(), theme_radios(), theme_select(), theme_submit(), theme_system_admin_by_module(), theme_system_modules(), theme_system_modules_uninstall(), theme_system_powered_by(), theme_system_theme_select_form(), theme_system_themes_form(), theme_tablesort_indicator(), theme_taxonomy_overview_terms(), theme_taxonomy_overview_vocabularies(), theme_taxonomy_term_select(), theme_textarea(), theme_textfield(), theme_token(), theme_trigger_display(), theme_update_page(), theme_update_report(), theme_update_version(), theme_upload_attachments(), theme_upload_form_current(), theme_user_admin_account(), theme_user_admin_new_role(), theme_user_admin_perm(), theme_user_list(), theme_xml_icon(), tracker_page(), translation_node_overview(), update_results_page(), update_status(), update_task_list(), upload_js(), upload_nodeapi(), user_admin_access(), user_admin_account(), user_block(), user_edit_form(), user_login_block(), user_user(), and user_view().

theme_get_registry ( $ registry = NULL )

Retrieve the stored theme registry.

If the theme registry is already in memory it will be returned; otherwise it will attempt to load the registry from cache. If this fails, it will construct the registry and cache it.

Definition at line 189 of file theme.inc.

Referenced by _theme_set_registry(), drupal_render_form(), and theme().

theme_get_setting | ( | $ | setting_name,
 |  | $ | refresh = FALSE
 | ) |  |

Retrieve a setting for the current theme.

This function is designed for use from within themes & engines to determine theme settings made in the admin interface.

Caches values for speed (use $refresh = TRUE to refresh cache)

Parameters:
$setting_name | The name of the setting to be retrieved.
$refresh | Whether to reload the cache of settings.
Returns:
The value of the requested setting, NULL if the setting does not exist.

Definition at line 901 of file theme.inc.

References $theme_key, base_path(), list_themes(), theme_get_settings(), and variable_get().

Referenced by chameleon_node(), chameleon_page(), template_preprocess_comment(), template_preprocess_maintenance_page(), template_preprocess_node(), and template_preprocess_page().

theme_get_settings ( $ key = NULL )

Retrieve an associative array containing the settings for a theme.

The final settings are arrived at by merging the default settings, the site-wide settings, and the settings defined for the specific theme. If no $key was specified, only the site-wide theme defaults are retrieved.

The default values for each of settings are also defined in this function. To add new settings, add their default values here, and then add form elements to system_theme_settings() in system.module.

Parameters:
$key The template/style value for a given theme.
Returns:
An associative array containing theme settings.

Definition at line 845 of file theme.inc.

References $name, $type, module_exists(), node_get_types(), user_access(), and variable_get().

Referenced by system_theme_settings(), and theme_get_setting().

theme_render_template | ( | $ | file,
 |  | $ | variables
 | ) |  |

Render a system default template, which is essentially a PHP template.

Parameters:
$file | The filename of the template to render.
$variables | A keyed array of variables that will appear in the output.
Returns:
The output generated by the template.

Definition at line 960 of file theme.inc.

Referenced by theme_install_page(), and theme_update_page().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/theme.maintenance.inc File Reference

includes

theme.maintenance.inc File Reference

Detailed Description

Theming for maintenance pages.

Definition in file theme.maintenance.inc.

Go to the source code of this file.

Functions

  • _drupal_maintenance_theme ()
    Sets up the theming system for site installs, updates and when the site is in off-line mode.
  • _theme_load_offline_registry ($theme, $base_theme=NULL, $theme_engine=NULL)
    This builds the registry when the site needs to bypass any database calls.
  • template_preprocess_maintenance_page (&$variables)
    The variables generated here is a mirror of template_preprocess_page().
  • theme_install_page ($content)
    Generate a themed installation page.
  • theme_task_list ($items, $active=NULL)
    Return a themed list of maintenance tasks to perform.
  • theme_update_page ($content, $show_messages=TRUE)
    Generate a themed update page.

Function Documentation

_drupal_maintenance_theme ( )

Sets up the theming system for site installs, updates and when the site is in off-line mode.

It also applies when the database is unavailable.

Minnelli is always used for the initial install and update operations. In other cases, "settings.php" must have a "maintenance_theme" key set for the $conf variable in order to change the maintenance theme.

Definition at line 17 of file theme.maintenance.inc.

References $module_list, $theme, $theme_key, _init_theme(), drupal_add_css(), drupal_get_path(), drupal_load(), list_themes(), module_list(), unicode_check(), and variable_get().

Referenced by drupal_maintenance_theme().

_theme_load_offline_registry | ( | $ | theme,
 |  | $ | base_theme = NULL,
 |  | $ | theme_engine = NULL
 | ) |  |

This builds the registry when the site needs to bypass any database calls.

Definition at line 74 of file theme.maintenance.inc.

References $theme, $theme_engine, _theme_build_registry(), and _theme_set_registry().

template_preprocess_maintenance_page ( &$ variables )

The variables generated here is a mirror of template_preprocess_page().

This preprocessor will run it's course when theme_maintenance_page() is invoked. It is also used in theme_install_page() and theme_update_page() to keep all the variables consistent.

An alternate template file of "maintenance-page-offline.tpl.php" can be used when the database is offline to hide errors and completely replace the content.

The $variables array contains the following arguments:

  • $content
  • $show_blocks

See also:
maintenance-page.tpl.php

Definition at line 205 of file theme.maintenance.inc.

References $body_classes, $head_title, $theme, _system_theme_data(), base_path(), check_url(), drupal_add_css(), drupal_get_content(), drupal_get_css(), drupal_get_html_head(), drupal_get_js(), drupal_get_title(), drupal_set_html_head(), filter_xss_admin(), theme(), theme_get_setting(), and variable_get().

Referenced by theme_install_page(), and theme_update_page().

theme_install_page ( $ content )

Generate a themed installation page.

Note: this function is not themeable.

Parameters:
$content The page content to show.

Definition at line 109 of file theme.maintenance.inc.

References $content, $messages, $theme_path, $title, drupal_set_header(), drupal_set_message(), request_uri(), st(), template_preprocess_maintenance_page(), theme(), and theme_render_template().

theme_update_page | ( | $ | content,
 |  | $ | show_messages = TRUE
 | ) |  |

Generate a themed update page.

Note: this function is not themeable.

Parameters:
$content | The page content to show.
$show_messages | Whether to output status and error messages. FALSE can be useful to postpone the messages to a subsequent page.

Definition at line 162 of file theme.maintenance.inc.

References $content, $messages, $theme_path, $title, drupal_set_header(), drupal_set_message(), template_preprocess_maintenance_page(), theme(), and theme_render_template().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/unicode.inc File Reference

includes

unicode.inc File Reference

Go to the source code of this file.

Enumerations

  • enum UNICODE_ERROR
    Indicates an error during check for PHP unicode support. More...
  • enum UNICODE_MULTIBYTE
    Indicates that full unicode support with the PHP mbstring extension is being used. More...
  • enum UNICODE_SINGLEBYTE
    Indicates that standard PHP (emulated) unicode support is being used. More...

Functions

  • _decode_entities ($prefix, $codepoint, $original, &$table, &$exclude)
    Helper function for decode_entities.
  • _mime_header_decode ($matches)
    Helper function to mime_header_decode.
  • _unicode_caseflip ($matches)
    Helper function for case conversion of Latin-1.
  • _unicode_check ()
    Perform checks about Unicode support in PHP, and set the right settings if needed.
  • decode_entities ($text, $exclude=array())
    Decode all HTML entities (including numerical ones) to regular UTF-8 bytes.
  • drupal_convert_to_utf8 ($data, $encoding)
    Convert data to UTF-8.
  • drupal_strlen ($text)
    Count the amount of characters in a UTF-8 string.
  • drupal_strtolower ($text)
    Lowercase a UTF-8 string.
  • drupal_strtoupper ($text)
    Uppercase a UTF-8 string.
  • drupal_substr ($text, $start, $length=NULL)
    Cut off a piece of a string based on character indices and counts.
  • drupal_truncate_bytes ($string, $len)
    Truncate a UTF-8-encoded string safely to a number of bytes.
  • drupal_ucfirst ($text)
    Capitalize the first letter of a UTF-8 string.
  • drupal_xml_parser_create (&$data)
    Prepare a new XML parser.
  • mime_header_decode ($header)
    Complement to mime_header_encode.
  • mime_header_encode ($string)
    Encodes MIME/HTTP header values that contain non-ASCII, UTF-8 encoded characters.
  • truncate_utf8 ($string, $len, $wordsafe=FALSE, $dots=FALSE)
    Truncate a UTF-8-encoded string safely to a number of characters.
  • unicode_check ()
    Wrapper around _unicode_check().
  • unicode_requirements ()
    Return Unicode library status and errors.

Enumeration Type Documentation

enum UNICODE_ERROR

Indicates an error during check for PHP unicode support.

Definition at line 7 of file unicode.inc.

enum UNICODE_MULTIBYTE

Indicates that full unicode support with the PHP mbstring extension is being used.

Definition at line 18 of file unicode.inc.

enum UNICODE_SINGLEBYTE

Indicates that standard PHP (emulated) unicode support is being used.

Definition at line 12 of file unicode.inc.

Function Documentation

_decode_entities | ( | $ | prefix,
 |  | $ | codepoint,
 |  | $ | original,
 |  | &$ | table,
 |  | &$ | exclude
 | ) |  |

Helper function for decode_entities.

Definition at line 351 of file unicode.inc.

_mime_header_decode ( $ matches )

Helper function to mime_header_decode.

Definition at line 309 of file unicode.inc.

References drupal_convert_to_utf8().

_unicode_caseflip ( $ matches )

Helper function for case conversion of Latin-1.

Used for flipping U+C0-U+DE to U+E0-U+FD and back.

Definition at line 450 of file unicode.inc.

_unicode_check ( )

Perform checks about Unicode support in PHP, and set the right settings if needed.

Because Drupal needs to be able to handle text in various encodings, we do not support mbstring function overloading. HTTP input/output conversion must be disabled for similar reasons.

Parameters:
$errors Whether to report any fatal errors with form_set_error().

Definition at line 38 of file unicode.inc.

References get_t().

Referenced by unicode_check(), and unicode_requirements().

decode_entities | ( | $ | text,
 |  | $ | exclude = array()
 | ) |  |

Decode all HTML entities (including numerical ones) to regular UTF-8 bytes.

Double-escaped entities will only be decoded once ("&amp;lt;" becomes "&lt;", not "<").

Parameters:
$text | The text to decode entities in.
$exclude | An array of characters which should not be decoded. For example, array('<', '&', '"'). This affects both named and numerical entities.

Definition at line 331 of file unicode.inc.

Referenced by _comment_form_submit(), _filter_url_parse_full_links(), _filter_url_parse_partial_links(), db_connect(), drupal_html_to_text(), filter_xss_bad_protocol(), and format_rss_channel().

drupal_convert_to_utf8 | ( | $ | data,
 |  | $ | encoding
 | ) |  |

Convert data to UTF-8.

Requires the iconv, GNU recode or mbstring PHP extension.

Parameters:
$data | The data to be converted.
$encoding | The encoding that the data is in
Returns:
Converted data or FALSE.

Definition at line 173 of file unicode.inc.

References watchdog().

Referenced by _mime_header_decode(), and drupal_xml_parser_create().

drupal_strlen ( $ text )

Count the amount of characters in a UTF-8 string.

This is less than or equal to the byte count.

Definition at line 401 of file unicode.inc.

References $multibyte.

Referenced by _form_validate(), node_teaser(), theme_username(), and truncate_utf8().

drupal_strtolower ( $ text )

Lowercase a UTF-8 string.

Definition at line 432 of file unicode.inc.

References $multibyte.

Referenced by _color_rewrite_stylesheet(), book_export(), parse_size(), and template_preprocess_page().

drupal_strtoupper ( $ text )

Uppercase a UTF-8 string.

Definition at line 415 of file unicode.inc.

References $multibyte.

Referenced by drupal_ucfirst(), and tablesort_sql().

drupal_substr | ( | $ | text,
 |  | $ | start,
 |  | $ | length = NULL
 | ) |  |

Cut off a piece of a string based on character indices and counts.

Follows the same behavior as PHP's own substr() function.

Note that for cutting off a string at a known character/substring location, the usage of PHP's normal strpos/substr is safe and much faster.

Definition at line 470 of file unicode.inc.

References $multibyte.

Referenced by drupal_ucfirst(), theme_username(), and truncate_utf8().

drupal_truncate_bytes | ( | $ | string,
 |  | $ | len
 | ) |  |

Truncate a UTF-8-encoded string safely to a number of bytes.

If the end position is in the middle of a UTF-8 sequence, it scans backwards until the beginning of the byte sequence.

Use this function whenever you want to chop off a string at an unsure location. On the other hand, if you're sure that you're splitting on a character boundary (e.g. after using strpos() or similar), you can safely use substr() instead.

Parameters:
$string | The string to truncate.
$len | An upper limit on the returned string length.
Returns:
The truncated string.

Definition at line 209 of file unicode.inc.

Referenced by mime_header_encode().

drupal_ucfirst ( $ text )

Capitalize the first letter of a UTF-8 string.

Definition at line 457 of file unicode.inc.

References drupal_strtoupper(), and drupal_substr().

Referenced by node_menu(), system_modules(), system_modules_confirm_form(), and taxonomy_help().

drupal_xml_parser_create ( &$ data )

Prepare a new XML parser.

This is a wrapper around xml_parser_create() which extracts the encoding from the XML data first and sets the output encoding to UTF-8. This function should be used instead of xml_parser_create(), because PHP 4's XML parser doesn't check the input encoding itself. "Starting from PHP 5, the input encoding is automatically detected, so that the encoding parameter specifies only the output encoding."

This is also where unsupported encodings will be converted. Callers should take this into account: $data might have been changed after the call.

Parameters:
&$data The XML data which will be parsed later.
Returns:
An XML parser object.

Definition at line 126 of file unicode.inc.

References drupal_convert_to_utf8(), and watchdog().

Referenced by aggregator_parse_feed().

mime_header_decode ( $ header )

Complement to mime_header_encode.

Definition at line 299 of file unicode.inc.

References $header.

mime_header_encode ( $ string )

Encodes MIME/HTTP header values that contain non-ASCII, UTF-8 encoded characters.

For example, mime_header_encode('tést.txt') returns "=?UTF-8?B?dMOpc3QudHh0?=".

See http://www.rfc-editor.org/rfc/rfc2047.txt for more information.

Notes:

  • Only encode strings that contain non-ASCII characters.
  • We progressively cut-off a chunk with truncate_utf8(). This is to ensure each chunk starts and ends on a character boundary.
  • Using
    as the chunk separator may cause problems on some systems and may have to be changed to
    or .

Definition at line 279 of file unicode.inc.

References $output, and drupal_truncate_bytes().

Referenced by drupal_mail_send().

truncate_utf8 | ( | $ | string,
 |  | $ | len,
 |  | $ | wordsafe = FALSE,
 |  | $ | dots = FALSE
 | ) |  |

Truncate a UTF-8-encoded string safely to a number of characters.

Parameters:
$string | The string to truncate.
$len | An upper limit on the returned string length.
$wordsafe | Flag to truncate at last space within the upper limit. Defaults to FALSE.
$dots | Flag to add trailing dots. Defaults to FALSE.
Returns:
The truncated string.

Definition at line 234 of file unicode.inc.

References drupal_strlen(), and drupal_substr().

Referenced by _book_toc_recurse(), _comment_form_submit(), _locale_translate_seek(), _menu_parents_recurse(), _statistics_link(), aggregator_parse_feed(), comment_admin_overview(), dblog_overview(), dblog_top(), and node_teaser().

unicode_check ( )

Wrapper around _unicode_check().

Definition at line 23 of file unicode.inc.

References _unicode_check().

Referenced by _drupal_bootstrap_full(), and _drupal_maintenance_theme().

unicode_requirements ( )

Return Unicode library status and errors.

Definition at line 79 of file unicode.inc.

References _unicode_check(), and get_t().

Referenced by system_requirements().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/xmlrpc.inc File Reference

includes

xmlrpc.inc File Reference

Detailed Description

Drupal XML-RPC library.

Based on the IXR - The Incutio XML-RPC Library - (c) Incutio Ltd 2002-2005 Version 1.7 (beta) - Simon Willison, 23rd May 2005 Site: http://scripts.incutio.com/xmlrpc/ Manual: http://scripts.incutio.com/xmlrpc/manual.php This version is made available under the GNU GPL License

Definition in file xmlrpc.inc.

Go to the source code of this file.

Functions

  • _xmlrpc ()
    Execute an XML remote procedural call.
  • xmlrpc_base64 ($data)
  • xmlrpc_base64_get_xml ($xmlrpc_base64)
  • xmlrpc_date ($time)
  • xmlrpc_date_get_xml ($xmlrpc_date)
  • xmlrpc_errno ()
    Returns the last XML-RPC client error number.
  • xmlrpc_error ($code=NULL, $message=NULL)
  • xmlrpc_error_get_xml ($xmlrpc_error)
  • xmlrpc_error_msg ()
    Returns the last XML-RPC client error message.
  • xmlrpc_message ($message)
    Construct an object representing an XML-RPC message.
  • xmlrpc_message_cdata ($parser, $cdata)
  • xmlrpc_message_get ()
  • xmlrpc_message_parse (&$xmlrpc_message)
    Parse an XML-RPC message.
  • xmlrpc_message_set ($value=NULL)
    Store a copy of the $xmlrpc_message object temporarily.
  • xmlrpc_message_tag_close ($parser, $tag)
  • xmlrpc_message_tag_open ($parser, $tag, $attr)
  • xmlrpc_request ($method, $args)
    Construct an object representing an XML-RPC request.
  • xmlrpc_value ($data, $type=FALSE)
    Recursively turn a data structure into objects with 'data' and 'type' attributes.
  • xmlrpc_value_calculate_type (&$xmlrpc_value)
    Map PHP type to XML-RPC type.
  • xmlrpc_value_get_xml ($xmlrpc_value)
    Generate XML representing the given value.

Function Documentation

_xmlrpc ( )

Execute an XML remote procedural call.

This is private function; call xmlrpc() in common.inc instead of this function.

Returns:
A $xmlrpc_message object if the call succeeded; FALSE if the call failed

Definition at line 427 of file xmlrpc.inc.

References $result, $url, drupal_http_request(), t(), xmlrpc_error(), xmlrpc_message(), xmlrpc_message_parse(), and xmlrpc_request().

xmlrpc_base64 ( $ data )

Definition at line 409 of file xmlrpc.inc.

Referenced by xmlrpc_example_manyTypesTest().

xmlrpc_base64_get_xml ( $ xmlrpc_base64 )

Definition at line 416 of file xmlrpc.inc.

Referenced by xmlrpc_value_get_xml().

xmlrpc_date ( $ time )

Definition at line 379 of file xmlrpc.inc.

Referenced by _blogapi_get_post(), xmlrpc_example_manyTypesTest(), and xmlrpc_message_tag_close().

xmlrpc_date_get_xml ( $ xmlrpc_date )

Definition at line 405 of file xmlrpc.inc.

Referenced by xmlrpc_value_get_xml().

xmlrpc_errno ( )

Returns the last XML-RPC client error number.

Definition at line 466 of file xmlrpc.inc.

References xmlrpc_error().

xmlrpc_error | ( | $ | code = NULL,
 |  | $ | message = NULL
 | ) |  |

Definition at line 345 of file xmlrpc.inc.

References module_invoke().

Referenced by _xmlrpc(), blogapi_error(), xmlrpc_errno(), xmlrpc_error_msg(), xmlrpc_server_call(), xmlrpc_server_error(), xmlrpc_server_method_signature(), and xmlrpc_server_multicall().

xmlrpc_error_get_xml ( $ xmlrpc_error )

Definition at line 357 of file xmlrpc.inc.

References name.

Referenced by xmlrpc_server_error().

xmlrpc_error_msg ( )

Returns the last XML-RPC client error message.

Definition at line 474 of file xmlrpc.inc.

References xmlrpc_error().

xmlrpc_message ( $ message )

Construct an object representing an XML-RPC message.

Parameters:
$message String containing XML as defined at http://www.xmlrpc.com/spec
Returns:
Object

Definition at line 141 of file xmlrpc.inc.

Referenced by _xmlrpc(), and xmlrpc_server().

xmlrpc_message_cdata | ( | $ | parser,
 |  | $ | cdata
 | ) |  |

Definition at line 228 of file xmlrpc.inc.

References xmlrpc_message_get(), and xmlrpc_message_set().

xmlrpc_message_get ( )

Definition at line 201 of file xmlrpc.inc.

References xmlrpc_message_set().

Referenced by xmlrpc_message_cdata(), xmlrpc_message_parse(), xmlrpc_message_tag_close(), and xmlrpc_message_tag_open().

xmlrpc_message_parse ( &$ xmlrpc_message )

Parse an XML-RPC message.

If parsing fails, the faultCode and faultString will be added to the message object.

Parameters:
$xmlrpc_message Object generated by xmlrpc_message()
Returns:
TRUE if parsing succeeded; FALSE otherwise

Definition at line 159 of file xmlrpc.inc.

References xmlrpc_message_get(), and xmlrpc_message_set().

Referenced by _xmlrpc(), and xmlrpc_server().

xmlrpc_message_set ( $ value = NULL )

Store a copy of the $xmlrpc_message object temporarily.

Parameters:
$value Object
Returns:
The most recently stored $xmlrpc_message

Definition at line 193 of file xmlrpc.inc.

References $value.

Referenced by xmlrpc_message_cdata(), xmlrpc_message_get(), xmlrpc_message_parse(), xmlrpc_message_tag_close(), and xmlrpc_message_tag_open().

xmlrpc_message_tag_close | ( | $ | parser,
 |  | $ | tag
 | ) |  |

Definition at line 234 of file xmlrpc.inc.

References $tag, $value, xmlrpc_date(), xmlrpc_message_get(), and xmlrpc_message_set().

xmlrpc_message_tag_open | ( | $ | parser,
 |  | $ | tag,
 |  | $ | attr
 | ) |  |

Definition at line 205 of file xmlrpc.inc.

References $tag, xmlrpc_message_get(), and xmlrpc_message_set().

xmlrpc_request | ( | $ | method,
 |  | $ | args
 | ) |  |

Construct an object representing an XML-RPC request.

Parameters:
$method | The name of the method to be called
$args | An array of parameters to send with the method.
Returns:
Object

Definition at line 323 of file xmlrpc.inc.

References xmlrpc_value(), and xmlrpc_value_get_xml().

Referenced by _xmlrpc().

xmlrpc_value | ( | $ | data,
 |  | $ | type = FALSE
 | ) |  |

Recursively turn a data structure into objects with 'data' and 'type' attributes.

Parameters:
$data | The data structure.
$type | Optional type assign to $data.
Returns:
Object.

Definition at line 23 of file xmlrpc.inc.

References $type, $value, and xmlrpc_value_calculate_type().

Referenced by xmlrpc_request(), and xmlrpc_server().

xmlrpc_value_calculate_type ( &$ xmlrpc_value )

Map PHP type to XML-RPC type.

Parameters:
$xmlrpc_value Variable whose type should be mapped.
Returns:
XML-RPC type as string.
See also:
http://www.xmlrpc.com/spec#scalars

Definition at line 54 of file xmlrpc.inc.

Referenced by xmlrpc_value().

xmlrpc_value_get_xml ( $ xmlrpc_value )

Generate XML representing the given value.

Parameters:
$xmlrpc_value
Returns:
XML representation of value.

Definition at line 90 of file xmlrpc.inc.

References $item, $name, $return, $value, check_plain(), xmlrpc_base64_get_xml(), and xmlrpc_date_get_xml().

Referenced by xmlrpc_request(), and xmlrpc_server().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/xmlrpcs.inc File Reference

includes

xmlrpcs.inc File Reference

Go to the source code of this file.

Functions

  • xmlrpc_server ($callbacks)
    The main entry point for XML-RPC requests.
  • xmlrpc_server_call ($xmlrpc_server, $methodname, $args)
    Dispatch the request and any parameters to the appropriate handler.
  • xmlrpc_server_error ($error, $message=FALSE)
    Throw an XML-RPC error.
  • xmlrpc_server_get ()
  • xmlrpc_server_get_capabilities ()
    XML-RPC method system.getCapabilities maps to this function.
  • xmlrpc_server_list_methods ()
    XML-RPC method system.listMethods maps to this function.
  • xmlrpc_server_method_help ($method)
    XML-RPC method system.methodHelp maps to this function.
  • xmlrpc_server_method_signature ($methodname)
    XML-RPC method system.methodSignature maps to this function.
  • xmlrpc_server_multicall ($methodcalls)
  • xmlrpc_server_output ($xml)
  • xmlrpc_server_set ($xmlrpc_server=NULL)
    Store a copy of the request temporarily.

Function Documentation

xmlrpc_server ( $ callbacks )

The main entry point for XML-RPC requests.

Parameters:
$callbacks Array of external XML-RPC method names with the callbacks they map to.

Definition at line 10 of file xmlrpcs.inc.

References $result, t(), xmlrpc_message(), xmlrpc_message_parse(), xmlrpc_server_call(), xmlrpc_server_error(), xmlrpc_server_output(), xmlrpc_server_set(), xmlrpc_value(), and xmlrpc_value_get_xml().

xmlrpc_server_call | ( | $ | xmlrpc_server,
 |  | $ | methodname,
 |  | $ | args
 | ) |  |

Dispatch the request and any parameters to the appropriate handler.

Parameters:
$xmlrpc_server
$methodname | The external XML-RPC method name, e.g. 'system.methodHelp'
$args | Array containing any parameters that were sent along with the request.

Definition at line 145 of file xmlrpcs.inc.

References $type, t(), and xmlrpc_error().

Referenced by xmlrpc_server(), and xmlrpc_server_multicall().

xmlrpc_server_error | ( | $ | error,
 |  | $ | message = FALSE
 | ) |  |

Throw an XML-RPC error.

Parameters:
$error | an error object OR integer error code
$message | description of error, used only if integer error code was passed

Definition at line 100 of file xmlrpcs.inc.

References xmlrpc_error(), xmlrpc_error_get_xml(), and xmlrpc_server_output().

Referenced by xmlrpc_server().

xmlrpc_server_get ( )

Definition at line 132 of file xmlrpcs.inc.

References xmlrpc_server_set().

Referenced by xmlrpc_server_list_methods(), xmlrpc_server_method_help(), xmlrpc_server_method_signature(), and xmlrpc_server_multicall().

xmlrpc_server_get_capabilities ( )

XML-RPC method system.getCapabilities maps to this function.

See http://groups.yahoo.com/group/xml-rpc/message/2897

Definition at line 256 of file xmlrpcs.inc.

xmlrpc_server_list_methods ( )

XML-RPC method system.listMethods maps to this function.

Definition at line 247 of file xmlrpcs.inc.

References xmlrpc_server_get().

xmlrpc_server_method_help ( $ method )

XML-RPC method system.methodHelp maps to this function.

Parameters:
$method Name of method for which we return a help string.

Definition at line 310 of file xmlrpcs.inc.

References xmlrpc_server_get().

xmlrpc_server_method_signature ( $ methodname )

XML-RPC method system.methodSignature maps to this function.

Parameters:
$methodname Name of method for which we return a method signature.
Returns:
array An array of types representing the method signature of the function that the methodname maps to. The methodSignature of this function is 'array', 'string' because it takes an array and returns a string.

Definition at line 288 of file xmlrpcs.inc.

References $return, $type, t(), xmlrpc_error(), and xmlrpc_server_get().

xmlrpc_server_multicall ( $ methodcalls )

Definition at line 212 of file xmlrpcs.inc.

References $result, $return, t(), xmlrpc_error(), xmlrpc_server_call(), and xmlrpc_server_get().

xmlrpc_server_output ( $ xml )

Definition at line 107 of file xmlrpcs.inc.

References exit.

Referenced by xmlrpc_server(), and xmlrpc_server_error().

xmlrpc_server_set ( $ xmlrpc_server = NULL )

Store a copy of the request temporarily.

Parameters:
$xmlrpc_server Request object created by xmlrpc_server().

Definition at line 123 of file xmlrpcs.inc.

Referenced by xmlrpc_server(), and xmlrpc_server_get().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator-feed-source.tpl.php File Reference

modules » aggregator

aggregator-feed-source.tpl.php File Reference

Detailed Description

Default theme implementation to present the source of the feed.

The contents are render above feed listings when browsing source feeds. For example, "example.com/aggregator/sources/1".

Available variables:

  • $source_icon: Feed icon linked to the source. Rendered through theme_feed_icon().
  • $source_image: Image set by the feed source.
  • $source_description: Description set by the feed source.
  • $source_url: URL to the feed source.
  • $last_checked: How long ago the feed was checked locally.

See also:
template_preprocess()

template_preprocess_aggregator_feed_source()

Definition in file aggregator-feed-source.tpl.php.

Go to the source code of this file.

Variables

  • print $last_checked
  • print $source_description
  • print $source_icon
  • print $source_image
  • print $source_url

Variable Documentation

print $last_checked

Definition at line 33 of file aggregator-feed-source.tpl.php.

print $source_description

Definition at line 27 of file aggregator-feed-source.tpl.php.

print $source_icon

Definition at line 24 of file aggregator-feed-source.tpl.php.

print $source_image

Definition at line 25 of file aggregator-feed-source.tpl.php.

print $source_url

Definition at line 30 of file aggregator-feed-source.tpl.php.

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator-item.tpl.php File Reference

modules » aggregator

aggregator-item.tpl.php File Reference

Detailed Description

Default theme implementation to format an individual feed item for display on the aggregator page.

Available variables:

  • $feed_url: URL to the originating feed item.
  • $feed_title: Title of the feed item.
  • $source_url: Link to the local source section.
  • $source_title: Title of the remote source.
  • $source_date: Date the feed was posted on the remote source.
  • $content: Feed item content.
  • $categories: Linked categories assigned to the feed.

See also:
template_preprocess()

template_preprocess_aggregator_item()

Definition in file aggregator-item.tpl.php.

Go to the source code of this file.

Variables

  • print $feed_title
  • print $feed_url
  • endif

Variable Documentation

print $feed_title

Definition at line 24 of file aggregator-item.tpl.php.

print $feed_url

Definition at line 24 of file aggregator-item.tpl.php.

Referenced by node_page_default().

endif

Definition at line 44 of file aggregator-item.tpl.php.

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator-summary-item.tpl.php File Reference

modules » aggregator

aggregator-summary-item.tpl.php File Reference

Detailed Description

Default theme implementation to present a linked feed item for summaries.

Available variables:

  • $feed_url: Link to originating feed.
  • $feed_title: Title of feed.
  • $feed_age: Age of remote feed.
  • $source_url: Link to remote source.
  • $source_title: Locally set title for the source.

See also:
template_preprocess()

template_preprocess_aggregator_summary_item()

Definition in file aggregator-summary-item.tpl.php.

Go to the source code of this file.

Variables

  • print $feed_age
  • print $feed_title
  • print $feed_url

Variable Documentation

print $feed_age

Definition at line 19 of file aggregator-summary-item.tpl.php.

print $feed_title

Definition at line 19 of file aggregator-summary-item.tpl.php.

print $feed_url

Definition at line 19 of file aggregator-summary-item.tpl.php.

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator-summary-items.tpl.php File Reference

modules » aggregator

aggregator-summary-items.tpl.php File Reference

Detailed Description

Default theme implementation to present feeds as list items.

Each iteration generates a single feed source or category.

Available variables:

  • $title: Title of the feed or category.
  • $summary_list: Unordered list of linked feed items generated through theme_item_list().
  • $source_url: URL to the local source or category.

See also:
template_preprocess()

template_preprocess_aggregator_summary-items()

Definition in file aggregator-summary-items.tpl.php.

Go to the source code of this file.

Variables

  • print $source_url
  • print $summary_list
  • print $title

Variable Documentation

print $source_url

Definition at line 23 of file aggregator-summary-items.tpl.php.

print $summary_list

Definition at line 21 of file aggregator-summary-items.tpl.php.

print $title

Definition at line 20 of file aggregator-summary-items.tpl.php.

Referenced by _forum_parent_select(), _menu_overview_tree_form(), _menu_parents_recurse(), _statistics_format_item(), _statistics_link(), _taxonomy_term_select(), aggregator_form_category_submit(), aggregator_form_feed_submit(), aggregator_parse_feed(), blog_page_user(), blogapi_blogger_title(), book_block(), book_remove_form(), chameleon_page(), comment_form_box(), drupal_add_feed(), drupal_get_title(), drupal_set_title(), format_rss_channel(), format_rss_item(), forum_block(), menu_block(), menu_parent_options(), node_multiple_delete_confirm(), node_search(), node_title_list(), profile_browse(), profile_view_profile(), system_theme_settings(), tablesort_header(), taxonomy_term_page(), template_preprocess_forums(), theme_box(), theme_feed_icon(), theme_form_element(), theme_image(), theme_install_page(), theme_item_list(), theme_more_link(), theme_node_list(), theme_update_page(), theme_user_list(), and translation_node_overview().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator-wrapper.tpl.php File Reference

modules » aggregator

aggregator-wrapper.tpl.php File Reference

Go to the source code of this file.

Variables

  • print $content
  • print $pager

Variable Documentation

print $content

Definition at line 17 of file aggregator-wrapper.tpl.php.

Referenced by _openid_meta_httpequiv(), blogapi_blogger_edit_post(), blogapi_blogger_new_post(), blogapi_metaweblog_edit_post(), blogapi_metaweblog_new_post(), chameleon_page(), drupal_get_content(), drupal_render(), drupal_set_content(), forum_block(), menu_overview_page(), node_add_page(), node_view(), phptemplate_comment_wrapper(), profile_browse(), statistics_block(), system_admin_menu_block(), system_admin_menu_block_page(), system_logging_overview(), system_settings_overview(), theme_admin_block_content(), theme_box(), theme_install_page(), theme_multipage_form_example_node_form(), theme_node_add_list(), and theme_update_page().

print $pager

Definition at line 18 of file aggregator-wrapper.tpl.php.

Referenced by _locale_translate_seek(), system_actions_manage(), and taxonomy_select_nodes().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator.admin.inc File Reference

modules » aggregator

aggregator.admin.inc File Reference

Detailed Description

Admin page callbacks for the aggregator module.

Definition in file aggregator.admin.inc.

Go to the source code of this file.

Functions

  • aggregator_admin_overview ()
    Menu callback; displays the aggregator administration page.
  • aggregator_admin_refresh_feed ($feed)
    Menu callback; refreshes a feed, then redirects to the overview page.
  • aggregator_admin_remove_feed ($form_state, $feed)
  • aggregator_admin_remove_feed_submit ($form, &$form_state)
    Remove all items from a feed and redirect to the overview page.
  • aggregator_admin_settings ()
    Form builder; Configure the aggregator system.
  • aggregator_form_category (&$form_state, $edit=array('title'=> '', 'description'=> '', 'cid'=> NULL))
    Form builder; Generate a form to add/edit/delete aggregator categories.
  • aggregator_form_category_submit ($form, &$form_state)
    Process aggregator_form_category form submissions.
  • aggregator_form_category_validate ($form, &$form_state)
    Validate aggregator_form_feed form submissions.
  • aggregator_form_feed (&$form_state, $edit=array('refresh'=> 900, 'title'=> '', 'url'=> '', 'fid'=> NULL))
    Form builder; Generate a form to add/edit feed sources.
  • aggregator_form_feed_submit ($form, &$form_state)
    Process aggregator_form_feed form submissions.
  • aggregator_form_feed_validate ($form, &$form_state)
    Validate aggregator_form_feed form submissions.
  • aggregator_view ()
    Displays the aggregator administration page.

Function Documentation

aggregator_admin_overview ( )

Menu callback; displays the aggregator administration page.

Definition at line 12 of file aggregator.admin.inc.

References aggregator_view().

aggregator_admin_refresh_feed ( $ feed )

Menu callback; refreshes a feed, then redirects to the overview page.

Parameters:
$feed An associative array describing the feed to be refreshed.

Definition at line 212 of file aggregator.admin.inc.

References aggregator_refresh(), and drupal_goto().

aggregator_admin_remove_feed | ( | $ | form_state,
 |  | $ | feed
 | ) |  |

Definition at line 179 of file aggregator.admin.inc.

References confirm_form(), and t().

aggregator_admin_remove_feed_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Remove all items from a feed and redirect to the overview page.

Parameters:
$feed An associative array describing the feed to be cleared.

Definition at line 201 of file aggregator.admin.inc.

References aggregator_remove().

aggregator_form_category_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process aggregator_form_category form submissions.

Todo:
Add delete confirmation dialog.

Definition at line 305 of file aggregator.admin.inc.

References $title, aggregator_save_category(), arg(), drupal_set_message(), l(), t(), and watchdog().

aggregator_form_category_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate aggregator_form_feed form submissions.

Definition at line 285 of file aggregator.admin.inc.

References db_fetch_object(), db_query(), form_set_error(), and t().

aggregator_form_feed_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process aggregator_form_feed form submissions.

Todo:
Add delete confirmation dialog.

Definition at line 141 of file aggregator.admin.inc.

References $title, aggregator_save_feed(), arg(), drupal_set_message(), l(), t(), and watchdog().

aggregator_form_feed_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate aggregator_form_feed form submissions.

Definition at line 112 of file aggregator.admin.inc.

References $result, db_fetch_object(), db_query(), form_set_error(), t(), url(), and valid_url().

aggregator_view ( )

Displays the aggregator administration page.

Returns:
The page HTML.

Definition at line 22 of file aggregator.admin.inc.

References $header, $output, $result, db_fetch_object(), db_query(), format_interval(), format_plural(), l(), t(), and theme().

Referenced by aggregator_admin_overview().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator.install File Reference

modules » aggregator

aggregator.install File Reference

Go to the source code of this file.

Functions

  • aggregator_install ()
    Implementation of hook_install().
  • aggregator_schema ()
    Implementation of hook_schema().
  • aggregator_uninstall ()
    Implementation of hook_uninstall().

Function Documentation

aggregator_install ( )

Implementation of hook_install().

Definition at line 7 of file aggregator.install.

References drupal_install_schema().

aggregator_schema ( )

Implementation of hook_schema().

Definition at line 28 of file aggregator.install.

References t().

aggregator_uninstall ( )

Implementation of hook_uninstall().

Definition at line 15 of file aggregator.install.

References drupal_uninstall_schema(), and variable_del().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator.module File Reference

modules » aggregator

aggregator.module File Reference

Detailed Description

Used to aggregate syndicated content (RSS, RDF, and Atom).

Definition in file aggregator.module.

Go to the source code of this file.

Functions

  • _aggregator_category_title ($category)
    Menu callback.
  • _aggregator_has_categories ()
    Find out whether there are any aggregator categories.
  • _aggregator_items ($count)
    Helper function for drupal_map_assoc.
  • aggregator_block ($op= 'list', $delta=0, $edit=array())
    Implementation of hook_block().
  • aggregator_category_load ($cid)
    Load an aggregator category.
  • aggregator_cron ()
    Implementation of hook_cron().
  • aggregator_element_data ($parser, $data)
    Call-back function used by the XML parser.
  • aggregator_element_end ($parser, $name)
    Call-back function used by the XML parser.
  • aggregator_element_start ($parser, $name, $attributes)
    Call-back function used by the XML parser.
  • aggregator_feed_load ($fid)
    Load an aggregator feed.
  • aggregator_filter_xss ($value)
    Safely render HTML content, as allowed.
  • aggregator_help ($path, $arg)
    Implementation of hook_help().
  • aggregator_init ()
    Implementation of hook_init().
  • aggregator_menu ()
    Implementation of hook_menu().
  • aggregator_parse_feed (&$data, $feed)
    Parse a feed and store its items.
  • aggregator_parse_w3cdtf ($date_str)
    Parse the W3C date/time format, a subset of ISO 8601.
  • aggregator_perm ()
    Implementation of hook_perm().
  • aggregator_refresh ($feed)
    Checks a news feed for new items.
  • aggregator_remove ($feed)
    Removes all items from a feed.
  • aggregator_save_category ($edit)
    Add/edit/delete aggregator categories.
  • aggregator_save_feed ($edit)
    Add/edit/delete an aggregator feed.
  • aggregator_save_item ($edit)
    Add/edit/delete an aggregator item.
  • aggregator_theme ()
    Implementation of hook_theme().
  • theme_aggregator_block_item ($item, $feed=0)
    Format an individual feed item for display in the block.

Function Documentation

_aggregator_category_title ( $ category )

Menu callback.

Returns:
An aggregator category title.

Definition at line 255 of file aggregator.module.

_aggregator_has_categories ( )

Find out whether there are any aggregator categories.

Returns:
TRUE if there is at least one category and the user has access to them, FALSE otherwise.

Definition at line 272 of file aggregator.module.

References db_query(), db_result(), and user_access().

_aggregator_items ( $ count )

Helper function for drupal_map_assoc.

Parameters:
$count Items count.
Returns:
Plural-formatted "@count items"

Definition at line 922 of file aggregator.module.

References format_plural().

aggregator_block | ( | $ | op = 'list',
 |  | $ | delta = 0,
 |  | $ | edit = array()
 | ) |  |

Implementation of hook_block().

Generates blocks for the latest news items in each category and feed.

Definition at line 300 of file aggregator.module.

References $id, $item, $items, $op, $result, $type, $value, check_plain(), db_fetch_object(), db_query(), db_query_range(), db_result(), drupal_map_assoc(), t(), theme(), url(), and user_access().

aggregator_category_load ( $ cid )

Load an aggregator category.

Parameters:
$cid The category id.
Returns:
An associative array describing the category.

Definition at line 867 of file aggregator.module.

References db_fetch_array(), and db_query().

aggregator_cron ( )

Implementation of hook_cron().

Checks news feeds for updates once their refresh interval has elapsed.

Definition at line 288 of file aggregator.module.

References $result, aggregator_refresh(), db_fetch_array(), and db_query().

aggregator_element_data | ( | $ | parser,
 |  | $ | data
 | ) |  |

Call-back function used by the XML parser.

Definition at line 529 of file aggregator.module.

References $channel, $element, $image, $item, $items, and $tag.

aggregator_element_end | ( | $ | parser,
 |  | $ | name
 | ) |  |

Call-back function used by the XML parser.

Definition at line 507 of file aggregator.module.

References $element, and $name.

aggregator_element_start | ( | $ | parser,
 |  | $ | name,
 |  | $ | attributes
 | ) |  |

Call-back function used by the XML parser.

Definition at line 463 of file aggregator.module.

References $attributes, $channel, $element, $item, $items, $name, and $tag.

aggregator_feed_load ( $ fid )

Load an aggregator feed.

Parameters:
$fid The feed id.
Returns:
An associative array describing the feed.

Definition at line 851 of file aggregator.module.

References db_fetch_array(), and db_query().

aggregator_filter_xss ( $ value )

Safely render HTML content, as allowed.

Parameters:
$value The content to be filtered.
Returns:
The filtered content.

Definition at line 910 of file aggregator.module.

References $value, filter_xss(), and variable_get().

Referenced by template_preprocess_aggregator_feed_source(), and template_preprocess_aggregator_item().

aggregator_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 12 of file aggregator.module.

References $output, t(), and url().

aggregator_init ( )

Implementation of hook_init().

Definition at line 262 of file aggregator.module.

References drupal_add_css(), and drupal_get_path().

aggregator_menu ( )

Implementation of hook_menu().

Definition at line 81 of file aggregator.module.

References $items.

aggregator_parse_feed | ( | &$ | data,
 |  | $ | feed
 | ) |  |

Parse a feed and store its items.

Parameters:
$data | The feed data.
$feed | An associative array describing the feed to be parsed.
Returns:
0 on error, 1 otherwise.

Definition at line 698 of file aggregator.module.

References $channel, $image, $item, $items, $result, $title, $value, aggregator_parse_w3cdtf(), aggregator_save_item(), db_fetch_object(), db_query(), drupal_set_message(), drupal_xml_parser_create(), t(), truncate_utf8(), variable_get(), and watchdog().

Referenced by aggregator_refresh().

aggregator_parse_w3cdtf ( $ date_str )

Parse the W3C date/time format, a subset of ISO 8601.

PHP date parsing functions do not handle this format. See http://www.w3.org/TR/NOTE-datetime for more information. Originally from MagpieRSS (http://magpierss.sourceforge.net/).

Parameters:
$date_str A string with a potentially W3C DTF date.
Returns:
A timestamp if parsed successfully or FALSE if not.

Definition at line 660 of file aggregator.module.

Referenced by aggregator_parse_feed().

aggregator_perm ( )

Implementation of hook_perm().

Definition at line 279 of file aggregator.module.

aggregator_refresh ( $ feed )

Checks a news feed for new items.

Parameters:
$feed An associative array describing the feed to be refreshed.

Definition at line 579 of file aggregator.module.

References $channel, $image, $result, $value, aggregator_parse_feed(), cache_clear_all(), check_plain(), check_url(), db_query(), drupal_http_request(), drupal_set_message(), module_invoke(), t(), and watchdog().

Referenced by aggregator_admin_refresh_feed(), and aggregator_cron().

aggregator_remove ( $ feed )

Removes all items from a feed.

Parameters:
$feed An associative array describing the feed to be cleared.

Definition at line 447 of file aggregator.module.

References $item, $items, $result, db_fetch_object(), db_query(), drupal_set_message(), and t().

Referenced by aggregator_admin_remove_feed_submit().

aggregator_save_category ( $ edit )

Add/edit/delete aggregator categories.

Parameters:
$edit An associative array describing the category to be added/edited/deleted.

Definition at line 373 of file aggregator.module.

References $op, db_last_insert_id(), db_query(), and menu_link_maintain().

Referenced by aggregator_form_category_submit().

aggregator_save_feed ( $ edit )

Add/edit/delete an aggregator feed.

Parameters:
$edit An associative array describing the feed to be added/edited/deleted.

Definition at line 404 of file aggregator.module.

References $item, $items, $result, $value, db_fetch_object(), db_last_insert_id(), and db_query().

Referenced by aggregator_form_feed_submit().

aggregator_save_item ( $ edit )

Add/edit/delete an aggregator item.

Parameters:
$edit An associative array describing the item to be added/edited/deleted.

Definition at line 824 of file aggregator.module.

References db_fetch_object(), db_last_insert_id(), and db_query().

Referenced by aggregator_parse_feed().

aggregator_theme ( )

Implementation of hook_theme().

Definition at line 33 of file aggregator.module.

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator.pages.inc File Reference

modules » aggregator

aggregator.pages.inc File Reference

Detailed Description

User page callbacks for the aggregator module.

Definition in file aggregator.pages.inc.

Go to the source code of this file.

Functions

  • _aggregator_page_list ($items, $op, $feed_source= '')
    Prints an aggregator page listing a number of feed items.
  • aggregator_categorize_items ($items, $feed_source= '')
    Form builder; build the page list form.
  • aggregator_categorize_items_submit ($form, &$form_state)
    Process aggregator_categorize_items form submissions.
  • aggregator_categorize_items_validate ($form, &$form_state)
    Validate aggregator_categorize_items form submissions.
  • aggregator_feed_items_load ($sql)
    Load feed items by passing a SQL query.
  • aggregator_page_categories ()
    Menu callback; displays all the categories used by the aggregator.
  • aggregator_page_category ($arg1, $arg2=NULL)
    Menu callback; displays all the items aggregated in a particular category.
  • aggregator_page_last ()
    Menu callback; displays the most recent items gathered from any feed.
  • aggregator_page_opml ($cid=NULL)
    Menu callback; generates an OPML representation of all feeds.
  • aggregator_page_rss ()
    Menu callback; generate an RSS 0.92 feed of aggregator items or categories.
  • aggregator_page_source ($arg1, $arg2=NULL)
    Menu callback; displays all the items captured from a particular feed.
  • aggregator_page_sources ()
    Menu callback; displays all the feeds used by the aggregator.
  • template_preprocess_aggregator_feed_source (&$variables)
    Process variables for aggregator-feed-source.tpl.php.
  • template_preprocess_aggregator_item (&$variables)
    Process variables for aggregator-item.tpl.php.
  • template_preprocess_aggregator_summary_item (&$variables)
    Process variables for aggregator-summary-item.tpl.php.
  • template_preprocess_aggregator_summary_items (&$variables)
    Process variables for aggregator-summary-items.tpl.php.
  • template_preprocess_aggregator_wrapper (&$variables)
    Process variables for aggregator-wrapper.tpl.php.
  • theme_aggregator_categorize_items ($form)
    Theme the page list form for assigning categories.
  • theme_aggregator_page_opml ($feeds)
    Theme the OPML feed output.
  • theme_aggregator_page_rss ($feeds, $category=NULL)
    Theme the RSS output.

Function Documentation

_aggregator_page_list | ( | $ | items,
 |  | $ | op,
 |  | $ | feed_source = ''
 | ) |  |

Prints an aggregator page listing a number of feed items.

Various menu callbacks use this function to print their feeds.

Parameters:
$items | The items to be listed.
$op | Which form should be added to the items. Only 'categorize' is now recognized.
$feed_source | The feed source URL.
Returns:
The items HTML.

Definition at line 115 of file aggregator.pages.inc.

References $item, $items, $op, $output, aggregator_categorize_items(), theme(), and user_access().

Referenced by aggregator_page_category(), aggregator_page_last(), and aggregator_page_source().

aggregator_categorize_items_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process aggregator_categorize_items form submissions.

Definition at line 192 of file aggregator.pages.inc.

References db_query(), drupal_set_message(), and t().

aggregator_categorize_items_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate aggregator_categorize_items form submissions.

Definition at line 183 of file aggregator.pages.inc.

References form_error(), t(), and user_access().

aggregator_feed_items_load ( $ sql )

Load feed items by passing a SQL query.

Parameters:
$sql The query to be executed.
Returns:
An array of the feed items.

Definition at line 85 of file aggregator.pages.inc.

References $item, $items, $result, db_fetch_object(), db_query(), and pager_query().

Referenced by aggregator_page_category(), aggregator_page_last(), and aggregator_page_source().

aggregator_page_categories ( )

Menu callback; displays all the categories used by the aggregator.

Definition at line 301 of file aggregator.pages.inc.

References $item, $items, $output, $result, db_fetch_object(), db_query(), db_query_range(), theme(), url(), and variable_get().

aggregator_page_category | ( | $ | arg1,
 |  | $ | arg2 = NULL
 | ) |  |

Menu callback; displays all the items aggregated in a particular category.

If there are two arguments then this function is called as a form.

Parameters:
$arg1 | If there are two arguments then $arg1 is $form_state. Otherwise, $arg1 is $category.
$arg2 | If there are two arguments then $arg2 is $category.
Returns:
The items HTML.

Definition at line 62 of file aggregator.pages.inc.

References $items, _aggregator_page_list(), aggregator_feed_items_load(), arg(), drupal_add_feed(), drupal_get_breadcrumb(), drupal_set_breadcrumb(), l(), t(), url(), and variable_get().

aggregator_page_last ( )

Menu callback; displays the most recent items gathered from any feed.

Returns:
The items HTML.

Definition at line 15 of file aggregator.pages.inc.

References $items, _aggregator_page_list(), aggregator_feed_items_load(), arg(), drupal_add_feed(), t(), url(), and variable_get().

aggregator_page_opml ( $ cid = NULL )

Menu callback; generates an OPML representation of all feeds.

Parameters:
$cid If set, feeds are exported only from a category with this ID. Otherwise, all feeds are exported.
Returns:
The output XML.

Definition at line 395 of file aggregator.pages.inc.

References $item, $result, db_fetch_object(), db_query(), and theme().

aggregator_page_rss ( )

Menu callback; generate an RSS 0.92 feed of aggregator items or categories.

Definition at line 323 of file aggregator.pages.inc.

References $item, $result, arg(), db_fetch_object(), db_query(), db_query_range(), theme(), and variable_get().

aggregator_page_source | ( | $ | arg1,
 |  | $ | arg2 = NULL
 | ) |  |

Menu callback; displays all the items captured from a particular feed.

If there are two arguments then this function is the categorize form.

Parameters:
$arg1 | If there are two arguments then $arg1 is $form_state. Otherwise, $arg1 is $feed.
$arg2 | If there are two arguments then $arg2 is feed.
Returns:
The items HTML.

Definition at line 35 of file aggregator.pages.inc.

References $items, _aggregator_page_list(), aggregator_feed_items_load(), arg(), check_plain(), drupal_set_title(), and theme().

aggregator_page_sources ( )

Menu callback; displays all the feeds used by the aggregator.

Definition at line 277 of file aggregator.pages.inc.

References $item, $items, $output, $result, db_fetch_object(), db_query(), db_query_range(), t(), theme(), url(), and variable_get().

template_preprocess_aggregator_feed_source ( &$ variables )

Process variables for aggregator-feed-source.tpl.php.

See also:
aggregator-feed-source.tpl.php

Definition at line 474 of file aggregator.pages.inc.

References aggregator_filter_xss(), check_url(), format_interval(), l(), link, t(), theme(), url(), and user_access().

template_preprocess_aggregator_item ( &$ variables )

Process variables for aggregator-item.tpl.php.

See also:
aggregator-item.tpl.php

Definition at line 248 of file aggregator.pages.inc.

References $item, aggregator_filter_xss(), check_plain(), check_url(), format_date(), format_interval(), l(), link, t(), url(), and variable_get().

template_preprocess_aggregator_summary_item ( &$ variables )

Process variables for aggregator-summary-item.tpl.php.

See also:
aggregator-summary-item.tpl.php

Definition at line 454 of file aggregator.pages.inc.

References $item, check_plain(), check_url(), format_interval(), link, and t().

template_preprocess_aggregator_summary_items ( &$ variables )

Process variables for aggregator-summary-items.tpl.php.

See also:
aggregator-summary-item.tpl.php

Definition at line 443 of file aggregator.pages.inc.

References check_plain(), and theme().

template_preprocess_aggregator_wrapper ( &$ variables )

Process variables for aggregator-wrapper.tpl.php.

See also:
aggregator-wrapper.tpl.php

Definition at line 239 of file aggregator.pages.inc.

References theme().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/block/block-admin-display-form.tpl.php File Reference

modules » block

block-admin-display-form.tpl.php File Reference

Detailed Description

Default theme implementation to configure blocks.

Available variables:

  • $block_regions: An array of regions. Keyed by name with the title as value.
  • $block_listing: An array of blocks keyed by region and then delta.
  • $form_submit: Form submit button.
  • $throttle: TRUE or FALSE depending on throttle module being enabled.

Each $block_listing[$region] contains an array of blocks for that region.

Each $data in $block_listing[$region] contains:

  • $data->region_title: Region title for the listed block.
  • $data->block_title: Block title.
  • $data->region_select: Drop-down menu for assigning a region.
  • $data->weight_select: Drop-down menu for setting weights.
  • $data->throttle_check: Checkbox to enable throttling.
  • $data->configure_link: Block configuration link.
  • $data->delete_link: For deleting user added blocks.

See also:
template_preprocess_block_admin_display_form()

theme_block_admin_display()

Definition in file block-admin-display-form.tpl.php.

Go to the source code of this file.

Variables

  • $row = 0
  • endif

Variable Documentation

$row = 0

Definition at line 51 of file block-admin-display-form.tpl.php.

Referenced by _node_access_rebuild_batch_operation(), batch_example_op_2(), batch_test_update_1(), blog_feed_last(), blog_feed_user(), book_admin_edit_submit(), comment_get_recent(), drupal_get_installed_schema_version(), language_list(), node_feed(), node_overview_types(), node_revision_overview(), path_admin_overview(), system_actions_manage(), taxonomy_term_page(), template_preprocess_forum_list(), template_preprocess_forum_topic_list(), theme_book_admin_table(), theme_comment_admin_overview(), theme_menu_overview_form(), theme_node_admin_nodes(), theme_node_search_admin(), theme_poll_choices(), theme_profile_admin_overview(), theme_system_modules(), theme_system_theme_select_form(), theme_system_themes_form(), theme_table(), theme_taxonomy_overview_terms(), theme_taxonomy_overview_vocabularies(), theme_update_report(), theme_upload_form_current(), theme_user_admin_perm(), and user_access().

endif

Definition at line 46 of file block-admin-display-form.tpl.php.

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/block/block.admin.inc File Reference

modules » block

block.admin.inc File Reference

Detailed Description

Admin page callbacks for the block module.

Definition in file block.admin.inc.

Go to the source code of this file.

Functions

  • _block_compare ($a, $b)
    Helper function for sorting blocks on admin/build/block.
  • block_add_block_form (&$form_state)
    Menu callback: display the custom block addition form.
  • block_add_block_form_submit ($form, &$form_state)
    Save the new custom block.
  • block_add_block_form_validate ($form, &$form_state)
  • block_admin_configure (&$form_state, $module=NULL, $delta=0)
    Menu callback; displays the block configuration form.
  • block_admin_configure_submit ($form, &$form_state)
  • block_admin_configure_validate ($form, &$form_state)
  • block_admin_display ($theme=NULL)
    Menu callback for admin/build/block.
  • block_admin_display_form (&$form_state, $blocks, $theme=NULL)
    Generate main blocks administration form.
  • block_admin_display_form_submit ($form, &$form_state)
    Process main blocks administration form submission.
  • block_box_delete (&$form_state, $bid=0)
    Menu callback; confirm deletion of custom blocks.
  • block_box_delete_submit ($form, &$form_state)
    Deletion of custom blocks.
  • template_preprocess_block_admin_display_form (&$variables)
    Process variables for block-admin-display.tpl.php.

Function Documentation

_block_compare | ( | $ | a,
 |  | $ | b
 | ) |  |

Helper function for sorting blocks on admin/build/block.

Active blocks are sorted by region, then by weight. Disabled blocks are sorted by name.

Definition at line 110 of file block.admin.inc.

References $status, $theme_key, and system_region_list().

block_add_block_form ( &$ form_state )

Menu callback: display the custom block addition form.

Definition at line 287 of file block.admin.inc.

References block_admin_configure().

block_add_block_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Save the new custom block.

Definition at line 300 of file block.admin.inc.

References $theme, cache_clear_all(), db_last_insert_id(), db_query(), drupal_set_message(), list_themes(), name, and t().

block_add_block_form_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 291 of file block.admin.inc.

References db_query(), db_result(), form_set_error(), and t().

block_admin_configure | ( | &$ | form_state,
 |  | $ | module = NULL,
 |  | $ | delta = 0
 | ) |  |

Menu callback; displays the block configuration form.

Definition at line 142 of file block.admin.inc.

References $result, db_fetch_array(), db_fetch_object(), db_query(), drupal_set_title(), module_invoke(), t(), and user_access().

Referenced by block_add_block_form().

block_admin_configure_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 269 of file block.admin.inc.

References cache_clear_all(), db_query(), drupal_set_message(), form_get_errors(), module_invoke(), and t().

block_admin_configure_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 261 of file block.admin.inc.

References db_query(), db_result(), form_set_error(), and t().

block_admin_display ( $ theme = NULL )

Menu callback for admin/build/block.

Definition at line 12 of file block.admin.inc.

References $custom_theme, $theme, _block_rehash(), drupal_get_form(), and variable_get().

block_admin_display_form | ( | &$ | form_state,
 |  | $ | blocks,
 |  | $ | theme = NULL
 | ) |  |

Generate main blocks administration form.

Definition at line 28 of file block.admin.inc.

References $custom_theme, $theme, $theme_key, arg(), check_plain(), drupal_add_css(), drupal_get_path(), init_theme(), l(), module_exists(), system_region_list(), t(), url(), and variable_get().

block_admin_display_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process main blocks administration form submission.

Definition at line 94 of file block.admin.inc.

References cache_clear_all(), db_query(), drupal_set_message(), and t().

block_box_delete | ( | &$ | form_state,
 |  | $ | bid = 0
 | ) |  |

Menu callback; confirm deletion of custom blocks.

Definition at line 324 of file block.admin.inc.

References block_box_get(), confirm_form(), and t().

block_box_delete_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Deletion of custom blocks.

Definition at line 335 of file block.admin.inc.

References cache_clear_all(), db_query(), drupal_set_message(), and t().

template_preprocess_block_admin_display_form ( &$ variables )

Process variables for block-admin-display.tpl.php.

The $variables array contains the following arguments:

  • $form

See also:
block-admin-display.tpl.php

theme_block_admin_display()

Definition at line 353 of file block.admin.inc.

References $theme_key, $value, drupal_render(), drupal_set_content(), element_children(), module_exists(), system_region_list(), and t().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/block/block.install File Reference

modules » block

block.install File Reference

Go to the source code of this file.

Functions

  • block_schema ()
    Implementation of hook_schema().

Function Documentation

block_schema ( )

Implementation of hook_schema().

Definition at line 7 of file block.install.

References drupal_get_schema_unprocessed(), and t().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/block/block.module File Reference

modules » block

block.module File Reference

Detailed Description

Controls the boxes that are displayed around the main content.

Definition in file block.module.

Go to the source code of this file.

Enumerations

  • enum BLOCK_CACHE_GLOBAL
    The block is the same for every user on every page where it is visible. More...
  • enum BLOCK_CACHE_PER_PAGE
    The block can change depending on the page being viewed. More...
  • enum BLOCK_CACHE_PER_ROLE
    The block can change depending on the roles the user viewing the page belongs to. More...
  • enum BLOCK_CACHE_PER_USER
    The block can change depending on the user viewing the page. More...
  • enum BLOCK_NO_CACHE
    Constants defining cache granularity for blocks. More...
  • enum BLOCK_REGION_NONE
    Denotes that a block is not enabled in any region and should not be shown. More...

Functions

  • _block_get_cache_id ($block)
    Assemble the cache_id to use for a given block.
  • _block_rehash ()
    Update the 'blocks' DB table with the blocks currently exported by modules.
  • _block_themes_access ($theme)
    Menu item access callback - only admin or enabled themes can be accessed.
  • block_block ($op= 'list', $delta=0, $edit=array())
    Implementation of hook_block().
  • block_box_form ($edit=array())
    Define the custom block form.
  • block_box_get ($bid)
  • block_box_save ($edit, $delta)
  • block_help ($path, $arg)
    Implementation of hook_help().
  • block_list ($region)
    Return all blocks in the specified region for the current user.
  • block_menu ()
    Implementation of hook_menu().
  • block_perm ()
    Implementation of hook_perm().
  • block_theme ()
    Implementation of hook_theme().
  • block_user ($type, $edit, &$account, $category=NULL)
    Implementation of hook_user().

Enumeration Type Documentation

enum BLOCK_CACHE_GLOBAL

The block is the same for every user on every page where it is visible.

Definition at line 62 of file block.module.

enum BLOCK_CACHE_PER_PAGE

The block can change depending on the page being viewed.

Definition at line 57 of file block.module.

enum BLOCK_CACHE_PER_ROLE

The block can change depending on the roles the user viewing the page belongs to.

This is the default setting, used when the block does not specify anything.

Definition at line 45 of file block.module.

enum BLOCK_CACHE_PER_USER

The block 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 BLOCK_CACHE_PER_ROLE is not sufficient.

Definition at line 52 of file block.module.

enum BLOCK_NO_CACHE

Constants defining cache granularity for blocks.

Modules specify the caching patterns for their blocks using binary combinations of these constants in their hook_block(op 'list'): $block[delta]['cache'] = BLOCK_CACHE_PER_ROLE | BLOCK_CACHE_PER_PAGE; BLOCK_CACHE_PER_ROLE is used as a default when no caching pattern is specified.

The block cache is cleared in cache_clear_all(), and uses the same clearing policy than page cache (node, comment, user, taxonomy added or updated...). Blocks requiring more fine-grained clearing might consider disabling the built-in block cache (BLOCK_NO_CACHE) and roll their own.

Note that user 1 is excluded from block caching. The block should not get cached. This setting should be used:

  • for simple blocks (notably those that do not perform any db query), where querying the db cache would be more expensive than directly generating the content.
  • for blocks that change too frequently.

Definition at line 39 of file block.module.

enum BLOCK_REGION_NONE

Denotes that a block is not enabled in any region and should not be shown.

Definition at line 13 of file block.module.

Function Documentation

_block_get_cache_id ( $ block )

Assemble the cache_id to use for a given block.

The cache_id string reflects the viewing context for the current block instance, obtained by concatenating the relevant context information (user, page, ...) according to the block's cache settings (BLOCK_CACHE_* constants). Two block instances can use the same cached content when they share the same cache_id.

Theme and language contexts are automatically differenciated.

Parameters:
$block
Returns:
The string used as cache_id for the block.

Definition at line 502 of file block.module.

References $base_root, $language, $theme, $user, module_exists(), request_uri(), and variable_get().

Referenced by block_list().

_block_rehash ( )

Update the 'blocks' DB table with the blocks currently exported by modules.

Returns:
Blocks currently exported by modules.

Definition at line 226 of file block.module.

References $result, $theme_key, db_fetch_array(), db_query(), drupal_set_message(), drupal_write_record(), init_theme(), module_invoke(), module_list(), system_region_list(), and t().

Referenced by block_admin_display().

_block_themes_access ( $ theme )

Menu item access callback - only admin or enabled themes can be accessed.

Definition at line 177 of file block.module.

References $theme, user_access(), and variable_get().

block_block | ( | $ | op = 'list',
 |  | $ | delta = 0,
 |  | $ | edit = array()
 | ) |  |

Implementation of hook_block().

Generates the administrator-defined blocks for display.

Definition at line 186 of file block.module.

References $op, $result, block_box_form(), block_box_get(), block_box_save(), check_markup(), db_fetch_object(), db_query(), and filter_access().

block_box_form ( $ edit = array() )

Define the custom block form.

Definition at line 304 of file block.module.

References filter_form(), t(), and url().

Referenced by block_block().

block_box_get ( $ bid )

Definition at line 297 of file block.module.

References db_fetch_array(), and db_query().

Referenced by block_block(), and block_box_delete().

block_box_save | ( | $ | edit,
 |  | $ | delta
 | ) |  |

Definition at line 335 of file block.module.

References db_query(), and filter_access().

Referenced by block_block().

block_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 67 of file block.module.

References $output, module_exists(), t(), and url().

block_list ( $ region )

Return all blocks in the specified region for the current user.

Parameters:
$region The name of a region.
Returns:
An array of block objects, indexed with module_delta. If you are displaying your blocks in one or two sidebars, you may check whether this array is empty to see how many columns are going to be displayed.
Todo:
Now that the blocks table has a primary key, we should use that as the array key instead of module_delta.

Definition at line 396 of file block.module.

References $result, $theme_key, $user, _block_get_cache_id(), cache_get(), cache_set(), check_plain(), content, db_fetch_object(), db_placeholders(), db_query(), db_rewrite_sql(), delta, drupal_eval(), drupal_get_path_alias(), drupal_match_path(), module, module_implements(), module_invoke(), and subject.

Referenced by theme_blocks().

block_menu ( )

Implementation of hook_menu().

Definition at line 119 of file block.module.

References $items, $theme, check_plain(), list_themes(), and variable_get().

block_perm ( )

Implementation of hook_perm().

Definition at line 112 of file block.module.

block_theme ( )

Implementation of hook_theme().

Definition at line 99 of file block.module.

block_user | ( | $ | type,
 |  | $ | edit,
 |  | &$ | account,
 |  | $ | category = NULL
 | ) |  |

Implementation of hook_user().

Allow users to decide which custom blocks to display when they visit the site.

Definition at line 351 of file block.module.

References $result, $return, $type, check_plain(), db_fetch_object(), db_placeholders(), db_query(), delta, module, module_invoke(), and t().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/blog/blog.module File Reference

modules » blog

blog.module File Reference

Detailed Description

Enables keeping an easily and regularly updated web page or a blog.

Definition in file blog.module.

Go to the source code of this file.

Functions

  • blog_access ($op, $node, $account)
    Implementation of hook_access().
  • blog_block ($op= 'list', $delta=0)
    Implementation of hook_block().
  • blog_form (&$node)
    Implementation of hook_form().
  • blog_help ($path, $arg)
    Implementation of hook_help().
  • blog_link ($type, $node=NULL, $teaser=FALSE)
    Implementation of hook_link().
  • blog_menu ()
    Implementation of hook_menu().
  • blog_node_info ()
    Implementation of hook_node_info().
  • blog_perm ()
    Implementation of hook_perm().
  • blog_user ($type, &$edit, &$user)
    Implementation of hook_user().
  • blog_view ($node, $teaser=FALSE, $page=FALSE)
    Implementation of hook_view().

Function Documentation

blog_access | ( | $ | op,
 |  | $ | node,
 |  | $ | account
 | ) |  |

Implementation of hook_access().

Definition at line 32 of file blog.module.

References $op, and user_access().

blog_block | ( | $ | op = 'list',
 |  | $ | delta = 0
 | ) |  |

Implementation of hook_block().

Displays the most recent 10 blog titles.

Definition at line 175 of file blog.module.

References $op, $result, $user, db_query_range(), db_rewrite_sql(), node_title_list(), t(), theme(), url(), and user_access().

blog_form ( &$ node )

Implementation of hook_form().

Definition at line 76 of file blog.module.

References $item, $nid, $type, check_plain(), check_url(), db_fetch_object(), db_query(), l(), link, name, node_body_field(), node_get_types(), and node_load().

blog_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 61 of file blog.module.

References $output, t(), and url().

blog_link | ( | $ | type,
 |  | $ | node = NULL,
 |  | $ | teaser = FALSE
 | ) |  |

Implementation of hook_link().

Definition at line 116 of file blog.module.

References $links, $type, arg(), name, and t().

blog_menu ( )

Implementation of hook_menu().

Definition at line 135 of file blog.module.

References $items.

blog_node_info ( )

Implementation of hook_node_info().

Definition at line 12 of file blog.module.

References t().

blog_perm ( )

Implementation of hook_perm().

Definition at line 25 of file blog.module.

blog_user | ( | $ | type,
 |  | &$ | edit,
 |  | &$ | user
 | ) |  |

Implementation of hook_user().

Definition at line 47 of file blog.module.

References $type, $user, l(), name, t(), and user_access().

blog_view | ( | $ | node,
 |  | $ | teaser = FALSE,
 |  | $ | page = FALSE
 | ) |  |

Implementation of hook_view().

Definition at line 105 of file blog.module.

References drupal_set_breadcrumb(), l(), name, node_prepare(), and t().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/blog/blog.pages.inc File Reference

modules » blog

blog.pages.inc File Reference

Detailed Description

Page callback file for the blog module.

Definition in file blog.pages.inc.

Go to the source code of this file.

Functions

  • blog_feed_last ()
    Menu callback; displays an RSS feed containing recent blog entries of all users.
  • blog_feed_user ($account)
    Menu callback; displays an RSS feed containing recent blog entries of a given user.
  • blog_page_last ()
    Menu callback; displays a Drupal page containing recent blog entries of all users.
  • blog_page_user ($account)
    Menu callback; displays a Drupal page containing recent blog entries of a given user.

Function Documentation

blog_feed_last ( )

Menu callback; displays an RSS feed containing recent blog entries of all users.

Definition at line 104 of file blog.pages.inc.

References $channel, $items, $result, $row, db_fetch_object(), db_query_range(), db_rewrite_sql(), node_feed(), url(), and variable_get().

blog_feed_user ( $ account )

Menu callback; displays an RSS feed containing recent blog entries of a given user.

Definition at line 89 of file blog.pages.inc.

References $channel, $items, $result, $row, db_fetch_object(), db_query_range(), db_rewrite_sql(), node_feed(), url(), and variable_get().

blog_page_last ( )

Menu callback; displays a Drupal page containing recent blog entries of all users.

Definition at line 55 of file blog.pages.inc.

References $items, $output, $result, $user, db_fetch_object(), db_rewrite_sql(), drupal_add_feed(), drupal_set_message(), l(), nid, node_load(), node_view(), pager_query(), t(), theme(), url(), user_access(), and variable_get().

blog_page_user ( $ account )

Menu callback; displays a Drupal page containing recent blog entries of a given user.

Definition at line 12 of file blog.pages.inc.

References $items, $output, $result, $title, $user, db_fetch_object(), db_rewrite_sql(), drupal_add_feed(), drupal_set_message(), drupal_set_title(), l(), name, nid, node_load(), node_view(), pager_query(), t(), theme(), url(), user_access(), and variable_get().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/blogapi/blogapi.install File Reference

modules » blogapi

blogapi.install File Reference

Go to the source code of this file.

Functions

  • blogapi_update_6000 ()
    Inform users about the new permission.
Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/blogapi/blogapi.module File Reference

modules » blogapi

blogapi.module File Reference

Detailed Description

Enable users to post using applications that support XML-RPC blog APIs.

Definition in file blogapi.module.

Go to the source code of this file.

Functions

  • _blogapi_get_node_types ()
  • _blogapi_get_post ($node, $bodies=TRUE)
  • _blogapi_mt_extra (&$node, $struct)
    Handles extra information sent by clients according to MovableType's spec.
  • _blogapi_validate_blogid ($blogid)
    Validate blog ID, which maps to a content type in Drupal.
  • blogap_mti_publish_post ($postid, $username, $password)
    Blogging API callback.
  • blogapi_admin_settings ()
  • blogapi_blogger_delete_post ($appkey, $postid, $username, $password, $publish)
    Blogging API callback.
  • blogapi_blogger_edit_post ($appkey, $postid, $username, $password, $content, $publish)
    Blogging API callback.
  • blogapi_blogger_get_post ($appkey, $postid, $username, $password)
    Blogging API callback.
  • blogapi_blogger_get_recent_posts ($appkey, $blogid, $username, $password, $number_of_posts, $bodies=TRUE)
    Blogging API callback.
  • blogapi_blogger_get_user_info ($appkey, $username, $password)
    Blogging API callback.
  • blogapi_blogger_get_users_blogs ($appid, $username, $password)
    Blogging API callback.
  • blogapi_blogger_new_post ($appkey, $blogid, $username, $password, $content, $publish)
    Blogging API callback.
  • blogapi_blogger_title (&$contents)
    For the blogger API, extract the node title from the contents field.
  • blogapi_error ($message)
    Prepare an error message for returning to the XMLRPC caller.
  • blogapi_help ($path, $arg)
    Implementation of hook_help().
  • blogapi_init ()
  • blogapi_menu ()
  • blogapi_metaweblog_edit_post ($postid, $username, $password, $content, $publish)
  • blogapi_metaweblog_get_category_list ($blogid, $username, $password)
    Blogging API callback.
  • blogapi_metaweblog_get_post ($postid, $username, $password)
  • blogapi_metaweblog_get_recent_posts ($blogid, $username, $password, $number_of_posts)
  • blogapi_metaweblog_new_media_object ($blogid, $username, $password, $file)
    Blogging API callback.
  • blogapi_metaweblog_new_post ($blogid, $username, $password, $content, $publish)
  • blogapi_mt_get_category_list ($blogid, $username, $password)
  • blogapi_mt_get_post_categories ($postid, $username, $password)
    Blogging API callback.
  • blogapi_mt_get_recent_post_titles ($blogid, $username, $password, $number_of_posts)
  • blogapi_mt_set_post_categories ($postid, $username, $password, $categories)
    Blogging API callback.
  • blogapi_mt_supported_text_filters ()
    Blogging API callback.
  • blogapi_perm ()
    Implementation of hook_perm().
  • blogapi_rsd ()
  • blogapi_validate_user ($username, $password)
    Ensure that the given user has permission to edit a blog.
  • blogapi_xmlrpc ()
    Implementation of hook_xmlrpc().

Function Documentation

_blogapi_get_node_types ( )

Definition at line 718 of file blogapi.module.

References $name, $type, node_access(), node_get_types(), and variable_get().

Referenced by _blogapi_validate_blogid(), and blogapi_blogger_get_users_blogs().

_blogapi_get_post | ( | $ | node,
 |  | $ | bodies = TRUE
 | ) |  |

Definition at line 675 of file blogapi.module.

References name, nid, url(), and xmlrpc_date().

Referenced by blogapi_blogger_get_post(), and blogapi_blogger_get_recent_posts().

_blogapi_mt_extra | ( | &$ | node,
 |  | $ | struct
 | ) |  |

Handles extra information sent by clients according to MovableType's spec.

Definition at line 630 of file blogapi.module.

References format_date().

Referenced by blogapi_blogger_edit_post(), and blogapi_blogger_new_post().

_blogapi_validate_blogid ( $ blogid )

Validate blog ID, which maps to a content type in Drupal.

Only content types configured to work with Blog API are supported.

Returns:
TRUE if the content type is supported and the user has permission to post, or a blogapi_error() XML construct otherwise.

Definition at line 710 of file blogapi.module.

References _blogapi_get_node_types(), blogapi_error(), and t().

Referenced by blogapi_blogger_get_recent_posts(), blogapi_blogger_new_post(), and blogapi_metaweblog_get_category_list().

blogap_mti_publish_post | ( | $ | postid,
 |  | $ | username,
 |  | $ | password
 | ) |  |

Blogging API callback.

Publishes the given node

Definition at line 490 of file blogapi.module.

References $user, blogapi_error(), blogapi_validate_user(), node_access(), node_load(), node_save(), and t().

blogapi_admin_settings ( )

Definition at line 559 of file blogapi.module.

References node_get_types(), system_settings_form(), t(), and variable_get().

blogapi_blogger_delete_post | ( | $ | appkey,
 |  | $ | postid,
 |  | $ | username,
 |  | $ | password,
 |  | $ | publish
 | ) |  |

Blogging API callback.

Removes the specified blog node.

Definition at line 313 of file blogapi.module.

References $user, blogapi_error(), blogapi_validate_user(), and node_delete().

blogapi_blogger_edit_post | ( | $ | appkey,
 |  | $ | postid,
 |  | $ | username,
 |  | $ | password,
 |  | $ | content,
 |  | $ | publish
 | ) |  |

Blogging API callback.

Modifies the specified blog node.

Definition at line 244 of file blogapi.module.

References $content, $user, _blogapi_mt_extra(), blogapi_blogger_title(), blogapi_error(), blogapi_validate_user(), form_get_errors(), format_date(), l(), nid, node_access(), node_invoke_nodeapi(), node_load(), node_save(), node_submit(), node_validate(), t(), user_access(), and watchdog().

Referenced by blogapi_metaweblog_edit_post().

blogapi_blogger_get_post | ( | $ | appkey,
 |  | $ | postid,
 |  | $ | username,
 |  | $ | password
 | ) |  |

Blogging API callback.

Returns a specified blog node.

Definition at line 299 of file blogapi.module.

References $user, _blogapi_get_post(), blogapi_error(), blogapi_validate_user(), and node_load().

Referenced by blogapi_metaweblog_get_post().

blogapi_blogger_get_recent_posts | ( | $ | appkey,
 |  | $ | blogid,
 |  | $ | username,
 |  | $ | password,
 |  | $ | number_of_posts,
 |  | $ | bodies = TRUE
 | ) |  |

Blogging API callback.

Returns the latest few postings in a user's blog. $bodies TRUE returns a bandwidth-friendly list.

Definition at line 328 of file blogapi.module.

References $result, $user, _blogapi_get_post(), _blogapi_validate_blogid(), blogapi_error(), blogapi_validate_user(), db_fetch_object(), and db_query_range().

Referenced by blogapi_metaweblog_get_recent_posts(), and blogapi_mt_get_recent_post_titles().

blogapi_blogger_get_user_info | ( | $ | appkey,
 |  | $ | username,
 |  | $ | password
 | ) |  |

Blogging API callback.

Returns profile information about a user.

Definition at line 160 of file blogapi.module.

References $name, $user, blogapi_error(), blogapi_validate_user(), name, and url().

blogapi_blogger_get_users_blogs | ( | $ | appid,
 |  | $ | username,
 |  | $ | password
 | ) |  |

Blogging API callback.

Finds the URL of a user's blog.

Definition at line 141 of file blogapi.module.

References $type, $user, _blogapi_get_node_types(), blogapi_error(), blogapi_validate_user(), name, and url().

blogapi_blogger_new_post | ( | $ | appkey,
 |  | $ | blogid,
 |  | $ | username,
 |  | $ | password,
 |  | $ | content,
 |  | $ | publish
 | ) |  |

Blogging API callback.

Inserts a new blog post as a node.

Definition at line 181 of file blogapi.module.

References $content, $user, _blogapi_mt_extra(), _blogapi_validate_blogid(), blogapi_blogger_title(), blogapi_error(), blogapi_validate_user(), form_get_errors(), format_date(), l(), nid, node_access(), node_invoke_nodeapi(), node_save(), node_submit(), node_validate(), t(), user_access(), variable_get(), and watchdog().

Referenced by blogapi_metaweblog_new_post().

blogapi_blogger_title ( &$ contents )

For the blogger API, extract the node title from the contents field.

Definition at line 548 of file blogapi.module.

References $title.

Referenced by blogapi_blogger_edit_post(), and blogapi_blogger_new_post().

blogapi_error ( $ message )

Prepare an error message for returning to the XMLRPC caller.

Definition at line 513 of file blogapi.module.

References xmlrpc_error().

Referenced by _blogapi_validate_blogid(), blogap_mti_publish_post(), blogapi_blogger_delete_post(), blogapi_blogger_edit_post(), blogapi_blogger_get_post(), blogapi_blogger_get_recent_posts(), blogapi_blogger_get_user_info(), blogapi_blogger_get_users_blogs(), blogapi_blogger_new_post(), blogapi_metaweblog_new_media_object(), blogapi_mt_get_post_categories(), and blogapi_mt_set_post_categories().

blogapi_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 12 of file blogapi.module.

References $output, t(), and url().

blogapi_init ( )

Definition at line 593 of file blogapi.module.

References drupal_add_link(), drupal_is_front_page(), t(), and url().

blogapi_menu ( )

Definition at line 574 of file blogapi.module.

References $items.

blogapi_metaweblog_edit_post | ( | $ | postid,
 |  | $ | username,
 |  | $ | password,
 |  | $ | content,
 |  | $ | publish
 | ) |  |

Definition at line 357 of file blogapi.module.

References $content, and blogapi_blogger_edit_post().

blogapi_metaweblog_get_category_list | ( | $ | blogid,
 |  | $ | username,
 |  | $ | password
 | ) |  |

Blogging API callback.

Returns a list of the taxonomy terms that can be associated with a blog node.

Definition at line 392 of file blogapi.module.

References _blogapi_validate_blogid(), and module_invoke().

Referenced by blogapi_mt_get_category_list().

blogapi_metaweblog_get_post | ( | $ | postid,
 |  | $ | username,
 |  | $ | password
 | ) |  |

Definition at line 361 of file blogapi.module.

References blogapi_blogger_get_post().

blogapi_metaweblog_get_recent_posts | ( | $ | blogid,
 |  | $ | username,
 |  | $ | password,
 |  | $ | number_of_posts
 | ) |  |

Definition at line 415 of file blogapi.module.

References blogapi_blogger_get_recent_posts().

blogapi_metaweblog_new_media_object | ( | $ | blogid,
 |  | $ | username,
 |  | $ | password,
 |  | $ | file
 | ) |  |

Blogging API callback.

Inserts a file into Drupal.

Definition at line 368 of file blogapi.module.

References $name, $user, blogapi_error(), blogapi_validate_user(), file_create_url(), file_save_data(), and t().

blogapi_metaweblog_new_post | ( | $ | blogid,
 |  | $ | username,
 |  | $ | password,
 |  | $ | content,
 |  | $ | publish
 | ) |  |

Definition at line 353 of file blogapi.module.

References $content, and blogapi_blogger_new_post().

blogapi_mt_get_category_list | ( | $ | blogid,
 |  | $ | username,
 |  | $ | password
 | ) |  |

Definition at line 423 of file blogapi.module.

References blogapi_metaweblog_get_category_list().

blogapi_mt_get_post_categories | ( | $ | postid,
 |  | $ | username,
 |  | $ | password
 | ) |  |

Blogging API callback.

Returns a list of the taxonomy terms that are assigned to a particular node.

Definition at line 431 of file blogapi.module.

References $user, blogapi_error(), blogapi_validate_user(), module_invoke(), and node_load().

blogapi_mt_get_recent_post_titles | ( | $ | blogid,
 |  | $ | username,
 |  | $ | password,
 |  | $ | number_of_posts
 | ) |  |

Definition at line 419 of file blogapi.module.

References blogapi_blogger_get_recent_posts().

blogapi_mt_set_post_categories | ( | $ | postid,
 |  | $ | username,
 |  | $ | password,
 |  | $ | categories
 | ) |  |

Blogging API callback.

Assigns taxonomy terms to a particular node.

Definition at line 454 of file blogapi.module.

References $user, blogapi_error(), blogapi_validate_user(), node_load(), and node_save().

blogapi_mt_supported_text_filters ( )

Blogging API callback.

Sends a list of available input formats.

Definition at line 472 of file blogapi.module.

References filter_formats().

blogapi_perm ( )

Implementation of hook_perm().

Definition at line 26 of file blogapi.module.

blogapi_rsd ( )

Definition at line 602 of file blogapi.module.

References $base_url, drupal_set_header(), name, and url().

blogapi_validate_user | ( | $ | username,
 |  | $ | password
 | ) |  |

Ensure that the given user has permission to edit a blog.

Definition at line 527 of file blogapi.module.

References $user, t(), user_access(), and user_authenticate().

Referenced by blogap_mti_publish_post(), blogapi_blogger_delete_post(), blogapi_blogger_edit_post(), blogapi_blogger_get_post(), blogapi_blogger_get_recent_posts(), blogapi_blogger_get_user_info(), blogapi_blogger_get_users_blogs(), blogapi_blogger_new_post(), blogapi_metaweblog_new_media_object(), blogapi_mt_get_post_categories(), and blogapi_mt_set_post_categories().

blogapi_xmlrpc ( )

Implementation of hook_xmlrpc().

Definition at line 33 of file blogapi.module.

References t().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/book/book-all-books-block.tpl.php File Reference

modules » book

book-all-books-block.tpl.php File Reference

Detailed Description

Default theme implementation for rendering book outlines within a block.

This template is used only when the block is configured to "show block on all pages" which presents Multiple independent books on all pages.

Available variables:

  • $book_menus: Array of book outlines rendered as an unordered list. It is keyed to the parent book ID which is also the ID of the parent node containing an entire outline.

See also:
template_preprocess_book_all_books_block()

Definition in file book-all-books-block.tpl.php.

Go to the source code of this file.

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/book/book-export-html.tpl.php File Reference

modules » book

book-export-html.tpl.php File Reference

Detailed Description

Default theme implementation for printed version of book outline.

Available variables:

  • $title: Top level node title.
  • $head: Header tags.
  • $language: Language code. e.g. "en" for english.
  • $language_rtl: TRUE or FALSE depending on right to left language scripts.
  • $base_url: URL to home page.
  • $content: Nodes within the current outline rendered through book-node-export-html.tpl.php.

See also:
template_preprocess_book_export_html()

Definition in file book-export-html.tpl.php.

Go to the source code of this file.

Variables

  • print $base_url
  • print $head
  • print $title
  • print $language language

Variable Documentation

print $base_url

Definition at line 25 of file book-export-html.tpl.php.

print $head

Definition at line 24 of file book-export-html.tpl.php.

print $title

Definition at line 23 of file book-export-html.tpl.php.

print language language

Definition at line 21 of file book-export-html.tpl.php.

Referenced by _locale_export_get_strings(), _locale_languages_common_controls(), _locale_rebuild_js(), _translation_tab_access(), contact_mail(), language_initialize(), language_url_rewrite(), locale_form_alter(), locale_languages_edit_form_submit(), locale_languages_edit_form_validate(), locale_languages_overview_form_submit(), locale_update_js_files(), locale_user(), node_admin_nodes(), node_feed(), path_admin_overview(), path_form_alter(), path_nodeapi(), theme_locale_languages_overview_form(), translation_form_alter(), translation_link(), translation_node_overview(), translation_nodeapi(), url(), user_mail_tokens(), and user_preferred_language().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/book/book-navigation.tpl.php File Reference

modules » book

book-navigation.tpl.php File Reference

Detailed Description

Default theme implementation to navigate books.

Presented under nodes that are a part of book outlines.

Available variables:

  • $tree: The immediate children of the current node rendered as an unordered list.
  • $current_depth: Depth of the current node within the book outline. Provided for context.
  • $prev_url: URL to the previous node.
  • $prev_title: Title of the previous node.
  • $parent_url: URL to the parent node.
  • $parent_title: Title of the parent node. Not printed by default. Provided as an option.
  • $next_url: URL to the next node.
  • $next_title: Title of the next node.
  • $has_links: Flags TRUE whenever the previous, parent or next data has a value.
  • $book_id: The book ID of the current outline being viewed. Same as the node ID containing the entire outline. Provided for context.
  • $book_url: The book/node URL of the current outline being viewed. Provided as an option. Not used by default.
  • $book_title: The book/node title of the current outline being viewed. Provided as an option. Not used by default.

See also:
template_preprocess_book_navigation()

Definition in file book-navigation.tpl.php.

Go to the source code of this file.

Variables

  • endif

Variable Documentation

endif

Definition at line 41 of file book-navigation.tpl.php.

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/book/book-node-export-html.tpl.php File Reference

modules » book

book-node-export-html.tpl.php File Reference

Detailed Description

Default theme implementation for rendering a single node in a printer friendly outline.

See also:
book-node-export-html.tpl.php Where it is collected and printed out.
Available variables:
  • $depth: Depth of the current node inside the outline.
  • $title: Node title.
  • $content: Node content.
  • $children: All the child nodes recursively rendered through this file.

See also:
template_preprocess_book_node_export_html()

Definition in file book-node-export-html.tpl.php.

Go to the source code of this file.

Variables

  • print $children
  • print $content
  • print $depth
  • print $title
  • print $node nid

Variable Documentation

print $children

Definition at line 24 of file book-node-export-html.tpl.php.

Referenced by _forum_parent_select(), _taxonomy_term_children(), book_children(), book_export_traverse(), book_node_export(), drupal_render(), menu_local_tasks(), taxonomy_del_term(), taxonomy_form_term(), taxonomy_get_children(), taxonomy_get_tree(), and theme_item_list().

print $content

Definition at line 23 of file book-node-export-html.tpl.php.

print $depth

Definition at line 21 of file book-node-export-html.tpl.php.

Referenced by _menu_tree_data(), file_scan_directory(), menu_local_tasks(), menu_tree_data(), taxonomy_get_tree(), taxonomy_select_nodes(), and taxonomy_term_page().

print $title

Definition at line 22 of file book-node-export-html.tpl.php.

print $node nid

Definition at line 21 of file book-node-export-html.tpl.php.

Referenced by _blogapi_get_post(), _book_add_form_elements(), _book_update_outline(), _node_index_node(), _node_mass_update_batch_process(), _node_revision_access(), _trigger_normalize_comment_context(), blog_page_last(), blog_page_user(), blogapi_blogger_edit_post(), blogapi_blogger_new_post(), book_admin_edit_submit(), book_form_alter(), book_link(), book_nodeapi(), book_outline_form(), book_remove_form(), book_remove_form_submit(), comment_admin_overview(), comment_admin_overview_submit(), comment_confirm_delete(), comment_confirm_delete_submit(), comment_form_submit(), comment_link(), comment_links(), comment_multiple_delete_confirm_submit(), comment_new_page_count(), comment_nodeapi(), comment_reply(), fileupload_delete(), fileupload_form(), fileupload_insert(), fileupload_load(), fileupload_update(), forum_form(), forum_get_topics(), forum_nodeapi(), forum_taxonomy(), hook_delete(), hook_insert(), hook_link(), hook_mail(), hook_nodeapi(), hook_update(), hook_update_index(), hook_view(), locale_form_alter(), menu_nodeapi(), multipage_form_example_delete(), multipage_form_example_load(), node_access(), node_access_example_nodeapi(), node_access_rebuild(), node_access_write_grants(), node_admin_nodes(), node_delete(), node_delete_confirm(), node_example_delete(), node_example_insert(), node_feed(), node_form(), node_form_delete_submit(), node_form_submit(), node_load(), node_object_prepare(), node_page_default(), node_revision_delete_confirm(), node_revision_delete_confirm_submit(), node_revision_list(), node_revision_revert_confirm(), node_save(), node_show(), node_title_list(), node_validate(), nodeapi_example_nodeapi(), path_nodeapi(), poll_block(), poll_cancel(), poll_cron(), poll_delete(), poll_insert(), poll_load(), poll_update(), poll_view(), poll_view_results(), poll_vote(), poll_votes(), statistics_link(), statistics_node_tracker(), statistics_nodeapi(), system_mail(), system_message_action(), system_send_email_action(), taxonomy_form_alter(), taxonomy_node_delete(), taxonomy_node_save(), taxonomy_render_nodes(), template_preprocess_forum_topic_navigation(), template_preprocess_node(), theme_comment_block(), theme_comment_view(), tracker_page(), translation_form_alter(), translation_node_overview(), translation_nodeapi(), translation_remove_from_set(), upload_delete(), and upload_save().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/book/book.admin.inc File Reference

modules » book

book.admin.inc File Reference

Detailed Description

Admin page callbacks for the book module.

Definition in file book.admin.inc.

Go to the source code of this file.

Functions

  • _book_admin_compare ($a, $b)
    Used by uasort() in _book_admin_sort_tree() to compare items in a book tree.
  • _book_admin_sort_tree (&$tree)
    Recursive helper to sort each layer of a book tree by weight.
  • _book_admin_table ($node)
    Build the table portion of the form for the book administration page.
  • _book_admin_table_tree ($tree, &$form)
    Recursive helper to build the main table in the book administration page form.
  • book_admin_edit ($form_state, $node)
    Build the form to administrate the hierarchy of a single book.
  • book_admin_edit_submit ($form, &$form_state)
    Handle submission of the book administrative page form.
  • book_admin_overview ()
    Returns an administrative overview of all books.
  • book_admin_settings ()
    Builds and returns the book settings form.
  • book_admin_settings_validate ($form, &$form_state)
    Validate the book settings form.
  • theme_book_admin_table ($form)
    Theme function for the book administration page form.

Function Documentation

_book_admin_compare | ( | $ | a,
 |  | $ | b
 | ) |  |

Used by uasort() in _book_admin_sort_tree() to compare items in a book tree.

Definition at line 244 of file book.admin.inc.

_book_admin_sort_tree ( &$ tree )

Recursive helper to sort each layer of a book tree by weight.

Definition at line 232 of file book.admin.inc.

_book_admin_table ( $ node )

Build the table portion of the form for the book administration page.

See also:
book_admin_edit()

Definition at line 131 of file book.admin.inc.

References _book_admin_table_tree(), and book_menu_subtree_data().

Referenced by book_admin_edit().

_book_admin_table_tree | ( | $ | tree,
 |  | &$ | form
 | ) |  |

Recursive helper to build the main table in the book administration page form.

See also:
book_admin_edit()

Definition at line 150 of file book.admin.inc.

Referenced by _book_admin_table().

book_admin_edit_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Handle submission of the book administrative page form.

This function takes care to save parent menu items before their children. Saving menu items in the incorrect order can break the menu tree.

See also:
book_admin_edit()

menu_overview_form_submit()

Definition at line 92 of file book.admin.inc.

References $row, drupal_set_message(), element_children(), l(), menu_link_save(), nid, node_load(), node_save(), t(), and watchdog().

book_admin_overview ( )

Returns an administrative overview of all books.

Definition at line 12 of file book.admin.inc.

References book_get_books(), l(), t(), and theme().

book_admin_settings_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate the book settings form.

See also:
book_admin_settings()

Definition at line 57 of file book.admin.inc.

References form_set_error(), and t().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/book/book.install File Reference

modules » book

book.install File Reference

Go to the source code of this file.

Functions

  • _book_install_type_create ()
  • book_install ()
    Implementation of hook_install().
  • book_schema ()
    Implementation of hook_schema().
  • book_uninstall ()
    Implementation of hook_uninstall().
  • book_update_6000 ()
    Drupal 5.x to 6.x update.

Function Documentation

_book_install_type_create ( )

Definition at line 25 of file book.install.

References _node_type_set_defaults(), node_type_save(), t(), and variable_set().

Referenced by book_install(), and book_update_6000().

book_install ( )

Implementation of hook_install().

Definition at line 7 of file book.install.

References _book_install_type_create(), and drupal_install_schema().

book_schema ( )

Implementation of hook_schema().

Definition at line 252 of file book.install.

References t().

book_uninstall ( )

Implementation of hook_uninstall().

Definition at line 17 of file book.install.

References db_query(), drupal_uninstall_schema(), and menu_cache_clear_all().

book_update_6000 ( )

Drupal 5.x to 6.x update.

This function moves any existing book hierarchy into the new structure used in the 6.x module. Rather than storing the hierarchy in the {book} table, the menu API is used to store the hierarchy in the {menu_links} table and the {book} table serves to uniquely connect a node to a menu link.

In order to accomplish this, the current hierarchy is processed using a stack. The stack insures that each parent is processed before any of its children in the book hierarchy, and is compatible with batched update processing.

Definition at line 59 of file book.install.

References $result, _book_install_type_create(), db_create_table(), db_fetch_array(), db_fetch_object(), db_query(), db_query_range(), db_result(), menu_link_save(), and update_sql().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/book/book.module File Reference

modules » book

book.module File Reference

Detailed Description

Allows users to structure the pages of a site in a hierarchy or outline.

Definition in file book.module.

Go to the source code of this file.

Functions

  • _book_add_form_elements (&$form, $node)
    Build the common elements of the book form for the node and outline forms.
  • _book_flatten_menu ($tree, &$flat)
    Recursive helper function for book_get_flat_menu().
  • _book_link_defaults ($nid)
    Return an array with default values for a book link.
  • _book_outline_access ($node)
    Menu item access callback - determine if the outline tab is accessible.
  • _book_outline_remove_access ($node)
    Menu item access callback - determine if the user can remove nodes from the outline.
  • _book_parent_depth_limit ($book_link)
    Find the depth limit for items in the parent select.
  • _book_parent_select ($book_link)
    Build the parent selection form element for the node form or outline tab.
  • _book_toc_recurse ($tree, $indent, &$toc, $exclude, $depth_limit)
    A recursive helper function for book_toc().
  • _book_update_outline (&$node)
    Common helper function to handles additions and updates to the book outline.
  • book_block ($op= 'list', $delta=0, $edit=array())
    Implementation of hook_block().
  • book_build_active_trail ($book_link)
    Build an active trail to show in the breadcrumb.
  • book_children ($book_link)
    Format the menu links for the child pages of the current page.
  • book_export_traverse ($tree, $visit_func)
    Traverse the book tree to build printable or exportable output.
  • book_form_alter (&$form, $form_state, $form_id)
    Implementation of hook_form_alter().
  • book_form_node_delete_confirm_alter (&$form, $form_state)
    Form altering function for the confirm form for a single node deletion.
  • book_get_books ()
    Returns an array of all books.
  • book_get_flat_menu ($book_link)
    Get the book menu tree for a page, and return it as a linear array.
  • book_help ($path, $arg)
    Implementation of hook_help().
  • book_init ()
    Implementation of hook_init().
  • book_link ($type, $node=NULL, $teaser=FALSE)
    Implementation of hook_link().
  • book_link_load ($mlid)
    Like menu_link_load(), but adds additional data from the {book} table.
  • book_menu ()
    Implementation of hook_menu().
  • book_menu_name ($bid)
    Generate the corresponding menu name from a book ID.
  • book_menu_subtree_data ($item)
    Get the data representing a subtree of the book hierarchy.
  • book_next ($book_link)
    Fetches the menu link for the next page of the book.
  • book_node_export ($node, $children= '')
    Generates printer-friendly HTML for a node.
  • book_node_type ($op, $type)
    Implementation of hook_node_type().
  • book_nodeapi (&$node, $op, $teaser, $page)
    Implementation of hook_nodeapi().
  • book_perm ()
    Implementation of hook_perm().
  • book_prev ($book_link)
    Fetches the menu link for the previous page of the book.
  • book_theme ()
    Implementation of hook_theme().
  • book_toc ($bid, $exclude=array(), $depth_limit)
    Returns an array of book pages in table of contents order.
  • book_type_is_allowed ($type)
    Determine if a given node type is in the list of types allowed for books.
  • book_update_bid ($book_link)
    Update the bid for a page and its children when it is moved to a new book.
  • template_preprocess_book_export_html (&$variables)
    Process variables for book-export-html.tpl.php.
  • template_preprocess_book_navigation (&$variables)
    Process variables for book-navigation.tpl.php.
  • template_preprocess_book_node_export_html (&$variables)
    Process variables for book-node-export-html.tpl.php.
  • theme_book_title_link ($link)
    Generate the HTML output for a link to a book title when used as a block title.

Function Documentation

_book_add_form_elements | ( | &$ | form,
 |  | $ | node
 | ) |  |

Build the common elements of the book form for the node and outline forms.

Definition at line 362 of file book.module.

References $nid, _book_parent_select(), book_get_books(), drupal_add_js(), nid, t(), and user_access().

Referenced by book_form_alter(), and book_outline_form().

_book_flatten_menu | ( | $ | tree,
 |  | &$ | flat
 | ) |  |

Recursive helper function for book_get_flat_menu().

Definition at line 529 of file book.module.

Referenced by book_get_flat_menu().

_book_link_defaults ( $ nid )

Return an array with default values for a book link.

Definition at line 768 of file book.module.

References $nid.

Referenced by book_nodeapi(), and book_outline_form().

_book_outline_access ( $ node )

Menu item access callback - determine if the outline tab is accessible.

Definition at line 152 of file book.module.

References node_access(), and user_access().

Referenced by _book_outline_remove_access().

_book_outline_remove_access ( $ node )

Menu item access callback - determine if the user can remove nodes from the outline.

Definition at line 159 of file book.module.

References _book_outline_access().

_book_parent_depth_limit ( $ book_link )

Find the depth limit for items in the parent select.

Definition at line 746 of file book.module.

References menu_link_children_relative_depth().

Referenced by book_nodeapi(), and book_outline_form().

_book_parent_select ( $ book_link )

Build the parent selection form element for the node form or outline tab.

This function is also called when generating a new set of options during the AJAX callback, so an array is returned that can be used to replace an existing form element.

Definition at line 322 of file book.module.

References book_toc(), t(), and variable_get().

Referenced by _book_add_form_elements(), and book_form_update().

_book_toc_recurse | ( | $ | tree,
 |  | $ | indent,
 |  | &$ | toc,
 |  | $ | exclude,
 |  | $ | depth_limit
 | ) |  |

A recursive helper function for book_toc().

Definition at line 831 of file book.module.

References truncate_utf8().

Referenced by book_toc().

_book_update_outline ( &$ node )

Common helper function to handles additions and updates to the book outline.

Performs all additions and updates to the book outline through node addition, node editing, node deletion, or the outline tab.

Definition at line 439 of file book.module.

References $new, book_menu_name(), book_update_bid(), db_fetch_array(), db_query(), db_result(), menu_link_save(), and nid.

Referenced by book_nodeapi(), and book_outline_form_submit().

book_block | ( | $ | op = 'list',
 |  | $ | delta = 0,
 |  | $ | edit = array()
 | ) |  |

Implementation of hook_block().

Displays the book table of contents in a block when the current page is a single-node view of a book node.

Definition at line 176 of file book.module.

References $op, $title, book_get_books(), db_query(), db_result(), db_rewrite_sql(), menu_get_object(), menu_tree_all_data(), menu_tree_output(), t(), theme(), variable_get(), and variable_set().

book_build_active_trail ( $ book_link )

Build an active trail to show in the breadcrumb.

Definition at line 620 of file book.module.

References menu_tree_all_data(), and t().

Referenced by book_nodeapi().

book_children ( $ book_link )

Format the menu links for the child pages of the current page.

Definition at line 590 of file book.module.

References $children, book_get_flat_menu(), and menu_tree_output().

Referenced by template_preprocess_book_navigation().

book_export_traverse | ( | $ | tree,
 |  | $ | visit_func
 | ) |  |

Traverse the book tree to build printable or exportable output.

During the traversal, the $visit_func() callback is applied to each node, and is called recursively for each child of the node (in weight, title order).

Parameters:
$tree | A subtree of the book menu hierarchy, rooted at the current page.
$visit_func | A function callback to be called upon visiting a node in the tree.
Returns:
The output generated in visiting each node.

Definition at line 902 of file book.module.

References $children, $output, book_node_export(), and node_load().

Referenced by book_export_html().

book_form_alter | ( | &$ | form,
 |  | $ | form_state,
 |  | $ | form_id
 | ) |  |

Implementation of hook_form_alter().

Adds the book fieldset to the node form.

See also:
book_pick_book_submit()

book_submit()

Definition at line 284 of file book.module.

References _book_add_form_elements(), book_type_is_allowed(), nid, t(), and user_access().

book_form_node_delete_confirm_alter | ( | &$ | form,
 |  | $ | form_state
 | ) |  |

Form altering function for the confirm form for a single node deletion.

Definition at line 753 of file book.module.

References node_load(), and t().

book_get_books ( )

Returns an array of all books.

This list may be used for generating a list of all the books, or for building the options for a form select.

Definition at line 256 of file book.module.

References $result, db_fetch_array(), db_query(), and db_rewrite_sql().

Referenced by _book_add_form_elements(), book_admin_overview(), book_block(), and book_render().

book_get_flat_menu ( $ book_link )

Get the book menu tree for a page, and return it as a linear array.

Parameters:
$book_link A fully loaded menu link that is part of the book hierarchy.
Returns:
A linear array of menu links in the order that the links are shown in the menu, so the previous and next pages are the elements before and after the element corresponding to $node. The children of $node (if any) will come immediately after it in the array.

Definition at line 514 of file book.module.

References _book_flatten_menu(), and menu_tree_all_data().

Referenced by book_children(), book_next(), and book_prev().

book_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 999 of file book.module.

References $output, t(), and url().

book_init ( )

Implementation of hook_init().

Add's the book module's CSS.

Definition at line 166 of file book.module.

References drupal_add_css(), and drupal_get_path().

book_link | ( | $ | type,
 |  | $ | node = NULL,
 |  | $ | teaser = FALSE
 | ) |  |

Implementation of hook_link().

Definition at line 49 of file book.module.

References $links, $type, nid, node_access(), t(), user_access(), and variable_get().

book_link_load ( $ mlid )

Like menu_link_load(), but adds additional data from the {book} table.

Do not call when loading a node, since this function may call node_load().

Definition at line 1021 of file book.module.

References $item, _menu_link_translate(), db_fetch_array(), and db_query().

Referenced by book_nodeapi(), and template_preprocess_book_navigation().

book_menu ( )

Implementation of hook_menu().

Definition at line 77 of file book.module.

References $items.

book_menu_name ( $ bid )

Generate the corresponding menu name from a book ID.

Definition at line 613 of file book.module.

Referenced by _book_update_outline(), book_nodeapi(), book_outline_form_submit(), and book_toc().

book_menu_subtree_data ( $ item )

Get the data representing a subtree of the book hierarchy.

The root of the subtree will be the link passed as a parameter, so the returned tree will contain this item and all its descendents in the menu tree.

Parameters:
$item A fully loaded menu link.
Returns:
An subtree of menu links in an array, in the order they should be rendered.

Definition at line 1040 of file book.module.

References $item, cache_get(), cache_set(), db_query(), menu_tree_check_access(), menu_tree_collect_node_links(), and menu_tree_data().

Referenced by _book_admin_table(), book_export_html(), and book_prev().

book_next ( $ book_link )

Fetches the menu link for the next page of the book.

Definition at line 576 of file book.module.

References book_get_flat_menu().

Referenced by template_preprocess_book_navigation().

book_node_export | ( | $ | node,
 |  | $ | children = ''
 | ) |  |

Generates printer-friendly HTML for a node.

See also:
book_export_traverse()
Parameters:
$node | The node to generate output for.
$children | All the rendered child nodes within the current node.
Returns:
The HTML generated for the given node.

Definition at line 937 of file book.module.

References $children, content, drupal_render(), node_build_content(), and theme().

Referenced by book_export_traverse().

book_node_type | ( | $ | op,
 |  | $ | type
 | ) |  |

Implementation of hook_node_type().

Update book module's persistent variables if the machine-readable name of a node type is changed.

Definition at line 974 of file book.module.

References $op, $type, variable_get(), and variable_set().

book_nodeapi | ( | &$ | node,
 |  | $ | op,
 |  | $ | teaser,
 |  | $ | page
 | ) |  |

Implementation of hook_nodeapi().

Appends book navigation to all nodes in the book, and handles book outline insertions and updates via the node form.

Definition at line 653 of file book.module.

References $op, $result, _book_link_defaults(), _book_parent_depth_limit(), _book_update_outline(), book_build_active_trail(), book_link_load(), book_menu_name(), db_fetch_array(), db_query(), menu_link_delete(), menu_set_active_menu_name(), menu_set_active_trail(), nid, node_load(), theme(), and user_access().

book_perm ( )

Implementation of hook_perm().

Definition at line 42 of file book.module.

book_prev ( $ book_link )

Fetches the menu link for the previous page of the book.

Definition at line 543 of file book.module.

References book_get_flat_menu(), and book_menu_subtree_data().

Referenced by template_preprocess_book_navigation().

book_theme ( )

Implementation of hook_theme().

Definition at line 12 of file book.module.

book_toc | ( | $ | bid,
 |  | $ | exclude = array(),
 |  | $ | depth_limit
 | ) |  |

Returns an array of book pages in table of contents order.

Parameters:
$bid | The ID of the book whose pages are to be listed.
$exclude | Optional array of mlid values. Any link whose mlid is in this array will be excluded (along with its children).
$depth_limit | Any link deeper than this value will be excluded (along with its children).
Returns:
An array of mlid, title pairs for use as options for selecting a book page.

Definition at line 859 of file book.module.

References _book_toc_recurse(), book_menu_name(), and menu_tree_all_data().

Referenced by _book_parent_select().

book_type_is_allowed ( $ type )

Determine if a given node type is in the list of types allowed for books.

Definition at line 964 of file book.module.

References $type, and variable_get().

Referenced by book_form_alter().

book_update_bid ( $ book_link )

Update the bid for a page and its children when it is moved to a new book.

Parameters:
$book_link A fully loaded menu link that is part of the book hierarchy.

Definition at line 486 of file book.module.

References $result, db_fetch_array(), and db_query().

Referenced by _book_update_outline().

template_preprocess_book_export_html ( &$ variables )

Process variables for book-export-html.tpl.php.

The $variables array contains the following arguments:

  • $title
  • $contents
  • $depth

See also:
book-export-html.tpl.php

Definition at line 878 of file book.module.

References $base_url, $language, check_plain(), and drupal_get_html_head().

template_preprocess_book_navigation ( &$ variables )

Process variables for book-navigation.tpl.php.

The $variables array contains the following arguments:

  • $book_link

See also:
book-navigation.tpl.php

Definition at line 780 of file book.module.

References $links, book_children(), book_link_load(), book_next(), book_prev(), check_plain(), drupal_add_link(), and url().

template_preprocess_book_node_export_html ( &$ variables )

Process variables for book-node-export-html.tpl.php.

The $variables array contains the following arguments:

  • $node
  • $children

See also:
book-node-export-html.tpl.php

Definition at line 955 of file book.module.

References check_plain().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/book/book.pages.inc File Reference

modules » book

book.pages.inc File Reference

Detailed Description

User page callbacks for the book module.

Definition in file book.pages.inc.

Go to the source code of this file.

Functions

  • book_export ($type, $nid)
    Menu callback; Generates various representation of a book page and its children.
  • book_export_html ($nid)
    This function is called by book_export() to generate HTML for export.
  • book_form_update ()
    AJAX callback to replace the book parent select options.
  • book_outline ($node)
    Menu callback; show the outline form for a single node.
  • book_outline_form (&$form_state, $node)
    Build the form to handle all book outline operations via the outline tab.
  • book_outline_form_submit ($form, &$form_state)
    Handles book outline form submissions from the outline tab.
  • book_remove_button_submit ($form, &$form_state)
    Button submit function to redirect to removal confirm form.
  • book_remove_form (&$form_state, $node)
    Menu callback; builds a form to confirm removal of a node from the book.
  • book_remove_form_submit ($form, &$form_state)
    Confirm form submit function to remove a node from the book.
  • book_render ()
    Menu callback; prints a listing of all books.

Function Documentation

book_export | ( | $ | type,
 |  | $ | nid
 | ) |  |

Menu callback; Generates various representation of a book page and its children.

The function delegates the generation of output to helper functions. The function name is derived by prepending 'book_export_' to the given output type. So, e.g., a type of 'html' results in a call to the function book_export_html().

Parameters:
$type A string encoding the type of output requested. The following types are currently supported in book module:
  • html: HTML (printer friendly output)

Other types may be supported in contributed modules.

Parameters:
$nid An integer representing the node id (nid) of the node to export
Returns:
A string representing the node and its children in the book hierarchy in a format determined by the $type parameter.

Definition at line 42 of file book.pages.inc.

References $nid, $type, drupal_not_found(), drupal_set_message(), drupal_strtolower(), and t().

book_export_html ( $ nid )

This function is called by book_export() to generate HTML for export.

The given node is /embedded to its absolute depth in a top level section/. For example, a child node with depth 2 in the hierarchy is contained in (otherwise empty) <div> elements corresponding to depth 0 and depth 1. This is intended to support WYSIWYG output - e.g., level 3 sections always look like level 3 sections, no matter their depth relative to the node selected to be exported as printer-friendly HTML.

Parameters:
$nid An integer representing the node id (nid) of the node to export.
Returns:
A string containing HTML representing the node and its children in the book hierarchy.

Definition at line 74 of file book.pages.inc.

References $nid, book_export_traverse(), book_menu_subtree_data(), drupal_access_denied(), node_load(), theme(), and user_access().

book_form_update ( )

AJAX callback to replace the book parent select options.

This function is called when the selected book is changed. It updates the cached form (either the node form or the book outline form) and returns rendered output to be used to replace the select containing the possible parent pages in the newly selected book.

Parameters:
$build_id | The form's build_id.
$bid | A bid from from among those in the form's book select.
Returns:
Prints the replacement HTML in JSON format.

Definition at line 233 of file book.pages.inc.

References $output, _book_parent_select(), cache_get(), cache_set(), drupal_json(), drupal_render(), exit, and form_builder().

book_outline ( $ node )

Menu callback; show the outline form for a single node.

Definition at line 92 of file book.pages.inc.

References check_plain(), drupal_get_form(), and drupal_set_title().

book_outline_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Handles book outline form submissions from the outline tab.

See also:
book_outline_form()

Definition at line 155 of file book.pages.inc.

References _book_update_outline(), book_menu_name(), drupal_set_message(), and t().

book_remove_button_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Button submit function to redirect to removal confirm form.

See also:
book_outline_form()

Definition at line 146 of file book.pages.inc.

book_remove_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Confirm form submit function to remove a node from the book.

See also:
book_remove_form()

Definition at line 207 of file book.pages.inc.

References db_query(), drupal_set_message(), menu_link_delete(), nid, and t().

book_render ( )

Menu callback; prints a listing of all books.

Definition at line 12 of file book.pages.inc.

References book_get_books(), l(), and theme().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/color/color.install File Reference

modules » color

color.install File Reference

Go to the source code of this file.

Functions

  • color_requirements ($phase)

Function Documentation

color_requirements ( $ phase )

Definition at line 4 of file color.install.

References t().

Generated on Tue Feb 12 15:30:44 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/color/color.module File Reference

modules » color

color.module File Reference

Go to the source code of this file.

Functions

  • _color_blend ($img, $hex1, $hex2, $alpha)
    Blend two hex colors and return the GD color.
  • _color_gd ($img, $hex)
    Convert a hex triplet into a GD color.
  • _color_hsl2rgb ($hsl)
    Convert a HSL triplet into RGB.
  • _color_hue2rgb ($m1, $m2, $h)
    Helper function for _color_hsl2rgb().
  • _color_pack ($rgb, $normalize=false)
    Convert an RGB triplet to a hex color.
  • _color_page_alter (&$vars)
    Callback for the theme to alter the resources used.
  • _color_render_images ($theme, &$info, &$paths, $palette)
    Render images that match a given palette.
  • _color_rewrite_stylesheet ($theme, &$info, &$paths, $palette, $style)
    Rewrite the stylesheet to match the colors in the palette.
  • _color_rgb2hsl ($rgb)
    Convert an RGB triplet to HSL.
  • _color_save_stylesheet ($file, $style, &$paths)
    Save the rewritten stylesheet to disk.
  • _color_shift ($given, $ref1, $ref2, $target)
    Shift a given color, using a reference pair and a target blend color.
  • _color_unpack ($hex, $normalize=false)
    Convert a hex color into an RGB triplet.
  • color_form_alter (&$form, $form_state, $form_id)
    Implementation of hook_form_alter().
  • color_get_info ($theme)
    Retrieve the color.module info for a particular theme.
  • color_get_palette ($theme, $default=false)
    Helper function to retrieve the color palette for a particular theme.
  • color_help ($path, $arg)
    Implementation of hook_help().
  • color_scheme_form (&$form_state, $theme)
    Form callback.
  • color_scheme_form_submit ($form, &$form_state)
    Submit handler for color change form.
  • color_theme ()
    Implementation of hook_theme().
  • theme_color_scheme_form ($form)
    Theme color form.

Function Documentation

_color_blend | ( | $ | img,
 |  | $ | hex1,
 |  | $ | hex2,
 |  | $ | alpha
 | ) |  |

Blend two hex colors and return the GD color.

Definition at line 588 of file color.module.

References _color_unpack().

Referenced by _color_render_images().

_color_gd | ( | $ | img,
 |  | $ | hex
 | ) |  |

Convert a hex triplet into a GD color.

Definition at line 580 of file color.module.

References _color_unpack().

Referenced by _color_render_images().

_color_hsl2rgb ( $ hsl )

Convert a HSL triplet into RGB.

Definition at line 626 of file color.module.

References _color_hue2rgb().

Referenced by _color_shift().

_color_hue2rgb | ( | $ | m1,
 |  | $ | m2,
 |  | $ | h
 | ) |  |

Helper function for _color_hsl2rgb().

Definition at line 642 of file color.module.

Referenced by _color_hsl2rgb().

_color_pack | ( | $ | rgb,
 |  | $ | normalize = false
 | ) |  |

Convert an RGB triplet to a hex color.

Definition at line 615 of file color.module.

Referenced by _color_shift().

_color_page_alter ( &$ vars )

Callback for the theme to alter the resources used.

Definition at line 69 of file color.module.

References $language, $logo, $theme_key, base_path(), drupal_get_css(), and variable_get().

Referenced by phptemplate_preprocess_page().

_color_render_images | ( | $ | theme,
 |  | &$ | info,
 |  | &$ | paths,
 |  | $ | palette
 | ) |  |

Render images that match a given palette.

Definition at line 455 of file color.module.

References $image, $theme, _color_blend(), _color_gd(), and variable_set().

Referenced by color_scheme_form_submit().

_color_rewrite_stylesheet | ( | $ | theme,
 |  | &$ | info,
 |  | &$ | paths,
 |  | $ | palette,
 |  | $ | style
 | ) |  |

Rewrite the stylesheet to match the colors in the palette.

Definition at line 369 of file color.module.

References $output, $theme, _color_shift(), base_path(), color_get_palette(), drupal_strtolower(), and list_themes().

Referenced by color_scheme_form_submit().

_color_rgb2hsl ( $ rgb )

Convert an RGB triplet to HSL.

Definition at line 653 of file color.module.

Referenced by _color_shift().

_color_save_stylesheet | ( | $ | file,
 |  | $ | style,
 |  | &$ | paths
 | ) |  |

Save the rewritten stylesheet to disk.

Definition at line 442 of file color.module.

References file_save_data().

Referenced by color_scheme_form_submit().

_color_shift | ( | $ | given,
 |  | $ | ref1,
 |  | $ | ref2,
 |  | $ | target
 | ) |  |

Shift a given color, using a reference pair and a target blend color.

Note: this function is significantly different from the JS version, as it is written to match the blended images perfectly.

Constraint: if (ref2 == target + (ref1 - target) * delta) for some fraction delta then (return == target + (given - target) * delta)

Loose constraint: Preserve relative positions in saturation and luminance space.

Definition at line 529 of file color.module.

References $result, _color_hsl2rgb(), _color_pack(), _color_rgb2hsl(), and _color_unpack().

Referenced by _color_rewrite_stylesheet().

_color_unpack | ( | $ | hex,
 |  | $ | normalize = false
 | ) |  |

Convert a hex color into an RGB triplet.

Definition at line 601 of file color.module.

Referenced by _color_blend(), _color_gd(), and _color_shift().

color_form_alter | ( | &$ | form,
 |  | $ | form_state,
 |  | $ | form_id
 | ) |  |

Implementation of hook_form_alter().

Definition at line 32 of file color.module.

References $theme, arg(), color_get_info(), color_scheme_form(), drupal_set_message(), element_children(), list_themes(), t(), theme(), url(), and variable_get().

color_get_info ( $ theme )

Retrieve the color.module info for a particular theme.

Definition at line 122 of file color.module.

References $theme, and drupal_get_path().

Referenced by color_form_alter(), color_get_palette(), and color_scheme_form().

color_get_palette | ( | $ | theme,
 |  | $ | default = false
 | ) |  |

Helper function to retrieve the color palette for a particular theme.

Definition at line 134 of file color.module.

References $theme, color_get_info(), and variable_get().

Referenced by _color_rewrite_stylesheet(), color_scheme_form(), and color_scheme_form_submit().

color_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 7 of file color.module.

References $output, t(), and url().

color_scheme_form | ( | &$ | form_state,
 |  | $ | theme
 | ) |  |

Form callback.

Returns the configuration form.

Definition at line 150 of file color.module.

References $name, $theme, $value, arg(), color_get_info(), color_get_palette(), drupal_add_css(), drupal_add_js(), drupal_get_path(), t(), and variable_get().

Referenced by color_form_alter().

color_scheme_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit handler for color change form.

Definition at line 242 of file color.module.

References $id, $theme, _color_render_images(), _color_rewrite_stylesheet(), _color_save_stylesheet(), _drupal_build_css_path(), base_path(), color_get_palette(), drupal_get_path(), drupal_load_stylesheet(), drupal_set_message(), file_check_directory(), file_copy(), file_directory_path(), format_size(), parse_size(), t(), variable_del(), variable_get(), and variable_set().

color_theme ( )

Implementation of hook_theme().

Definition at line 21 of file color.module.

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/comment/comment-folded.tpl.php File Reference

modules » comment

comment-folded.tpl.php File Reference

Detailed Description

Default theme implementation for folded comments.

Available variables:

  • $title: Linked title to full comment.
  • $new: New comment marker.
  • $author: Comment author. Can be link or plain text.
  • $date: Date and time of posting.
  • $comment: Full comment object.

See also:
template_preprocess_comment_folded()

theme_comment_folded()

Definition in file comment-folded.tpl.php.

Go to the source code of this file.

Variables

  • print $title $new

Variable Documentation

print $title $new

Definition at line 20 of file comment-folded.tpl.php.

Referenced by _book_update_outline(), comment_link(), filter_admin_format_form_submit(), system_node_type(), system_update_6017(), and tracker_page().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/comment/comment-wrapper.tpl.php File Reference

modules » comment

comment-wrapper.tpl.php File Reference

Detailed Description

Default theme implementation to wrap aggregator content.

Default theme implementation to wrap comments.

Available variables:

  • $content: All aggregator content.
  • $page: Pager links rendered through theme_pager().

See also:
template_preprocess()

template_preprocess_comment_wrapper()

Available variables:
  • $content: All comments for a given page. Also contains sorting controls and comment forms if the site is configured for it.

The following variables are provided for contextual information.

  • $node: Node object the comments are attached to. The constants below the variables show the possible values and should be used for comparison.
  • $display_mode
    • COMMENT_MODE_FLAT_COLLAPSED
    • COMMENT_MODE_FLAT_EXPANDED
    • COMMENT_MODE_THREADED_COLLAPSED
    • COMMENT_MODE_THREADED_EXPANDED
  • $display_order
    • COMMENT_ORDER_NEWEST_FIRST
    • COMMENT_ORDER_OLDEST_FIRST
  • $comment_controls_state
    • COMMENT_CONTROLS_ABOVE
    • COMMENT_CONTROLS_BELOW
    • COMMENT_CONTROLS_ABOVE_BELOW
    • COMMENT_CONTROLS_HIDDEN

See also:
template_preprocess_comment_wrapper()

theme_comment_wrapper()

Definition in file comment-wrapper.tpl.php.

Go to the source code of this file.

Variables

  • print $content

Variable Documentation

print $content

Definition at line 35 of file comment-wrapper.tpl.php.

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/comment/comment.admin.inc File Reference

modules » comment

comment.admin.inc File Reference

Detailed Description

Admin page callbacks for the comment module.

Definition in file comment.admin.inc.

Go to the source code of this file.

Functions

  • _comment_delete_thread ($comment)
    Perform the actual deletion of a comment and all its replies.
  • comment_admin ($type= 'new')
    Menu callback; present an administrative comment listing.
  • comment_admin_overview ($type= 'new', $arg)
    Form builder; Builds the comment overview form for the admin.
  • comment_admin_overview_submit ($form, &$form_state)
    Process comment_admin_overview form submissions.
  • comment_admin_overview_validate ($form, &$form_state)
    Validate comment_admin_overview form submissions.
  • comment_confirm_delete (&$form_state, $comment)
    Form builder; Builds the confirmation form for deleting a single comment.
  • comment_confirm_delete_submit ($form, &$form_state)
    Process comment_confirm_delete form submissions.
  • comment_delete ($cid=NULL)
    Menu callback; delete a comment.
  • comment_multiple_delete_confirm (&$form_state)
    List the selected comments and verify that the admin really wants to delete them.
  • comment_multiple_delete_confirm_submit ($form, &$form_state)
    Process comment_multiple_delete_confirm form submissions.
  • theme_comment_admin_overview ($form)
    Theme the comment admin form.

Function Documentation

_comment_delete_thread ( $ comment )

Perform the actual deletion of a comment and all its replies.

Parameters:
$comment An associative array describing the comment to be deleted.

Definition at line 278 of file comment.admin.inc.

References $result, comment_invoke_comment(), db_fetch_object(), db_query(), subject, and watchdog().

Referenced by comment_confirm_delete_submit(), and comment_multiple_delete_confirm_submit().

comment_admin ( $ type = 'new' )

Menu callback; present an administrative comment listing.

Definition at line 12 of file comment.admin.inc.

References $type, arg(), and drupal_get_form().

comment_admin_overview_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process comment_admin_overview form submissions.

Execute the chosen 'Update option' on the selected comments, such as publishing, unpublishing or deleting.

Definition at line 97 of file comment.admin.inc.

References $value, _comment_load(), _comment_update_node_statistics(), cache_clear_all(), comment_invoke_comment(), comment_operations(), db_query(), drupal_set_message(), l(), nid, subject, t(), and watchdog().

comment_admin_overview_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate comment_admin_overview form submissions.

We can't execute any 'Update options' if no comments were selected.

Definition at line 83 of file comment.admin.inc.

References drupal_goto(), form_set_error(), and t().

comment_confirm_delete_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process comment_confirm_delete form submissions.

Definition at line 256 of file comment.admin.inc.

References _comment_delete_thread(), _comment_update_node_statistics(), cache_clear_all(), drupal_set_message(), nid, and t().

comment_delete ( $ cid = NULL )

Menu callback; delete a comment.

Parameters:
$cid The comment do be deleted.

Definition at line 218 of file comment.admin.inc.

References $output, db_fetch_object(), db_query(), drupal_get_form(), drupal_set_message(), and t().

comment_multiple_delete_confirm_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process comment_multiple_delete_confirm form submissions.

Perform the actual comment deletion.

Definition at line 199 of file comment.admin.inc.

References $value, _comment_delete_thread(), _comment_load(), _comment_update_node_statistics(), cache_clear_all(), drupal_set_message(), nid, and t().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/comment/comment.install File Reference

modules » comment

comment.install File Reference

Go to the source code of this file.

Functions

  • comment_enable ()
    Implementation of hook_enable().
  • comment_schema ()
    Implementation of hook_schema().
  • comment_update_1 ()
    Changed node_comment_statistics to use node->changed to avoid future timestamps.
  • comment_update_6001 ()
  • comment_update_6002 ()
    Changed comment settings from global to per-node -- copy global settings to all node types.
  • comment_update_6003 ()
    Add index to parent ID field.

Function Documentation

comment_enable ( )

Implementation of hook_enable().

Definition at line 7 of file comment.install.

References db_query().

comment_schema ( )

Implementation of hook_schema().

Definition at line 74 of file comment.install.

References t().

comment_update_1 ( )

Changed node_comment_statistics to use node->changed to avoid future timestamps.

Definition at line 15 of file comment.install.

References db_query(), variable_get(), and variable_set().

comment_update_6001 ( )

Definition at line 26 of file comment.install.

References update_sql().

comment_update_6002 ( )

Changed comment settings from global to per-node -- copy global settings to all node types.

Definition at line 36 of file comment.install.

References $type, $value, drupal_load(), node_get_types(), variable_del(), variable_get(), and variable_set().

comment_update_6003 ( )

Add index to parent ID field.

Definition at line 64 of file comment.install.

References db_add_index().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/comment/comment.module File Reference

modules » comment

comment.module File Reference

Detailed Description

Enables users to comment on published content.

When enabled, the Drupal comment module creates a discussion board for each Drupal node. Users can post comments to discuss a forum topic, weblog post, story, collaborative book page, etc.

Definition in file comment.module.

Go to the source code of this file.

Enumerations

  • enum COMMENT_ANONYMOUS_MAY_CONTACT
    Anonymous posters may leave their contact information. More...
  • enum COMMENT_ANONYMOUS_MAYNOT_CONTACT
    Anonymous posters may not enter their contact information. More...
  • enum COMMENT_ANONYMOUS_MUST_CONTACT
    Anonymous posters must leave their contact information. More...
  • enum COMMENT_CONTROLS_ABOVE
    Comment controls should be shown above the comment list. More...
  • enum COMMENT_CONTROLS_ABOVE_BELOW
    Comment controls should be shown both above and below the comment list. More...
  • enum COMMENT_CONTROLS_BELOW
    Comment controls should be shown below the comment list. More...
  • enum COMMENT_CONTROLS_HIDDEN
    Comment controls are hidden. More...
  • enum COMMENT_FORM_BELOW
    Comment form should be shown below post or list of comments. More...
  • enum COMMENT_FORM_SEPARATE_PAGE
    Comment form should be displayed on a separate page. More...
  • enum COMMENT_MODE_FLAT_COLLAPSED
    Comments are displayed in a flat list - collapsed. More...
  • enum COMMENT_MODE_FLAT_EXPANDED
    Comments are displayed in a flat list - expanded. More...
  • enum COMMENT_MODE_THREADED_COLLAPSED
    Comments are displayed as a threaded list - collapsed. More...
  • enum COMMENT_MODE_THREADED_EXPANDED
    Comments are displayed as a threaded list - expanded. More...
  • enum COMMENT_NODE_DISABLED
    Comments for this node are disabled. More...
  • enum COMMENT_NODE_READ_ONLY
    Comments for this node are locked. More...
  • enum COMMENT_NODE_READ_WRITE
    Comments are enabled on this node. More...
  • enum COMMENT_NOT_PUBLISHED
    Comment is awaiting approval. More...
  • enum COMMENT_ORDER_NEWEST_FIRST
    Comments are ordered by date - newest first. More...
  • enum COMMENT_ORDER_OLDEST_FIRST
    Comments are ordered by date - oldest first. More...
  • enum COMMENT_PREVIEW_OPTIONAL
    Comment preview is optional. More...
  • enum COMMENT_PREVIEW_REQUIRED
    Comment preview is required. More...
  • enum COMMENT_PUBLISHED
    Comment is published. More...

Functions

  • _comment_form_submit (&$comment_values)
    Prepare a comment for submission.
  • _comment_get_display_setting ($setting, $node)
    Return a current comment display setting.
  • _comment_get_modes ()
    Return an array of viewing modes for comment listings.
  • _comment_get_orders ()
    Return an array of viewing orders for comment listings.
  • _comment_load ($cid)
    Misc functions: helpers, privates, history.
  • _comment_per_page ()
    Return an array of "comments per page" settings from which the user can choose.
  • _comment_update_node_statistics ($nid)
    Updates the comment statistics for a given node.
  • comment_access ($op, $comment)
    This is *not* a hook_access() implementation.
  • comment_action_info ()
    Implementation of hook_action_info().
  • comment_block ($op= 'list', $delta=0)
    Implementation of hook_block().
  • comment_controls ($mode=COMMENT_MODE_THREADED_EXPANDED, $order=COMMENT_ORDER_NEWEST_FIRST, $comments_per_page=50)
    Build a comment control form.
  • comment_controls_submit ($form, &$form_state)
    Process comment_controls form submissions.
  • comment_form (&$form_state, $edit, $title=NULL)
    Generate the basic commenting form, for appending to a node or display on a separate page.
  • comment_form_add_preview ($form, &$form_state)
    Form builder; Generate and validate a comment preview form.
  • comment_form_alter (&$form, $form_state, $form_id)
    Implementation of hook_form_alter().
  • comment_form_box ($edit, $title=NULL)
    Theme the comment form box.
  • comment_form_submit ($form, &$form_state)
    Process comment form submissions; prepare the comment, store it, and set a redirection target.
  • comment_form_validate ($form, &$form_state)
    Validate comment form submissions.
  • comment_get_recent ($number=10)
    Find a number of recent comments.
  • comment_help ($path, $arg)
    Implementation of hook_help().
  • comment_hook_info ()
    Implementation of hook_hook_info().
  • comment_invoke_comment (&$comment, $op)
    Invoke a hook_comment() operation in all modules.
  • comment_link ($type, $node=NULL, $teaser=FALSE)
    Implementation of hook_link().
  • comment_links ($comment, $return=1)
    Build command links for a comment (e.g. edit, reply, delete) with respect to the current user's access permissions.
  • comment_menu ()
    Implementation of hook_menu().
  • comment_new_page_count ($num_comments, $new_replies, $node)
    Calculate page number for first new comment.
  • comment_node_type ($op, $info)
    Implementation of hook_node_type().
  • comment_node_url ()
    A simple helper function.
  • comment_nodeapi (&$node, $op, $arg=0)
    Implementation of hook_nodeapi().
  • comment_num_all ($nid)
    Get comment count for a node.
  • comment_num_new ($nid, $timestamp=0)
    Get number of new comments for current user and specified node.
  • comment_num_replies ($pid)
    Get replies count for a comment.
  • comment_operations ($action=NULL)
    Comment operations.
  • comment_perm ()
    Implementation of hook_perm().
  • comment_render ($node, $cid=0)
    Renders comment(s).
  • comment_save ($edit)
    Accepts a submission of new or changed comment content.
  • comment_theme ()
    Implementation of hook_theme().
  • comment_unpublish_action ($comment, $context=array())
    Drupal action to unpublish a comment.
  • comment_unpublish_by_keyword_action ($comment, $context)
    Implementation of a configurable Drupal action.
  • comment_unpublish_by_keyword_action_form ($context)
    Form builder; Prepare a form for blacklisted keywords.
  • comment_unpublish_by_keyword_action_submit ($form, $form_state)
    Process comment_unpublish_by_keyword_action_form form submissions.
  • comment_user ($type, $edit, &$user, $category=NULL)
    Implementation of hook_user().
  • comment_validate ($edit)
    Validate comment data.
  • int2vancode ($i=0)
    Generate vancode.
  • template_preprocess_comment (&$variables)
    Process variables for comment.tpl.php.
  • template_preprocess_comment_folded (&$variables)
    Process variables for comment-folded.tpl.php.
  • template_preprocess_comment_wrapper (&$variables)
    Process variables for comment-wrapper.tpl.php.
  • theme_comment_block ()
    Returns a formatted list of recent comments to be displayed in the comment block.
  • theme_comment_controls ($form)
    Theme comment controls box where the user can change the default display mode and display order of comments.
  • theme_comment_flat_collapsed ($comment, $node)
    Theme comment flat collapsed view.
  • theme_comment_flat_expanded ($comment, $node)
    Theme comment flat expanded view.
  • theme_comment_post_forbidden ($node)
    Theme a "you can't post comments" notice.
  • theme_comment_submitted ($comment)
    Theme a "Submitted by ..." notice.
  • theme_comment_thread_collapsed ($comment, $node)
    Theme comment thread collapsed view.
  • theme_comment_thread_expanded ($comment, $node)
    Theme comment thread expanded view.
  • theme_comment_view ($comment, $node, $links=array(), $visible=TRUE)
    Theme a single comment block.
  • vancode2int ($c= '00')
    Decode vancode back to an integer.

Enumeration Type Documentation

enum COMMENT_ANONYMOUS_MAY_CONTACT

Anonymous posters may leave their contact information.

Definition at line 81 of file comment.module.

enum COMMENT_ANONYMOUS_MAYNOT_CONTACT

Anonymous posters may not enter their contact information.

Definition at line 76 of file comment.module.

enum COMMENT_ANONYMOUS_MUST_CONTACT

Anonymous posters must leave their contact information.

Definition at line 86 of file comment.module.

enum COMMENT_CONTROLS_ABOVE

Comment controls should be shown above the comment list.

Definition at line 56 of file comment.module.

enum COMMENT_CONTROLS_ABOVE_BELOW

Comment controls should be shown both above and below the comment list.

Definition at line 66 of file comment.module.

enum COMMENT_CONTROLS_BELOW

Comment controls should be shown below the comment list.

Definition at line 61 of file comment.module.

enum COMMENT_CONTROLS_HIDDEN

Comment controls are hidden.

Definition at line 71 of file comment.module.

enum COMMENT_FORM_BELOW

Comment form should be shown below post or list of comments.

Definition at line 96 of file comment.module.

enum COMMENT_FORM_SEPARATE_PAGE

Comment form should be displayed on a separate page.

Definition at line 91 of file comment.module.

enum COMMENT_MODE_FLAT_COLLAPSED

Comments are displayed in a flat list - collapsed.

Definition at line 26 of file comment.module.

enum COMMENT_MODE_FLAT_EXPANDED

Comments are displayed in a flat list - expanded.

Definition at line 31 of file comment.module.

enum COMMENT_MODE_THREADED_COLLAPSED

Comments are displayed as a threaded list - collapsed.

Definition at line 36 of file comment.module.

enum COMMENT_MODE_THREADED_EXPANDED

Comments are displayed as a threaded list - expanded.

Definition at line 41 of file comment.module.

enum COMMENT_NODE_DISABLED

Comments for this node are disabled.

Definition at line 101 of file comment.module.

enum COMMENT_NODE_READ_ONLY

Comments for this node are locked.

Definition at line 106 of file comment.module.

enum COMMENT_NODE_READ_WRITE

Comments are enabled on this node.

Definition at line 111 of file comment.module.

enum COMMENT_NOT_PUBLISHED

Comment is awaiting approval.

Definition at line 21 of file comment.module.

enum COMMENT_ORDER_NEWEST_FIRST

Comments are ordered by date - newest first.

Definition at line 46 of file comment.module.

enum COMMENT_ORDER_OLDEST_FIRST

Comments are ordered by date - oldest first.

Definition at line 51 of file comment.module.

enum COMMENT_PREVIEW_OPTIONAL

Comment preview is optional.

Definition at line 116 of file comment.module.

enum COMMENT_PREVIEW_REQUIRED

Comment preview is required.

Definition at line 121 of file comment.module.

enum COMMENT_PUBLISHED

Comment is published.

Definition at line 16 of file comment.module.

Function Documentation

_comment_form_submit ( &$ comment_values )

Prepare a comment for submission.

Parameters:
$comment_values An associative array containing the comment data.

Definition at line 1504 of file comment.module.

References check_markup(), decode_entities(), t(), truncate_utf8(), and user_load().

Referenced by comment_form_add_preview(), and comment_form_submit().

_comment_get_display_setting | ( | $ | setting,
 |  | $ | node
 | ) |  |

Return a current comment display setting.

Parameters:
$setting | can be one of these: 'mode', 'sort', 'comments_per_page'
$node | The comment node in question.

Definition at line 1877 of file comment.module.

References $user, $value, and variable_get().

Referenced by comment_new_page_count(), comment_render(), and template_preprocess_comment_wrapper().

_comment_get_modes ( )

Return an array of viewing modes for comment listings.

We can't use a global variable array because the locale system is not initialized yet when the comment module is loaded.

Definition at line 1839 of file comment.module.

References t().

Referenced by comment_controls(), and comment_form_alter().

_comment_get_orders ( )

Return an array of viewing orders for comment listings.

We can't use a global variable array because the locale system is not initialized yet when the comment module is loaded.

Definition at line 1854 of file comment.module.

References t().

Referenced by comment_controls(), and comment_form_alter().

_comment_load ( $ cid )

Misc functions: helpers, privates, history.

Load the entire comment by cid.

Parameters:
$cid The identifying comment id.
Returns:
The comment object.

Definition at line 1101 of file comment.module.

References db_fetch_object(), and db_query().

Referenced by comment_admin_overview_submit(), comment_multiple_delete_confirm(), comment_multiple_delete_confirm_submit(), and comment_save().

_comment_per_page ( )

Return an array of "comments per page" settings from which the user can choose.

Definition at line 1865 of file comment.module.

References drupal_map_assoc().

Referenced by comment_controls(), and comment_form_alter().

_comment_update_node_statistics ( $ nid )

Updates the comment statistics for a given node.

This should be called any time a comment is added, deleted, or updated.

The following fields are contained in the node_comment_statistics table.

  • last_comment_timestamp: the timestamp of the last comment for this node or the node create stamp if no comments exist for the node.
  • last_comment_name: the name of the anonymous poster for the last comment
  • last_comment_uid: the uid of the poster for the last comment for this node or the node authors uid if no comments exists for the node.
  • comment_count: the total number of approved/published comments on this node.

Definition at line 1925 of file comment.module.

References $nid, db_fetch_object(), db_query(), db_query_range(), db_result(), and name.

Referenced by comment_admin_overview_submit(), comment_confirm_delete_submit(), comment_multiple_delete_confirm_submit(), and comment_save().

comment_access | ( | $ | op,
 |  | $ | comment
 | ) |  |

This is *not* a hook_access() implementation.

This function is called to determine whether the current user has access to a particular comment.

Authenticated users can edit their comments as long they have not been replied to. This prevents people from changing or revising their statements based on the replies to their posts.

Parameters:
$op | The operation that is to be performed on the comment. Only 'edit' is recognized now.
$comment | The comment object.
Returns:
TRUE if the current user has acces to the comment, FALSE otherwise.

Definition at line 661 of file comment.module.

References $op, $user, comment_num_replies(), and user_access().

Referenced by comment_edit(), and comment_links().

comment_action_info ( )

Implementation of hook_action_info().

Definition at line 2019 of file comment.module.

References t().

comment_block | ( | $ | op = 'list',
 |  | $ | delta = 0
 | ) |  |

Implementation of hook_block().

Generates a block with the most recent comments.

Definition at line 282 of file comment.module.

References $op, t(), theme(), and user_access().

comment_controls_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process comment_controls form submissions.

Definition at line 1647 of file comment.module.

References $user, drupal_set_message(), t(), and user_save().

comment_form_alter | ( | &$ | form,
 |  | $ | form_state,
 |  | $ | form_id
 | ) |  |

Implementation of hook_form_alter().

Definition at line 488 of file comment.module.

References _comment_get_modes(), _comment_get_orders(), _comment_per_page(), drupal_anonymous_user(), t(), url(), user_access(), and variable_get().

comment_form_box | ( | $ | edit,
 |  | $ | title = NULL
 | ) |  |

Theme the comment form box.

Parameters:
$edit | The form structure.
$title | The form title.

Definition at line 1413 of file comment.module.

References $title, drupal_get_form(), and theme().

Referenced by comment_edit(), comment_render(), and comment_reply().

comment_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process comment form submissions; prepare the comment, store it, and set a redirection target.

Definition at line 1535 of file comment.module.

References _comment_form_submit(), comment_new_page_count(), comment_save(), nid, and node_load().

comment_form_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate comment form submissions.

Definition at line 1485 of file comment.module.

References $user, and comment_validate().

comment_get_recent ( $ number = 10 )

Find a number of recent comments.

This is done in two steps. 1. Find the n (specified by $number) nodes that have the most recent comments. This is done by querying node_comment_statistics which has an index on last_comment_timestamp, and is thus a fast query. 2. Loading the information from the comments table based on the nids found in step 1.

Parameters:
$number (optional) The maximum number of comments to find.
Returns:
An array of comment objects each containing a nid, subject, cid, and timestamp, or an empty array if there are no recent comments visible to the current user.

Definition at line 309 of file comment.module.

References $result, $row, db_fetch_object(), db_query_range(), and db_rewrite_sql().

Referenced by theme_comment_block().

comment_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 126 of file comment.module.

References $output, t(), and url().

comment_hook_info ( )

Implementation of hook_hook_info().

Definition at line 1995 of file comment.module.

References t().

comment_invoke_comment | ( | &$ | comment,
 |  | $ | op
 | ) |  |

Invoke a hook_comment() operation in all modules.

Parameters:
&$comment | A comment object.
$op | A string containing the name of the comment operation.
Returns:
The returned value of the invoked hooks.

Definition at line 1951 of file comment.module.

References $name, $op, $result, $return, and module_implements().

Referenced by _comment_delete_thread(), comment_admin_overview_submit(), comment_save(), comment_validate(), and theme_comment_view().

comment_link | ( | $ | type,
 |  | $ | node = NULL,
 |  | $ | teaser = FALSE
 | ) |  |

Implementation of hook_link().

Definition at line 405 of file comment.module.

References $links, $new, $type, comment_links(), comment_new_page_count(), comment_num_all(), comment_num_new(), format_plural(), nid, t(), theme(), user_access(), and variable_get().

comment_links | ( | $ | comment,
 |  | $ | return = 1
 | ) |  |

Build command links for a comment (e.g. edit, reply, delete) with respect to the current user's access permissions.

Parameters:
$comment | The comment to which the links will be related.
$return | Not used.
Returns:
An associative array containing the links.

Definition at line 806 of file comment.module.

References $links, $return, $user, comment_access(), comment_node_url(), nid, node_comment_mode(), node_load(), t(), theme(), and user_access().

Referenced by comment_link().

comment_menu ( )

Implementation of hook_menu().

Definition at line 196 of file comment.module.

References $items.

comment_new_page_count | ( | $ | num_comments,
 |  | $ | new_replies,
 |  | $ | node
 | ) |  |

Calculate page number for first new comment.

Parameters:
$num_comments | Number of comments.
$new_replies | Number of new replies.
$node | The first new comment node.
Returns:
"page=X" if the page number is greater than zero; empty string otherwise.

Definition at line 345 of file comment.module.

References $result, _comment_get_display_setting(), db_query(), db_result(), and nid.

Referenced by comment_form_submit(), comment_link(), template_preprocess_forum_topic_list(), and tracker_page().

comment_node_type | ( | $ | op,
 |  | $ | info
 | ) |  |

Implementation of hook_node_type().

Definition at line 249 of file comment.module.

References $op, and variable_del().

comment_node_url ( )

A simple helper function.

Returns:
The 0th and the 1st path components joined by a slash.

Definition at line 675 of file comment.module.

References arg().

Referenced by comment_links(), and template_preprocess_comment_folded().

comment_nodeapi | ( | &$ | node,
 |  | $ | op,
 |  | $ | arg = 0
 | ) |  |

Implementation of hook_nodeapi().

Definition at line 593 of file comment.module.

References $op, check_markup(), check_plain(), db_fetch_array(), db_fetch_object(), db_query(), db_result(), format_plural(), nid, subject, url(), and variable_get().

comment_num_all ( $ nid )

Get comment count for a node.

Parameters:
$nid The node id.
Returns:
The comment count.

Definition at line 1113 of file comment.module.

References $nid, db_query(), and db_result().

Referenced by comment_link().

comment_num_new | ( | $ | nid,
 |  | $ | timestamp = 0
 | ) |  |

Get number of new comments for current user and specified node.

Parameters:
$nid | node-id to count comments for
$timestamp | time to count from (defaults to time of last user access to node)

Definition at line 1149 of file comment.module.

References $nid, $result, $user, db_query(), db_result(), and node_last_viewed().

Referenced by comment_link(), forum_get_topics(), and tracker_page().

comment_num_replies ( $ pid )

Get replies count for a comment.

Parameters:
$pid The comment id.
Returns:
The replies count.

Definition at line 1130 of file comment.module.

References db_query(), and db_result().

Referenced by comment_access().

comment_operations ( $ action = NULL )

Comment operations.

We offer different update operations depending on which comment administration page we're on.

Parameters:
$action The comment administration page.
Returns:
An associative array containing the offered operations.

Definition at line 1066 of file comment.module.

References t().

Referenced by comment_admin_overview(), and comment_admin_overview_submit().

comment_perm ( )

Implementation of hook_perm().

Definition at line 273 of file comment.module.

comment_render | ( | $ | node,
 |  | $ | cid = 0
 | ) |  |

Renders comment(s).

Parameters:
$node | The node which comment(s) needs rendering.
$cid | Optional, if given, only one comment is rendered.
To display threaded comments in the correct order we keep a 'thread' field and order by that value. This field keeps this data in a way which is easy to update and convenient to use.

A "thread" value starts at "1". If we add a child (A) to this comment, we assign it a "thread" = "1.1". A child of (A) will have "1.1.1". Next brother of (A) will get "1.2". Next brother of the parent of (A) will get "2" and so on.

First of all note that the thread field stores the depth of the comment: depth 0 will be "X", depth 1 "X.X", depth 2 "X.X.X", etc.

Now to get the ordering right, consider this example:

1 1.1 1.1.1 1.2 2

If we "ORDER BY thread ASC" we get the above result, and this is the natural order sorted by time. However, if we "ORDER BY thread DESC" we get:

2 1.2 1.1.1 1.1 1

Clearly, this is not a natural way to see a thread, and users will get confused. The natural order to show a thread by time desc would be:

2 1 1.2 1.1 1.1.1

which is what we already did before the standard pager patch. To achieve this we simply add a "/" at the end of each "thread" value. This way out thread fields will look like depicted below:

1/ 1.1/ 1.1.1/ 1.2/ 2/

we add "/" since this char is, in ASCII, higher than every number, so if now we "ORDER BY thread DESC" we get the correct order. However this would spoil the reverse ordering, "ORDER BY thread ASC" -- here, we do not need to consider the trailing "/" so we use a substring only.

Definition at line 918 of file comment.module.

References $links, $nid, $output, $result, $user, _comment_get_display_setting(), arg(), comment_form_box(), db_fetch_object(), db_query(), db_rewrite_sql(), drupal_add_css(), drupal_alter(), drupal_get_form(), drupal_get_path(), drupal_unpack(), module_invoke_all(), node_comment_mode(), pager_query(), t(), theme(), user_access(), and variable_get().

Referenced by node_show().

comment_save ( $ edit )

Accepts a submission of new or changed comment content.

Parameters:
$edit A comment array.
Returns:
If the comment is successfully saved the comment ID is returned. If the comment is not saved, FALSE is returned.

Definition at line 689 of file comment.module.

References $user, _comment_load(), _comment_update_node_statistics(), cache_clear_all(), comment_invoke_comment(), db_last_insert_id(), db_query(), db_result(), drupal_set_message(), form_get_errors(), int2vancode(), ip_address(), l(), node_comment_mode(), t(), user_access(), vancode2int(), and watchdog().

Referenced by comment_form_submit().

comment_theme ( )

Implementation of hook_theme().

Definition at line 143 of file comment.module.

comment_unpublish_action | ( | $ | comment,
 |  | $ | context = array()
 | ) |  |

Drupal action to unpublish a comment.

Parameters:
$context | Keyed array. Must contain the id of the comment if $comment is not passed.
$comment | An optional comment object.

Definition at line 2048 of file comment.module.

References db_query(), db_result(), and watchdog().

comment_unpublish_by_keyword_action | ( | $ | comment,
 |  | $ | context
 | ) |  |

Implementation of a configurable Drupal action.

Unpublish a comment if it contains a certain string.

Parameters:
$context | An array providing more information about the context of the call to this action. Unused here since this action currently only supports the insert and update ops of the comment hook, both of which provide a complete $comment object.
$comment | A comment object.

Definition at line 2094 of file comment.module.

References db_query(), subject, and watchdog().

comment_unpublish_by_keyword_action_submit | ( | $ | form,
 |  | $ | form_state
 | ) |  |

Process comment_unpublish_by_keyword_action_form form submissions.

Definition at line 2079 of file comment.module.

References drupal_explode_tags().

comment_user | ( | $ | type,
 |  | $ | edit,
 |  | &$ | user,
 |  | $ | category = NULL
 | ) |  |

Implementation of hook_user().

Definition at line 639 of file comment.module.

References $type, $user, and db_query().

comment_validate ( $ edit )

Validate comment data.

Parameters:
$edit An associative array containig the comment data.
Returns:
The original $edit.

Definition at line 1179 of file comment.module.

References $user, comment_invoke_comment(), db_query(), db_result(), form_set_error(), node_load(), t(), user_load(), valid_email_address(), valid_url(), and variable_get().

Referenced by comment_form_validate().

int2vancode ( $ i = 0 )

Generate vancode.

Consists of a leading character indicating length, followed by N digits with a numerical value in base 36. Vancodes can be sorted as strings without messing up numerical order.

It goes: 00, 01, 02, ..., 0y, 0z, 110, 111, ... , 1zy, 1zz, 2100, 2101, ..., 2zzy, 2zzz, 31000, 31001, ...

Definition at line 1979 of file comment.module.

Referenced by comment_save().

template_preprocess_comment ( &$ variables )

Process variables for comment.tpl.php.

See also:
comment.tpl.php

theme_comment()

Definition at line 1676 of file comment.module.

References format_date(), l(), subject, t(), theme(), and theme_get_setting().

template_preprocess_comment_folded ( &$ variables )

Process variables for comment-folded.tpl.php.

See also:
comment-folded.tpl.php

theme_comment_folded()

Definition at line 1704 of file comment.module.

References comment_node_url(), format_date(), l(), subject, t(), and theme().

template_preprocess_comment_wrapper ( &$ variables )

Process variables for comment-wrapper.tpl.php.

See also:
comment-wrapper.tpl.php

theme_comment_wrapper()

Definition at line 1810 of file comment.module.

References _comment_get_display_setting(), and variable_get().

vancode2int ( $ c = '00' )

Decode vancode back to an integer.

Definition at line 1988 of file comment.module.

Referenced by comment_save().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/comment/comment.pages.inc File Reference

modules » comment

comment.pages.inc File Reference

Detailed Description

User page callbacks for the comment module.

Definition in file comment.pages.inc.

Go to the source code of this file.

Functions

  • comment_edit ($cid)
    Form builder; generate a comment editing form.
  • comment_reply ($node, $pid=NULL)
    This function is responsible for generating a comment reply form.

Function Documentation

comment_reply | ( | $ | node,
 |  | $ | pid = NULL
 | ) |  |

This function is responsible for generating a comment reply form.

There are several cases that have to be handled, including:

  • replies to comments
  • replies to nodes
  • attempts to reply to nodes that can no longer accept comments
  • respecting access permissions ('access comments', 'post comments', etc.)

The node or comment that is being replied to must appear above the comment form to provide the user context while authoring the comment.

Parameters:
$node | Every comment belongs to a node. This is that node.
$pid | Some comments are replies to other comments. In those cases, $pid is the parent comment's cid.
Returns:
The rendered parent node or comment plus the new comment form.

Definition at line 51 of file comment.pages.inc.

References $op, $output, comment_form_box(), db_fetch_object(), db_query(), drupal_goto(), drupal_set_breadcrumb(), drupal_set_message(), drupal_unpack(), l(), nid, node_comment_mode(), node_view(), t(), theme(), and user_access().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/comment/comment.tpl.php File Reference

modules » comment

comment.tpl.php File Reference

Go to the source code of this file.

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/contact/contact.admin.inc File Reference

modules » contact

contact.admin.inc File Reference

Detailed Description

Admin page callbacks for the contact module.

Definition in file contact.admin.inc.

Go to the source code of this file.

Functions

  • contact_admin_categories ()
    Categories/list tab.
  • contact_admin_delete (&$form_state, $contact)
    Category delete page.
  • contact_admin_delete_submit ($form, &$form_state)
    Process category delete form submission.
  • contact_admin_edit ($form_state=array(), $op, $contact=NULL)
    Category edit page.
  • contact_admin_edit_submit ($form, &$form_state)
    Process the contact category edit page form submission.
  • contact_admin_edit_validate ($form, &$form_state)
    Validate the contact category edit page form submission.
  • contact_admin_settings ()

Function Documentation

contact_admin_categories ( )

Categories/list tab.

Definition at line 12 of file contact.admin.inc.

References $header, $result, db_fetch_object(), db_query(), l(), t(), and theme().

contact_admin_delete | ( | &$ | form_state,
 |  | $ | contact
 | ) |  |

Category delete page.

Definition at line 131 of file contact.admin.inc.

References confirm_form(), and t().

contact_admin_delete_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process category delete form submission.

Definition at line 144 of file contact.admin.inc.

References db_query(), drupal_set_message(), t(), and watchdog().

contact_admin_edit | ( | $ | form_state = array(),
 |  | $ | op,
 |  | $ | contact = NULL
 | ) |  |

Category edit page.

Definition at line 26 of file contact.admin.inc.

References $op, and t().

contact_admin_edit_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process the contact category edit page form submission.

Definition at line 101 of file contact.admin.inc.

References db_query(), drupal_set_message(), drupal_write_record(), l(), t(), and watchdog().

contact_admin_edit_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate the contact category edit page form submission.

Definition at line 81 of file contact.admin.inc.

References form_set_error(), t(), and valid_email_address().

contact_admin_settings ( )

Definition at line 154 of file contact.admin.inc.

References drupal_map_assoc(), system_settings_form(), t(), url(), and variable_get().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/contact/contact.install File Reference

modules » contact

contact.install File Reference

Go to the source code of this file.

Functions

  • contact_install ()
    Implementation of hook_install().
  • contact_schema ()
    Implementation of hook_schema().
  • contact_uninstall ()
    Implementation of hook_uninstall().

Function Documentation

contact_install ( )

Implementation of hook_install().

Definition at line 7 of file contact.install.

References drupal_install_schema().

contact_schema ( )

Implementation of hook_schema().

Definition at line 27 of file contact.install.

References t().

contact_uninstall ( )

Implementation of hook_uninstall().

Definition at line 15 of file contact.install.

References drupal_uninstall_schema(), and variable_del().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/contact/contact.module File Reference

modules » contact

contact.module File Reference

Detailed Description

Enables the use of personal and site-wide contact forms.

Definition in file contact.module.

Go to the source code of this file.

Functions

  • _contact_user_tab_access ($account)
    Determine if a user can access to the contact tab.
  • contact_help ($path, $arg)
    Implementation of hook_help().
  • contact_load ($cid)
    Load the data for a single contact category.
  • contact_mail ($key, &$message, $params)
    Implementation of hook_mail().
  • contact_menu ()
    Implementation of hook_menu().
  • contact_perm ()
    Implementation of hook_perm.
  • contact_user ($type, &$edit, &$user, $category=NULL)
    Implementation of hook_user().

Function Documentation

_contact_user_tab_access ( $ account )

Determine if a user can access to the contact tab.

Definition at line 111 of file contact.module.

References $user, and user_access().

contact_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 12 of file contact.module.

References $output, module_exists(), t(), and url().

contact_load ( $ cid )

Load the data for a single contact category.

Definition at line 127 of file contact.module.

References db_fetch_array(), and db_query().

Referenced by contact_mail_page_submit().

contact_mail | ( | $ | key,
 |  | &$ | message,
 |  | $ | params
 | ) |  |

Implementation of hook_mail().

Definition at line 162 of file contact.module.

References $language, $user, language, name, t(), url(), and variable_get().

contact_menu ( )

Implementation of hook_menu().

Definition at line 44 of file contact.module.

References $items.

contact_perm ( )

Implementation of hook_perm.

Definition at line 38 of file contact.module.

contact_user | ( | $ | type,
 |  | &$ | edit,
 |  | &$ | user,
 |  | $ | category = NULL
 | ) |  |

Implementation of hook_user().

Allows the user the option of enabling/disabling his personal contact form.

Definition at line 137 of file contact.module.

References $type, t(), url(), and variable_get().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/contact/contact.pages.inc File Reference

modules » contact

contact.pages.inc File Reference

Detailed Description

User page callbacks for the contact module.

Definition in file contact.pages.inc.

Go to the source code of this file.

Functions

  • contact_mail_page ()
  • contact_mail_page_submit ($form, &$form_state)
    Process the site-wide contact page form submission.
  • contact_mail_page_validate ($form, &$form_state)
    Validate the site-wide contact page form submission.
  • contact_mail_user (&$form_state, $recipient)
  • contact_mail_user_submit ($form, &$form_state)
    Process the personal contact page form submission.
  • contact_site_page ()
    Site-wide contact page.
  • contact_user_page ($account)
    Personal contact page.

Function Documentation

contact_mail_page ( )

Definition at line 26 of file contact.pages.inc.

References $result, $user, db_fetch_object(), db_query(), drupal_set_message(), filter_xss_admin(), name, t(), url(), and variable_get().

contact_mail_page_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process the site-wide contact page form submission.

Definition at line 119 of file contact.pages.inc.

References $language, contact_load(), drupal_mail(), drupal_set_message(), flood_register_event(), language_default(), t(), and watchdog().

contact_mail_page_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate the site-wide contact page form submission.

Definition at line 107 of file contact.pages.inc.

References form_set_error(), t(), and valid_email_address().

contact_mail_user | ( | &$ | form_state,
 |  | $ | recipient
 | ) |  |

Definition at line 174 of file contact.pages.inc.

References $user, check_plain(), name, and t().

contact_mail_user_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process the personal contact page form submission.

Definition at line 208 of file contact.pages.inc.

References $language, $user, drupal_mail(), drupal_set_message(), flood_register_event(), name, t(), user_preferred_language(), and watchdog().

contact_site_page ( )

Site-wide contact page.

Definition at line 13 of file contact.pages.inc.

References $output, $user, drupal_get_form(), flood_is_allowed(), t(), and variable_get().

contact_user_page ( $ account )

Personal contact page.

Definition at line 157 of file contact.pages.inc.

References $output, $user, check_plain(), drupal_get_form(), drupal_set_title(), flood_is_allowed(), name, t(), url(), valid_email_address(), and variable_get().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/dblog/dblog.admin.inc File Reference

modules » dblog

dblog.admin.inc File Reference

Detailed Description

Administrative page callbacks for the dblog module.

Definition in file dblog.admin.inc.

Go to the source code of this file.

Functions

  • _dblog_format_message ($dblog)
    Formats a log message for display.
  • dblog_admin_settings ()
    dblog module settings form.
  • dblog_build_filter_query ()
    Build query for dblog administration filters based on session.
  • dblog_event ($id)
    Menu callback; displays details about a log message.
  • dblog_filter_form ()
    Return form for dblog administration filters.
  • dblog_filter_form_submit ($form, &$form_state)
    Process result from dblog administration filter form.
  • dblog_filter_form_validate ($form, &$form_state)
    Validate result from dblog administration filter form.
  • dblog_filters ()
    List dblog administration filters that can be applied.
  • dblog_overview ()
    Menu callback; displays a listing of log messages.
  • dblog_top ($type)
    Menu callback; generic function to display a page of the most frequent dblog events of a specified type.

Function Documentation

_dblog_format_message ( $ dblog )

Formats a log message for display.

Parameters:
$dblog An object with at least the message and variables properties

Definition at line 234 of file dblog.admin.inc.

References t().

Referenced by dblog_event(), dblog_overview(), and dblog_top().

dblog_build_filter_query ( )

Build query for dblog administration filters based on session.

Definition at line 173 of file dblog.admin.inc.

References $value, and dblog_filters().

Referenced by dblog_overview().

dblog_event ( $ id )

Menu callback; displays details about a log message.

Definition at line 121 of file dblog.admin.inc.

References $attributes, $id, $output, $result, _dblog_format_message(), check_plain(), db_fetch_object(), db_query(), format_date(), l(), link, t(), theme(), and watchdog_severity_levels().

dblog_filter_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process result from dblog administration filter form.

Definition at line 304 of file dblog.admin.inc.

References $name, $op, dblog_filters(), and t().

dblog_filter_form_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate result from dblog administration filter form.

Definition at line 295 of file dblog.admin.inc.

References form_set_error(), and t().

dblog_filters ( )

List dblog administration filters that can be applied.

Definition at line 204 of file dblog.admin.inc.

References $type, _dblog_get_message_types(), t(), and watchdog_severity_levels().

Referenced by dblog_build_filter_query(), dblog_filter_form(), and dblog_filter_form_submit().

dblog_overview ( )

Menu callback; displays a listing of log messages.

Definition at line 30 of file dblog.admin.inc.

References $header, $output, $result, _dblog_format_message(), db_fetch_object(), dblog_build_filter_query(), drupal_get_form(), format_date(), l(), link, pager_query(), t(), tablesort_sql(), theme(), and truncate_utf8().

dblog_top ( $ type )

Menu callback; generic function to display a page of the most frequent dblog events of a specified type.

Definition at line 94 of file dblog.admin.inc.

References $header, $output, $result, $type, _dblog_format_message(), db_fetch_object(), pager_query(), t(), tablesort_sql(), theme(), and truncate_utf8().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/dblog/dblog.install File Reference

modules » dblog

dblog.install File Reference

Go to the source code of this file.

Functions

  • dblog_install ()
    Implementation of hook_install().
  • dblog_schema ()
    Implementation of hook_schema().
  • dblog_uninstall ()
    Implementation of hook_uninstall().

Function Documentation

dblog_install ( )

Implementation of hook_install().

Definition at line 7 of file dblog.install.

References drupal_install_schema().

dblog_schema ( )

Implementation of hook_schema().

Definition at line 23 of file dblog.install.

References t().

dblog_uninstall ( )

Implementation of hook_uninstall().

Definition at line 15 of file dblog.install.

References drupal_uninstall_schema().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/dblog/dblog.module File Reference

modules » dblog

dblog.module File Reference

Detailed Description

System monitoring and logging for administrators.

The dblog module monitors your site and keeps a list of recorded events containing usage and performance data, errors, warnings, and similar operational information.

See also:
watchdog()

Definition in file dblog.module.

Go to the source code of this file.

Functions

  • _dblog_get_message_types ()
  • dblog_cron ()
    Implementation of hook_cron().
  • dblog_help ($path, $arg)
    Implementation of hook_help().
  • dblog_init ()
  • dblog_menu ()
    Implementation of hook_menu().
  • dblog_theme ()
    Implementation of hook_theme().
  • dblog_user ($op, &$edit, &$user)
    Implementation of hook_user().
  • dblog_watchdog ($log=array())
  • theme_dblog_filters ($form)
    Theme dblog administration filter selector.

Function Documentation

_dblog_get_message_types ( )

Definition at line 113 of file dblog.module.

References $result, db_fetch_object(), and db_query().

Referenced by dblog_filters().

dblog_cron ( )

Implementation of hook_cron().

Remove expired log messages and flood control events.

Definition at line 98 of file dblog.module.

References db_query(), db_result(), and variable_get().

dblog_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 18 of file dblog.module.

References $output, and t().

dblog_init ( )

Definition at line 84 of file dblog.module.

References arg(), drupal_add_css(), and drupal_get_path().

dblog_menu ( )

Implementation of hook_menu().

Definition at line 44 of file dblog.module.

References $items.

dblog_theme ( )

Implementation of hook_theme().

Definition at line 33 of file dblog.module.

dblog_user | ( | $ | op,
 |  | &$ | edit,
 |  | &$ | user
 | ) |  |

Implementation of hook_user().

Definition at line 107 of file dblog.module.

References $op, $user, and db_query().

dblog_watchdog ( $ log = array() )

Definition at line 124 of file dblog.module.

References db_query(), and db_set_active().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/filter/filter.admin.inc File Reference

modules » filter

filter.admin.inc File Reference

Detailed Description

Admin page callbacks for the filter module.

Definition in file filter.admin.inc.

Go to the source code of this file.

Functions

  • filter_admin_configure (&$form_state, $format)
    Build a form to change the settings for a format's filters.
  • filter_admin_configure_page ($format)
    Menu callback; display settings defined by a format's filters.
  • filter_admin_configure_submit ($form, &$form_state)
    Clear the filter's cache when configuration settings are saved.
  • filter_admin_delete ()
    Menu callback; confirm deletion of a format.
  • filter_admin_delete_submit ($form, &$form_state)
    Process filter delete form submission.
  • filter_admin_format_form (&$form_state, $format)
    Generate a filter format form.
  • filter_admin_format_form_submit ($form, &$form_state)
    Process filter format form submissions.
  • filter_admin_format_form_validate ($form, &$form_state)
    Validate filter format form submissions.
  • filter_admin_format_page ($format=NULL)
    Menu callback; Display a filter format form.
  • filter_admin_order (&$form_state, $format=NULL)
    Build the form for ordering filters for a format.
  • filter_admin_order_page ($format)
    Menu callback; display form for ordering filters for a format.
  • filter_admin_order_submit ($form, &$form_state)
    Process filter order configuration form submission.
  • filter_admin_overview ()
    Menu callback; Displays a list of all input formats and which one is the default.
  • filter_admin_overview_submit ($form, &$form_state)
  • theme_filter_admin_order ($form)
    Theme filter order configuration form.
  • theme_filter_admin_overview ($form)
    Theme the admin overview form.

Function Documentation

filter_admin_configure_page ( $ format )

Menu callback; display settings defined by a format's filters.

Definition at line 288 of file filter.admin.inc.

References drupal_get_form(), drupal_set_title(), name, and t().

filter_admin_configure_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Clear the filter's cache when configuration settings are saved.

Definition at line 322 of file filter.admin.inc.

References cache_clear_all().

filter_admin_delete_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process filter delete form submission.

Definition at line 267 of file filter.admin.inc.

References cache_clear_all(), db_query(), drupal_set_message(), t(), and variable_get().

filter_admin_format_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process filter format form submissions.

Definition at line 176 of file filter.admin.inc.

References $id, $name, $new, $return, cache_clear_all(), db_query(), db_result(), drupal_set_message(), filter_list_format(), module_invoke(), t(), and user_roles().

filter_admin_format_form_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate filter format form submissions.

Definition at line 163 of file filter.admin.inc.

References $name, $result, db_fetch_object(), db_query(), form_set_error(), and t().

filter_admin_format_page ( $ format = NULL )

Menu callback; Display a filter format form.

Definition at line 79 of file filter.admin.inc.

References drupal_get_form(), drupal_set_title(), name, and t().

filter_admin_order_page ( $ format )

Menu callback; display form for ordering filters for a format.

Definition at line 329 of file filter.admin.inc.

References drupal_get_form(), drupal_set_title(), name, and t().

filter_admin_order_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process filter order configuration form submission.

Definition at line 386 of file filter.admin.inc.

References $id, cache_clear_all(), db_query(), drupal_set_message(), and t().

filter_admin_overview_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 42 of file filter.admin.inc.

References drupal_set_message(), t(), and variable_set().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/filter/filter.install File Reference

modules » filter

filter.install File Reference

Go to the source code of this file.

Functions

  • filter_schema ()
    Implementation of hook_schema().

Function Documentation

filter_schema ( )

Implementation of hook_schema().

Definition at line 7 of file filter.install.

References drupal_get_schema_unprocessed(), and t().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/filter/filter.module File Reference

modules » filter

filter.module File Reference

Detailed Description

Framework for handling filtering of content.

Definition in file filter.module.

Go to the source code of this file.

Enumerations

  • enum FILTER_FORMAT_DEFAULT
  • enum FILTER_HTML_ESCAPE
  • enum FILTER_HTML_STRIP

Functions

  • _filter_list_cmp ($a, $b)
    Helper function for sorting the filter list by filter name.
  • _filter_tips ($format, $long=FALSE)
    End of "Filtering functions".
  • filter_admin_format_title ($format)
    Display a filter format form title.
  • filter_cron ()
    Implementation of hook_cron().
  • filter_filter_tips ($delta, $format, $long=FALSE)
    Implementation of hook_filter_tips().
  • filter_format_allowcache ($format)
    Check if text in a certain input format is allowed to be cached.
  • filter_format_load ($arg)
  • filter_formats ($index=NULL)
    Retrieve a list of input formats.
  • filter_help ($path, $arg)
    Implementation of hook_help().
  • filter_list_all ()
    Build a list of all filters.
  • filter_list_format ($format)
    Retrieve a list of filters for a certain format.
  • filter_menu ()
    Implementation of hook_menu().
  • filter_perm ()
    Implementation of hook_perm().
  • filter_resolve_format ($format)
    Resolve a format id, including the default format.
  • filter_theme ()
    Implementation of hook_theme().
  • theme_filter_tips_more_info ()
    Format a link to the more extensive filter tips.
Standard filters
Filters implemented by the filter.module.

  • _filter_autop ($text)
    Convert line breaks into.
  • _filter_html ($text, $format)
    HTML filter.
  • _filter_html_settings ($format)
    Settings for the HTML filter.
  • _filter_htmlcorrector ($text)
    Scan input and make sure that all HTML tags are properly closed and nested.
  • _filter_url ($text, $format)
    URL filter.
  • _filter_url_parse_full_links ($match)
    Make links out of absolute URLs.
  • _filter_url_parse_partial_links ($match)
    Make links out of domain names starting with "www.".
  • _filter_url_settings ($format)
    Settings for URL filter.
  • _filter_url_trim ($text, $length=NULL)
    Shortens long URLs to http://www.example.com/long/url.
  • _filter_xss_attributes ($attr)
    Processes a string of HTML attributes.
  • _filter_xss_split ($m, $store=FALSE)
    Processes an HTML tag.
  • filter_filter ($op, $delta=0, $format=-1, $text= '')
    Implementation of hook_filter().
  • filter_xss ($string, $allowed_tags=array('a', 'em', 'strong', 'cite', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'))
    Filters XSS.
  • filter_xss_admin ($string)
    Very permissive XSS/HTML filter for admin-only use.
  • filter_xss_bad_protocol ($string, $decode=TRUE)
    Processes an HTML attribute value and ensures it does not contain an URL with a disallowed protocol (e.g.
Filtering functions
Modules which need to have content filtered can use these functions to interact with the filter system.

For more info, see the hook_filter() documentation.

Note: because filters can inject JavaScript or execute PHP code, security is vital here. When a user supplies a $format, you should validate it with filter_access($format) before accepting/using it. This is normally done in the validation stage of the node system. You should for example never make a preview of content in a disallowed format.

  • check_markup ($text, $format=FILTER_FORMAT_DEFAULT, $check=TRUE)
    Run all the enabled filters on a piece of text.
  • filter_access ($format)
    Returns TRUE if the user is allowed to access this format.
  • filter_form ($value=FILTER_FORMAT_DEFAULT, $weight=NULL, $parents=array('format'))
    Generate a selector for choosing a format in a form.
  • filter_form_validate ($form)

Enumeration Type Documentation

enum FILTER_FORMAT_DEFAULT

Definition at line 12 of file filter.module.

enum FILTER_HTML_ESCAPE

Definition at line 15 of file filter.module.

enum FILTER_HTML_STRIP

Definition at line 14 of file filter.module.

Function Documentation

_filter_autop ( $ text )

Convert line breaks into.

and
in an intelligent fashion. Based on: http://photomatt.net/scripts/autop

Definition at line 866 of file filter.module.

References $output, and $tag.

Referenced by filter_filter().

_filter_html | ( | $ | text,
 |  | $ | format
 | ) |  |

HTML filter.

Provides filtering of input into accepted HTML.

Definition at line 691 of file filter.module.

References check_plain(), filter_xss(), and variable_get().

Referenced by filter_filter().

_filter_html_settings ( $ format )

Settings for the HTML filter.

Definition at line 652 of file filter.module.

References t(), and variable_get().

Referenced by filter_filter().

_filter_htmlcorrector ( $ text )

Scan input and make sure that all HTML tags are properly closed and nested.

Definition at line 754 of file filter.module.

References $output, $tag, $value, and drupal_map_assoc().

Referenced by drupal_html_to_text(), and filter_filter().

_filter_list_cmp | ( | $ | a,
 |  | $ | b
 | ) |  |

Helper function for sorting the filter list by filter name.

Definition at line 345 of file filter.module.

References name.

_filter_tips | ( | $ | format,
 |  | $ | long = FALSE
 | ) |  |

End of "Filtering functions".

Helper function for fetching filter tips.

Definition at line 552 of file filter.module.

References $id, db_fetch_object(), db_query(), delta, filter_formats(), filter_list_format(), module, and module_invoke().

Referenced by filter_admin_format_form(), filter_form(), and filter_tips_long().

_filter_url | ( | $ | text,
 |  | $ | format
 | ) |  |

URL filter.

Automatically converts text web addresses (URLs, e-mail addresses, ftp links, etc.) into hyperlinks.

Definition at line 732 of file filter.module.

References _filter_url_trim(), and variable_get().

Referenced by filter_filter().

_filter_url_parse_full_links ( $ match )

Make links out of absolute URLs.

Definition at line 828 of file filter.module.

References _filter_url_trim(), check_plain(), check_url(), and decode_entities().

_filter_url_parse_partial_links ( $ match )

Make links out of domain names starting with "www.".

Definition at line 838 of file filter.module.

References _filter_url_trim(), check_plain(), and decode_entities().

_filter_url_settings ( $ format )

Settings for URL filter.

Definition at line 712 of file filter.module.

References t(), and variable_get().

Referenced by filter_filter().

_filter_url_trim | ( | $ | text,
 |  | $ | length = NULL
 | ) |  |

Shortens long URLs to http://www.example.com/long/url.

..

Definition at line 848 of file filter.module.

Referenced by _filter_url(), _filter_url_parse_full_links(), and _filter_url_parse_partial_links().

_filter_xss_attributes ( $ attr )

Processes a string of HTML attributes.

Returns:
Cleaned up version of the HTML attributes.

Definition at line 1057 of file filter.module.

References filter_xss_bad_protocol().

Referenced by _filter_xss_split().

_filter_xss_split | ( | $ | m,
 |  | $ | store = FALSE
 | ) |  |

Processes an HTML tag.

Parameters:
@m | An array with various meaning depending on the value of $store. If $store is TRUE then the array contains the allowed tags. If $store is FALSE then the array has one element, the HTML tag to process.
$store | Whether to store $m.
Returns:
If the element isn't allowed, an empty string. Otherwise, the cleaned up version of the HTML element.

Definition at line 1001 of file filter.module.

References _filter_xss_attributes().

Referenced by filter_xss().

check_markup | ( | $ | text,
 |  | $ | format = FILTER_FORMAT_DEFAULT,
 |  | $ | check = TRUE
 | ) |  |

Run all the enabled filters on a piece of text.

Parameters:
$text | The text to be filtered.
$format | The format of the text to be filtered. Specify FILTER_FORMAT_DEFAULT for the default format.
$check | Whether to check the $format with filter_access() first. Defaults to TRUE. Note that this will check the permissions of the current user, so you should specify $check = FALSE when viewing other people's content. When showing content that is not (yet) stored in the database (eg. upon preview), set to TRUE so the user's permissions are checked.

Definition at line 418 of file filter.module.

References cache_get(), cache_set(), delta, filter_access(), filter_format_allowcache(), filter_list_format(), filter_resolve_format(), module, module_invoke(), and t().

Referenced by _comment_form_submit(), block_block(), comment_nodeapi(), node_prepare(), profile_view_field(), theme_comment_view(), and user_comment().

filter_access ( $ format )

Returns TRUE if the user is allowed to access this format.

Definition at line 533 of file filter.module.

References filter_formats(), filter_resolve_format(), user_access(), and variable_get().

Referenced by block_block(), block_box_save(), check_markup(), and node_access().

filter_admin_format_title ( $ format )

Display a filter format form title.

Definition at line 145 of file filter.module.

filter_cron ( )

Implementation of hook_cron().

Expire outdated filter cache entries

Definition at line 161 of file filter.module.

References cache_clear_all().

filter_filter | ( | $ | op,
 |  | $ | delta = 0,
 |  | $ | format = -1,
 |  | $ | text = ''
 | ) |  |

Implementation of hook_filter().

Contains a basic set of essential filters.

  • HTML filter: Validates user-supplied HTML, transforming it as necessary.
  • Line break converter: Converts newlines into paragraph and break tags.
  • URL and e-mail address filter: Converts newlines into paragraph and break tags.

Definition at line 601 of file filter.module.

References $op, _filter_autop(), _filter_html(), _filter_html_settings(), _filter_htmlcorrector(), _filter_url(), _filter_url_settings(), and t().

filter_filter_tips | ( | $ | delta,
 |  | $ | format,
 |  | $ | long = FALSE
 | ) |  |

Implementation of hook_filter_tips().

Definition at line 168 of file filter.module.

References $base_url, $header, $output, $tag, check_plain(), t(), theme(), and variable_get().

filter_form_validate ( $ form )

Definition at line 520 of file filter.module.

References element_children(), form_error(), t(), and watchdog().

filter_format_allowcache ( $ format )

Check if text in a certain input format is allowed to be cached.

Definition at line 358 of file filter.module.

References db_query(), db_result(), and filter_resolve_format().

Referenced by check_markup().

filter_format_load ( $ arg )

Definition at line 138 of file filter.module.

References filter_formats().

filter_formats ( $ index = NULL )

Retrieve a list of input formats.

Definition at line 287 of file filter.module.

References $result, $user, db_fetch_object(), db_query(), user_access(), and variable_get().

Referenced by _filter_tips(), blogapi_mt_supported_text_filters(), filter_access(), filter_admin_overview(), filter_form(), and filter_format_load().

filter_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 20 of file filter.module.

References $output, t(), and url().

filter_list_all ( )

Build a list of all filters.

Definition at line 325 of file filter.module.

References $name, module_invoke(), and module_list().

Referenced by filter_admin_format_form().

filter_list_format ( $ format )

Retrieve a list of filters for a certain format.

Definition at line 370 of file filter.module.

References $result, db_fetch_object(), db_query(), delta, module, and module_invoke().

Referenced by _filter_tips(), check_markup(), filter_admin_configure(), filter_admin_format_form(), filter_admin_format_form_submit(), filter_admin_order(), and node_teaser().

filter_menu ( )

Implementation of hook_menu().

Definition at line 69 of file filter.module.

References $items.

filter_perm ( )

Implementation of hook_perm().

Definition at line 152 of file filter.module.

filter_resolve_format ( $ format )

Resolve a format id, including the default format.

Definition at line 352 of file filter.module.

References variable_get().

Referenced by check_markup(), filter_access(), filter_form(), and filter_format_allowcache().

filter_theme ( )

Implementation of hook_theme().

Definition at line 46 of file filter.module.

filter_xss | ( | $ | string,
 |  | $ | allowed_tags = array('a', 'em', 'strong', 'cite', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd')
 | ) |  |

Filters XSS.

Based on kses by Ulf Harnhammar, see http://sourceforge.net/projects/kses

For examples of various XSS attacks, see: http://ha.ckers.org/xss.html

This code does four things:

  • Removes characters and constructs that can trick browsers
  • Makes sure all HTML entities are well-formed
  • Makes sure all HTML tags and attributes are well-formed
  • Makes sure no HTML tags contain URLs with a disallowed protocol (e.g. javascript:)

Parameters:
$string | The string with raw HTML in it. It will be stripped of everything that can cause an XSS attack.
$allowed_tags | An array of allowed tags.
$format | The format to use.

Definition at line 955 of file filter.module.

References _filter_xss_split(), and drupal_validate_utf8().

Referenced by _filter_html(), aggregator_filter_xss(), drupal_html_to_text(), filter_xss_admin(), node_revision_overview(), and system_message_action().

filter_xss_admin ( $ string )

Very permissive XSS/HTML filter for admin-only use.

Use only for fields where it is impractical to use the whole filter system, but where some (mainly inline) mark-up is desired (so check_plain() is not acceptable).

Allows all tags that can be used inside an HTML body, save for scripts and styles.

Definition at line 930 of file filter.module.

References filter_xss().

Referenced by actions_synchronize(), contact_mail_page(), drupal_site_offline(), node_help(), node_overview_types(), template_preprocess_forum_list(), template_preprocess_maintenance_page(), template_preprocess_page(), theme_form_element(), theme_node_add_list(), theme_taxonomy_term_page(), and user_register().

filter_xss_bad_protocol | ( | $ | string,
 |  | $ | decode = TRUE
 | ) |  |

Processes an HTML attribute value and ensures it does not contain an URL with a disallowed protocol (e.g.

javascript:)

Parameters:
$string | The string with the attribute value.
$decode | Whether to decode entities in the $string. Set to FALSE if the $string is in plain text, TRUE otherwise. Defaults to TRUE.
Returns:
Cleaned up and HTML-escaped version of $string.

Definition at line 1170 of file filter.module.

References check_plain(), decode_entities(), and variable_get().

Referenced by _filter_xss_attributes(), check_url(), menu_path_is_external(), and url().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/filter/filter.pages.inc File Reference

modules » filter

filter.pages.inc File Reference

Detailed Description

User page callbacks for the filter module.

Definition in file filter.pages.inc.

Go to the source code of this file.

Functions

  • filter_tips_long ()
    Menu callback; show a page with long filter tips.
  • theme_filter_tips ($tips, $long=FALSE, $extra= '')
    Format a set of filter tips.

Function Documentation

filter_tips_long ( )

Menu callback; show a page with long filter tips.

Definition at line 13 of file filter.pages.inc.

References $output, _filter_tips(), arg(), and theme().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forum-icon.tpl.php File Reference

modules » forum

forum-icon.tpl.php File Reference

Detailed Description

Display an appropriate icon for a forum post.

Available variables:

  • $new_posts: Indicates whether or not the topic contains new posts.
  • $icon: The icon to display. May be one of 'hot', 'hot-new', 'new', 'default', 'closed', or 'sticky'.

See also:
template_preprocess_forum_icon()

theme_forum_icon()

Definition in file forum-icon.tpl.php.

Go to the source code of this file.

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forum-list.tpl.php File Reference

modules » forum

forum-list.tpl.php File Reference

Detailed Description

Default theme implementation to display a list of forums and containers.

Available variables:

  • $forums: An array of forums and containers to display. It is keyed to the numeric id's of all child forums and containers.
  • $forum_id: Forum id for the current forum. Parent to all items within the $forums array.

Each $forum in $forums contains:

  • $forum->is_container: Is TRUE if the forum can contain other forums. Is FALSE if the forum can contain only topics.
  • $forum->depth: How deep the forum is in the current hierarchy.
  • $forum->zebra: 'even' or 'odd' string used for row class.
  • $forum->name: The name of the forum.
  • $forum->link: The URL to link to this forum.
  • $forum->description: The description of this forum.
  • $forum->new_topics: True if the forum contains unread posts.
  • $forum->new_url: A URL to the forum's unread posts.
  • $forum->new_text: Text for the above URL which tells how many new posts.
  • $forum->old_topics: A count of posts that have already been read.
  • $forum->num_posts: The total number of posts in the forum.
  • $forum->last_reply: Text representing the last time a forum was posted or commented in.

See also:
template_preprocess_forum_list()

theme_forum_list()

Definition in file forum-list.tpl.php.

Go to the source code of this file.

Variables

  • print $forum_id
  • print $forum link
  • print $forum name

Variable Documentation

print $forum_id

Definition at line 34 of file forum-list.tpl.php.

print $forum link

Definition at line 52 of file forum-list.tpl.php.

Referenced by blog_form(), dblog_event(), dblog_overview(), node_feed(), template_preprocess_aggregator_feed_source(), template_preprocess_aggregator_item(), template_preprocess_aggregator_summary_item(), theme_aggregator_block_item(), and theme_aggregator_page_rss().

print $forum name

Definition at line 52 of file forum-list.tpl.php.

Referenced by _blogapi_get_post(), _comment_update_node_statistics(), _filter_list_cmp(), _locale_export_po(), _locale_languages_common_controls(), _locale_rebuild_js(), _system_is_incompatible(), _taxonomy_term_select(), _theme_build_registry(), _update_process_info_list(), _user_password_dynamic_validation(), block_add_block_form_submit(), blog_form(), blog_link(), blog_page_user(), blog_user(), blog_view(), blogapi_blogger_get_user_info(), blogapi_blogger_get_users_blogs(), blogapi_rsd(), comment_form(), comment_form_add_preview(), contact_mail(), contact_mail_page(), contact_mail_user(), contact_mail_user_submit(), contact_user_page(), drupal_check_profile(), filter_admin_configure_page(), filter_admin_delete(), filter_admin_format_form(), filter_admin_format_page(), filter_admin_order(), filter_admin_order_page(), filter_form(), forum_confirm_delete(), forum_nodeapi(), hook_mail(), hook_watchdog(), image_get_available_toolkits(), install_select_locale(), install_select_locale_form(), install_select_profile(), install_select_profile_form(), locale_batch_by_component(), locale_language_list(), locale_languages_delete_form(), locale_languages_delete_form_submit(), locale_languages_overview_form(), locale_translate_edit_form(), locale_translate_overview_screen(), locale_update_6000(), locale_update_6005(), locale_user(), module_list(), module_rebuild_cache(), node_add(), node_admin_nodes(), node_feed(), node_form(), node_menu(), node_preview(), node_submit(), node_type_delete_confirm(), node_type_form(), node_type_form_submit(), node_type_form_validate(), node_type_save(), node_validate(), openid_user_identities(), poll_votes(), profile_admin_overview(), profile_block(), profile_form_profile(), profile_save_profile(), profile_validate_profile(), profile_view_field(), profile_view_profile(), statistics_user_tracker(), system_get_files_database(), system_mail(), system_menu(), system_message_action(), system_modules_uninstall(), system_theme_data(), system_theme_select_form(), system_themes_form(), system_update_6018(), system_update_6042(), taxonomy_add_term_page(), taxonomy_autocomplete(), taxonomy_form(), taxonomy_form_alter(), taxonomy_help(), taxonomy_implode_tags(), taxonomy_link(), taxonomy_node_validate(), taxonomy_overview_terms(), taxonomy_overview_vocabularies(), taxonomy_rss_item(), taxonomy_term_confirm_delete(), taxonomy_term_confirm_parents(), taxonomy_term_page(), taxonomy_vocabulary_confirm_delete(), taxonomy_vocabulary_confirm_reset_alphabetical(), template_preprocess_forum_list(), template_preprocess_forums(), template_preprocess_user_picture(), theme_username(), tracker_page(), update_fix_compatibility(), update_get_project_name(), user_admin_role(), user_authenticate_finalize(), user_autocomplete(), user_block(), user_block_user_action(), user_confirm_delete(), user_confirm_delete_submit(), user_delete(), user_edit(), user_logout(), user_mail_tokens(), user_pass_reset(), user_pass_submit(), user_register_submit(), user_roles(), user_search(), user_view(), and xmlrpc_error_get_xml().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forum-submitted.tpl.php File Reference

modules » forum

forum-submitted.tpl.php File Reference

Detailed Description

Default theme implementation to format a simple string indicated when and by whom a topic was submitted.

Available variables:

  • $author: The author of the post.
  • $time: How long ago the post was created.
  • $topic: An object with the raw data of the post. Unsafe, be sure to clean this data before printing.

See also:
template_preprocess_forum_submitted()

theme_forum_submitted()

Definition in file forum-submitted.tpl.php.

Go to the source code of this file.

Variables

  • else __pad0__
  • endif

Variable Documentation

else __pad0__

Definition at line 27 of file forum-submitted.tpl.php.

endif

Definition at line 28 of file forum-submitted.tpl.php.

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forum-topic-list.tpl.php File Reference

modules » forum

forum-topic-list.tpl.php File Reference

Detailed Description

Theme implementation to display a list of forum topics.

Available variables:

  • $header: The table header. This is pre-generated with click-sorting information. If you need to change this,
    See also:
    template_preprocess_forum_topic_list().
  • $pager: The pager to display beneath the table.
  • $topics: An array of topics to be displayed.
  • $topic_id: Numeric id for the current forum topic.

Each $topic in $topics contains:

  • $topic->icon: The icon to display.
  • $topic->moved: A flag to indicate whether the topic has been moved to another forum.
  • $topic->title: The title of the topic. Safe to output.
  • $topic->message: If the topic has been moved, this contains an explanation and a link.
  • $topic->zebra: 'even' or 'odd' string used for row class.
  • $topic->num_comments: The number of replies on this topic.
  • $topic->new_replies: A flag to indicate whether there are unread comments.
  • $topic->new_url: If there are unread replies, this is a link to them.
  • $topic->new_text: Text containing the translated, properly pluralized count.
  • $topic->created: An outputtable string represented when the topic was posted.
  • $topic->last_reply: An outputtable string representing when the topic was last replied to.
  • $topic->timestamp: The raw timestamp this topic was posted.

See also:
template_preprocess_forum_topic_list()

theme_forum_topic_list()

Definition in file forum-topic-list.tpl.php.

Go to the source code of this file.

Variables

  • print $header
  • print $topic_id

Variable Documentation

print $header

Definition at line 38 of file forum-topic-list.tpl.php.

Referenced by _locale_export_po_generate(), _locale_import_one_string(), _locale_import_parse_header(), _locale_translate_seek(), _theme_table_cell(), aggregator_view(), contact_admin_categories(), dblog_overview(), dblog_top(), drupal_http_request(), drupal_page_cache_header(), drupal_set_header(), file_transfer(), filter_filter_tips(), mime_header_decode(), node_overview_types(), node_revision_overview(), openid_user_identities(), path_admin_overview(), poll_votes(), statistics_node_tracker(), statistics_recent_hits(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), statistics_user_tracker(), system_actions_manage(), tablesort_cell(), tablesort_get_order(), tablesort_get_sort(), tablesort_init(), tablesort_sql(), template_preprocess_forum_topic_list(), theme_book_admin_table(), theme_filter_admin_order(), theme_filter_admin_overview(), theme_locale_languages_overview_form(), theme_menu_overview_form(), theme_node_admin_nodes(), theme_node_search_admin(), theme_profile_admin_overview(), theme_system_modules(), theme_system_modules_uninstall(), theme_system_theme_select_form(), theme_system_themes_form(), theme_table(), theme_taxonomy_overview_terms(), theme_taxonomy_overview_vocabularies(), theme_trigger_display(), theme_update_report(), theme_upload_attachments(), theme_upload_form_current(), theme_user_admin_account(), theme_user_admin_new_role(), theme_user_admin_perm(), tracker_page(), translation_node_overview(), user_admin_access(), and user_admin_account().

print $topic_id

Definition at line 36 of file forum-topic-list.tpl.php.

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forum-topic-navigation.tpl.php File Reference

modules » forum

forum-topic-navigation.tpl.php File Reference

Detailed Description

Default theme implementation to display the topic navigation string at the bottom of all forum topics.

Available variables:

  • $prev: The node ID of the previous post.
  • $prev_url: The URL of the previous post.
  • $prev_title: The title of the previous post.

  • $next: The node ID of the next post.
  • $next_url: The URL of the next post.
  • $next_title: The title of the next post.

  • $node: The raw node currently being viewed. Contains unsafe data and any data in this must be cleaned before presenting.

See also:
template_preprocess_forum_topic_navigation()

theme_forum_topic_navigation()

Definition in file forum-topic-navigation.tpl.php.

Go to the source code of this file.

Variables

  • endif

Variable Documentation

endif

Definition at line 35 of file forum-topic-navigation.tpl.php.

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forum.admin.inc File Reference

modules » forum

forum.admin.inc File Reference

Detailed Description

Administrative page callbacks for the forum module.

Definition in file forum.admin.inc.

Go to the source code of this file.

Functions

  • _forum_parent_select ($tid, $title, $child_type)
    Returns a select box for available parent terms.
  • forum_admin_settings ()
    Form builder for the forum settings page.
  • forum_confirm_delete (&$form_state, $tid)
    Returns a confirmation page for deleting a forum taxonomy term.
  • forum_confirm_delete_submit ($form, &$form_state)
    Implementation of forms api _submit call.
  • forum_form_container (&$form_state, $edit=array())
    Returns a form for adding a container to the forum vocabulary.
  • forum_form_forum (&$form_state, $edit=array())
    Returns a form for adding a forum to the forum vocabulary.
  • forum_form_main ($type, $edit=array())
  • forum_form_submit ($form, &$form_state)
    Process forum form and container form submissions.
  • forum_overview (&$form_state)
    Returns an overview list of existing forums and containers.

Function Documentation

_forum_parent_select | ( | $ | tid,
 |  | $ | title,
 |  | $ | child_type
 | ) |  |

Returns a select box for available parent terms.

Parameters:
$tid | ID of the term which is being added or edited
$title | Title to display the select box with
$child_type | Whether the child is forum or container

Definition at line 256 of file forum.admin.inc.

References $children, $title, t(), taxonomy_get_parents(), taxonomy_get_tree(), and variable_get().

Referenced by forum_form_container(), and forum_form_forum().

forum_admin_settings ( )

Form builder for the forum settings page.

See also:
system_settings_form()

Definition at line 188 of file forum.admin.inc.

References drupal_map_assoc(), system_settings_form(), t(), and variable_get().

forum_confirm_delete | ( | &$ | form_state,
 |  | $ | tid
 | ) |  |

Returns a confirmation page for deleting a forum taxonomy term.

Parameters:
$tid ID of the term to be deleted

Definition at line 162 of file forum.admin.inc.

References confirm_form(), name, t(), taxonomy_get_term(), and url().

forum_confirm_delete_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Implementation of forms api _submit call.

Deletes a forum after confirmation.

Definition at line 174 of file forum.admin.inc.

References drupal_set_message(), t(), taxonomy_del_term(), and watchdog().

forum_form_main | ( | $ | type,
 |  | $ | edit = array()
 | ) |  |

Definition at line 9 of file forum.admin.inc.

References $type, drupal_get_form(), and t().

forum_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process forum form and container form submissions.

Definition at line 72 of file forum.admin.inc.

References $status, $type, drupal_set_message(), t(), taxonomy_save_term(), variable_get(), and variable_set().

forum_overview ( &$ form_state )

Returns an overview list of existing forums and containers.

Definition at line 217 of file forum.admin.inc.

References drupal_set_title(), element_children(), l(), module_load_include(), t(), taxonomy_overview_terms(), taxonomy_vocabulary_load(), url(), and variable_get().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forum.install File Reference

modules » forum

forum.install File Reference

Go to the source code of this file.

Functions

  • forum_enable ()
  • forum_install ()
    Implementation of hook_install().
  • forum_schema ()
    Implementation of hook_schema().
  • forum_uninstall ()
    Implementation of hook_uninstall().
  • forum_update_6000 ()
    Create the forum vocabulary if does not exist.

Function Documentation

forum_enable ( )

Definition at line 14 of file forum.install.

References t(), taxonomy_save_vocabulary(), taxonomy_vocabulary_load(), variable_get(), and variable_set().

forum_install ( )

Implementation of hook_install().

Definition at line 7 of file forum.install.

References db_query(), and drupal_install_schema().

forum_schema ( )

Implementation of hook_schema().

Definition at line 67 of file forum.install.

References t().

forum_uninstall ( )

Implementation of hook_uninstall().

Definition at line 45 of file forum.install.

References db_query(), drupal_load(), taxonomy_del_vocabulary(), variable_del(), and variable_get().

forum_update_6000 ( )

Create the forum vocabulary if does not exist.

Assign the vocabulary a low weight so it will appear first in forum topic create and edit forms. Do not just call forum_enable() because in future versions it might do something different.

Definition at line 109 of file forum.install.

References t(), taxonomy_get_vocabularies(), taxonomy_save_vocabulary(), variable_get(), and variable_set().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forum.module File Reference

modules » forum

forum.module File Reference

Detailed Description

Enable threaded discussions about general topics.

Definition in file forum.module.

Go to the source code of this file.

Functions

  • _forum_get_topic_order ($sortby)
  • _forum_get_topic_order_sql ($sortby)
  • _forum_new ($tid)
    Finds the first unread node for a given forum.
  • _forum_topics_unread ($term, $uid)
    Calculate the number of nodes the user has not yet read and are newer than NODE_NEW_LIMIT.
  • _forum_user_last_visit ($nid)
  • forum_access ($op, $node, $account)
    Implementation of hook_access().
  • forum_block ($op= 'list', $delta=0, $edit=array())
    Implementation of hook_block().
  • forum_form (&$node, $form_state)
    Implementation of hook_form().
  • forum_form_alter (&$form, $form_state, $form_id)
    Implementation of hook_form_alter().
  • forum_get_forums ($tid=0)
    Returns a list of all forums for a given taxonomy id.
  • forum_get_topics ($tid, $sortby, $forum_per_page)
  • forum_help ($path, $arg)
    Implementation of hook_help().
  • forum_init ()
    Implementation of hook_init().
  • forum_link_alter (&$links, $node)
  • forum_load ($node)
    Implementation of hook_load().
  • forum_menu ()
    Implementation of hook_menu().
  • forum_node_info ()
    Implementation of hook_node_info().
  • forum_nodeapi (&$node, $op, $teaser, $page)
    Implementation of hook_nodeapi().
  • forum_perm ()
    Implementation of hook_perm().
  • forum_taxonomy ($op, $type, $term=NULL)
    Implementation of hook_taxonomy().
  • forum_term_load ($tid)
    Fetch a forum term.
  • forum_theme ()
    Implementation of hook_theme().
  • template_preprocess_forum_icon (&$variables)
    Process variables to format the icon for each individual topic.
  • template_preprocess_forum_list (&$variables)
    Process variables to format a forum listing.
  • template_preprocess_forum_submitted (&$variables)
    Process variables to format submission info for display in the forum list and topic list.
  • template_preprocess_forum_topic_list (&$variables)
    Preprocess variables to format the topic listing.
  • template_preprocess_forum_topic_navigation (&$variables)
    Preprocess variables to format the next/previous forum topic navigation links.
  • template_preprocess_forums (&$variables)
    Process variables for forums.tpl.php.

Function Documentation

_forum_get_topic_order ( $ sortby )

Definition at line 933 of file forum.module.

Referenced by _forum_get_topic_order_sql(), and forum_get_topics().

_forum_get_topic_order_sql ( $ sortby )

Definition at line 950 of file forum.module.

References _forum_get_topic_order().

Referenced by template_preprocess_forum_topic_navigation().

_forum_new ( $ tid )

Finds the first unread node for a given forum.

Definition at line 618 of file forum.module.

References $nid, $user, db_query_range(), db_result(), and db_rewrite_sql().

_forum_topics_unread | ( | $ | term,
 |  | $ | uid
 | ) |  |

Calculate the number of nodes the user has not yet read and are newer than NODE_NEW_LIMIT.

Definition at line 550 of file forum.module.

References db_query(), db_result(), and db_rewrite_sql().

Referenced by template_preprocess_forum_list().

_forum_user_last_visit ( $ nid )

Definition at line 920 of file forum.module.

References $nid, $result, $user, db_fetch_object(), and db_query().

Referenced by forum_get_topics().

forum_access | ( | $ | op,
 |  | $ | node,
 |  | $ | account
 | ) |  |

Implementation of hook_access().

Definition at line 307 of file forum.module.

References $op, and user_access().

forum_block | ( | $ | op = 'list',
 |  | $ | delta = 0,
 |  | $ | edit = array()
 | ) |  |

Implementation of hook_block().

Generates a block containing the currently active forum topics and the most recently added forum topics.

Definition at line 400 of file forum.module.

References $content, $op, $result, $title, db_query_range(), db_rewrite_sql(), drupal_map_assoc(), node_title_list(), t(), theme(), url(), user_access(), variable_get(), and variable_set().

forum_form | ( | &$ | node,
 |  | $ | form_state
 | ) |  |

Implementation of hook_form().

Definition at line 445 of file forum.module.

References $type, check_plain(), nid, node_body_field(), node_get_types(), t(), taxonomy_node_get_terms_by_vocabulary(), and variable_get().

forum_form_alter | ( | &$ | form,
 |  | $ | form_state,
 |  | $ | form_id
 | ) |  |

Implementation of hook_form_alter().

Definition at line 355 of file forum.module.

References t(), and variable_get().

forum_get_forums ( $ tid = 0 )

Returns a list of all forums for a given taxonomy id.

Forum objects contain the following fields -num_topics Number of topics in the forum -num_posts Total number of posts in all topics -last_post Most recent post for the forum

Parameters:
$tid Taxonomy ID of the vocabulary that holds the forum list.
Returns:
Array of object containing the forum information.

Definition at line 493 of file forum.module.

References $forums, db_fetch_object(), db_query(), db_query_range(), db_rewrite_sql(), taxonomy_get_tree(), and variable_get().

Referenced by forum_page().

forum_get_topics | ( | $ | tid,
 |  | $ | sortby,
 |  | $ | forum_per_page
 | ) |  |

Definition at line 556 of file forum.module.

References $forum_topic_list_header, $result, $topics, $user, _forum_get_topic_order(), _forum_user_last_visit(), comment_num_new(), db_fetch_object(), db_rewrite_sql(), nid, pager_query(), t(), tablesort_sql(), and taxonomy_get_term().

Referenced by forum_page().

forum_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 12 of file forum.module.

References $output, t(), url(), and variable_get().

forum_init ( )

Implementation of hook_init().

Definition at line 156 of file forum.module.

References drupal_add_css(), and drupal_get_path().

forum_link_alter | ( | &$ | links,
 |  | $ | node
 | ) |  |

Definition at line 465 of file forum.module.

References $links, taxonomy_get_term(), and variable_get().

forum_load ( $ node )

Implementation of hook_load().

Definition at line 388 of file forum.module.

References db_fetch_object(), and db_query().

forum_menu ( )

Implementation of hook_menu().

Definition at line 84 of file forum.module.

References $items.

forum_node_info ( )

Implementation of hook_node_info().

Definition at line 293 of file forum.module.

References t().

forum_nodeapi | ( | &$ | node,
 |  | $ | op,
 |  | $ | teaser,
 |  | $ | page
 | ) |  |

Implementation of hook_nodeapi().

Definition at line 163 of file forum.module.

References $op, arg(), db_fetch_array(), db_query(), db_query_range(), db_result(), drupal_set_breadcrumb(), form_set_error(), l(), name, nid, t(), taxonomy_get_parents_all(), taxonomy_get_term(), taxonomy_get_tree(), taxonomy_node_get_terms_by_vocabulary(), taxonomy_vocabulary_load(), theme(), and variable_get().

forum_perm ( )

Implementation of hook_perm().

Definition at line 321 of file forum.module.

forum_taxonomy | ( | $ | op,
 |  | $ | type,
 |  | $ | term = NULL
 | ) |  |

Implementation of hook_taxonomy().

Definition at line 328 of file forum.module.

References $op, $results, $type, db_fetch_object(), db_query(), nid, node_delete(), variable_del(), variable_get(), and variable_set().

forum_term_load ( $ tid )

Fetch a forum term.

Parameters:
$tid The ID of the term which should be loaded.
Returns:
An associative array containing the term data or FALSE if the term cannot be loaded, or is not part of the forum vocabulary.

Definition at line 76 of file forum.module.

References $result, db_fetch_array(), db_query(), db_rewrite_sql(), and variable_get().

forum_theme ( )

Implementation of hook_theme().

Definition at line 38 of file forum.module.

template_preprocess_forum_icon ( &$ variables )

Process variables to format the icon for each individual topic.

$variables contains the following data:

  • $new_posts
  • $num_posts = 0
  • $comment_mode = 0
  • $sticky = 0

See also:
forum-icon.tpl.php

theme_forum_icon()

Definition at line 854 of file forum.module.

References variable_get().

template_preprocess_forum_list ( &$ variables )

Process variables to format a forum listing.

$variables contains the following information:

  • $forums
  • $parents
  • $tid

See also:
forum-list.tpl.php

theme_forum_list()

Definition at line 744 of file forum.module.

References $id, $row, $user, _forum_topics_unread(), check_plain(), filter_xss_admin(), format_plural(), name, theme(), and url().

template_preprocess_forum_submitted ( &$ variables )

Process variables to format submission info for display in the forum list and topic list.

$variables will contain: $topic

See also:
forum-submitted.tpl.php

theme_forum_submitted()

Definition at line 915 of file forum.module.

References format_interval(), and theme().

template_preprocess_forum_topic_list ( &$ variables )

Preprocess variables to format the topic listing.

$variables contains the following data:

  • $tid
  • $topics
  • $sortby
  • $forum_per_page

See also:
forum-topic-list.tpl.php

theme_forum_topic_list()

Definition at line 787 of file forum.module.

References $forum_topic_list_header, $header, $id, $row, _theme_table_cell(), check_plain(), comment_new_page_count(), format_plural(), l(), t(), tablesort_header(), tablesort_init(), theme(), and url().

template_preprocess_forum_topic_navigation ( &$ variables )

Preprocess variables to format the next/previous forum topic navigation links.

$variables contains $node.

See also:
forum-topic-navigation.tpl.php

theme_forum_topic_navigation()

Definition at line 880 of file forum.module.

References $output, $result, _forum_get_topic_order_sql(), check_plain(), db_fetch_object(), db_query(), db_rewrite_sql(), nid, url(), and variable_get().

template_preprocess_forums ( &$ variables )

Process variables for forums.tpl.php.

The $variables array contains the following arguments:

  • $forums
  • $topics
  • $parents
  • $tid
  • $sortby
  • $forum_per_page

See also:
forums.tpl.php

Definition at line 641 of file forum.module.

References $title, $type, $user, check_plain(), drupal_add_feed(), drupal_get_destination(), drupal_set_breadcrumb(), drupal_set_title(), l(), name, node_access(), node_get_types(), t(), taxonomy_vocabulary_load(), theme(), url(), and variable_get().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forum.pages.inc File Reference

modules » forum

forum.pages.inc File Reference

Detailed Description

User page callbacks for the forum module.

Definition in file forum.pages.inc.

Go to the source code of this file.

Functions

  • forum_page ($tid=0)
    Menu callback; prints a forum listing.

Function Documentation

forum_page ( $ tid = 0 )

Menu callback; prints a forum listing.

Definition at line 12 of file forum.pages.inc.

References $forums, $topics, forum_get_forums(), forum_get_topics(), taxonomy_get_parents_all(), theme(), and variable_get().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forums.tpl.php File Reference

modules » forum

forums.tpl.php File Reference

Detailed Description

Default theme implementation to display a forum which may contain forum containers as well as forum topics.

Variables available:

  • $links: An array of links that allow a user to post new forum topics. It may also contain a string telling a user they must log in in order to post.
  • $forums: The forums to display (as processed by forum-list.tpl.php)
  • $topics: The topics to display (as processed by forum-topic-list.tpl.php)
  • $forums_defined: A flag to indicate that the forums are configured.

See also:
template_preprocess_forums()

theme_forums()

Definition in file forums.tpl.php.

Go to the source code of this file.

Variables

  • print $forums
  • print $topics
  • endif

Variable Documentation

print $forums

Definition at line 24 of file forums.tpl.php.

Referenced by forum_get_forums(), and forum_page().

print $topics

Definition at line 25 of file forums.tpl.php.

Referenced by forum_get_topics(), and forum_page().

endif

Definition at line 27 of file forums.tpl.php.

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/help/help.admin.inc File Reference

modules » help

help.admin.inc File Reference

Detailed Description

Admin page callbacks for the help module.

Definition in file help.admin.inc.

Go to the source code of this file.

Functions

  • help_links_as_list ()
  • help_main ()
    Menu callback; prints a page listing a glossary of Drupal terminology.
  • help_page ($name)
    Menu callback; prints a page listing general help for a module.

Function Documentation

help_links_as_list ( )

Definition at line 48 of file help.admin.inc.

References $name, $output, drupal_help_arg(), l(), module_implements(), module_invoke(), and module_rebuild_cache().

Referenced by help_main().

help_main ( )

Menu callback; prints a page listing a glossary of Drupal terminology.

Definition at line 12 of file help.admin.inc.

References $output, drupal_add_css(), drupal_get_path(), help_links_as_list(), and t().

help_page ( $ name )

Menu callback; prints a page listing general help for a module.

Definition at line 22 of file help.admin.inc.

References $name, $output, drupal_get_path(), drupal_help_arg(), drupal_parse_info_file(), drupal_set_title(), module_hook(), module_invoke(), system_get_module_admin_tasks(), t(), and theme().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/help/help.module File Reference

modules » help

help.module File Reference

Detailed Description

Manages displaying online help.

Definition in file help.module.

Go to the source code of this file.

Functions

  • help_help ($path, $arg)
    Implementation of hook_help().
  • help_menu ()
    Implementation of hook_menu().

Function Documentation

help_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 37 of file help.module.

References $output, and t().

help_menu ( )

Implementation of hook_menu().

Definition at line 12 of file help.module.

References $items, and module_implements().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/locale/locale.install File Reference

modules » locale

locale.install File Reference

Go to the source code of this file.

Functions

  • locale_install ()
    Implementation of hook_install().
  • locale_schema ()
    Implementation of hook_schema().
  • locale_uninstall ()
    End of "addtogroup updates_5x_to_6x".
  • locale_update_6000 ()
    {locales_meta} table became {languages}.
  • locale_update_6001 ()
    Change locale column to language.
  • locale_update_6002 ()
    Remove empty translations, we don't need these anymore.
  • locale_update_6003 ()
    Prune strings with no translations (will be automatically re-registered if still in use).
  • locale_update_6004 ()
    Fix remaining inconsistent indexes.
  • locale_update_6005 ()
    Change language setting variable of content types.

Function Documentation

locale_install ( )

Implementation of hook_install().

Definition at line 7 of file locale.install.

References db_query(), and drupal_install_schema().

locale_schema ( )

Implementation of hook_schema().

Definition at line 227 of file locale.install.

References t().

locale_uninstall ( )

End of "addtogroup updates_5x_to_6x".

Implementation of hook_uninstall().

Definition at line 211 of file locale.install.

References db_fetch_object(), db_query(), drupal_uninstall_schema(), file_create_path(), and file_delete().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/locale/locale.module File Reference

modules » locale

locale.module File Reference

Detailed Description

Add language handling functionality and enables the translation of the user interface to languages other than English.

When enabled, multiple languages can be set up. The site interface can be displayed in different languages, as well as nodes can have languages assigned. The setup of languages and translations is completely web based. Gettext portable object files are supported.

Definition in file locale.module.

Go to the source code of this file.

Enumerations

  • enum LANGUAGE_LTR
    Language written left to right. More...
  • enum LANGUAGE_RTL
    Language written right to left. More...

Functions

  • locale ($string=NULL, $langcode=NULL, $reset=FALSE)
    Provides interface translation services.
  • locale_block ($op= 'list', $delta=0)
    Implementation of hook_block().
  • locale_form_alter (&$form, $form_state, $form_id)
    Implementation of hook_form_alter().
  • locale_get_plural ($count, $langcode=NULL)
    Returns plural form index for a specific number.
  • locale_help ($path, $arg)
    Implementation of hook_help().
  • locale_inc_callback ()
    Wrapper function to be able to set callbacks in locale.inc.
  • locale_language_list ($field= 'name', $all=FALSE)
    Returns array of language names.
  • locale_language_name ($lang)
    Returns a language name.
  • locale_locale ($op= 'groups')
    Implementation of hook_locale().
  • locale_menu ()
    Implementation of hook_menu().
  • locale_perm ()
    Implementation of hook_perm().
  • locale_system_update ($components)
    Imports translations when new modules or themes are installed or enabled.
  • locale_theme ()
    Implementation of hook_theme().
  • locale_update_js_files ()
    Update JavaScript translation file, if required, and add it to the page.
  • locale_user ($type, $edit, &$user, $category=NULL)
    Implementation of hook_user().

Enumeration Type Documentation

enum LANGUAGE_LTR

Language written left to right.

Possible value of $language->direction.

Definition at line 18 of file locale.module.

enum LANGUAGE_RTL

Language written right to left.

Possible value of $language->direction.

Definition at line 23 of file locale.module.

Function Documentation

locale | ( | $ | string = NULL,
 |  | $ | langcode = NULL,
 |  | $ | reset = FALSE
 | ) |  |

Provides interface translation services.

This function is called from t() to translate a string if needed.

Parameters:
$string | A string to look up translation for. If omitted, all the cached strings will be returned in all languages already used on the page.
$langcode | Language code to use for the lookup.
$reset | Set to TRUE to reset the in-memory cache.

Definition at line 323 of file locale.module.

References $language, $result, cache_clear_all(), cache_get(), cache_set(), db_fetch_object(), db_query(), request_uri(), and variable_get().

Referenced by locale_update_6000(), and t().

locale_block | ( | $ | op = 'list',
 |  | $ | delta = 0
 | ) |  |

Implementation of hook_block().

Displays a language switcher. Translation links may be provided by other modules.

Definition at line 556 of file locale.module.

References $language, $links, $op, drupal_alter(), language_list(), t(), theme(), and variable_get().

locale_form_alter | ( | &$ | form,
 |  | $ | form_state,
 |  | $ | form_id
 | ) |  |

Implementation of hook_form_alter().

Adds language fields to forms.

Definition at line 244 of file locale.module.

References language, language_default(), locale_language_list(), nid, t(), url(), and variable_get().

locale_get_plural | ( | $ | count,
 |  | $ | langcode = NULL
 | ) |  |

Returns plural form index for a specific number.

The index is computed from the formula of this language.

Parameters:
$count | Number to return plural for.
$langcode | Optional language code to translate to a language other than what is used to display the page.

Definition at line 404 of file locale.module.

References $language, and language_list().

Referenced by format_plural().

locale_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 32 of file locale.module.

References $output, t(), and url().

locale_inc_callback ( )

Wrapper function to be able to set callbacks in locale.inc.

Definition at line 178 of file locale.module.

Referenced by locale_update_js_files().

locale_language_list | ( | $ | field = 'name',
 |  | $ | all = FALSE
 | ) |  |

Returns array of language names.

Parameters:
$field | 'name' => names in current language, localized 'native' => native names
$all | Boolean to return all languages or only enabled ones

Definition at line 449 of file locale.module.

References $language, language_list(), name, and t().

Referenced by locale_form_alter(), locale_language_name(), locale_translate_export_screen(), locale_translate_import_form(), and locale_translate_seek_form().

locale_language_name ( $ lang )

Returns a language name.

Definition at line 432 of file locale.module.

References locale_language_list(), and t().

locale_locale ( $ op = 'groups' )

Implementation of hook_locale().

Definition at line 195 of file locale.module.

References $op, and t().

locale_menu ( )

Implementation of hook_menu().

Locale module only provides administrative menu items, so all menu items are invoked through locale_inc_callback().

Definition at line 84 of file locale.module.

References $items.

locale_perm ( )

Implementation of hook_perm().

Definition at line 188 of file locale.module.

locale_system_update ( $ components )

Imports translations when new modules or themes are installed or enabled.

This function will either import translation for the component change right away, or start a batch if more files need to be imported.

Parameters:
$components An array of component (theme and/or module) names to import translations for.

Definition at line 474 of file locale.module.

References batch_set(), and locale_batch_by_component().

locale_theme ( )

Implementation of hook_theme().

Definition at line 298 of file locale.module.

locale_update_js_files ( )

Update JavaScript translation file, if required, and add it to the page.

This function checks all JavaScript files currently added via drupal_add_js() and invokes parsing if they have not yet been parsed for Drupal.t() and Drupal.formatPlural() calls. Also refreshes the JavaScript translation file if necessary, and adds it to the page.

Definition at line 489 of file locale.module.

References $language, $type, drupal_add_js(), file_create_path(), language, locale_inc_callback(), variable_get(), variable_set(), and watchdog().

Referenced by drupal_get_js().

locale_user | ( | $ | type,
 |  | $ | edit,
 |  | &$ | user,
 |  | $ | category = NULL
 | ) |  |

Implementation of hook_user().

Definition at line 205 of file locale.module.

References $item, $language, $name, $type, $user, language, language_list(), name, t(), user_access(), user_preferred_language(), and variable_get().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/menu/menu.admin.inc File Reference

modules » menu

menu.admin.inc File Reference

Detailed Description

Administrative page callbaks for menu module.

Definition in file menu.admin.inc.

Go to the source code of this file.

Functions

  • _menu_overview_tree_form ($tree)
    Recursive helper function for menu_overview_form().
  • menu_configure ()
    Menu callback; Build the form presenting menu configuration options.
  • menu_custom_delete_submit ($form, &$form_state)
    Submit function for the 'Delete' button on the menu editing form.
  • menu_delete_menu_confirm (&$form_state, $menu)
    Build a confirm form for deletion of a custom menu.
  • menu_delete_menu_confirm_submit ($form, &$form_state)
    Delete a custom menu and all items in it.
  • menu_delete_menu_page ($menu)
    Menu callback; check access and get a confirm form for deletion of a custom menu.
  • menu_edit_item (&$form_state, $type, $item, $menu)
    Menu callback; Build the menu link editing form.
  • menu_edit_item_submit ($form, &$form_state)
    Process menu and menu item add/edit form submissions.
  • menu_edit_item_validate ($form, &$form_state)
    Validate form values for a menu link being added or edited.
  • menu_edit_menu (&$form_state, $type, $menu=array())
    Menu callback; Build the form that handles the adding/editing of a custom menu.
  • menu_edit_menu_submit ($form, &$form_state)
    Submit function for adding or editing a custom menu.
  • menu_edit_menu_validate ($form, &$form_state)
    Validates the human and machine-readable names when adding or editing a menu.
  • menu_item_delete_form (&$form_state, $item)
    Build a confirm form for deletion of a single menu link.
  • menu_item_delete_form_submit ($form, &$form_state)
    Process menu delete form submissions.
  • menu_item_delete_page ($item)
    Menu callback; Check access and present a confirm form for deleting a menu link.
  • menu_item_delete_submit ($form, &$form_state)
    Submit function for the delete button on the menu item editing form.
  • menu_overview_form (&$form_state, $menu)
    Form for editing an entire menu tree at once.
  • menu_overview_form_submit ($form, &$form_state)
    Submit handler for the menu overview form.
  • menu_overview_page ()
    Menu callback which shows an overview page of all the custom menus and their descriptions.
  • menu_reset_item_confirm (&$form_state, $item)
    Menu callback; reset a single modified item.
  • menu_reset_item_confirm_submit ($form, &$form_state)
    Process menu reset item form submissions.
  • theme_menu_overview_form ($form)
    Theme the menu overview form into a table.

Function Documentation

_menu_overview_tree_form ( $ tree )

Recursive helper function for menu_overview_form().

Definition at line 62 of file menu.admin.inc.

References $item, $op, $title, $value, l(), and t().

Referenced by menu_overview_form().

menu_configure ( )

Menu callback; Build the form presenting menu configuration options.

Definition at line 600 of file menu.admin.inc.

References menu_get_menus(), system_settings_form(), t(), and variable_get().

menu_custom_delete_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit function for the 'Delete' button on the menu editing form.

Definition at line 433 of file menu.admin.inc.

menu_delete_menu_confirm | ( | &$ | form_state,
 |  | $ | menu
 | ) |  |

Build a confirm form for deletion of a custom menu.

Definition at line 452 of file menu.admin.inc.

References confirm_form(), db_query(), db_result(), format_plural(), and t().

menu_delete_menu_confirm_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Delete a custom menu and all items in it.

Definition at line 466 of file menu.admin.inc.

References $item, $result, cache_clear_all(), db_fetch_array(), db_query(), db_result(), drupal_set_message(), menu_cache_clear_all(), menu_link_delete(), menu_list_system_menus(), menu_reset_item(), t(), and watchdog().

menu_delete_menu_page ( $ menu )

Menu callback; check access and get a confirm form for deletion of a custom menu.

Definition at line 440 of file menu.admin.inc.

References drupal_access_denied(), drupal_get_form(), and menu_list_system_menus().

menu_edit_item | ( | &$ | form_state,
 |  | $ | type,
 |  | $ | item,
 |  | $ | menu
 | ) |  |

Menu callback; Build the menu link editing form.

Definition at line 226 of file menu.admin.inc.

References $item, $type, l(), menu_get_menus(), menu_parent_options(), and t().

menu_edit_item_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process menu and menu item add/edit form submissions.

Definition at line 368 of file menu.admin.inc.

References $item, drupal_set_message(), menu_link_save(), and t().

menu_edit_item_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate form values for a menu link being added or edited.

Definition at line 334 of file menu.admin.inc.

References $item, drupal_get_normal_path(), drupal_set_message(), form_set_error(), menu_path_is_external(), menu_valid_path(), and t().

menu_edit_menu | ( | &$ | form_state,
 |  | $ | type,
 |  | $ | menu = array()
 | ) |  |

Menu callback; Build the form that handles the adding/editing of a custom menu.

Definition at line 387 of file menu.admin.inc.

References $type, menu_list_system_menus(), and t().

menu_edit_menu_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit function for adding or editing a custom menu.

Definition at line 520 of file menu.admin.inc.

References $result, db_fetch_array(), db_query(), db_result(), menu_link_load(), and menu_link_save().

menu_edit_menu_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validates the human and machine-readable names when adding or editing a menu.

Definition at line 499 of file menu.admin.inc.

References $item, db_query(), db_query_range(), db_result(), form_set_error(), format_plural(), and t().

menu_item_delete_form | ( | &$ | form_state,
 |  | $ | item
 | ) |  |

Build a confirm form for deletion of a single menu link.

Definition at line 562 of file menu.admin.inc.

References $item, confirm_form(), and t().

menu_item_delete_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process menu delete form submissions.

Definition at line 570 of file menu.admin.inc.

References $item, drupal_set_message(), menu_link_delete(), t(), and watchdog().

menu_item_delete_page ( $ item )

Menu callback; Check access and present a confirm form for deleting a menu link.

Definition at line 549 of file menu.admin.inc.

References $item, drupal_access_denied(), and drupal_get_form().

menu_item_delete_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit function for the delete button on the menu item editing form.

Definition at line 361 of file menu.admin.inc.

menu_overview_form | ( | &$ | form_state,
 |  | $ | menu
 | ) |  |

Form for editing an entire menu tree at once.

Shows for one menu the menu items accessible to the current user and relevant operations.

Definition at line 29 of file menu.admin.inc.

References $menu_admin, $result, _menu_overview_tree_form(), db_query(), element_children(), menu_tree_check_access(), menu_tree_collect_node_links(), menu_tree_data(), and t().

menu_overview_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit handler for the menu overview form.

This function takes great care in saving parent items first, then items underneath them. Saving items in the incorrect order can break the menu tree.

See also:
menu_overview_form()

Definition at line 128 of file menu.admin.inc.

References $element, $item, element_children(), and menu_link_save().

menu_overview_page ( )

Menu callback which shows an overview page of all the custom menus and their descriptions.

Definition at line 12 of file menu.admin.inc.

References $content, $result, db_fetch_array(), db_query(), and theme().

menu_reset_item_confirm | ( | &$ | form_state,
 |  | $ | item
 | ) |  |

Menu callback; reset a single modified item.

Definition at line 582 of file menu.admin.inc.

References $item, confirm_form(), and t().

menu_reset_item_confirm_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process menu reset item form submissions.

Definition at line 590 of file menu.admin.inc.

References $item, drupal_set_message(), menu_reset_item(), and t().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/menu/menu.install File Reference

modules » menu

menu.install File Reference

Go to the source code of this file.

Functions

  • menu_install ()
    Implementation of hook_install().
  • menu_schema ()
    Implementation of hook_schema().
  • menu_uninstall ()
    Implementation of hook_uninstall().

Function Documentation

menu_install ( )

Implementation of hook_install().

Definition at line 7 of file menu.install.

References db_query(), drupal_install_schema(), and get_t().

menu_schema ( )

Implementation of hook_schema().

Definition at line 29 of file menu.install.

References t().

menu_uninstall ( )

Implementation of hook_uninstall().

Definition at line 20 of file menu.install.

References drupal_uninstall_schema(), and menu_rebuild().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/menu/menu.module File Reference

modules » menu

menu.module File Reference

Detailed Description

Allows administrators to customize the site navigation menu.

Definition in file menu.module.

Go to the source code of this file.

Enumerations

  • enum MENU_MAX_MENU_NAME_LENGTH_UI
    Maximum length of menu name as entered by the user. More...

Functions

  • _menu_parent_depth_limit ($item)
    Find the depth limit for items in the parent select.
  • _menu_parents_recurse ($tree, $menu_name, $indent, &$options, $exclude, $depth_limit)
    Recursive helper function for menu_parent_options().
  • menu_block ($op= 'list', $delta=0)
    Implementation of hook_block().
  • menu_enable ()
    Implementation of hook_enable().
  • menu_form_alter (&$form, $form_state, $form_id)
    Implementation of hook_form_alter().
  • menu_get_menus ($all=TRUE)
    Return an associative array of the custom menus names.
  • menu_help ($path, $arg)
    Implementation of hook_help().
  • menu_load ($menu_name)
    Load the data for a single custom menu.
  • menu_menu ()
    Implementation of hook_menu().
  • menu_node_form_submit ($form, &$form_state)
    Decompose the selected menu parent option into the menu_name and plid.
  • menu_nodeapi (&$node, $op)
    Implementation of hook_nodeapi().
  • menu_overview_title ($menu)
    Title callback for the menu overview page and links.
  • menu_parent_options ($menus, $item)
    Return a list of menu items that are valid possible parents for the given menu item.
  • menu_perm ()
    Implementation of hook_perm().
  • menu_reset_item ($item)
    Reset a system-defined menu item.
  • menu_theme ()
    Implemenation of hook_theme().

Enumeration Type Documentation

enum MENU_MAX_MENU_NAME_LENGTH_UI

Maximum length of menu name as entered by the user.

Database length is 32 and we add a menu- prefix.

Definition at line 13 of file menu.module.

Function Documentation

_menu_parent_depth_limit ( $ item )

Find the depth limit for items in the parent select.

Definition at line 344 of file menu.module.

References $item, and menu_link_children_relative_depth().

Referenced by menu_nodeapi(), and menu_parent_options().

_menu_parents_recurse | ( | $ | tree,
 |  | $ | menu_name,
 |  | $ | indent,
 |  | &$ | options,
 |  | $ | exclude,
 |  | $ | depth_limit
 | ) |  |

Recursive helper function for menu_parent_options().

Definition at line 226 of file menu.module.

References $title, t(), and truncate_utf8().

Referenced by menu_parent_options().

menu_block | ( | $ | op = 'list',
 |  | $ | delta = 0
 | ) |  |

Implementation of hook_block().

Definition at line 261 of file menu.module.

References $name, $op, $title, check_plain(), menu_get_menus(), and menu_tree().

menu_enable ( )

Implementation of hook_enable().

Add a link for each custom menu.

Definition at line 156 of file menu.module.

References $result, db_fetch_array(), db_query(), db_result(), menu_cache_clear_all(), menu_link_save(), and menu_rebuild().

Referenced by system_update_6021().

menu_form_alter | ( | &$ | form,
 |  | $ | form_state,
 |  | $ | form_id
 | ) |  |

Implementation of hook_form_alter().

Adds menu item fields to the node form.

Definition at line 351 of file menu.module.

References $item, menu_get_menus(), menu_parent_options(), t(), and user_access().

menu_get_menus ( $ all = TRUE )

Return an associative array of the custom menus names.

Parameters:
$all If FALSE return only user-added menus, or if TRUE also include the menus defined by the system.
Returns:
An array with the machine-readable names as the keys, and human-readable titles as the values.

Definition at line 433 of file menu.module.

References $result, db_fetch_array(), db_query(), and menu_list_system_menus().

Referenced by menu_block(), menu_configure(), menu_edit_item(), and menu_form_alter().

menu_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 18 of file menu.module.

References $output, t(), and url().

menu_load ( $ menu_name )

Load the data for a single custom menu.

Definition at line 183 of file menu.module.

References db_fetch_array(), and db_query().

menu_menu ( )

Implementation of hook_menu().

Definition at line 46 of file menu.module.

References $items.

menu_node_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Decompose the selected menu parent option into the menu_name and plid.

Definition at line 419 of file menu.module.

menu_nodeapi | ( | &$ | node,
 |  | $ | op
 | ) |  |

Implementation of hook_nodeapi().

Definition at line 286 of file menu.module.

References $item, $op, $result, _menu_parent_depth_limit(), db_fetch_array(), db_query(), db_query_range(), db_result(), drupal_set_message(), menu_link_delete(), menu_link_load(), menu_link_save(), nid, t(), and variable_get().

menu_overview_title ( $ menu )

Title callback for the menu overview page and links.

Definition at line 176 of file menu.module.

menu_parent_options | ( | $ | menus,
 |  | $ | item
 | ) |  |

Return a list of menu items that are valid possible parents for the given menu item.

Parameters:
$menus | An array of menu names and titles, such as from menu_get_menus().
$item | The menu item for which to generate a list of parents. If $item['mlid'] == 0 then the complete tree is returned.
Returns:
An array of menu link titles keyed on the a string containing the menu name and mlid. The list excludes the given item and its children.

Definition at line 199 of file menu.module.

References $item, $title, _menu_parent_depth_limit(), _menu_parents_recurse(), menu_tree_all_data(), and variable_get().

Referenced by menu_edit_item(), and menu_form_alter().

menu_perm ( )

Implementation of hook_perm().

Definition at line 39 of file menu.module.

menu_reset_item ( $ item )

Reset a system-defined menu item.

Definition at line 248 of file menu.module.

References $item, _menu_link_build(), menu_link_save(), and menu_router_build().

Referenced by menu_delete_menu_confirm_submit(), and menu_reset_item_confirm_submit().

menu_theme ( )

Implemenation of hook_theme().

Definition at line 142 of file menu.module.

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/node/content_types.inc File Reference

modules » node

content_types.inc File Reference

Detailed Description

Content type editing UI.

Definition in file content_types.inc.

Go to the source code of this file.

Functions

  • node_node_type ($op, $info)
    Implementation of hook_node_type().
  • node_overview_types ()
    Displays the content type admin overview page.
  • node_type_delete_confirm (&$form_state, $type)
    Menu callback; delete a single content type.
  • node_type_delete_confirm_submit ($form, &$form_state)
    Process content type delete confirm submissions.
  • node_type_form (&$form_state, $type=NULL)
    Generates the node type editing form.
  • node_type_form_submit ($form, &$form_state)
    Implementation of hook_form_submit().
  • node_type_form_validate ($form, &$form_state)
    Implementation of hook_form_validate().
  • node_type_reset (&$type)
    Resets all of the relevant fields of a module-defined node type to their default values.

Function Documentation

node_node_type | ( | $ | op,
 |  | $ | info
 | ) |  |

Implementation of hook_node_type().

Definition at line 345 of file content_types.inc.

References $op, drupal_set_message(), format_plural(), and node_type_update_nodes().

node_overview_types ( )

Displays the content type admin overview page.

Definition at line 12 of file content_types.inc.

References $header, $name, $row, $type, check_plain(), filter_xss_admin(), l(), node_get_types(), node_hook(), t(), and theme().

node_type_delete_confirm | ( | &$ | form_state,
 |  | $ | type
 | ) |  |

Menu callback; delete a single content type.

Definition at line 379 of file content_types.inc.

References $type, confirm_form(), db_query(), db_result(), format_plural(), name, and t().

node_type_delete_confirm_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process content type delete confirm submissions.

Definition at line 399 of file content_types.inc.

References drupal_set_message(), menu_rebuild(), node_type_delete(), node_types_rebuild(), t(), and watchdog().

node_type_form | ( | &$ | form_state,
 |  | $ | type = NULL
 | ) |  |

Generates the node type editing form.

Definition at line 51 of file content_types.inc.

References $type, drupal_map_assoc(), module, name, t(), theme(), and variable_get().

node_type_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Implementation of hook_form_submit().

Definition at line 253 of file content_types.inc.

References $op, $status, $type, $value, drupal_set_message(), l(), menu_rebuild(), name, node_type_reset(), node_type_save(), node_types_rebuild(), t(), variable_del(), variable_set(), and watchdog().

node_type_form_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Implementation of hook_form_validate().

Definition at line 219 of file content_types.inc.

References $type, form_set_error(), name, node_get_types(), and t().

node_type_reset ( &$ type )

Resets all of the relevant fields of a module-defined node type to their default values.

Parameters:
&$type The node type to reset. The node type is passed back by reference with its resetted values. If there is no module-defined info for this node type, then nothing happens.

Definition at line 364 of file content_types.inc.

References $type, $value, _node_type_set_defaults(), and module_invoke_all().

Referenced by node_type_form_submit().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/node/node.admin.inc File Reference

modules » node

node.admin.inc File Reference

Detailed Description

Content administration and module settings UI.

Definition in file node.admin.inc.

Go to the source code of this file.

Functions

  • _node_mass_update_batch_finished ($success, $results, $operations)
    Node Mass Update Batch 'finished' callback.
  • _node_mass_update_batch_process ($nodes, $updates, &$context)
    Node Mass Update Batch operation.
  • _node_mass_update_helper ($nid, $updates)
    Node Mass Update - helper function.
  • node_admin_content ($form_state)
    Menu callback: content administration.
  • node_admin_nodes ()
    Form builder: Builds the node administration overview.
  • node_admin_nodes_submit ($form, &$form_state)
    Process node_admin_nodes form submissions.
  • node_admin_nodes_validate ($form, &$form_state)
    Validate node_admin_nodes form submissions.
  • node_build_filter_query ()
    Build query for node administration filters based on session.
  • node_configure ()
    Menu callback; presents general node configuration options.
  • node_configure_rebuild_confirm ()
    Menu callback: confirm rebuilding of permissions.
  • node_configure_rebuild_confirm_submit ($form, &$form_state)
    Handler for wipe confirmation.
  • node_configure_validate ($form, &$form_state)
    Form validate callback.
  • node_filter_form ()
    Return form for node administration filters.
  • node_filter_form_submit ($form, &$form_state)
    Process result from node administration filter form.
  • node_filters ()
    List node administration filters that can be applied.
  • node_mass_update ($nodes, $updates)
    Make mass update of nodes, changing all nodes in the $nodes array to update them with the field values in $updates.
  • node_multiple_delete_confirm (&$form_state, $nodes)
  • node_multiple_delete_confirm_submit ($form, &$form_state)
  • node_node_operations ()
    Implementation of hook_node_operations().
  • theme_node_admin_nodes ($form)
    Theme node administration overview.
  • theme_node_filter_form ($form)
    Theme node administration filter form.
  • theme_node_filters ($form)
    Theme node administration filter selector.

Function Documentation

_node_mass_update_batch_finished | ( | $ | success,
 |  | $ | results,
 |  | $ | operations
 | ) |  |

Node Mass Update Batch 'finished' callback.

Definition at line 430 of file node.admin.inc.

References $results, drupal_set_message(), format_plural(), t(), and theme().

_node_mass_update_batch_process | ( | $ | nodes,
 |  | $ | updates,
 |  | &$ | context
 | ) |  |

Node Mass Update Batch operation.

Definition at line 399 of file node.admin.inc.

References $nid, _node_mass_update_helper(), l(), and nid.

_node_mass_update_helper | ( | $ | nid,
 |  | $ | updates
 | ) |  |

Node Mass Update - helper function.

Definition at line 387 of file node.admin.inc.

References $name, $nid, $value, node_load(), and node_save().

Referenced by _node_mass_update_batch_process(), and node_mass_update().

node_admin_content ( $ form_state )

Menu callback: content administration.

Definition at line 445 of file node.admin.inc.

References node_admin_nodes(), node_filter_form(), and node_multiple_delete_confirm().

node_admin_nodes ( )

Form builder: Builds the node administration overview.

Definition at line 460 of file node.admin.inc.

References $result, check_plain(), db_fetch_object(), db_query(), db_result(), db_rewrite_sql(), drupal_get_destination(), l(), language, language_list(), module_exists(), module_invoke_all(), name, nid, node_build_filter_query(), node_get_types(), node_mark(), pager_query(), t(), and theme().

Referenced by node_admin_content().

node_admin_nodes_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process node_admin_nodes form submissions.

Execute the chosen 'Update option' on the selected nodes.

Definition at line 530 of file node.admin.inc.

References cache_clear_all(), and module_invoke_all().

node_admin_nodes_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate node_admin_nodes form submissions.

Check if any nodes have been selected to perform the chosen 'Update option' on.

Definition at line 518 of file node.admin.inc.

References form_set_error(), and t().

node_build_filter_query ( )

Build query for node administration filters based on session.

Definition at line 176 of file node.admin.inc.

References $value, and node_filters().

Referenced by node_admin_nodes().

node_configure ( )

Menu callback; presents general node configuration options.

Definition at line 12 of file node.admin.inc.

References $status, db_query(), db_result(), drupal_map_assoc(), module_implements(), system_settings_form(), t(), and variable_get().

node_configure_rebuild_confirm ( )

Menu callback: confirm rebuilding of permissions.

Definition at line 78 of file node.admin.inc.

References confirm_form(), and t().

node_configure_rebuild_confirm_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Handler for wipe confirmation.

Definition at line 86 of file node.admin.inc.

References node_access_rebuild().

node_configure_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Form validate callback.

Definition at line 69 of file node.admin.inc.

References drupal_goto(), and t().

node_filter_form ( )

Return form for node administration filters.

Definition at line 212 of file node.admin.inc.

References $type, $value, drupal_add_js(), module_invoke(), node_filters(), and t().

Referenced by node_admin_content().

node_filter_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process result from node administration filter form.

Definition at line 317 of file node.admin.inc.

References form_options_flatten(), node_filters(), and t().

node_filters ( )

List node administration filters that can be applied.

Definition at line 138 of file node.admin.inc.

References module_exists(), module_invoke(), node_get_types(), and t().

Referenced by node_build_filter_query(), node_filter_form(), and node_filter_form_submit().

node_mass_update | ( | $ | nodes,
 |  | $ | updates
 | ) |  |

Make mass update of nodes, changing all nodes in the $nodes array to update them with the field values in $updates.

IMPORTANT NOTE: This function is intended to work when called from a form submit handler. Calling it outside of the form submission process may not work correctly.

Parameters:
array | $nodes Array of node nids to update.
array | $updates Array of key/value pairs with node field names and the value to update that field to.

Definition at line 356 of file node.admin.inc.

References $nid, _node_mass_update_helper(), batch_set(), drupal_get_path(), drupal_set_message(), and t().

node_multiple_delete_confirm | ( | &$ | form_state,
 |  | $ | nodes
 | ) |  |

Definition at line 603 of file node.admin.inc.

References $nid, $title, $value, check_plain(), confirm_form(), db_query(), db_result(), and t().

Referenced by node_admin_content().

node_multiple_delete_confirm_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 624 of file node.admin.inc.

References $nid, $value, drupal_set_message(), node_delete(), and t().

node_node_operations ( )

Implementation of hook_node_operations().

Definition at line 95 of file node.admin.inc.

References t().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/node/node.install File Reference

modules » node

node.install File Reference

Go to the source code of this file.

Functions

  • node_schema ()
    Implementation of hook_schema().

Function Documentation

node_schema ( )

Implementation of hook_schema().

Definition at line 7 of file node.install.

References t().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/node/node.module File Reference

modules » node

node.module File Reference

Detailed Description

The core that allows content to be submitted to the site.

Modules and scripts may programmatically submit nodes using the usual form API pattern.

Definition in file node.module.

Go to the source code of this file.

Enumerations

  • enum NODE_BUILD_NORMAL
  • enum NODE_BUILD_PREVIEW
  • enum NODE_BUILD_PRINT
  • enum NODE_BUILD_RSS
  • enum NODE_BUILD_SEARCH_INDEX
  • enum NODE_BUILD_SEARCH_RESULT
  • enum NODE_NEW_LIMIT

Functions

  • _node_access_join_sql ($node_alias= 'n', $node_access_alias= 'na')
    Generate an SQL join clause for use in fetching a node listing.
  • _node_access_rebuild_batch_finished ($success, $results, $operations)
    Post-processing for node_access_rebuild_batch.
  • _node_access_rebuild_batch_operation (&$context)
    Batch operation for node_access_rebuild_batch.
  • _node_access_where_sql ($op= 'view', $node_access_alias= 'na', $account=NULL)
    Generate an SQL where clause for use in fetching a node listing.
  • _node_add_access ()
  • _node_index_node ($node)
    Index a single node.
  • _node_revision_access ($node, $op= 'view')
  • _node_save_revision (&$node, $uid, $update=NULL)
    Helper function to save a revision with the uid of the current user.
  • _node_type_set_defaults ($info)
    Set default values for a node type defined through hook_node_info().
  • _node_types_build ()
    Builds and returns the list of available node types.
  • node_access ($op, $node, $account=NULL)
    Determine whether the current user may perform the given operation on the specified node.
  • node_access_acquire_grants ($node)
    This function will call module invoke to get a list of grants and then write them to the database.
  • node_access_grants ($op, $account=NULL)
    Fetch an array of permission IDs granted to the given user ID.
  • node_access_needs_rebuild ($rebuild=NULL)
    Flag / unflag the node access grants for rebuilding, or read the current value of the flag.
  • node_access_rebuild ($batch_mode=FALSE)
    Rebuild the node access database.
  • node_access_view_all_nodes ()
    Determine whether the user has a global viewing grant for all nodes.
  • node_access_write_grants ($node, $grants, $realm=NULL, $delete=TRUE)
    This function will write a list of grants to the database, deleting any pre-existing grants.
  • node_action_info ()
    Implementation of hook_action_info().
  • node_assign_owner_action (&$node, $context)
    Implementation of a configurable Drupal action.
  • node_assign_owner_action_form ($context)
  • node_assign_owner_action_submit ($form, $form_state)
  • node_assign_owner_action_validate ($form, $form_state)
  • node_block ($op= 'list', $delta=0)
    Implementation of hook_block().
  • node_build_content ($node, $teaser=FALSE, $page=FALSE)
    Builds a structured array representing the node's content.
  • node_comment_mode ($nid)
    Retrieve the comment mode for the given node ID (none, read, or read/write).
  • node_content_access ($op, $node, $account)
    Implementation of hook_access().
  • node_content_form ($node, $form_state)
    Implementation of hook_form().
  • node_cron ()
    Implementation of hook_cron().
  • node_db_rewrite_sql ($query, $primary_table, $primary_field)
    Implementation of hook_db_rewrite_sql.
  • node_delete ($nid)
    Delete a node.
  • node_feed ($nids=FALSE, $channel=array())
    A generic function for generating RSS feeds from a set of nodes.
  • node_form_alter (&$form, $form_state, $form_id)
    Implementation of hook_form_alter().
  • node_forms ()
    End of "defgroup node_content".
  • node_get_types ($op= 'types', $node=NULL, $reset=FALSE)
    Builds a list of available node types, and returns all of part of this list in the specified format.
  • node_help ($path, $arg)
    Implementation of hook_help().
  • node_hook (&$node, $hook)
    Determine whether a node hook exists.
  • node_hook_info ()
    Implementation of hook_hook_info().
  • node_init ()
    Implementation of hook_init().
  • node_invoke (&$node, $hook, $a2=NULL, $a3=NULL, $a4=NULL)
    Invoke a node hook.
  • node_invoke_nodeapi (&$node, $op, $a3=NULL, $a4=NULL)
    Invoke a hook_nodeapi() operation in all modules.
  • node_last_changed ($nid)
  • node_last_viewed ($nid)
    Retrieves the timestamp at which the current user last viewed the specified node.
  • node_link ($type, $node=NULL, $teaser=FALSE)
    Implementation of hook_link().
  • node_load ($param=array(), $revision=NULL, $reset=NULL)
    Load a node object from the database.
  • node_make_sticky_action (&$node, $context=array())
    Implementation of a Drupal action.
  • node_make_unsticky_action (&$node, $context=array())
    Implementation of a Drupal action.
  • node_mark ($nid, $timestamp)
    Decide on the type of marker to be displayed for a given node.
  • node_menu ()
    Implementation of hook_menu().
  • node_page_default ()
    Menu callback; Generate a listing of promoted nodes.
  • node_page_title ($node)
    Title callback.
  • node_page_view ($node, $cid=NULL)
    Menu callback; view a single node.
  • node_perm ()
    Implementation of hook_perm().
  • node_prepare ($node, $teaser=FALSE)
    Apply filters and build the node's standard elements.
  • node_promote_action (&$node, $context=array())
    Implementation of a Drupal action.
  • node_publish_action (&$node, $context=array())
    Implementation of a Drupal action.
  • node_revision_list ($node)
    Return a list of all the existing revision numbers.
  • node_save (&$node)
    Save a node object into the database.
  • node_save_action ($node)
    Implementation of a Drupal action.
  • node_search ($op= 'search', $keys=NULL)
    Implementation of hook_search().
  • node_search_validate ($form, &$form_state)
    Form API callback for the search form.
  • node_show ($node, $cid, $message=FALSE)
    Generate a page displaying a single node, along with its comments.
  • node_submit ($node)
    Prepare node for save and allow modules to make changes.
  • node_tag_new ($nid)
    Update the 'last viewed' timestamp of the specified node for current user.
  • node_teaser ($body, $format=NULL, $size=NULL)
    Generate a teaser for a node body.
  • node_teaser_include_verify (&$form, &$form_state)
    Ensure value of "teaser_include" checkbox is consistent with other form data.
  • node_teaser_js (&$form, &$form_state)
    See if the user used JS to submit a teaser.
  • node_theme ()
    Implementation of hook_theme().
  • node_title_list ($result, $title=NULL)
    Gather a listing of links to nodes.
  • node_type_delete ($type)
    Deletes a node type from the database.
  • node_type_save ($info)
    Saves a node type to the database.
  • node_type_update_nodes ($old_type, $type)
    Updates all nodes of one type to be of another type.
  • node_types_rebuild ()
    Resets the database cache of node types, and saves all new or non-modified module-defined node types to the database.
  • node_unpromote_action (&$node, $context=array())
    Implementation of a Drupal action.
  • node_unpublish_action (&$node, $context=array())
    Implementation of a Drupal action.
  • node_unpublish_by_keyword_action ($node, $context)
    Implementation of a configurable Drupal action.
  • node_unpublish_by_keyword_action_form ($context)
  • node_unpublish_by_keyword_action_submit ($form, $form_state)
  • node_update_index ()
    Implementation of hook_update_index().
  • node_user ($op, &$edit, &$user)
    Implementation of hook_user().
  • node_validate ($node, $form=array())
    Perform validation checks on the given node.
  • node_view ($node, $teaser=FALSE, $page=FALSE, $links=TRUE)
    Generate a display of the given node.
  • theme_node_list ($items, $title=NULL)
    Format a listing of links to nodes.
  • theme_node_log_message ($log)
    Theme a log message.
  • theme_node_search_admin ($form)
    Theme the content ranking part of the search settings admin page.
  • theme_node_submitted ($node)
    Format the "Submitted by username on date/time" for each node.

Enumeration Type Documentation

enum NODE_BUILD_NORMAL

Definition at line 12 of file node.module.

enum NODE_BUILD_PREVIEW

Definition at line 13 of file node.module.

enum NODE_BUILD_PRINT

Definition at line 17 of file node.module.

enum NODE_BUILD_RSS

Definition at line 16 of file node.module.

enum NODE_BUILD_SEARCH_INDEX

Definition at line 14 of file node.module.

enum NODE_BUILD_SEARCH_RESULT

Definition at line 15 of file node.module.

enum NODE_NEW_LIMIT

Definition at line 10 of file node.module.

Function Documentation

_node_add_access ( )

Definition at line 1387 of file node.module.

References $type, node_access(), node_get_types(), and node_hook().

_node_index_node ( $ node )

Index a single node.

Parameters:
$node The node to index.

Definition at line 1783 of file node.module.

References check_plain(), content, drupal_render(), nid, node_build_content(), node_invoke_nodeapi(), node_load(), search_index(), and variable_set().

Referenced by node_update_index().

_node_revision_access | ( | $ | node,
 |  | $ | op = 'view'
 | ) |  |

Definition at line 1360 of file node.module.

References $op, db_query(), db_result(), nid, node_access(), node_load(), and user_access().

_node_save_revision | ( | &$ | node,
 |  | $ | uid,
 |  | $ | update = NULL
 | ) |  |

Helper function to save a revision with the uid of the current user.

Node is taken by reference, becuse drupal_write_record() updates the $node with the revision id, and we need to pass that back to the caller.

Definition at line 946 of file node.module.

References drupal_write_record().

Referenced by node_save().

_node_type_set_defaults ( $ info )

Set default values for a node type defined through hook_node_info().

Definition at line 579 of file node.module.

References t().

Referenced by _book_install_type_create(), _node_types_build(), default_profile_tasks(), example_profile_tasks(), and node_type_reset().

_node_types_build ( )

Builds and returns the list of available node types.

The list of types is built by querying hook_node_info() in all modules, and by comparing this information with the node types in the {node_type} table.

Definition at line 541 of file node.module.

References $type, _node_type_set_defaults(), db_fetch_object(), db_query(), db_rewrite_sql(), module, and module_invoke_all().

Referenced by node_get_types(), and node_types_rebuild().

node_action_info ( )

Implementation of hook_action_info().

Definition at line 2487 of file node.module.

References t().

node_assign_owner_action | ( | &$ | node,
 |  | $ | context
 | ) |  |

Implementation of a configurable Drupal action.

Assigns ownership of a node to a user.

Definition at line 2646 of file node.module.

References db_query(), db_result(), node_get_types(), and watchdog().

node_assign_owner_action_form ( $ context )

Definition at line 2652 of file node.module.

References $result, db_fetch_object(), db_query(), db_result(), and t().

node_assign_owner_action_submit | ( | $ | form,
 |  | $ | form_state
 | ) |  |

Definition at line 2696 of file node.module.

References db_query(), and db_result().

node_assign_owner_action_validate | ( | $ | form,
 |  | $ | form_state
 | ) |  |

Definition at line 2689 of file node.module.

References db_query(), db_result(), form_set_error(), and t().

node_block | ( | $ | op = 'list',
 |  | $ | delta = 0
 | ) |  |

Implementation of hook_block().

Definition at line 1608 of file node.module.

References $op, t(), theme(), and url().

node_build_content | ( | $ | node,
 |  | $ | teaser = FALSE,
 |  | $ | page = FALSE
 | ) |  |

Builds a structured array representing the node's content.

Parameters:
$node | A node object.
$teaser | Whether to display the teaser only, as on the main page.
$page | Whether the node is being displayed by itself as a page.
Returns:
An structured array containing the individual elements of the node's body.

Definition at line 1066 of file node.module.

References node_hook(), node_invoke(), node_invoke_nodeapi(), and node_prepare().

Referenced by _node_index_node(), book_node_export(), node_search(), and node_view().

node_comment_mode ( $ nid )

Retrieve the comment mode for the given node ID (none, read, or read/write).

Definition at line 1331 of file node.module.

References $nid, db_query(), and db_result().

Referenced by comment_links(), comment_render(), comment_reply(), and comment_save().

node_cron ( )

Implementation of hook_cron().

Definition at line 115 of file node.module.

References db_query().

node_delete ( $ nid )

Delete a node.

Definition at line 961 of file node.module.

References $nid, cache_clear_all(), db_query(), drupal_set_message(), nid, node_access(), node_get_types(), node_invoke(), node_invoke_nodeapi(), node_load(), search_wipe(), t(), and watchdog().

Referenced by blogapi_blogger_delete_post(), forum_taxonomy(), node_delete_confirm_submit(), and node_multiple_delete_confirm_submit().

node_feed | ( | $ | nids = FALSE,
 |  | $ | channel = array()
 | ) |  |

A generic function for generating RSS feeds from a set of nodes.

Parameters:
$nids | An array of node IDs (nid). Defaults to FALSE so empty feeds can be generated with passing an empty array, if no items are to be added to the feed.
$channel | An associative array containing title, link, description and other keys. The link should be an absolute URL.

Definition at line 1634 of file node.module.

References $base_url, $channel, $element, $item, $items, $language, $nid, $output, $result, $row, db_fetch_object(), db_query_range(), db_rewrite_sql(), drupal_attributes(), drupal_set_header(), format_date(), format_rss_channel(), format_rss_item(), l(), language, link, name, nid, node_hook(), node_invoke(), node_invoke_nodeapi(), node_load(), node_prepare(), t(), url(), and variable_get().

Referenced by blog_feed_last(), blog_feed_user(), and taxonomy_term_page().

node_form_alter | ( | &$ | form,
 |  | $ | form_state,
 |  | $ | form_id
 | ) |  |

Implementation of hook_form_alter().

Definition at line 1809 of file node.module.

References module_invoke(), node_get_types(), t(), and user_access().

node_forms ( )

End of "defgroup node_content".

Implementation of hook_forms(). All node forms share the same form handler

Definition at line 2434 of file node.module.

References $type, and node_get_types().

node_get_types | ( | $ | op = 'types',
 |  | $ | node = NULL,
 |  | $ | reset = FALSE
 | ) |  |

Builds a list of available node types, and returns all of part of this list in the specified format.

Parameters:
$op | The format in which to return the list. When this is set to 'type', 'module', or 'name', only the specified node type is returned. When set to 'types' or 'names', all node types are returned.
$node | A node object, array, or string that indicates the node type to return. Leave at default value (NULL) to return a list of all node types.
$reset | Whether or not to reset this function's internal cache (defaults to FALSE).
Returns:
Either an array of all available node types, or a single node type, in a variable format. Returns FALSE if the node type is not found.

Definition at line 413 of file node.module.

References $op, $type, _node_types_build(), and module.

Referenced by _blogapi_get_node_types(), _node_add_access(), blog_form(), blogapi_admin_settings(), book_admin_settings(), comment_update_6002(), forum_form(), hook_form(), hook_mail(), locale_update_6005(), node_access(), node_add(), node_admin_nodes(), node_assign_owner_action(), node_content_form(), node_delete(), node_example_form(), node_filters(), node_form_alter(), node_form_submit(), node_forms(), node_help(), node_hook(), node_invoke(), node_make_sticky_action(), node_make_unsticky_action(), node_menu(), node_overview_types(), node_perm(), node_promote_action(), node_publish_action(), node_revision_delete_confirm_submit(), node_revision_revert_confirm_submit(), node_save_action(), node_search(), node_type_delete(), node_type_form_validate(), node_types_rebuild(), node_unpromote_action(), node_unpublish_action(), node_unpublish_by_keyword_action(), node_validate(), poll_form(), system_mail(), system_message_action(), system_theme_settings(), taxonomy_form_vocabulary(), taxonomy_overview_vocabularies(), template_preprocess_forums(), theme_get_settings(), and tracker_page().

node_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 22 of file node.module.

References $output, $type, drupal_set_message(), filter_xss_admin(), node_access_needs_rebuild(), node_get_types(), node_load(), t(), url(), and user_access().

node_hook | ( | &$ | node,
 |  | $ | hook
 | ) |  |

Determine whether a node hook exists.

Parameters:
&$node | Either a node object, node array, or a string containing the node type.
$hook | A string containing the name of the hook.
Returns:
TRUE iff the $hook exists in the node type of $node.

Definition at line 626 of file node.module.

References module_hook(), and node_get_types().

Referenced by _node_add_access(), hook_update_index(), node_build_content(), node_feed(), node_invoke(), and node_overview_types().

node_hook_info ( )

Implementation of hook_hook_info().

Definition at line 2460 of file node.module.

References t().

node_init ( )

Implementation of hook_init().

Definition at line 1583 of file node.module.

References drupal_add_css(), and drupal_get_path().

node_invoke | ( | &$ | node,
 |  | $ | hook,
 |  | $ | a2 = NULL,
 |  | $ | a3 = NULL,
 |  | $ | a4 = NULL
 | ) |  |

Invoke a node hook.

Parameters:
&$node | Either a node object, node array, or a string containing the node type.
$hook | A string containing the name of the hook.
$a2,$a3,$a4 | Arguments to pass on to the hook, after the $node argument.
Returns:
The returned value of the invoked hook.

Definition at line 646 of file node.module.

References node_get_types(), and node_hook().

Referenced by hook_search(), hook_update_index(), node_build_content(), node_delete(), node_feed(), node_form(), node_load(), node_object_prepare(), node_save(), and node_validate().

node_invoke_nodeapi | ( | &$ | node,
 |  | $ | op,
 |  | $ | a3 = NULL,
 |  | $ | a4 = NULL
 | ) |  |

Invoke a hook_nodeapi() operation in all modules.

Parameters:
&$node | A node object.
$op | A string containing the name of the nodeapi operation.
$a3,$a4 | Arguments to pass on to the hook, after the $node and $op arguments.
Returns:
The returned value of the invoked hooks.

Definition at line 669 of file node.module.

References $name, $op, $result, $return, and module_implements().

Referenced by _node_index_node(), blogapi_blogger_edit_post(), blogapi_blogger_new_post(), hook_search(), hook_update_index(), node_build_content(), node_delete(), node_feed(), node_load(), node_object_prepare(), node_revision_delete_confirm_submit(), node_save(), node_search(), node_validate(), node_view(), and translation_nodeapi().

node_last_changed ( $ nid )

Definition at line 1587 of file node.module.

References $nid, db_fetch_object(), and db_query().

Referenced by node_validate().

node_last_viewed ( $ nid )

Retrieves the timestamp at which the current user last viewed the specified node.

Definition at line 174 of file node.module.

References $nid, $user, db_fetch_object(), and db_query().

Referenced by comment_num_new(), node_mark(), and node_tag_new().

node_link | ( | $ | type,
 |  | $ | node = NULL,
 |  | $ | teaser = FALSE
 | ) |  |

Implementation of hook_link().

Definition at line 1342 of file node.module.

References $links, $type, and t().

node_load | ( | $ | param = array(),
 |  | $ | revision = NULL,
 |  | $ | reset = NULL
 | ) |  |

Load a node object from the database.

Parameters:
$param | Either the nid of the node or an array of conditions to match against in the database query
$revision | Which numbered revision to load. Defaults to the current version.
$reset | Whether to reset the internal node_load cache.
Returns:
A fully-populated node object.

Definition at line 697 of file node.module.

References $value, db_escape_string(), db_fetch_object(), db_query(), drupal_clone(), drupal_schema_fields_sql(), nid, node_invoke(), and node_invoke_nodeapi().

Referenced by _node_access_rebuild_batch_operation(), _node_index_node(), _node_mass_update_helper(), _node_revision_access(), _trigger_normalize_comment_context(), _trigger_normalize_user_context(), batch_example_op_1(), batch_example_op_2(), blog_form(), blog_page_last(), blog_page_user(), blogap_mti_publish_post(), blogapi_blogger_edit_post(), blogapi_blogger_get_post(), blogapi_mt_get_post_categories(), blogapi_mt_set_post_categories(), book_admin_edit_submit(), book_export_html(), book_export_traverse(), book_form_node_delete_confirm_alter(), book_nodeapi(), comment_form(), comment_form_add_preview(), comment_form_submit(), comment_links(), comment_validate(), hook_search(), hook_update_index(), node_access_rebuild(), node_delete(), node_feed(), node_help(), node_page_default(), node_search(), poll_block(), poll_cancel(), profile_block(), statistics_node_tracker(), system_message_action(), system_send_email_action(), taxonomy_render_nodes(), translation_node_overview(), translation_nodeapi(), and translation_path_get_translations().

node_make_sticky_action | ( | &$ | node,
 |  | $ | context = array()
 | ) |  |

Implementation of a Drupal action.

Sets the sticky-at-top-of-list property of a node to 1.

Definition at line 2601 of file node.module.

References node_get_types(), and watchdog().

node_make_unsticky_action | ( | &$ | node,
 |  | $ | context = array()
 | ) |  |

Implementation of a Drupal action.

Sets the sticky-at-top-of-list property of a node to 0.

Definition at line 2610 of file node.module.

References node_get_types(), and watchdog().

node_mark | ( | $ | nid,
 |  | $ | timestamp
 | ) |  |

Decide on the type of marker to be displayed for a given node.

Parameters:
$nid | Node ID whose history supplies the "last viewed" timestamp.
$timestamp | Time which is compared against node's "last viewed" timestamp.
Returns:
One of the MARK constants.

Definition at line 195 of file node.module.

References $nid, $user, and node_last_viewed().

Referenced by node_admin_nodes(), theme_comment_view(), and tracker_page().

node_menu ( )

Implementation of hook_menu().

Definition at line 1400 of file node.module.

References $items, $type, drupal_ucfirst(), name, and node_get_types().

node_page_default ( )

Menu callback; Generate a listing of promoted nodes.

Definition at line 1719 of file node.module.

References $feed_url, $output, $result, db_fetch_object(), db_rewrite_sql(), drupal_add_feed(), drupal_set_title(), nid, node_load(), node_view(), pager_query(), t(), theme(), url(), and variable_get().

node_page_title ( $ node )

Title callback.

Definition at line 1576 of file node.module.

node_page_view | ( | $ | node,
 |  | $ | cid = NULL
 | ) |  |

Menu callback; view a single node.

Definition at line 1755 of file node.module.

References check_plain(), drupal_set_title(), and node_show().

node_perm ( )

Implementation of hook_perm().

Definition at line 1122 of file node.module.

References $name, $type, check_plain(), module, and node_get_types().

node_prepare | ( | $ | node,
 |  | $ | teaser = FALSE
 | ) |  |

Apply filters and build the node's standard elements.

Definition at line 1031 of file node.module.

References check_markup().

Referenced by blog_view(), hook_update_index(), hook_view(), multipage_form_example_view(), node_build_content(), node_example_view(), and node_feed().

node_promote_action | ( | &$ | node,
 |  | $ | context = array()
 | ) |  |

Implementation of a Drupal action.

Sets the promote property of a node to 1.

Definition at line 2619 of file node.module.

References node_get_types(), and watchdog().

node_publish_action | ( | &$ | node,
 |  | $ | context = array()
 | ) |  |

Implementation of a Drupal action.

Sets the status of a node to 1, meaning published.

Definition at line 2583 of file node.module.

References node_get_types(), and watchdog().

node_revision_list ( $ node )

Return a list of all the existing revision numbers.

Definition at line 1595 of file node.module.

References $result, db_fetch_object(), db_query(), and nid.

Referenced by node_revision_overview().

node_save ( &$ node )

Save a node object into the database.

Definition at line 856 of file node.module.

References $op, $user, _node_save_revision(), cache_clear_all(), db_query(), drupal_write_record(), nid, node_access_acquire_grants(), node_invoke(), and node_invoke_nodeapi().

Referenced by _node_mass_update_helper(), blogap_mti_publish_post(), blogapi_blogger_edit_post(), blogapi_blogger_new_post(), blogapi_mt_set_post_categories(), book_admin_edit_submit(), node_form_submit(), node_revision_revert_confirm_submit(), and node_save_action().

node_save_action ( $ node )

Implementation of a Drupal action.

Saves a node.

Definition at line 2637 of file node.module.

References node_get_types(), node_save(), and watchdog().

node_search | ( | $ | op = 'search',
 |  | $ | keys = NULL
 | ) |  |

Implementation of hook_search().

Definition at line 1142 of file node.module.

References $item, $op, $results, $title, $type, _db_rewrite_sql(), check_plain(), content, db_query(), db_result(), do_search(), drupal_map_assoc(), drupal_render(), module_exists(), module_invoke(), node_build_content(), node_get_types(), node_invoke_nodeapi(), node_load(), search_excerpt(), search_query_extract(), search_query_insert(), t(), theme(), url(), and variable_get().

node_search_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Form API callback for the search form.

Registered in node_form_alter().

Definition at line 1879 of file node.module.

References form_set_value(), and search_query_insert().

node_show | ( | $ | node,
 |  | $ | cid,
 |  | $ | message = FALSE
 | ) |  |

Generate a page displaying a single node, along with its comments.

Definition at line 1094 of file node.module.

References $output, comment_render(), drupal_set_title(), format_date(), nid, node_tag_new(), node_view(), and t().

Referenced by node_page_view(), and poll_results().

node_submit ( $ node )

Prepare node for save and allow modules to make changes.

Definition at line 815 of file node.module.

References $user, name, node_teaser(), user_access(), and user_load().

Referenced by blogapi_blogger_edit_post(), blogapi_blogger_new_post(), and node_form_submit_build_node().

node_tag_new ( $ nid )

Update the 'last viewed' timestamp of the specified node for current user.

Definition at line 157 of file node.module.

References $nid, $user, db_query(), and node_last_viewed().

Referenced by node_show().

node_teaser | ( | $ | body,
 |  | $ | format = NULL,
 |  | $ | size = NULL
 | ) |  |

Generate a teaser for a node body.

If the end of the teaser is not indicated using the delimiter then we generate the teaser automatically, trying to end it at a sensible place such as the end of a paragraph, a line break, or the end of a sentence (in that order of preference).

Parameters:
$body | The content for which a teaser will be generated.
$format | The format of the content. If the content contains PHP code, we do not split it up to prevent parse errors. If the line break filter is present then we treat newlines embedded in $body as line breaks.
$size | The desired character length of the teaser. If omitted, the default value will be used. Ignored if the special delimiter is present in $body.
Returns:
The generated teaser.

Definition at line 301 of file node.module.

References drupal_strlen(), filter_list_format(), truncate_utf8(), and variable_get().

Referenced by node_preview(), node_submit(), and theme_aggregator_page_rss().

node_teaser_include_verify | ( | &$ | form,
 |  | &$ | form_state
 | ) |  |

Ensure value of "teaser_include" checkbox is consistent with other form data.

This handles two situations in which an unchecked checkbox is rejected:

1. The user defines a teaser (summary) but it is empty; 2. The user does not define a teaser (summary) (in this case an unchecked checkbox would cause the body to be empty, or missing the auto-generated teaser).

If JavaScript is active then it is used to force the checkbox to be checked when hidden, and so the second case will not arise.

In either case a warning message is output.

Definition at line 252 of file node.module.

References drupal_set_message(), form_set_value(), and t().

node_teaser_js | ( | &$ | form,
 |  | &$ | form_state
 | ) |  |

See if the user used JS to submit a teaser.

Definition at line 217 of file node.module.

References form_set_value().

node_theme ( )

Implementation of hook_theme().

Definition at line 67 of file node.module.

node_title_list | ( | $ | result,
 |  | $ | title = NULL
 | ) |  |

Gather a listing of links to nodes.

Parameters:
$result | A DB result object from a query to fetch node objects. If your query joins the node_comment_statistics table so that the comment_count field is available, a title attribute will be added to show the number of comments.
$title | A heading for the resulting list.
Returns:
An HTML list suitable as content for a block, or FALSE if no result can fetch from DB result object.

Definition at line 134 of file node.module.

References $items, $result, $title, db_fetch_object(), format_plural(), l(), nid, and theme().

Referenced by blog_block(), forum_block(), and statistics_block().

node_type_delete ( $ type )

Deletes a node type from the database.

Parameters:
$type The machine-readable name of the node type to be deleted.

Definition at line 512 of file node.module.

References $type, db_query(), module_invoke_all(), and node_get_types().

Referenced by node_type_delete_confirm_submit(), and node_types_rebuild().

node_type_save ( $ info )

Saves a node type to the database.

Parameters:
$info The node type to save, as an object.
Returns:
Status flag indicating outcome of the operation.

Definition at line 478 of file node.module.

References db_query(), db_result(), module, module_invoke_all(), and name.

Referenced by _book_install_type_create(), default_profile_tasks(), example_profile_tasks(), node_type_form_submit(), and node_types_rebuild().

node_type_update_nodes | ( | $ | old_type,
 |  | $ | type
 | ) |  |

Updates all nodes of one type to be of another type.

Parameters:
$old_type | The current node type of the nodes.
$type | The new node type of the nodes.
Returns:
The number of nodes whose node type field was modified.

Definition at line 529 of file node.module.

References $type, db_affected_rows(), and db_query().

Referenced by node_node_type().

node_types_rebuild ( )

Resets the database cache of node types, and saves all new or non-modified module-defined node types to the database.

Definition at line 452 of file node.module.

References $type, _node_types_build(), node_get_types(), node_type_delete(), and node_type_save().

Referenced by drupal_flush_all_caches(), node_type_delete_confirm_submit(), node_type_form_submit(), and system_modules().

node_unpromote_action | ( | &$ | node,
 |  | $ | context = array()
 | ) |  |

Implementation of a Drupal action.

Sets the promote property of a node to 0.

Definition at line 2628 of file node.module.

References node_get_types(), and watchdog().

node_unpublish_action | ( | &$ | node,
 |  | $ | context = array()
 | ) |  |

Implementation of a Drupal action.

Sets the status of a node to 0, meaning unpublished.

Definition at line 2592 of file node.module.

References node_get_types(), and watchdog().

node_unpublish_by_keyword_action | ( | $ | node,
 |  | $ | context
 | ) |  |

Implementation of a configurable Drupal action.

Unpublish a node if it contains a certain string.

Parameters:
$context | An array providing more information about the context of the call to this action.
$comment | A node object.

Definition at line 2725 of file node.module.

References drupal_clone(), node_get_types(), node_view(), and watchdog().

node_unpublish_by_keyword_action_form ( $ context )

Definition at line 2702 of file node.module.

References drupal_implode_tags(), and t().

node_unpublish_by_keyword_action_submit | ( | $ | form,
 |  | $ | form_state
 | ) |  |

Definition at line 2712 of file node.module.

References drupal_explode_tags().

node_update_index ( )

Implementation of hook_update_index().

Definition at line 1763 of file node.module.

References $result, _node_index_node(), db_fetch_object(), db_query(), db_query_range(), db_result(), variable_get(), and variable_set().

node_user | ( | $ | op,
 |  | &$ | edit,
 |  | &$ | user
 | ) |  |

Implementation of hook_user().

Definition at line 1299 of file node.module.

References $op, $user, and db_query().

node_validate | ( | $ | node,
 |  | $ | form = array()
 | ) |  |

Perform validation checks on the given node.

Definition at line 777 of file node.module.

References $type, form_set_error(), name, nid, node_get_types(), node_invoke(), node_invoke_nodeapi(), node_last_changed(), t(), user_access(), and user_load().

Referenced by blogapi_blogger_edit_post(), blogapi_blogger_new_post(), and node_form_validate().

node_view | ( | $ | node,
 |  | $ | teaser = FALSE,
 |  | $ | page = FALSE,
 |  | $ | links = TRUE
 | ) |  |

Generate a display of the given node.

Parameters:
$node | A node array or node object.
$teaser | Whether to display the teaser only or the full form.
$page | Whether the node is being displayed by itself as a page.
$links | Whether or not to display node links. Links are omitted for node previews.
Returns:
An HTML representation of the themed node.

Definition at line 1000 of file node.module.

References $content, $links, content, drupal_alter(), drupal_render(), module_invoke_all(), node_build_content(), node_invoke_nodeapi(), and theme().

Referenced by blog_page_last(), blog_page_user(), comment_form_add_preview(), comment_reply(), node_page_default(), node_show(), node_unpublish_by_keyword_action(), taxonomy_render_nodes(), and theme_node_preview().

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/node/node.pages.inc File Reference

modules » node

node.pages.inc File Reference

Detailed Description

Page callbacks for adding, editing, deleting, and revisions management for content.

Definition in file node.pages.inc.

Go to the source code of this file.

Functions

  • node_add ($type)
    Present a node submission form or a set of links to such forms.
  • node_add_page ()
  • node_body_field (&$node, $label, $word_count)
    Return a node body field, with format and teaser.
  • node_delete_confirm (&$form_state, $node)
    Menu callback -- ask for confirmation of node deletion.
  • node_delete_confirm_submit ($form, &$form_state)
    Execute node deletion.
  • node_form (&$form_state, $node)
    Generate the node add/edit form array.
  • node_form_build_preview ($form, &$form_state)
  • node_form_delete_submit ($form, &$form_state)
    Button sumit function: handle the 'Delete' button on the node form.
  • node_form_submit ($form, &$form_state)
  • node_form_submit_build_node ($form, &$form_state)
    Build a node by processing submitted form values and prepare for a form rebuild.
  • node_form_validate ($form, &$form_state)
  • node_object_prepare (&$node)
  • node_page_edit ($node)
    Menu callback; presents the node editing form, or redirects to delete confirmation.
  • node_preview ($node)
    Generate a node preview.
  • node_revision_delete_confirm ($form_state, $node_revision)
  • node_revision_delete_confirm_submit ($form, &$form_state)
  • node_revision_overview ($node)
    Generate an overview table of older revisions of a node.
  • node_revision_revert_confirm ($form_state, $node_revision)
    Ask for confirmation of the reversion to prevent against CSRF attacks.
  • node_revision_revert_confirm_submit ($form, &$form_state)
  • theme_node_add_list ($content)
    Display the list of available node types for node creation.
  • theme_node_form ($form)
    Present a node submission form.
  • theme_node_preview ($node)
    Display a node preview for display during node creation and editing.

Function Documentation

node_add ( $ type )

Present a node submission form or a set of links to such forms.

Definition at line 47 of file node.pages.inc.

References $output, $type, $user, drupal_get_form(), drupal_set_title(), name, node_access(), node_get_types(), and t().

node_add_page ( )

Definition at line 18 of file node.pages.inc.

References $content, $item, menu_get_item(), system_admin_menu_block(), and theme().

node_body_field | ( | &$ | node,
 |  | $ | label,
 |  | $ | word_count
 | ) |  |

Return a node body field, with format and teaser.

Definition at line 259 of file node.pages.inc.

References check_plain(), filter_form(), and t().

Referenced by blog_form(), forum_form(), node_content_form(), and node_example_form().

node_delete_confirm | ( | &$ | form_state,
 |  | $ | node
 | ) |  |

Menu callback -- ask for confirmation of node deletion.

Definition at line 494 of file node.pages.inc.

References confirm_form(), nid, and t().

node_delete_confirm_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Execute node deletion.

Definition at line 512 of file node.pages.inc.

References node_delete().

node_form | ( | &$ | form_state,
 |  | $ | node
 | ) |  |

Generate the node add/edit form array.

Definition at line 93 of file node.pages.inc.

References $user, format_date(), name, nid, node_access(), node_invoke(), node_object_prepare(), t(), user_access(), and variable_get().

node_form_build_preview | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 313 of file node.pages.inc.

References node_form_submit_build_node(), and node_preview().

node_form_delete_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Button sumit function: handle the 'Delete' button on the node form.

Definition at line 302 of file node.pages.inc.

References drupal_get_destination(), and nid.

node_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 447 of file node.pages.inc.

References $user, drupal_set_message(), l(), nid, node_form_submit_build_node(), node_get_types(), node_save(), t(), and watchdog().

node_form_submit_build_node | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Build a node by processing submitted form values and prepare for a form rebuild.

Definition at line 480 of file node.pages.inc.

References form_execute_handlers(), and node_submit().

Referenced by node_form_build_preview(), node_form_submit(), and poll_more_choices_submit().

node_form_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 64 of file node.pages.inc.

References node_validate().

node_object_prepare ( &$ node )

Definition at line 68 of file node.pages.inc.

References $user, format_date(), nid, node_invoke(), node_invoke_nodeapi(), and variable_get().

Referenced by node_form().

node_page_edit ( $ node )

Menu callback; presents the node editing form, or redirects to delete confirmation.

Definition at line 13 of file node.pages.inc.

References drupal_get_form(), and drupal_set_title().

node_preview ( $ node )

Generate a node preview.

Definition at line 362 of file node.pages.inc.

References $output, $user, drupal_clone(), drupal_set_title(), form_get_errors(), name, node_access(), node_teaser(), t(), theme(), and user_load().

Referenced by node_form_build_preview().

node_revision_delete_confirm | ( | $ | form_state,
 |  | $ | node_revision
 | ) |  |

Definition at line 588 of file node.pages.inc.

References confirm_form(), format_date(), nid, and t().

node_revision_delete_confirm_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 593 of file node.pages.inc.

References db_query(), db_result(), drupal_set_message(), format_date(), nid, node_get_types(), node_invoke_nodeapi(), t(), and watchdog().

node_revision_overview ( $ node )

Generate an overview table of older revisions of a node.

Definition at line 523 of file node.pages.inc.

References $header, $row, drupal_set_title(), filter_xss(), format_date(), l(), node_access(), node_revision_list(), t(), theme(), and user_access().

node_revision_revert_confirm | ( | $ | form_state,
 |  | $ | node_revision
 | ) |  |

Ask for confirmation of the reversion to prevent against CSRF attacks.

Definition at line 568 of file node.pages.inc.

References confirm_form(), format_date(), nid, and t().

node_revision_revert_confirm_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 573 of file node.pages.inc.

References drupal_set_message(), format_date(), module_exists(), node_get_types(), node_save(), t(), and watchdog().

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/node/node.tpl.php File Reference

modules » node

node.tpl.php File Reference

Go to the source code of this file.

Variables

  • print $node nid

Variable Documentation

print $node nid

Definition at line 51 of file node.tpl.php.

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/openid/openid.inc File Reference

modules » openid

openid.inc File Reference

Detailed Description

OpenID utility functions.

Definition in file openid.inc.

Go to the source code of this file.

Enumerations

  • enum OPENID_DH_DEFAULT_GEN
  • enum OPENID_DH_DEFAULT_MOD
  • enum OPENID_NS_1_0
  • enum OPENID_NS_1_1
  • enum OPENID_NS_2_0
  • enum OPENID_RAND_SOURCE
  • enum OPENID_SHA1_BLOCKSIZE

Functions

  • _openid_create_message ($data)
    Create a serialized message packet as per spec: $key:$value
    .
  • _openid_dh_base64_to_long ($str)
  • _openid_dh_binary_to_long ($str)
  • _openid_dh_long_to_base64 ($str)
  • _openid_dh_long_to_binary ($long)
  • _openid_dh_rand ($stop)
  • _openid_dh_xorsecret ($shared, $secret)
  • _openid_encode_message ($message)
    Encode a message from _openid_create_message for HTTP Post.
  • _openid_get_bytes ($num_bytes)
  • _openid_get_params ($str)
  • _openid_hmac ($key, $text)
  • _openid_is_xri ($identifier)
    Determine if the given identifier is an XRI ID.
  • _openid_link_href ($rel, $html)
    Pull the href attribute out of an html link element.
  • _openid_meta_httpequiv ($equiv, $html)
    Pull the http-equiv attribute out of an html meta element.
  • _openid_nonce ()
    Return a nonce value - formatted per OpenID spec.
  • _openid_normalize ($identifier)
    Normalize the given identifier as per spec.
  • _openid_normalize_url ($url)
  • _openid_normalize_xri ($xri)
  • _openid_parse_message ($message)
    Convert a direct communication message into an associative array.
  • _openid_response ($str=NULL)
  • _openid_sha1 ($text)
  • _openid_signature ($association, $message_array, $keys_to_sign)
    Sign certain keys in a message.
  • openid_redirect ($url, $message)
    Creates a js auto-submit redirect for (for the 2.x protocol).
  • openid_redirect_form (&$form_state, $url, $message)
  • openid_redirect_http ($url, $message)
    Performs an HTTP 302 redirect (for the 1.x protocol).

Variables

  • $exp = bcdiv($exp, 2)
  • $result = 1
  • $square = bcmod(bcmul($square, $square), $mod)

Enumeration Type Documentation

enum OPENID_DH_DEFAULT_GEN

Definition at line 17 of file openid.inc.

enum OPENID_DH_DEFAULT_MOD

Definition at line 10 of file openid.inc.

enum OPENID_NS_1_0

Definition at line 24 of file openid.inc.

enum OPENID_NS_1_1

Definition at line 23 of file openid.inc.

enum OPENID_NS_2_0

Definition at line 22 of file openid.inc.

enum OPENID_RAND_SOURCE

Definition at line 19 of file openid.inc.

enum OPENID_SHA1_BLOCKSIZE

Definition at line 18 of file openid.inc.

Function Documentation

_openid_create_message ( $ data )

Create a serialized message packet as per spec: $key:$value
.

Definition at line 125 of file openid.inc.

References $value.

Referenced by _openid_signature(), openid_association(), and openid_verify_assertion().

_openid_dh_base64_to_long ( $ str )

Definition at line 266 of file openid.inc.

References _openid_dh_binary_to_long().

Referenced by openid_association().

_openid_dh_binary_to_long ( $ str )

Definition at line 276 of file openid.inc.

Referenced by _openid_dh_base64_to_long(), and _openid_dh_rand().

_openid_dh_long_to_base64 ( $ str )

Definition at line 272 of file openid.inc.

References _openid_dh_long_to_binary().

Referenced by openid_association_request().

_openid_dh_long_to_binary ( $ long )

Definition at line 288 of file openid.inc.

Referenced by _openid_dh_long_to_base64(), _openid_dh_rand(), and _openid_dh_xorsecret().

_openid_dh_rand ( $ stop )

Definition at line 328 of file openid.inc.

References _openid_dh_binary_to_long(), _openid_dh_long_to_binary(), and _openid_get_bytes().

Referenced by openid_association().

_openid_dh_xorsecret | ( | $ | shared,
 |  | $ | secret
 | ) |  |

Definition at line 317 of file openid.inc.

References _openid_dh_long_to_binary(), and _openid_sha1().

Referenced by openid_association().

_openid_encode_message ( $ message )

Encode a message from _openid_create_message for HTTP Post.

Definition at line 140 of file openid.inc.

References $item, and $items.

Referenced by openid_association(), and openid_verify_assertion().

_openid_get_bytes ( $ num_bytes )

Definition at line 367 of file openid.inc.

Referenced by _openid_dh_rand().

_openid_get_params ( $ str )

Definition at line 408 of file openid.inc.

Referenced by _openid_response().

_openid_hmac | ( | $ | key,
 |  | $ | text
 | ) |  |

Definition at line 241 of file openid.inc.

References _openid_sha1().

Referenced by _openid_signature().

_openid_is_xri ( $ identifier )

Determine if the given identifier is an XRI ID.

Definition at line 76 of file openid.inc.

Referenced by _openid_normalize(), and openid_discovery().

_openid_link_href | ( | $ | rel,
 |  | $ | html
 | ) |  |

Pull the href attribute out of an html link element.

Definition at line 192 of file openid.inc.

Referenced by openid_discovery().

_openid_meta_httpequiv | ( | $ | equiv,
 |  | $ | html
 | ) |  |

Pull the http-equiv attribute out of an html meta element.

Definition at line 205 of file openid.inc.

References $content.

Referenced by openid_discovery().

_openid_nonce ( )

Return a nonce value - formatted per OpenID spec.

Definition at line 180 of file openid.inc.

_openid_normalize ( $ identifier )

Normalize the given identifier as per spec.

Definition at line 91 of file openid.inc.

References _openid_is_xri(), _openid_normalize_url(), and _openid_normalize_xri().

Referenced by openid_begin(), and openid_user_add_validate().

_openid_normalize_url ( $ url )

Definition at line 108 of file openid.inc.

References $url.

Referenced by _openid_normalize().

_openid_normalize_xri ( $ xri )

Definition at line 100 of file openid.inc.

Referenced by _openid_normalize().

_openid_parse_message ( $ message )

Convert a direct communication message into an associative array.

Definition at line 162 of file openid.inc.

References $item, and $items.

Referenced by openid_association(), and openid_verify_assertion().

_openid_response ( $ str = NULL )

Definition at line 387 of file openid.inc.

References _openid_get_params().

Referenced by openid_complete().

_openid_sha1 ( $ text )

Definition at line 255 of file openid.inc.

Referenced by _openid_dh_xorsecret(), and _openid_hmac().

_openid_signature | ( | $ | association,
 |  | $ | message_array,
 |  | $ | keys_to_sign
 | ) |  |

Sign certain keys in a message.

Parameters:
$association - object loaded from openid_association or openid_server_association table
  • important fields are ->assoc_type and ->mac_key
$message_array | - array of entire message about to be sent
$keys_to_sign | - keys in the message to include in signature (without 'openid.' appended)

Definition at line 224 of file openid.inc.

References _openid_create_message(), and _openid_hmac().

Referenced by openid_verify_assertion().

openid_redirect | ( | $ | url,
 |  | $ | message
 | ) |  |

Creates a js auto-submit redirect for (for the 2.x protocol).

Definition at line 43 of file openid.inc.

References $output, $url, drupal_get_form(), exit, and t().

Referenced by openid_begin().

openid_redirect_form | ( | &$ | form_state,
 |  | $ | url,
 |  | $ | message
 | ) |  |

Definition at line 52 of file openid.inc.

References $url, $value, and t().

openid_redirect_http | ( | $ | url,
 |  | $ | message
 | ) |  |

Performs an HTTP 302 redirect (for the 1.x protocol).

Definition at line 29 of file openid.inc.

References $url, and exit.

Referenced by openid_begin().

Variable Documentation

$exp = bcdiv($exp, 2)

Definition at line 435 of file openid.inc.

return $result = 1

Definition at line 429 of file openid.inc.

Referenced by _block_rehash(), _color_shift(), _comment_delete_thread(), _db_query(), _db_rewrite_sql(), _dblog_get_message_types(), _forum_user_last_visit(), _locale_export_get_strings(), _locale_parse_js_file(), _locale_rebuild_js(), _locale_translate_seek(), _menu_delete_item(), _menu_navigation_links_rebuild(), _menu_set_expanded_menus(), _menu_tree_data(), _node_access_rebuild_batch_operation(), _taxonomy_term_children(), _theme_process_registry(), _trigger_get_hook_actions(), _trigger_get_hook_aids(), _xmlrpc(), actions_do(), actions_get_all_actions(), actions_synchronize(), aggregator_block(), aggregator_cron(), aggregator_feed_items_load(), aggregator_form_feed_validate(), aggregator_page_categories(), aggregator_page_opml(), aggregator_page_rss(), aggregator_page_sources(), aggregator_parse_feed(), aggregator_refresh(), aggregator_remove(), aggregator_save_feed(), aggregator_view(), batch_example_op_2(), batch_test_update_1(), block_admin_configure(), block_block(), block_list(), block_user(), blog_block(), blog_feed_last(), blog_feed_user(), blog_page_last(), blog_page_user(), blogapi_blogger_get_recent_posts(), book_get_books(), book_nodeapi(), book_update_6000(), book_update_bid(), comment_admin_overview(), comment_get_recent(), comment_invoke_comment(), comment_new_page_count(), comment_num_new(), comment_render(), contact_admin_categories(), contact_mail_page(), custom_url_rewrite_inbound(), db_add_field(), db_fetch_array(), db_fetch_object(), db_result(), dblog_event(), dblog_overview(), dblog_top(), drupal_get_installed_schema_version(), drupal_get_normal_path(), drupal_get_path_alias(), drupal_http_request(), drupal_map_assoc(), drupal_test_mysql(), drupal_test_mysqli(), drupal_test_pgsql(), drupal_uninstall_module(), filter_admin_format_form_validate(), filter_formats(), filter_list_format(), forum_block(), forum_get_topics(), forum_term_load(), hook_cron(), hook_ping(), hook_update_index(), image_gd_crop(), image_gd_resize(), image_gd_rotate(), install_task_list(), install_verify_drupal(), language_list(), list_themes(), locale(), locale_batch_by_component(), locale_batch_by_language(), locale_translate_edit_form(), menu_delete_menu_confirm_submit(), menu_edit_menu_submit(), menu_enable(), menu_get_menus(), menu_get_names(), menu_link_delete(), menu_link_save(), menu_local_tasks(), menu_nodeapi(), menu_overview_form(), menu_overview_page(), menu_tree_check_access(), menu_tree_data(), menu_tree_page_data(), module_invoke_all(), module_list(), node_access(), node_access_example_nodeapi(), node_access_rebuild(), node_access_view_all_nodes(), node_admin_nodes(), node_assign_owner_action_form(), node_feed(), node_invoke_nodeapi(), node_page_default(), node_revision_list(), node_title_list(), node_update_index(), openid_authentication_page(), openid_discovery(), openid_user_identities(), openid_verify_assertion(), path_admin_overview(), ping_ping(), poll_cron(), poll_load(), poll_page(), poll_votes(), profile_admin_overview(), profile_admin_settings_autocomplete(), profile_autocomplete(), profile_block(), profile_browse(), profile_categories(), profile_form_profile(), profile_load_profile(), profile_save_profile(), profile_validate_profile(), profile_view_profile(), sess_read(), sess_write(), statistics_access_log(), statistics_block(), statistics_node_tracker(), statistics_recent_hits(), statistics_top_pages(), statistics_top_referrers(), statistics_top_visitors(), statistics_user_tracker(), system_actions_manage(), system_admin_menu_block(), system_admin_theme_submit(), system_check_http_request(), system_cron(), system_date_time_lookup(), system_get_files_database(), system_get_module_admin_tasks(), system_initialize_theme_blocks(), system_main_admin_page(), system_sql(), system_update_6018(), system_update_6034(), system_update_6039(), system_update_6045(), taxonomy_autocomplete(), taxonomy_del_vocabulary(), taxonomy_get_children(), taxonomy_get_parents(), taxonomy_get_related(), taxonomy_get_synonyms(), taxonomy_get_term_by_name(), taxonomy_get_tree(), taxonomy_get_vocabularies(), taxonomy_node_get_terms(), taxonomy_node_get_terms_by_vocabulary(), taxonomy_render_nodes(), taxonomy_select_nodes(), taxonomy_term_count_nodes(), taxonomy_term_page(), taxonomy_vocabulary_load(), template_preprocess_forum_topic_navigation(), template_preprocess_search_result(), template_preprocess_search_results(), theme_taxonomy_term_page(), tracker_page(), translation_node_get_translations(), trigger_nodeapi(), update_fix_compatibility(), update_sql(), upload_delete(), upload_file_download(), upload_load(), user_access(), user_admin_access(), user_admin_account(), user_admin_perm(), user_admin_perm_submit(), user_autocomplete(), user_block(), user_external_load(), user_fields(), user_get_authmaps(), user_load(), user_roles(), user_search(), variable_init(), xmlrpc_server(), and xmlrpc_server_multicall().

$square = bcmod(bcmul($square, $square), $mod)

Definition at line 434 of file openid.inc.

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/openid/openid.install File Reference

modules » openid

openid.install File Reference

Go to the source code of this file.

Functions

  • openid_install ()
    Implementation of hook_install().
  • openid_schema ()
    Implementation of hook_schema().
  • openid_uninstall ()
    Implementation of hook_uninstall().

Function Documentation

openid_install ( )

Implementation of hook_install().

Definition at line 7 of file openid.install.

References drupal_install_schema().

openid_schema ( )

Implementation of hook_schema().

Definition at line 23 of file openid.install.

References t().

openid_uninstall ( )

Implementation of hook_uninstall().

Definition at line 15 of file openid.install.

References drupal_uninstall_schema().

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/openid/openid.module File Reference

modules » openid

openid.module File Reference

Detailed Description

Implement OpenID Relying Party support for Drupal.

Definition in file openid.module.

Go to the source code of this file.

Functions

  • openid_association ($op_endpoint)
    Attempt to create a shared secret with the OpenID Provider.
  • openid_association_request ($public)
  • openid_authentication ($response)
    Authenticate a user or attempt registration.
  • openid_authentication_request ($claimed_id, $identity, $return_to= '', $assoc_handle= '', $version=2)
  • openid_begin ($claimed_id, $return_to= '', $form_values=array())
    The initial step of OpenID authentication responsible for the following:
    • Perform discovery on the claimed OpenID.

  • openid_complete ($response=array())
    Completes OpenID authentication by validating returned data from the OpenID Provider.
  • openid_discovery ($claimed_id)
    Perform discovery on a claimed ID to determine the OpenID provider endpoint.
  • openid_form_alter (&$form, $form_state, $form_id)
    Implementation of hook_form_alter : adds OpenID login to the login forms.
  • openid_help ($path, $arg)
    Implementation of hook_help().
  • openid_login_validate ($form, &$form_state)
    Login form _validate hook.
  • openid_menu ()
    Implementation of hook_menu.
  • openid_user ($op, &$edit, &$account, $category=NULL)
    Implementation of hook_user().
  • openid_verify_assertion ($op_endpoint, $response)
    Attempt to verify the response received from the OpenID Provider.

Function Documentation

openid_association ( $ op_endpoint )

Attempt to create a shared secret with the OpenID Provider.

Parameters:
$op_endpoint URL of the OpenID Provider endpoint.
Returns:
$assoc_handle The association handle.

Definition at line 333 of file openid.module.

References _openid_create_message(), _openid_dh_base64_to_long(), _openid_dh_rand(), _openid_dh_xorsecret(), _openid_encode_message(), _openid_parse_message(), db_query(), db_result(), drupal_http_request(), module_invoke(), module_load_include(), and openid_association_request().

Referenced by openid_begin().

openid_association_request ( $ public )

Definition at line 438 of file openid.module.

References _openid_dh_long_to_base64(), and module_load_include().

Referenced by openid_association().

openid_authentication ( $ response )

Authenticate a user or attempt registration.

Parameters:
$response Response values from the OpenID Provider.

Definition at line 384 of file openid.module.

References drupal_get_destination(), drupal_goto(), drupal_prepare_form(), drupal_redirect_form(), drupal_retrieve_form(), drupal_set_message(), drupal_validate_form(), form_get_errors(), module_load_include(), t(), url(), user_external_load(), user_external_login(), user_password(), user_save(), and variable_get().

Referenced by openid_authentication_page().

openid_authentication_request | ( | $ | claimed_id,
 |  | $ | identity,
 |  | $ | return_to = '',
 |  | $ | assoc_handle = '',
 |  | $ | version = 2
 | ) |  |

Definition at line 456 of file openid.module.

References module_invoke_all(), module_load_include(), and url().

Referenced by openid_begin().

openid_begin | ( | $ | claimed_id,
 |  | $ | return_to = '',
 |  | $ | form_values = array()
 | ) |  |

The initial step of OpenID authentication responsible for the following:

  • Perform discovery on the claimed OpenID.

  • If possible, create an association with the Provider's endpoint.
  • Create the authentication request.
  • Perform the appropriate redirect.

Parameters:
$claimed_id | The OpenID to authenticate
$return_to | The endpoint to return to from the OpenID Provider

Definition at line 153 of file openid.module.

References _openid_normalize(), form_set_error(), module_load_include(), openid_association(), openid_authentication_request(), openid_discovery(), openid_redirect(), openid_redirect_http(), and t().

Referenced by openid_login_validate(), and openid_user_add_validate().

openid_complete ( $ response = array() )

Completes OpenID authentication by validating returned data from the OpenID Provider.

Parameters:
$response Array of returned values from the OpenID Provider.
Returns:
$response Response values for further processing with $response['status'] set to one of 'success', 'failed' or 'cancel'.

Definition at line 215 of file openid.module.

References _openid_response(), module_load_include(), openid_discovery(), and openid_verify_assertion().

Referenced by openid_authentication_page(), and openid_user_identities().

openid_discovery ( $ claimed_id )

Perform discovery on a claimed ID to determine the OpenID provider endpoint.

Parameters:
$claimed_id The OpenID URL to perform discovery on.
Returns:
Array of services discovered (including OpenID version, endpoint URI, etc).

Definition at line 262 of file openid.module.

References $result, $url, _openid_is_xri(), _openid_link_href(), _openid_meta_httpequiv(), drupal_http_request(), module_invoke(), module_load_include(), and xrds_parse().

Referenced by openid_begin(), and openid_complete().

openid_form_alter | ( | &$ | form,
 |  | $ | form_state,
 |  | $ | form_id
 | ) |  |

Implementation of hook_form_alter : adds OpenID login to the login forms.

Definition at line 77 of file openid.module.

References $items, drupal_add_css(), drupal_add_js(), drupal_get_destination(), drupal_get_path(), l(), t(), theme(), url(), user_password(), and variable_get().

openid_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 42 of file openid.module.

References $output, t(), and url().

openid_login_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Login form _validate hook.

Definition at line 134 of file openid.module.

References openid_begin(), and url().

openid_menu ( )

Implementation of hook_menu.

Definition at line 12 of file openid.module.

References $items.

openid_user | ( | $ | op,
 |  | &$ | edit,
 |  | &$ | account,
 |  | $ | category = NULL
 | ) |  |

Implementation of hook_user().

Definition at line 64 of file openid.module.

References $op, drupal_set_message(), t(), and variable_get().

openid_verify_assertion | ( | $ | op_endpoint,
 |  | $ | response
 | ) |  |

Attempt to verify the response received from the OpenID Provider.

Parameters:
$op_endpoint | The OpenID Provider URL.
$response | Array of repsonse values from the provider.
Returns:
boolean

Definition at line 493 of file openid.module.

References $result, _openid_create_message(), _openid_encode_message(), _openid_parse_message(), _openid_signature(), db_fetch_object(), db_query(), drupal_http_request(), module_invoke(), and module_load_include().

Referenced by openid_complete().

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/openid/openid.pages.inc File Reference

modules » openid

openid.pages.inc File Reference

Detailed Description

User page callbacks for the openid module.

Definition in file openid.pages.inc.

Go to the source code of this file.

Functions

  • openid_authentication_page ()
    Menu callback; Process an OpenID authentication.
  • openid_user_add ()
    Form builder; Add an OpenID identity.
  • openid_user_add_validate ($form, &$form_state)
  • openid_user_delete ($account, $aid=0)
    Menu callback; Delete the specified OpenID identity from the system.
  • openid_user_identities ($account)
    Menu callback; Manage OpenID identities for the specified user.

Function Documentation

openid_authentication_page ( )

Menu callback; Process an OpenID authentication.

Definition at line 12 of file openid.pages.inc.

References $result, drupal_goto(), drupal_set_message(), openid_authentication(), openid_complete(), and t().

openid_user_add_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 70 of file openid.pages.inc.

References _openid_normalize(), arg(), db_query(), db_result(), form_set_error(), openid_begin(), t(), and url().

openid_user_delete | ( | $ | account,
 |  | $ | aid = 0
 | ) |  |

Menu callback; Delete the specified OpenID identity from the system.

Definition at line 85 of file openid.pages.inc.

References db_affected_rows(), db_query(), drupal_goto(), drupal_set_message(), and t().

openid_user_identities ( $ account )

Menu callback; Manage OpenID identities for the specified user.

Definition at line 30 of file openid.pages.inc.

References $header, $output, $result, check_plain(), db_fetch_object(), db_query(), drupal_add_css(), drupal_get_form(), drupal_get_path(), drupal_set_message(), drupal_set_title(), l(), name, openid_complete(), t(), and theme().

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/openid/xrds.inc File Reference

modules » openid

xrds.inc File Reference

Go to the source code of this file.

Functions

  • _xrds_cdata (&$parser, $data)
  • _xrds_element_end (&$parser, $name)
  • _xrds_element_start (&$parser, $name, $attribs)
    Parser callback functions.
  • _xrds_strip_namespace ($name)
  • xrds_parse ($xml)
    Main entry point for parsing XRDS documents.

Variables

  • $xrds_current_service = array()
  • $xrds_open_elements = array()
  • $xrds_services = array()

Function Documentation

_xrds_cdata | ( | &$ | parser,
 |  | $ | data
 | ) |  |

Definition at line 55 of file xrds.inc.

References $xrds_current_service, $xrds_open_elements, and $xrds_services.

_xrds_element_end | ( | &$ | parser,
 |  | $ | name
 | ) |  |

Definition at line 34 of file xrds.inc.

References $name, $xrds_current_service, $xrds_open_elements, $xrds_services, and _xrds_strip_namespace().

_xrds_element_start | ( | &$ | parser,
 |  | $ | name,
 |  | $ | attribs
 | ) |  |

Parser callback functions.

Definition at line 28 of file xrds.inc.

References $name, $xrds_open_elements, and _xrds_strip_namespace().

_xrds_strip_namespace ( $ name )

Definition at line 74 of file xrds.inc.

References $name.

Referenced by _xrds_element_end(), and _xrds_element_start().

xrds_parse ( $ xml )

Main entry point for parsing XRDS documents.

Definition at line 12 of file xrds.inc.

References $xrds_services.

Referenced by openid_discovery().

Variable Documentation

$xrds_current_service = array()

Definition at line 7 of file xrds.inc.

$xrds_open_elements = array()

Definition at line 5 of file xrds.inc.

$xrds_services = array()

Definition at line 6 of file xrds.inc.

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/path/path.admin.inc File Reference

modules » path

path.admin.inc File Reference

Detailed Description

Administrative page callbacks for the path module.

Definition in file path.admin.inc.

Go to the source code of this file.

Functions

  • path_admin_delete_confirm ($form_state, $pid)
    Menu callback; confirms deleting an URL alias.
  • path_admin_delete_confirm_submit ($form, &$form_state)
    Execute URL alias deletion.
  • path_admin_edit ($pid=0)
    Menu callback; handles pages for creating and editing URL aliases.
  • path_admin_filter_form (&$form_state, $keys= '')
    Return a form to filter URL aliases.
  • path_admin_filter_form_submit_filter ($form, &$form_state)
    Process filter form submission when the Filter button is pressed.
  • path_admin_filter_form_submit_reset ($form, &$form_state)
    Process filter form submission when the Reset button is pressed.
  • path_admin_filter_get_keys ()
    Helper function for grabbing filter keys.
  • path_admin_form (&$form_state, $edit=array('src'=> '', 'dst'=> '', 'language'=> '', 'pid'=> NULL))
    Return a form for editing or creating an individual URL alias.
  • path_admin_form_submit ($form, &$form_state)
    Save a new URL alias to the database.
  • path_admin_form_validate ($form, &$form_state)
    Verify that a new URL alias is valid.
  • path_admin_overview ($keys=NULL)
    Return a listing of all defined URL aliases.

Function Documentation

path_admin_delete_confirm | ( | $ | form_state,
 |  | $ | pid
 | ) |  |

Menu callback; confirms deleting an URL alias.

Definition at line 162 of file path.admin.inc.

References $output, confirm_form(), path_load(), t(), and user_access().

path_admin_delete_confirm_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Execute URL alias deletion.

Definition at line 176 of file path.admin.inc.

References path_admin_delete().

path_admin_edit ( $ pid = 0 )

Menu callback; handles pages for creating and editing URL aliases.

Definition at line 67 of file path.admin.inc.

References $output, check_plain(), drupal_get_form(), drupal_set_title(), and path_load().

path_admin_filter_form_submit_filter | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process filter form submission when the Filter button is pressed.

Definition at line 222 of file path.admin.inc.

path_admin_filter_form_submit_reset | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process filter form submission when the Reset button is pressed.

Definition at line 229 of file path.admin.inc.

path_admin_filter_get_keys ( )

Helper function for grabbing filter keys.

Definition at line 237 of file path.admin.inc.

path_admin_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Save a new URL alias to the database.

Definition at line 150 of file path.admin.inc.

References drupal_set_message(), path_set_alias(), and t().

path_admin_form_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Verify that a new URL alias is valid.

Definition at line 131 of file path.admin.inc.

References $item, $language, db_query(), db_result(), form_set_error(), menu_get_item(), and t().

path_admin_overview ( $ keys = NULL )

Return a listing of all defined URL aliases.

When filter key passed, perform a standard search on the given key, and return the list of matching URL aliases.

Definition at line 14 of file path.admin.inc.

References $header, $output, $result, $row, check_plain(), db_fetch_object(), db_query(), db_result(), drupal_get_destination(), drupal_get_form(), l(), language, module_exists(), module_invoke(), pager_query(), t(), tablesort_sql(), and theme().

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/path/path.module File Reference

modules » path

path.module File Reference

Detailed Description

Enables users to rename URLs.

Definition in file path.module.

Go to the source code of this file.

Functions

  • path_admin_delete ($pid=0)
    Post-confirmation; delete an URL alias.
  • path_form_alter (&$form, $form_state, $form_id)
    Implementation of hook_form_alter().
  • path_help ($path, $arg)
    Implementation of hook_help().
  • path_load ($pid)
    Fetch a specific URL alias from the database.
  • path_menu ()
    Implementation of hook_menu().
  • path_nodeapi (&$node, $op, $arg)
    Implementation of hook_nodeapi().
  • path_perm ()
    Implementation of hook_perm().
  • path_set_alias ($path=NULL, $alias=NULL, $pid=NULL, $language= '')
    Set an aliased path for a given Drupal path, preventing duplicates.

Function Documentation

path_admin_delete ( $ pid = 0 )

Post-confirmation; delete an URL alias.

Definition at line 78 of file path.module.

References db_query(), drupal_set_message(), and t().

Referenced by path_admin_delete_confirm_submit().

path_form_alter | ( | &$ | form,
 |  | $ | form_state,
 |  | $ | form_id
 | ) |  |

Implementation of hook_form_alter().

Definition at line 177 of file path.module.

References db_query(), db_result(), language, t(), and user_access().

path_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 12 of file path.module.

References $output, and t().

path_load ( $ pid )

Fetch a specific URL alias from the database.

Definition at line 215 of file path.module.

References db_fetch_array(), and db_query().

Referenced by path_admin_delete_confirm(), and path_admin_edit().

path_menu ( )

Implementation of hook_menu().

Definition at line 38 of file path.module.

References $items.

path_nodeapi | ( | &$ | node,
 |  | $ | op,
 |  | $ | arg
 | ) |  |

Implementation of hook_nodeapi().

Allows URL aliases for nodes to be specified at node edit time rather than through the administrative interface.

Definition at line 132 of file path.module.

References $language, $op, db_query(), db_result(), drupal_get_path_alias(), form_set_error(), language, nid, path_set_alias(), t(), and user_access().

path_perm ( )

Implementation of hook_perm().

Definition at line 208 of file path.module.

path_set_alias | ( | $ | path = NULL,
 |  | $ | alias = NULL,
 |  | $ | pid = NULL,
 |  | $ | language = ''
 | ) |  |

Set an aliased path for a given Drupal path, preventing duplicates.

Definition at line 86 of file path.module.

References $language, db_query(), drupal_clear_path_cache(), and drupal_get_path_alias().

Referenced by path_admin_form_submit(), and path_nodeapi().

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/php/php.install File Reference

modules » php

php.install File Reference

Go to the source code of this file.

Functions

  • php_disable ()
    Implementation of hook_disable().
  • php_install ()
    Implementation of hook_install().

Function Documentation

php_disable ( )

Implementation of hook_disable().

Definition at line 27 of file php.install.

References drupal_set_message(), and t().

php_install ( )

Implementation of hook_install().

Definition at line 7 of file php.install.

References db_query(), db_result(), drupal_set_message(), l(), and t().

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/php/php.module File Reference

modules » php

php.module File Reference

Detailed Description

Additional filter for PHP input.

Definition in file php.module.

Go to the source code of this file.

Functions

  • php_filter ($op, $delta=0, $format=-1, $text= '')
    Implementation of hook_filter().
  • php_filter_tips ($delta, $format, $long=false)
    Implementation of hook_filter_tips().
  • php_help ($path, $arg)
    Implementation of hook_help().

Function Documentation

php_filter | ( | $ | op,
 |  | $ | delta = 0,
 |  | $ | format = -1,
 |  | $ | text = ''
 | ) |  |

Implementation of hook_filter().

Contains a basic PHP evaluator.

Executes PHP code. Use with care.

Definition at line 72 of file php.module.

References $op, drupal_eval(), and t().

php_filter_tips | ( | $ | delta,
 |  | $ | format,
 |  | $ | long = false
 | ) |  |

Implementation of hook_filter_tips().

Definition at line 27 of file php.module.

References $base_url, $output, t(), and url().

php_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 13 of file php.module.

References $output, t(), and url().

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/ping/ping.module File Reference

modules » ping

ping.module File Reference

Detailed Description

Alerts other sites that your site has been updated.

Definition in file ping.module.

Go to the source code of this file.

Functions

  • _ping_notify ($name, $url)
    Call hook_ping() in all modules to notify remote sites that there is new content at this one.
  • ping_cron ()
    Implementation of hook_cron().
  • ping_help ($path, $arg)
    Implementation of hook_help().
  • ping_ping ($name= '', $url= '')
    Implementation of hook_ping().

Function Documentation

_ping_notify | ( | $ | name,
 |  | $ | url
 | ) |  |

Call hook_ping() in all modules to notify remote sites that there is new content at this one.

Definition at line 41 of file ping.module.

References $name, $url, and module_invoke_all().

Referenced by ping_cron().

ping_cron ( )

Implementation of hook_cron().

Fire off notifications of updates to remote sites.

Definition at line 27 of file ping.module.

References $base_url, _ping_notify(), db_query(), db_result(), and variable_get().

ping_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 12 of file ping.module.

References $output, t(), and url().

ping_ping | ( | $ | name = '',
 |  | $ | url = ''
 | ) |  |

Implementation of hook_ping().

Notifies pingomatic.com, blo.gs, and technorati.com of changes at this site.

Definition at line 50 of file ping.module.

References $name, $result, $url, watchdog(), and xmlrpc().

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/poll/poll-bar-block.tpl.php File Reference

modules » poll

poll-bar-block.tpl.php File Reference

Detailed Description

Display the bar for a single choice in a poll.

Variables available:

  • $title: The title of the poll.
  • $votes: The number of votes for this choice
  • $total_votes: The number of votes for this choice
  • $percentage: The percentage of votes for this choice.
  • $vote: The choice number of the current user's vote.
  • $voted: Set to TRUE if the user voted for this choice.

See also:
template_preprocess_poll_bar()

Definition in file poll-bar-block.tpl.php.

Go to the source code of this file.

Variables

  • print $percentage
  • print $title

Variable Documentation

print $percentage

Definition at line 22 of file poll-bar-block.tpl.php.

Referenced by _batch_do(), _batch_process(), _batch_progress_page_nojs(), and search_admin_settings().

print $title

Definition at line 20 of file poll-bar-block.tpl.php.

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/poll/poll-bar.tpl.php File Reference

modules » poll

poll-bar.tpl.php File Reference

Detailed Description

Display the bar for a single choice in a poll.

Variables available:

  • $title: The title of the poll.
  • $votes: The number of votes for this choice
  • $total_votes: The number of votes for this choice
  • $percentage: The percentage of votes for this choice.
  • $vote: The choice number of the current user's vote.
  • $voted: Set to TRUE if the user voted for this choice.

See also:
template_preprocess_poll_bar()

Definition in file poll-bar.tpl.php.

Go to the source code of this file.

Variables

  • print $percentage
  • print $title

Variable Documentation

print $percentage

Definition at line 22 of file poll-bar.tpl.php.

print $title

Definition at line 20 of file poll-bar.tpl.php.

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/poll/poll-results-block.tpl.php File Reference

modules » poll

poll-results-block.tpl.php File Reference

Detailed Description

Display the poll results in a block.

Variables available:

  • $title: The title of the poll.
  • $results: The results of the poll.
  • $votes: The total results in the poll.
  • $links: Links in the poll.
  • $nid: The nid of the poll
  • $cancel_form: A form to cancel the user's vote, if allowed.
  • $raw_links: The raw array of links. Should be run through theme('links') if used.
  • $vote: The choice number of the current user's vote.

See also:
template_preprocess_poll_results()
Variables available:
  • $title: The title of the poll.
  • $results: The results of the poll.
  • $votes: The total results in the poll.
  • $links: Links in the poll.
  • $nid: The nid of the poll
  • $cancel_form: A form to cancel the user's vote, if allowed.
  • $raw_links: The raw array of links.
  • $vote: The choice number of the current user's vote.

See also:
template_preprocess_poll_results()

Definition in file poll-results-block.tpl.php.

Go to the source code of this file.

Variables

  • print $links

Variable Documentation

print $links

Definition at line 29 of file poll-results-block.tpl.php.

Referenced by blog_link(), book_link(), chameleon_comment(), chameleon_node(), comment_link(), comment_links(), comment_render(), forum_link_alter(), hook_link(), hook_link_alter(), locale_block(), menu_navigation_links(), node_link(), node_view(), poll_view(), statistics_link(), taxonomy_link(), template_preprocess_book_navigation(), theme_comment_view(), theme_links(), theme_submenu(), theme_update_version(), translation_link(), translation_translation_link_alter(), update_results_page(), and upload_link().

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/poll/poll-results.tpl.php File Reference

modules » poll

poll-results.tpl.php File Reference

Go to the source code of this file.

Variables

  • print $results

Variable Documentation

print $results

Definition at line 22 of file poll-results.tpl.php.

Referenced by _locale_batch_language_finished(), _locale_batch_system_finished(), _node_mass_update_batch_finished(), actions_synchronize(), batch_example_finished(), forum_taxonomy(), hook_search(), node_search(), search_view(), taxonomy_overview_terms(), and update_finished().

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/poll/poll-vote.tpl.php File Reference

modules » poll

poll-vote.tpl.php File Reference

Detailed Description

Voting form for a poll.

  • $choice: The radio buttons for the choices in the poll.
  • $title: The title of the poll.
  • $block: True if this is being displayed as a block.
  • $vote: The vote button
  • $rest: Anything else in the form that may have been added via form_alter hooks.

See also:
template_preprocess_poll_vote()

Definition in file poll-vote.tpl.php.

Go to the source code of this file.

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/poll/poll.install File Reference

modules » poll

poll.install File Reference

Go to the source code of this file.

Functions

  • poll_install ()
    Implementation of hook_install().
  • poll_schema ()
    Implementation of hook_schema().
  • poll_uninstall ()
    Implementation of hook_uninstall().

Function Documentation

poll_install ( )

Implementation of hook_install().

Definition at line 7 of file poll.install.

References drupal_install_schema().

poll_schema ( )

Implementation of hook_schema().

Definition at line 23 of file poll.install.

References t().

poll_uninstall ( )

Implementation of hook_uninstall().

Definition at line 15 of file poll.install.

References drupal_uninstall_schema().

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/poll/poll.module File Reference

modules » poll

poll.module File Reference

Detailed Description

Enables your site to capture votes on different topics in the form of multiple choice questions.

Definition in file poll.module.

Go to the source code of this file.

Functions

  • _poll_choice_form ($delta, $value= '', $votes=0)
  • _poll_menu_access ($node, $perm, $inspect_allowvotes)
    Callback function to see if a node is acceptable for poll menu items.
  • poll_access ($op, $node, $account)
    Implementation of hook_access().
  • poll_block ($op= 'list', $delta=0)
    Implementation of hook_block().
  • poll_cancel ($form, &$form_state)
    Submit callback for poll_cancel_form.
  • poll_cancel_form (&$form_state, $nid)
    Builds the cancel form for a poll.
  • poll_choice_js ()
    Menu callback for AHAH additions.
  • poll_cron ()
    Implementation of hook_cron().
  • poll_delete ($node)
    Implementation of hook_delete().
  • poll_form (&$node, $form_state)
    Implementation of hook_form().
  • poll_help ($path, $arg)
    Implementation of hook_help().
  • poll_init ()
    Implementation of hook_init().
  • poll_insert ($node)
    Implementation of hook_insert().
  • poll_load ($node)
    Implementation of hook_load().
  • poll_menu ()
    Implementation of hook_menu().
  • poll_more_choices_submit ($form, &$form_state)
    Submit handler to add more choices to a poll form.
  • poll_node_form_submit (&$form, &$form_state)
    Implementation of hook_submit().
  • poll_node_info ()
    Implementation of hook_node_info().
  • poll_perm ()
    Implementation of hook_perm().
  • poll_teaser ($node)
    Creates a simple teaser that lists all the choices.
  • poll_theme ()
    Implementation of hook_theme().
  • poll_update ($node)
    Implementation of hook_update().
  • poll_user ($op, &$edit, &$user)
    Implementation of hook_user().
  • poll_validate ($node)
    Implementation of hook_validate().
  • poll_view ($node, $teaser=FALSE, $page=FALSE, $block=FALSE)
    Implementation of hook_view().
  • poll_view_results (&$node, $teaser, $page, $block)
    Generates a graphical representation of the results of a poll.
  • poll_view_voting (&$form_state, $node, $block)
    Generates the voting form for a poll.
  • poll_view_voting_validate ($form, &$form_state)
    Validation function for processing votes.
  • poll_vote ($form, &$form_state)
    Submit handler for processing a vote.
  • template_preprocess_poll_bar (&$variables)
    Preprocess the poll_bar theme hook.
  • template_preprocess_poll_results (&$variables)
    Preprocess the poll_results theme hook.
  • template_preprocess_poll_vote (&$variables)
    Themes the voting form for a poll.
  • theme_poll_choices ($form)
    Theme the admin poll form for choices.

Function Documentation

_poll_choice_form | ( | $ | delta,
 |  | $ | value = '',
 |  | $ | votes = 0
 | ) |  |

Definition at line 295 of file poll.module.

References $value, t(), and user_access().

Referenced by poll_choice_js(), and poll_form().

_poll_menu_access | ( | $ | node,
 |  | $ | perm,
 |  | $ | inspect_allowvotes
 | ) |  |

Callback function to see if a node is acceptable for poll menu items.

Definition at line 121 of file poll.module.

References user_access().

poll_access | ( | $ | op,
 |  | $ | node,
 |  | $ | account
 | ) |  |

Implementation of hook_access().

Definition at line 63 of file poll.module.

References $op, and user_access().

poll_block | ( | $ | op = 'list',
 |  | $ | delta = 0
 | ) |  |

Implementation of hook_block().

Generates a block containing the latest poll.

Definition at line 130 of file poll.module.

References $op, content, db_query(), db_result(), db_rewrite_sql(), drupal_render(), nid, node_load(), poll_view(), t(), and user_access().

poll_cancel | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit callback for poll_cancel_form.

Definition at line 771 of file poll.module.

References $user, db_query(), ip_address(), nid, and node_load().

poll_choice_js ( )

Menu callback for AHAH additions.

Definition at line 328 of file poll.module.

References $output, _poll_choice_form(), drupal_alter(), drupal_json(), drupal_render(), form_builder(), form_get_cache(), form_set_cache(), and theme().

poll_cron ( )

Implementation of hook_cron().

Closes polls that have exceeded their allowed runtime.

Definition at line 159 of file poll.module.

References $result, db_fetch_object(), db_query(), and nid.

poll_delete ( $ node )

Implementation of hook_delete().

Definition at line 488 of file poll.module.

References db_query(), and nid.

poll_form | ( | &$ | node,
 |  | $ | form_state
 | ) |  |

Implementation of hook_form().

Definition at line 184 of file poll.module.

References $type, $user, _poll_choice_form(), check_plain(), drupal_map_assoc(), node_get_types(), t(), and user_access().

poll_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 13 of file poll.module.

References $output, t(), and url().

poll_init ( )

Implementation of hook_init().

Definition at line 26 of file poll.module.

References drupal_add_css(), and drupal_get_path().

poll_insert ( $ node )

Implementation of hook_insert().

Definition at line 432 of file poll.module.

References db_query(), nid, and user_access().

poll_load ( $ node )

Implementation of hook_load().

Definition at line 398 of file poll.module.

References $result, $user, db_fetch_array(), db_fetch_object(), db_query(), ip_address(), nid, and user_access().

poll_menu ( )

Implementation of hook_menu().

Definition at line 77 of file poll.module.

References $items.

poll_more_choices_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit handler to add more choices to a poll form.

This handler is used when javascript is not available. It makes changes to the form state and the entire form is rebuilt during the page reload.

Definition at line 285 of file poll.module.

References node_form_submit_build_node().

poll_node_form_submit | ( | &$ | form,
 |  | &$ | form_state
 | ) |  |

Implementation of hook_submit().

Definition at line 365 of file poll.module.

References poll_teaser().

poll_node_info ( )

Implementation of hook_node_info().

Definition at line 169 of file poll.module.

References t().

poll_perm ( )

Implementation of hook_perm().

Definition at line 56 of file poll.module.

poll_teaser ( $ node )

Creates a simple teaser that lists all the choices.

This is primarily used for RSS.

Definition at line 537 of file poll.module.

References check_plain().

Referenced by poll_node_form_submit().

poll_theme ( )

Implementation of hook_theme().

Definition at line 33 of file poll.module.

poll_update ( $ node )

Implementation of hook_update().

Definition at line 454 of file poll.module.

References db_query(), and nid.

poll_user | ( | $ | op,
 |  | &$ | edit,
 |  | &$ | user
 | ) |  |

Implementation of hook_user().

Definition at line 789 of file poll.module.

References $op, $user, and db_query().

poll_validate ( $ node )

Implementation of hook_validate().

Definition at line 374 of file poll.module.

References form_set_error(), and t().

poll_view | ( | $ | node,
 |  | $ | teaser = FALSE,
 |  | $ | page = FALSE,
 |  | $ | block = FALSE
 | ) |  |

Implementation of hook_view().

Parameters:
$block An extra parameter that adapts the hook to display a block-ready rendering of the poll.

Definition at line 501 of file poll.module.

References $links, $output, $user, drupal_get_form(), module_invoke_all(), nid, poll_view_results(), and t().

Referenced by poll_block().

poll_view_results | ( | &$ | node,
 |  | $ | teaser,
 |  | $ | page,
 |  | $ | block
 | ) |  |

Generates a graphical representation of the results of a poll.

Definition at line 642 of file poll.module.

References nid, and theme().

Referenced by poll_view().

poll_view_voting_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validation function for processing votes.

Definition at line 591 of file poll.module.

References form_set_error(), and t().

poll_vote | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit handler for processing a vote.

Definition at line 600 of file poll.module.

References $user, cache_clear_all(), db_query(), drupal_set_message(), ip_address(), nid, and t().

template_preprocess_poll_bar ( &$ variables )

Preprocess the poll_bar theme hook.

Inputs: $title, $votes, $total_votes, $voted, $block

See also:
poll-bar.tpl.php

poll-bar-block.tpl.php

theme_poll_bar()

Definition at line 739 of file poll.module.

References check_plain().

template_preprocess_poll_results ( &$ variables )

Preprocess the poll_results theme hook.

Inputs: $raw_title, $results, $votes, $raw_links, $block, $nid, $vote. The $raw_* inputs to this are naturally unsafe; often safe versions are made to simply overwrite the raw version, but in this case it seems likely that the title and the links may be overridden by the theme layer, so they are left in with a different name for that purpose.

See also:
poll-results.tpl.php

poll-results-block.tpl.php

theme_poll_results()

Definition at line 717 of file poll.module.

References check_plain(), drupal_get_form(), theme(), and user_access().

template_preprocess_poll_vote ( &$ variables )

Themes the voting form for a poll.

Inputs: $form

Definition at line 626 of file poll.module.

References check_plain(), and drupal_render().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/poll/poll.pages.inc File Reference

modules » poll

poll.pages.inc File Reference

Detailed Description

User page callbacks for the poll module.

Definition in file poll.pages.inc.

Go to the source code of this file.

Functions

  • poll_page ()
    Menu callback to provide a simple list of all polls available.
  • poll_results ($node)
    Callback for the 'results' tab for polls you can vote on.
  • poll_votes ($node)
    Callback for the 'votes' tab for polls you can see other votes on.

Function Documentation

poll_page ( )

Menu callback to provide a simple list of all polls available.

Definition at line 12 of file poll.pages.inc.

References $output, $result, db_fetch_object(), db_rewrite_sql(), format_plural(), l(), pager_query(), t(), and theme().

poll_results ( $ node )

Callback for the 'results' tab for polls you can vote on.

Definition at line 52 of file poll.pages.inc.

References check_plain(), drupal_set_title(), and node_show().

poll_votes ( $ node )

Callback for the 'votes' tab for polls you can see other votes on.

Definition at line 30 of file poll.pages.inc.

References $header, $output, $result, check_plain(), db_fetch_object(), drupal_set_title(), name, nid, pager_query(), t(), tablesort_sql(), and theme().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/profile/profile-block.tpl.php File Reference

modules » profile

profile-block.tpl.php File Reference

Detailed Description

Default theme implementation for displaying a users profile within a block.

It only shows in relation to a node displayed as a full page.

Available variables:

  • $picture: Image configured for the account linking to the users page.
  • $profile: Keyed array of all profile fields that have a value.

Each $field in $profile contains:

  • $field->title: Title of the profile field.
  • $field->value: Value of the profile field.
  • $field->type: Type of the profile field, i.e., checkbox, textfield, textarea, selection, list, url or date.

Since $profile is keyed, a direct print of the field is possible. Not all accounts may have a value for a profile so do a check first. If a field of "last_name" was set for the site, the following can be used.

<?php if (isset($profile['last_name'])): ?>

<?php print $profile['last_name']->title; ?>:
<?php print $profile['last_name']->value; ?>
<?php endif; ?>

See also:
template_preprocess_profile_block()

Definition in file profile-block.tpl.php.

Go to the source code of this file.

Variables

  • print $picture

Variable Documentation

print $picture

Definition at line 33 of file profile-block.tpl.php.

Referenced by template_preprocess_user_picture(), and user_edit_form().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/profile/profile-listing.tpl.php File Reference

modules » profile

profile-listing.tpl.php File Reference

Detailed Description

Default theme implementation for displaying a user and their profile data for member listing pages.

See also:
profile-wrapper.tpl.php where all the data is collected and printed out.
Available variables:
  • $picture: Image configured for the account linking to the users page.
  • $name: User's account name linking to the users page.
  • $profile: Keyed array of all profile fields that are set as visible in member list pages (configured by site administrators). It also needs to have a value in order to be present.

Each $field in $profile contains:

  • $field->title: Title of the profile field.
  • $field->value: Value of the profile field.
  • $field->type: Type of the profile field, i.e., checkbox, textfield, textarea, selection, list, url or date.

Since $profile is keyed, a direct print of the field is possible. Not all accounts may have a value for a profile so do a check first. If a field of "last_name" was set for the site, the following can be used.

<?php if (isset($profile['last_name'])): ?>

<?php print $profile['last_name']->title; ?>:
<?php print $profile['last_name']->value; ?>
<?php endif; ?>

See also:
template_preprocess_profile_listing()

Definition in file profile-listing.tpl.php.

Go to the source code of this file.

Variables

  • print $name
  • print $picture

Variable Documentation

print $name

Definition at line 43 of file profile-listing.tpl.php.

Referenced by _blogapi_get_node_types(), _db_create_field_sql(), _db_create_index_sql(), _db_create_keys(), _db_query(), _drupal_initialize_schema(), _form_builder_handle_input_element(), _init_theme(), _node_mass_update_helper(), _ping_notify(), _theme_process_registry(), _update_build_fetch_url(), _upload_file_limits(), _xrds_element_end(), _xrds_element_start(), _xrds_strip_namespace(), aggregator_element_end(), aggregator_element_start(), blogapi_blogger_get_user_info(), blogapi_metaweblog_new_media_object(), color_scheme_form(), comment_invoke_comment(), confirm_form(), db_add_index(), db_add_unique_key(), db_create_table(), db_create_table_sql(), db_drop_index(), db_drop_unique_key(), db_set_active(), dblog_filter_form_submit(), drupal_get_filename(), drupal_get_path(), drupal_install_profile_name(), drupal_install_schema(), drupal_load(), drupal_mail_send(), update_xml_parser::end(), file_create_filename(), file_save_upload(), file_scan_directory(), filter_admin_format_form(), filter_admin_format_form_submit(), filter_admin_format_form_validate(), filter_admin_overview(), filter_list_all(), flood_is_allowed(), flood_register_event(), form_set_error(), help_links_as_list(), help_page(), hook_ping(), install_select_locale_form(), install_select_profile_form(), locale_add_language(), locale_translate_overview_screen(), locale_user(), menu_block(), menu_get_active_help(), menu_get_names(), module_iterate(), module_list(), module_load_all_includes(), module_load_include(), node_invoke_nodeapi(), node_overview_types(), node_perm(), ping_ping(), profile_browse(), update_xml_parser::start(), system_actions_configure(), system_module_build_dependencies(), system_modules_confirm_form(), system_modules_submit(), system_theme_settings(), system_update_6020(), taxonomy_form(), taxonomy_get_term_by_name(), theme(), theme_color_scheme_form(), theme_filter_admin_overview(), theme_filter_tips(), theme_get_settings(), theme_user_admin_new_role(), theme_username(), timer_read(), timer_start(), timer_stop(), update_check_incompatibility(), user_admin_perm(), user_external_login_register(), user_is_blocked(), user_pass_validate(), user_register_submit(), user_validate_name(), variable_del(), variable_get(), variable_init(), variable_set(), and xmlrpc_value_get_xml().

print $picture

Definition at line 40 of file profile-listing.tpl.php.

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/profile/profile-wrapper.tpl.php File Reference

modules » profile

profile-wrapper.tpl.php File Reference

Detailed Description

Default theme implementation for wrapping member listings and their profiles.

This template is used when viewing a list of users. It can be a general list for viewing all users with the url of "example.com/profile" or when viewing a set of users who share a specific value for a profile such as "example.com/profile/country/belgium".

Available variables:

  • $content: User account profiles iterated through profile-listing.tpl.php.
  • $current_field: The named field being browsed. Provided here for context. The above example would result in "last_name". An alternate template name is also based on this, e.g., "profile-wrapper-last_name.tpl.php".

See also:
template_preprocess_profile_wrapper()

Definition in file profile-wrapper.tpl.php.

Go to the source code of this file.

Variables

  • print $content

Variable Documentation

print $content

Definition at line 24 of file profile-wrapper.tpl.php.

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/profile/profile.admin.inc File Reference

modules » profile

profile.admin.inc File Reference

Detailed Description

Administrative page callbacks for the profile module.

Definition in file profile.admin.inc.

Go to the source code of this file.

Functions

  • profile_admin_overview ()
    Form builder to display a listing of all editable profile fields.
  • profile_admin_overview_submit ($form, &$form_state)
    Submit handler to update changed profile field weights and categories.
  • profile_admin_settings_autocomplete ($string)
    Retrieve a pipe delimited string of autocomplete suggestions for profile categories.
  • profile_field_delete (&$form_state, $fid)
    Menu callback; deletes a field from all user profiles.
  • profile_field_delete_submit ($form, &$form_state)
    Process a field delete form submission.
  • profile_field_form (&$form_state, $arg=NULL)
    Menu callback: Generate a form to add/edit a user profile field.
  • profile_field_form_submit ($form, &$form_state)
    Process profile_field_form submissions.
  • profile_field_form_validate ($form, &$form_state)
    Validate profile_field_form submissions.
  • theme_profile_admin_overview ($form)
    Theme the profile field overview into a drag and drop enabled table.

Function Documentation

profile_admin_overview_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit handler to update changed profile field weights and categories.

See also:
profile_admin_overview()

Definition at line 71 of file profile.admin.inc.

References cache_clear_all(), db_query(), drupal_set_message(), element_children(), menu_rebuild(), and t().

profile_admin_settings_autocomplete ( $ string )

Retrieve a pipe delimited string of autocomplete suggestions for profile categories.

Definition at line 396 of file profile.admin.inc.

References $result, check_plain(), db_fetch_object(), db_query_range(), drupal_to_js(), and exit.

profile_field_delete | ( | &$ | form_state,
 |  | $ | fid
 | ) |  |

Menu callback; deletes a field from all user profiles.

Definition at line 362 of file profile.admin.inc.

References confirm_form(), db_fetch_object(), db_query(), drupal_not_found(), t(), and url().

profile_field_delete_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process a field delete form submission.

Definition at line 380 of file profile.admin.inc.

References cache_clear_all(), db_query(), drupal_set_message(), l(), t(), and watchdog().

profile_field_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process profile_field_form submissions.

Definition at line 334 of file profile.admin.inc.

References cache_clear_all(), db_query(), drupal_set_message(), l(), menu_rebuild(), t(), and watchdog().

profile_field_form_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate profile_field_form submissions.

Definition at line 290 of file profile.admin.inc.

References db_query(), db_result(), form_set_error(), t(), and user_fields().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/profile/profile.install File Reference

modules » profile

profile.install File Reference

Go to the source code of this file.

Functions

  • profile_install ()
    Implementation of hook_install().
  • profile_schema ()
    Implementation of hook_schema().
  • profile_uninstall ()
    Implementation of hook_uninstall().

Function Documentation

profile_install ( )

Implementation of hook_install().

Definition at line 7 of file profile.install.

References drupal_install_schema().

profile_schema ( )

Implementation of hook_schema().

Definition at line 25 of file profile.install.

References t().

profile_uninstall ( )

Implementation of hook_uninstall().

Definition at line 15 of file profile.install.

References drupal_uninstall_schema(), and variable_del().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/profile/profile.module File Reference

modules » profile

profile.module File Reference

Detailed Description

Support for configurable user profiles.

Definition in file profile.module.

Go to the source code of this file.

Enumerations

  • enum PROFILE_HIDDEN
    Hidden profile field, only accessible by administrators, modules and themes. More...
  • enum PROFILE_PRIVATE
    Private field, content only available to privileged users. More...
  • enum PROFILE_PUBLIC
    Public field, content shown on profile page but not used on member list pages. More...
  • enum PROFILE_PUBLIC_LISTINGS
    Public field, content shown on profile page and on member list pages. More...

Functions

  • _profile_field_serialize ($type=NULL)
  • _profile_field_types ($type=NULL)
  • _profile_form_explanation ($field)
  • _profile_get_fields ($category, $register=FALSE)
  • _profile_update_user_fields ($fields, $account)
    Helper function: update an array of user fields by calling profile_view_field.
  • profile_block ($op= 'list', $delta=0, $edit=array())
    Implementation of hook_block().
  • profile_categories ()
  • profile_category_access ($category)
    Menu item access callback - check if a user has access to a profile category.
  • profile_form_profile ($edit, $user, $category, $register=FALSE)
  • profile_help ($path, $arg)
    Implementation of hook_help().
  • profile_load_profile (&$user)
  • profile_menu ()
    Implementation of hook_menu().
  • profile_save_profile (&$edit, &$user, $category, $register=FALSE)
  • profile_theme ()
    Implementation of hook_theme().
  • profile_user ($type, &$edit, &$user, $category=NULL)
    Implementation of hook_user().
  • profile_validate_profile ($edit, $category)
  • profile_view_field ($user, $field)
  • profile_view_profile (&$user)
  • template_preprocess_profile_block (&$variables)
    Process variables for profile-block.tpl.php.
  • template_preprocess_profile_listing (&$variables)
    Process variables for profile-listing.tpl.php.
  • template_preprocess_profile_wrapper (&$variables)
    Process variables for profile-wrapper.tpl.php.

Enumeration Type Documentation

enum PROFILE_HIDDEN

Hidden profile field, only accessible by administrators, modules and themes.

Definition at line 27 of file profile.module.

enum PROFILE_PRIVATE

Private field, content only available to privileged users.

Definition at line 12 of file profile.module.

enum PROFILE_PUBLIC

Public field, content shown on profile page but not used on member list pages.

Definition at line 17 of file profile.module.

enum PROFILE_PUBLIC_LISTINGS

Public field, content shown on profile page and on member list pages.

Definition at line 22 of file profile.module.

Function Documentation

_profile_field_serialize ( $ type = NULL )

Definition at line 551 of file profile.module.

References $type.

Referenced by profile_load_profile(), and profile_save_profile().

_profile_field_types ( $ type = NULL )

Definition at line 540 of file profile.module.

References $type, and t().

Referenced by profile_admin_overview(), and profile_field_form().

_profile_form_explanation ( $ field )

Definition at line 329 of file profile.module.

References $output, and t().

Referenced by profile_form_profile().

_profile_get_fields | ( | $ | category,
 |  | $ | register = FALSE
 | ) |  |

Definition at line 555 of file profile.module.

References db_query(), and user_access().

Referenced by profile_form_profile(), profile_save_profile(), and profile_validate_profile().

_profile_update_user_fields | ( | $ | fields,
 |  | $ | account
 | ) |  |

Helper function: update an array of user fields by calling profile_view_field.

Definition at line 422 of file profile.module.

References profile_view_field().

Referenced by profile_block(), and profile_browse().

profile_block | ( | $ | op = 'list',
 |  | $ | delta = 0,
 |  | $ | edit = array()
 | ) |  |

Implementation of hook_block().

Definition at line 134 of file profile.module.

References $op, $output, $profile, $result, _profile_update_user_fields(), arg(), check_plain(), db_fetch_object(), db_query(), l(), name, node_load(), t(), theme(), url(), user_access(), user_load(), variable_get(), and variable_set().

profile_categories ( )

Definition at line 447 of file profile.module.

References $result, db_fetch_object(), and db_query().

Referenced by profile_user().

profile_category_access ( $ category )

Menu item access callback - check if a user has access to a profile category.

Definition at line 465 of file profile.module.

References db_query(), db_result(), and user_access().

profile_form_profile | ( | $ | edit,
 |  | $ | user,
 |  | $ | category,
 |  | $ | register = FALSE
 | ) |  |

Definition at line 343 of file profile.module.

References $result, _profile_form_explanation(), _profile_get_fields(), check_plain(), db_fetch_object(), and name.

Referenced by profile_user().

profile_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 32 of file profile.module.

References $output, and t().

profile_load_profile ( &$ user )

Definition at line 224 of file profile.module.

References $result, $user, _profile_field_serialize(), db_fetch_object(), and db_query().

Referenced by profile_user(), and profile_view_profile().

profile_menu ( )

Implementation of hook_menu().

Definition at line 78 of file profile.module.

References $items.

profile_save_profile | ( | &$ | edit,
 |  | &$ | user,
 |  | $ | category,
 |  | $ | register = FALSE
 | ) |  |

Definition at line 233 of file profile.module.

References $result, $user, _profile_field_serialize(), _profile_get_fields(), db_fetch_object(), db_query(), and name.

Referenced by profile_user().

profile_theme ( )

Implementation of hook_theme().

Definition at line 54 of file profile.module.

profile_user | ( | $ | type,
 |  | &$ | edit,
 |  | &$ | user,
 |  | $ | category = NULL
 | ) |  |

Implementation of hook_user().

Definition at line 201 of file profile.module.

References $type, $user, db_query(), profile_categories(), profile_form_profile(), profile_load_profile(), profile_save_profile(), profile_validate_profile(), and profile_view_profile().

profile_validate_profile | ( | $ | edit,
 |  | $ | category
 | ) |  |

Definition at line 429 of file profile.module.

References $result, _profile_get_fields(), db_fetch_object(), form_set_error(), name, t(), user_access(), and valid_url().

Referenced by profile_user().

profile_view_field | ( | $ | user,
 |  | $ | field
 | ) |  |

Definition at line 246 of file profile.module.

References $user, $value, check_markup(), check_plain(), check_url(), l(), map_month(), name, user_access(), and variable_get().

Referenced by _profile_update_user_fields(), and profile_view_profile().

profile_view_profile ( &$ user )

Definition at line 293 of file profile.module.

References $result, $title, $user, $value, check_plain(), content, db_fetch_object(), db_query(), name, profile_load_profile(), profile_view_field(), and user_access().

Referenced by profile_user().

template_preprocess_profile_block ( &$ variables )

Process variables for profile-block.tpl.php.

The $variables array contains the following arguments:

  • $account
  • $fields

See also:
profile-block.tpl.php

Definition at line 483 of file profile.module.

References check_plain(), and theme().

template_preprocess_profile_listing ( &$ variables )

Process variables for profile-listing.tpl.php.

The $variables array contains the following arguments:

  • $account
  • $fields

See also:
profile-listing.tpl.php

Definition at line 507 of file profile.module.

References theme().

template_preprocess_profile_wrapper ( &$ variables )

Process variables for profile-wrapper.tpl.php.

The $variables array contains the following arguments:

  • $content

See also:
profile-wrapper.tpl.php

Definition at line 531 of file profile.module.

References arg().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/profile/profile.pages.inc File Reference

modules » profile

profile.pages.inc File Reference

Detailed Description

User page callbacks for the profile module.

Definition in file profile.pages.inc.

Go to the source code of this file.

Functions

  • profile_autocomplete ($field, $string)
    Callback to allow autocomplete of profile text fields.
  • profile_browse ()
    Menu callback; display a list of user information.

Function Documentation

profile_autocomplete | ( | $ | field,
 |  | $ | string
 | ) |  |

Callback to allow autocomplete of profile text fields.

Definition at line 110 of file profile.pages.inc.

References $result, check_plain(), db_fetch_object(), db_query(), db_query_range(), db_result(), and drupal_json().

profile_browse ( )

Menu callback; display a list of user information.

Definition at line 12 of file profile.pages.inc.

References $content, $name, $output, $profile, $result, $title, $value, _profile_update_user_fields(), check_plain(), db_fetch_object(), db_query(), drupal_access_denied(), drupal_not_found(), drupal_set_title(), pager_query(), t(), theme(), user_access(), and user_load().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/search/search-block-form.tpl.php File Reference

modules » search

search-block-form.tpl.php File Reference

Detailed Description

Default theme implementation for displaying a search form within a block region.

Available variables:

  • $search_form: The complete search form ready for print.
  • $search: Array of keyed search elements. Can be used to print each form element separately.

Default keys within $search:

  • $search['search_block_form']: Text input area wrapped in a div.
  • $search['submit']: Form submit button.
  • $search['hidden']: Hidden form elements. Used to validate forms when submitted.

Since $search is keyed, a direct print of the form element is possible. Modules can add to the search form so it is recommended to check for their existance before printing. The default keys will always exist.

<?php if (isset($search['extra_field'])): ?>

<?php print $search['extra_field']; ?>
<?php endif; ?>

To check for all available data within $search, use the code below.

<?php print '

'. check_plain(print_r($search, 1)) .'
'; ?>

See also:
template_preprocess_search_block_form()

Definition in file search-block-form.tpl.php.

Go to the source code of this file.

Variables

  • print $search_form

Variable Documentation

print $search_form

Definition at line 36 of file search-block-form.tpl.php.

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/search/search-result.tpl.php File Reference

modules » search

search-result.tpl.php File Reference

Detailed Description

Default theme implementation for displaying a single search result.

This template renders a single search result and is collected into search-results.tpl.php. This and the parent template are dependent to one another sharing the markup for definition lists.

Available variables:

  • $url: URL of the result.
  • $title: Title of the result.
  • $snippet: A small preview of the result. Does not apply to user searches.
  • $info: String of all the meta information ready for print. Does not apply to user searches.
  • info_split
    Contains same data as
    info split into a keyed array.
  • $type: The type of search, e.g., "node" or "user".

Default keys within $info_split:

  • $info_split['type']: Node type.
  • $info_split['user']: Author of the node linked to users profile. Depends on permission.
  • $info_split['date']: Last update of the node. Short formatted.
  • $info_split['comment']: Number of comments output as "% comments", % being the count. Depends on comment.module.
  • $info_split['upload']: Number of attachments output as "% attachments", % being the count. Depends on upload.module.

Since $info_split is keyed, a direct print of the item is possible. This array does not apply to user searches so it is recommended to check for their existance before printing. The default keys of 'type', 'user' and 'date' always exist for node searches. Modules may provide other data.

<?php if (isset($info_split['comment'])) : ?> <?php print $info_split['comment']; ?> <?php endif; ?>

To check for all available data within $info_split, use the code below.

<?php print '

'. check_plain(print_r($info_split, 1)) .'
'; ?>

See also:
template_preprocess_search_result()

Definition in file search-result.tpl.php.

Go to the source code of this file.

Variables

  • print $title
  • print $url

Variable Documentation

print $title

Definition at line 50 of file search-result.tpl.php.

print $url

Definition at line 50 of file search-result.tpl.php.

Referenced by _batch_progress_page_js(), _batch_progress_page_nojs(), _drupal_html_to_mail_urls(), _openid_normalize_url(), _ping_notify(), _update_build_fetch_url(), _update_refresh(), _xmlrpc(), batch_process(), db_connect(), drupal_add_feed(), drupal_goto(), drupal_http_request(), drupal_test_mysql(), drupal_test_mysqli(), drupal_test_pgsql(), example_form(), example_profile_tasks(), hook_ping(), install_change_settings(), install_configure_form(), install_tasks(), install_verify_settings(), openid_discovery(), openid_redirect(), openid_redirect_form(), openid_redirect_http(), ping_ping(), theme_aggregator_page_rss(), theme_feed_icon(), theme_image(), theme_more_help_link(), theme_more_link(), theme_xml_icon(), and valid_url().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/search/search-results.tpl.php File Reference

modules » search

search-results.tpl.php File Reference

Detailed Description

Default theme implementation for displaying search results.

This template collects each invocation of theme_search_result(). This and the child template are dependant to one another sharing the markup for definition lists.

Note that modules may implement their own search type and theme function completely bypassing this template.

Available variables:

  • $search_results: All results as it is rendered through search-result.tpl.php
  • $type: The type of search, e.g., "node" or "user".

See also:
template_preprocess_search_results()

Definition in file search-results.tpl.php.

Go to the source code of this file.

Variables

  • print $pager
  • print $search_results
  • print $type

Variable Documentation

print $pager

Definition at line 27 of file search-results.tpl.php.

print $search_results

Definition at line 25 of file search-results.tpl.php.

print $type

Definition at line 24 of file search-results.tpl.php.

Referenced by _blogapi_get_node_types(), _element_info(), _node_add_access(), _node_types_build(), _profile_field_serialize(), _profile_field_types(), _theme_process_registry(), _trigger_get_hook_actions(), _trigger_normalize_comment_context(), _trigger_normalize_node_context(), _trigger_normalize_user_context(), _update_cron_notify(), _update_requirement_check(), actions_save(), aggregator_block(), block_user(), blog_form(), blog_link(), blog_user(), blogapi_blogger_get_users_blogs(), book_export(), book_link(), book_node_type(), book_type_is_allowed(), comment_admin(), comment_link(), comment_update_6002(), comment_user(), contact_user(), db_placeholders(), db_type_placeholder(), dblog_filters(), dblog_top(), default_profile_tasks(), drupal_add_css(), drupal_add_js(), drupal_alter(), drupal_build_css_cache(), drupal_detect_database_types(), drupal_get_css(), drupal_get_filename(), drupal_get_js(), drupal_get_messages(), drupal_get_path(), drupal_is_denied(), drupal_load(), drupal_set_message(), drupal_verify_install_file(), example_element_elements(), example_profile_tasks(), expand_date(), form_execute_handlers(), format_date(), forum_form(), forum_form_main(), forum_form_submit(), forum_taxonomy(), hook_elements(), hook_form(), hook_link(), hook_taxonomy(), locale_update_6005(), locale_update_js_files(), locale_user(), menu_edit_item(), menu_edit_menu(), menu_get_object(), module_load_all_includes(), multipage_form_example_elements(), node_add(), node_content_access(), node_content_form(), node_example_form(), node_filter_form(), node_forms(), node_get_types(), node_help(), node_link(), node_menu(), node_overview_types(), node_perm(), node_search(), node_type_delete(), node_type_delete_confirm(), node_type_form(), node_type_form_submit(), node_type_form_validate(), node_type_reset(), node_type_update_nodes(), node_types_rebuild(), node_validate(), poll_form(), profile_field_form(), profile_user(), search_form_submit(), search_view(), statistics_link(), system_elements(), system_get_files_database(), system_theme_settings(), system_user(), taxonomy_get_vocabularies(), taxonomy_link(), taxonomy_overview_vocabularies(), taxonomy_save_vocabulary(), taxonomy_term_count_nodes(), template_preprocess_forums(), theme_get_settings(), theme_image(), theme_item_list(), theme_mark(), theme_status_messages(), translation_link(), translation_supported_type(), trigger_assign(), trigger_options(), trigger_taxonomy(), update_check_incompatibility(), update_help(), upload_link(), user_admin_access_add(), user_filter_form(), user_module_invoke(), user_user(), watchdog(), xmlrpc_server_call(), xmlrpc_server_method_signature(), and xmlrpc_value().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/search/search-theme-form.tpl.php File Reference

modules » search

search-theme-form.tpl.php File Reference

Detailed Description

Default theme implementation for displaying a search form directly into the theme layout.

Not to be confused with the search block or the search page.

Available variables:

  • $search_form: The complete search form ready for print.
  • $search: Array of keyed search elements. Can be used to print each form element separately.

Default keys within $search:

  • $search['search_theme_form']: Text input area wrapped in a div.
  • $search['submit']: Form submit button.
  • $search['hidden']: Hidden form elements. Used to validate forms when submitted.

Since $search is keyed, a direct print of the form element is possible. Modules can add to the search form so it is recommended to check for their existance before printing. The default keys will always exist.

<?php if (isset($search['extra_field'])): ?>

<?php print $search['extra_field']; ?>
<?php endif; ?>

To check for all available data within $search, use the code below.

<?php print '

'. check_plain(print_r($search, 1)) .'
'; ?>

See also:
template_preprocess_search_theme_form()

Definition in file search-theme-form.tpl.php.

Go to the source code of this file.

Variables

  • print $search_form

Variable Documentation

print $search_form

Definition at line 37 of file search-theme-form.tpl.php.

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/search/search.admin.inc File Reference

modules » search

search.admin.inc File Reference

Detailed Description

Admin page callbacks for the search module.

Definition in file search.admin.inc.

Go to the source code of this file.

Functions

  • search_admin_settings ()
    Menu callback; displays the search module settings page.
  • search_admin_settings_validate ($form, &$form_state)
    Validate callback.
  • search_wipe_confirm ()
    Menu callback: confirm wiping of the index.
  • search_wipe_confirm_submit (&$form, &$form_state)
    Handler for wipe confirmation.

Function Documentation

search_admin_settings_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate callback.

Definition at line 75 of file search.admin.inc.

References drupal_goto(), drupal_set_message(), search_wipe(), t(), and variable_get().

search_wipe_confirm ( )

Menu callback: confirm wiping of the index.

Definition at line 12 of file search.admin.inc.

References confirm_form(), and t().

search_wipe_confirm_submit | ( | &$ | form,
 |  | &$ | form_state
 | ) |  |

Handler for wipe confirmation.

Definition at line 20 of file search.admin.inc.

References drupal_set_message(), search_wipe(), and t().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/search/search.install File Reference

modules » search

search.install File Reference

Go to the source code of this file.

Functions

  • search_install ()
    Implementation of hook_install().
  • search_schema ()
    Implementation of hook_schema().
  • search_uninstall ()
    Implementation of hook_uninstall().

Function Documentation

search_install ( )

Implementation of hook_install().

Definition at line 7 of file search.install.

References drupal_install_schema().

search_schema ( )

Implementation of hook_schema().

Definition at line 27 of file search.install.

References t().

search_uninstall ( )

Implementation of hook_uninstall().

Definition at line 15 of file search.install.

References drupal_uninstall_schema(), and variable_del().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/search/search.module File Reference

modules » search

search.module File Reference

Detailed Description

Enables site-wide keyword searching.

Definition in file search.module.

Go to the source code of this file.

Enumerations

  • enum PREG_CLASS_CJK
    Matches all CJK characters that are candidates for auto-splitting (Chinese, Japanese, Korean). More...
  • enum PREG_CLASS_NUMBERS
    Matches all 'N' Unicode character classes (numbers). More...
  • enum PREG_CLASS_PUNCTUATION
    Matches all 'P' Unicode character classes (punctuation). More...
  • enum PREG_CLASS_SEARCH_EXCLUDE
    Matches Unicode character classes to exclude from the search index. More...

Functions

  • _search_excerpt_replace (&$text)
    End of "defgroup search".
  • _search_index_truncate (&$text)
    Helper function for array_walk in search_index_split.
  • _search_menu ($name)
  • _search_parse_query (&$word, &$scores, $not=FALSE)
    Helper function for search_parse_query();.
  • do_search ($keywords, $type, $join1= '', $where1= '1', $arguments1=array(), $columns2= 'i.relevance AS score', $join2= '', $arguments2=array(), $sort_parameters= 'ORDER BY score DESC')
    Do a query on the full-text search index for a word or words.
  • search_block ($op= 'list', $delta=0)
    Implementation of hook_block().
  • search_box (&$form_state, $form_id)
    Form builder; Output a search form for the search block and the theme's search box.
  • search_box_form_submit ($form, &$form_state)
    Process a block search form submission.
  • search_comment ($a1, $op)
    Implementation of hook_comment().
  • search_cron ()
    Implementation of hook_cron().
  • search_data ($keys=NULL, $type= 'node')
    Perform a standard search on the given keys, and return the formatted results.
  • search_dirty ($word=NULL)
    Marks a word as dirty (or retrieves the list of dirty words).
  • search_excerpt ($keys, $text)
    Returns snippets from a piece of text, with certain keywords highlighted.
  • search_expand_cjk ($matches)
    Basic CJK tokenizer.
  • search_form (&$form_state, $action= '', $keys= '', $type=NULL, $prompt=NULL)
    Render a search form.
  • search_forms ()
  • search_get_keys ()
    Helper function for grabbing search keys.
  • search_help ($path, $arg)
    Implementation of hook_help().
  • search_index ($sid, $type, $text)
    Update the full-text search index for a particular item.
  • search_index_split ($text)
    Splits a string into tokens for indexing.
  • search_invoke_preprocess (&$text)
    Invokes hook_search_preprocess() in modules.
  • search_menu ()
    Implementation of hook_menu().
  • search_nodeapi (&$node, $op, $teaser=NULL, $page=NULL)
    Implementation of hook_nodeapi().
  • search_parse_query ($text)
    Parse a search query into SQL conditions.
  • search_perm ()
    Implementation of hook_perm().
  • search_query_extract ($keys, $option)
    Extract a module-specific search option from a search query.
  • search_query_insert ($keys, $option, $value= '')
    Return a query with the given module-specific search option inserted in.
  • search_simplify ($text)
    Simplifies a string according to indexing rules.
  • search_theme ()
    Implementation of hook_theme().
  • search_touch_node ($nid)
    Change a node's changed timestamp to 'now' to force reindexing.
  • search_update_totals ()
    This function is called on shutdown to ensure that search_total is always up to date (even if cron times out or otherwise fails).
  • search_wipe ($sid=NULL, $type=NULL, $reindex=FALSE)
    Wipes a part of or the entire search index.
  • template_preprocess_search_block_form (&$variables)
    Process variables for search-block-form.tpl.php.
  • template_preprocess_search_theme_form (&$variables)
    Process variables for search-theme-form.tpl.php.

Enumeration Type Documentation

enum PREG_CLASS_CJK

Matches all CJK characters that are candidates for auto-splitting (Chinese, Japanese, Korean).

Contains kana and BMP ideographs.

Definition at line 87 of file search.module.

enum PREG_CLASS_NUMBERS

Matches all 'N' Unicode character classes (numbers).

Definition at line 53 of file search.module.

enum PREG_CLASS_PUNCTUATION

Matches all 'P' Unicode character classes (punctuation).

Definition at line 66 of file search.module.

enum PREG_CLASS_SEARCH_EXCLUDE

Matches Unicode character classes to exclude from the search index.

See: http://www.unicode.org/Public/UNIDATA/UCD.html#General_Category_Values

The index only contains the following character classes: Lu Letter, Uppercase Ll Letter, Lowercase Lt Letter, Titlecase Lo Letter, Other Nd Number, Decimal Digit No Number, Other

Definition at line 22 of file search.module.

Function Documentation

_search_excerpt_replace ( &$ text )

End of "defgroup search".

Helper function for array_walk in search_except.

Definition at line 1273 of file search.module.

_search_index_truncate ( &$ text )

Helper function for array_walk in search_index_split.

Definition at line 389 of file search.module.

_search_menu ( $ name )

Definition at line 214 of file search.module.

_search_parse_query | ( | &$ | word,
 |  | &$ | scores,
 |  | $ | not = FALSE
 | ) |  |

Helper function for search_parse_query();.

Definition at line 834 of file search.module.

search_block | ( | $ | op = 'list',
 |  | $ | delta = 0
 | ) |  |

Implementation of hook_block().

Definition at line 147 of file search.module.

search_comment | ( | $ | a1,
 |  | $ | op
 | ) |  |

Implementation of hook_comment().

Definition at line 647 of file search.module.

search_cron ( )

Implementation of hook_cron().

Fires hook_update_index() in all modules and cleans up dirty words (see search_dirty).

Definition at line 262 of file search.module.

search_dirty ( $ word = NULL )

Marks a word as dirty (or retrieves the list of dirty words).

This is used during indexing (cron). Words which are dirty have outdated total counts in the search_total table, and need to be recounted.

Definition at line 246 of file search.module.

search_expand_cjk ( $ matches )

Basic CJK tokenizer.

Simply splits a string into consecutive, overlapping sequences of characters ('minimum_word_size' long).

Definition at line 339 of file search.module.

search_forms ( )

Definition at line 1277 of file search.module.

search_get_keys ( )

Helper function for grabbing search keys.

Definition at line 961 of file search.module.

Referenced by search_view().

search_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 93 of file search.module.

Referenced by search_view().

search_index_split ( $ text )

Splits a string into tokens for indexing.

Definition at line 367 of file search.module.

search_invoke_preprocess ( &$ text )

Invokes hook_search_preprocess() in modules.

Definition at line 396 of file search.module.

search_menu ( )

Implementation of hook_menu().

Definition at line 164 of file search.module.

search_nodeapi | ( | &$ | node,
 |  | $ | op,
 |  | $ | teaser = NULL,
 |  | $ | page = NULL
 | ) |  |

Implementation of hook_nodeapi().

Definition at line 626 of file search.module.

search_parse_query ( $ text )

Parse a search query into SQL conditions.

We build two queries that matches the dataset bodies. do_search for more about these.

Parameters:
$text The search keys.
Returns:
A list of six elements. * A series of statements AND'd together which will be used to provide all possible matches. * Arguments for this query part. * A series of exact word matches OR'd together. * Arguments for this query part. * A bool indicating whether this is a simple query or not. Negative terms, presence of both AND / OR make this FALSE. * A bool indicating the presence of a lowercase or. Maybe the user wanted to use OR.

Definition at line 703 of file search.module.

search_perm ( )

Implementation of hook_perm().

Definition at line 140 of file search.module.

search_query_extract | ( | $ | keys,
 |  | $ | option
 | ) |  |

Extract a module-specific search option from a search query.

e.g. 'type:book'

Definition at line 663 of file search.module.

Referenced by node_search().

search_query_insert | ( | $ | keys,
 |  | $ | option,
 |  | $ | value = ''
 | ) |  |

Return a query with the given module-specific search option inserted in.

e.g. 'type:book'.

Definition at line 673 of file search.module.

Referenced by node_search(), and node_search_validate().

search_simplify ( $ text )

Simplifies a string according to indexing rules.

Definition at line 301 of file search.module.

search_theme ( )

Implementation of hook_theme().

Definition at line 114 of file search.module.

search_touch_node ( $ nid )

Change a node's changed timestamp to 'now' to force reindexing.

Parameters:
$nid The nid of the node that needs reindexing.

Definition at line 619 of file search.module.

search_update_totals ( )

This function is called on shutdown to ensure that search_total is always up to date (even if cron times out or otherwise fails).

Definition at line 277 of file search.module.

search_wipe | ( | $ | sid = NULL,
 |  | $ | type = NULL,
 |  | $ | reindex = FALSE
 | ) |  |

Wipes a part of or the entire search index.

Parameters:
$sid | (optional) The SID of the item to wipe. If specified, $type must be passed too.
$type | (optional) The type of item to wipe.

Definition at line 227 of file search.module.

Referenced by node_delete(), search_admin_settings_validate(), and search_wipe_confirm_submit().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/search/search.pages.inc File Reference

modules » search

search.pages.inc File Reference

Detailed Description

User page callbacks for the search module.

Definition in file search.pages.inc.

Go to the source code of this file.

Functions

  • search_form_submit ($form, &$form_state)
    Process a search form submission.
  • search_form_validate ($form, &$form_state)
    As the search form collates keys from other modules hooked in via hook_form_alter, the validation takes place in _submit.
  • search_view ($type= 'node')
    Menu callback; presents the search form and/or search results.
  • template_preprocess_search_result (&$variables)
    Process variables for search-result.tpl.php.
  • template_preprocess_search_results (&$variables)
    Process variables for search-results.tpl.php.

Function Documentation

search_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process a search form submission.

Definition at line 120 of file search.pages.inc.

References $type, form_set_error(), and t().

search_form_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

As the search form collates keys from other modules hooked in via hook_form_alter, the validation takes place in _submit.

search_form_validate() is used solely to set the 'processed_keys' form value for the basic search form.

Definition at line 113 of file search.pages.inc.

References form_set_value().

search_view ( $ type = 'node' )

Menu callback; presents the search form and/or search results.

Definition at line 12 of file search.pages.inc.

References $output, $results, $type, drupal_get_form(), drupal_goto(), drupal_help_arg(), l(), module_invoke(), search_data(), search_get_keys(), search_help(), t(), theme(), and watchdog().

template_preprocess_search_result ( &$ variables )

Process variables for search-result.tpl.php.

The $variables array contains the following arguments:

  • $result
  • $type

See also:
search-result.tpl.php

Definition at line 80 of file search.pages.inc.

References $result, check_plain(), check_url(), and format_date().

template_preprocess_search_results ( &$ variables )

Process variables for search-results.tpl.php.

The $variables array contains the following arguments:

  • $results
  • $type

See also:
search-results.tpl.php

Definition at line 61 of file search.pages.inc.

References $result, and theme().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/statistics/statistics.admin.inc File Reference

modules » statistics

statistics.admin.inc File Reference

Detailed Description

Admin page callbacks for the statistics module.

Definition in file statistics.admin.inc.

Go to the source code of this file.

Functions

  • statistics_access_log ($aid)
    Menu callback; Displays recent page accesses.
  • statistics_access_logging_settings ()
    Form builder; Configure access logging.
  • statistics_recent_hits ()
    Menu callback; presents the "recent hits" page.
  • statistics_top_pages ()
    Menu callback; presents the "top pages" page.
  • statistics_top_referrers ()
    Menu callback; presents the "referrer" page.
  • statistics_top_visitors ()
    Menu callback; presents the "top visitors" page.

Function Documentation

statistics_access_log ( $ aid )

Menu callback; Displays recent page accesses.

Definition at line 140 of file statistics.admin.inc.

References $result, check_plain(), db_fetch_object(), db_query(), drupal_not_found(), format_date(), l(), t(), theme(), and url().

statistics_recent_hits ( )

Menu callback; presents the "recent hits" page.

Definition at line 12 of file statistics.admin.inc.

References $header, $output, $result, _statistics_format_item(), db_fetch_object(), format_date(), l(), pager_query(), t(), tablesort_sql(), and theme().

statistics_top_pages ( )

Menu callback; presents the "top pages" page.

Definition at line 44 of file statistics.admin.inc.

References $header, $output, $result, _statistics_format_item(), db_fetch_object(), drupal_set_title(), format_interval(), pager_query(), t(), tablesort_sql(), theme(), and variable_get().

statistics_top_referrers ( )

Menu callback; presents the "referrer" page.

Definition at line 109 of file statistics.admin.inc.

References $header, $output, $result, _statistics_link(), db_fetch_object(), drupal_set_title(), format_interval(), pager_query(), t(), tablesort_sql(), theme(), url(), and variable_get().

statistics_top_visitors ( )

Menu callback; presents the "top visitors" page.

Definition at line 76 of file statistics.admin.inc.

References $header, $output, $result, db_fetch_object(), drupal_get_destination(), drupal_set_title(), format_interval(), l(), pager_query(), t(), tablesort_sql(), theme(), and variable_get().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/statistics/statistics.install File Reference

modules » statistics

statistics.install File Reference

Go to the source code of this file.

Functions

  • statistics_install ()
    Implementation of hook_install().
  • statistics_schema ()
    Implementation of hook_schema().
  • statistics_uninstall ()
    Implementation of hook_uninstall().
  • statistics_update_1000 ()
    Changes session ID field to VARCHAR(64) to add support for SHA-1 hashes.

Function Documentation

statistics_install ( )

Implementation of hook_install().

Definition at line 7 of file statistics.install.

References drupal_install_schema().

statistics_schema ( )

Implementation of hook_schema().

Definition at line 50 of file statistics.install.

References t().

statistics_uninstall ( )

Implementation of hook_uninstall().

Definition at line 34 of file statistics.install.

References drupal_uninstall_schema(), and variable_del().

statistics_update_1000 ( )

Changes session ID field to VARCHAR(64) to add support for SHA-1 hashes.

Definition at line 15 of file statistics.install.

References db_change_column(), and update_sql().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/statistics/statistics.module File Reference

modules » statistics

statistics.module File Reference

Detailed Description

Logs access statistics for your site.

Definition in file statistics.module.

Go to the source code of this file.

Functions

  • _statistics_format_item ($title, $path)
  • _statistics_link ($path, $width=35)
    It is possible to adjust the width of columns generated by the statistics module.
  • statistics_block ($op= 'list', $delta=0, $edit=array())
    Implementation of hook_block().
  • statistics_cron ()
    Implementation of hook_cron().
  • statistics_exit ()
    Implementation of hook_exit().
  • statistics_get ($nid)
    Retrieves a node's "view statistics".
  • statistics_help ($path, $arg)
    Implementation of hook_help().
  • statistics_link ($type, $node=NULL, $teaser=FALSE)
    Implementation of hook_link().
  • statistics_menu ()
    Implementation of hook_menu().
  • statistics_nodeapi (&$node, $op, $arg=0)
    Implementation of hook_nodeapi().
  • statistics_perm ()
    Implementation of hook_perm().
  • statistics_title_list ($dbfield, $dbrows)
    Returns all time or today top or last viewed node(s).
  • statistics_user ($op, &$edit, &$user)
    Implementation of hook_user().

Function Documentation

_statistics_format_item | ( | $ | title,
 |  | $ | path
 | ) |  |

Definition at line 305 of file statistics.module.

References $output, $title, and _statistics_link().

Referenced by statistics_recent_hits(), statistics_top_pages(), and statistics_user_tracker().

_statistics_link | ( | $ | path,
 |  | $ | width = 35
 | ) |  |

It is possible to adjust the width of columns generated by the statistics module.

Definition at line 299 of file statistics.module.

References $title, drupal_get_path_alias(), l(), and truncate_utf8().

Referenced by _statistics_format_item(), statistics_node_tracker(), and statistics_top_referrers().

statistics_block | ( | $ | op = 'list',
 |  | $ | delta = 0,
 |  | $ | edit = array()
 | ) |  |

Implementation of hook_block().

Definition at line 242 of file statistics.module.

References $content, $op, $result, drupal_map_assoc(), node_title_list(), statistics_title_list(), t(), user_access(), variable_get(), and variable_set().

statistics_cron ( )

Implementation of hook_cron().

Definition at line 179 of file statistics.module.

References db_query(), variable_get(), and variable_set().

statistics_exit ( )

Implementation of hook_exit().

This is where statistics are gathered on page accesses.

Definition at line 45 of file statistics.module.

References $recent_activity, $user, arg(), db_affected_rows(), db_query(), drupal_bootstrap(), drupal_get_title(), ip_address(), module_invoke(), referer_uri(), timer_read(), and variable_get().

statistics_get ( $ nid )

Retrieves a node's "view statistics".

Parameters:
$nid node ID
Returns:
An array with three entries: [0]=totalcount, [1]=daycount, [2]=timestamp
  • totalcount: count of the total number of times that node has been viewed.
  • daycount: count of the total number of times that node has been viewed "today". For the daycount to be reset, cron must be enabled.
  • timestamp: timestamp of when that node was last viewed.

Definition at line 229 of file statistics.module.

References $nid, db_fetch_array(), and db_query().

Referenced by statistics_link().

statistics_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 12 of file statistics.module.

References $output, t(), and url().

statistics_link | ( | $ | type,
 |  | $ | node = NULL,
 |  | $ | teaser = FALSE
 | ) |  |

Implementation of hook_link().

Definition at line 78 of file statistics.module.

References $id, $links, $type, format_plural(), nid, statistics_get(), and user_access().

statistics_menu ( )

Implementation of hook_menu().

Definition at line 95 of file statistics.module.

References $items.

statistics_nodeapi | ( | &$ | node,
 |  | $ | op,
 |  | $ | arg = 0
 | ) |  |

Implementation of hook_nodeapi().

Definition at line 315 of file statistics.module.

References $op, db_query(), and nid.

statistics_perm ( )

Implementation of hook_perm().

Definition at line 71 of file statistics.module.

statistics_title_list | ( | $ | dbfield,
 |  | $ | dbrows
 | ) |  |

Returns all time or today top or last viewed node(s).

Parameters:
$dbfield one of
  • 'totalcount': top viewed content of all time.
  • 'daycount': top viewed content for today.
  • 'timestamp': last viewed node.
$dbrows number of rows to be returned.
Returns:
A query result containing n.nid, n.title, u.uid, u.name of the selected node(s) or FALSE if the query could not be executed correctly.

Definition at line 208 of file statistics.module.

References db_query_range(), and db_rewrite_sql().

Referenced by statistics_block().

statistics_user | ( | $ | op,
 |  | &$ | edit,
 |  | &$ | user
 | ) |  |

Implementation of hook_user().

Definition at line 170 of file statistics.module.

References $op, $user, and db_query().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/statistics/statistics.pages.inc File Reference

modules » statistics

statistics.pages.inc File Reference

Detailed Description

User page callbacks for the statistics module.

Definition in file statistics.pages.inc.

Go to the source code of this file.

Functions

  • statistics_node_tracker ()
  • statistics_user_tracker ()

Function Documentation

statistics_node_tracker ( )

Definition at line 9 of file statistics.pages.inc.

References $header, $output, $result, _statistics_link(), arg(), check_plain(), db_fetch_object(), drupal_not_found(), drupal_set_title(), format_date(), l(), nid, node_load(), pager_query(), t(), tablesort_sql(), theme(), and url().

statistics_user_tracker ( )

Definition at line 42 of file statistics.pages.inc.

References $header, $output, $result, _statistics_format_item(), arg(), check_plain(), db_fetch_object(), drupal_not_found(), drupal_set_title(), format_date(), l(), name, pager_query(), t(), tablesort_sql(), theme(), and user_load().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/syslog/syslog.module File Reference

modules » syslog

syslog.module File Reference

Detailed Description

Redirects logging messages to syslog.

Definition in file syslog.module.

Go to the source code of this file.

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/system/block.tpl.php File Reference

modules » system

block.tpl.php File Reference

Go to the source code of this file.

Variables

  • print $block module $block delta

Variable Documentation

print $block module $block delta

Definition at line 29 of file block.tpl.php.

Referenced by _filter_tips(), block_list(), block_user(), check_markup(), filter_admin_configure(), filter_admin_format_form(), and filter_list_format().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/system/box.tpl.php File Reference

modules » system

box.tpl.php File Reference

Go to the source code of this file.

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/system/maintenance-page.tpl.php File Reference

modules » system

maintenance-page.tpl.php File Reference

Go to the source code of this file.

Variables

  • print $body_classes
  • print $head
  • print $language language print
    $language language print
    $language dir print $head_title
  • print $logo
  • print $scripts
  • print $site_name
  • print $styles
  • endif

Variable Documentation

print $body_classes

Definition at line 28 of file maintenance-page.tpl.php.

Referenced by template_preprocess_maintenance_page(), and template_preprocess_page().

print $head

Definition at line 23 of file maintenance-page.tpl.php.

print $language language print $language language print $language dir print $head_title

Definition at line 22 of file maintenance-page.tpl.php.

Referenced by template_preprocess_maintenance_page(), and template_preprocess_page().

print $logo

Definition at line 35 of file maintenance-page.tpl.php.

Referenced by _color_page_alter(), and chameleon_page().

print $scripts

Definition at line 25 of file maintenance-page.tpl.php.

Referenced by _system_theme_data().

print $site_name

Definition at line 42 of file maintenance-page.tpl.php.

Referenced by theme_aggregator_page_rss().

print $styles

Definition at line 24 of file maintenance-page.tpl.php.

endif

Definition at line 37 of file maintenance-page.tpl.php.

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/system/page.tpl.php File Reference

modules » system

page.tpl.php File Reference

Go to the source code of this file.

Variables

  • print $body_classes
  • print $head
  • print $language language print
    $language language print
    $language dir print $head_title
  • print $logo
  • print $scripts
  • print $site_name
  • print $styles
  • endif

Variable Documentation

print $body_classes

Definition at line 89 of file page.tpl.php.

print $head

Definition at line 84 of file page.tpl.php.

print $language language print $language language print $language dir print $head_title

Definition at line 83 of file page.tpl.php.

print $logo

Definition at line 96 of file page.tpl.php.

print $scripts

Definition at line 86 of file page.tpl.php.

print $site_name

Definition at line 103 of file page.tpl.php.

print $styles

Definition at line 85 of file page.tpl.php.

endif

Definition at line 98 of file page.tpl.php.

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/system/system.admin.inc File Reference

modules » system

system.admin.inc File Reference

Detailed Description

Admin page callbacks for the system module.

Definition in file system.admin.inc.

Go to the source code of this file.

Functions

  • _system_is_incompatible (&$incompatible, $files, $file)
    Recursively check compatibility.
  • _system_sql ($data, $keys)
    Theme a SQL result table.
  • system_admin_by_module ()
    Menu callback; prints a listing of admin tasks for each installed module.
  • system_admin_compact_page ($mode= 'off')
    Menu callback; Sets whether the admin menu is in compact mode or not.
  • system_admin_menu_block_page ()
    Provide a single block from the administration menu as a page.
  • system_admin_theme_settings ()
    Form builder; This function allows selection of the theme to show in administration sections.
  • system_batch_page ()
    Default page callback for batches.
  • system_clean_url_settings ()
    Form builder; Configure Clean URL settings.
  • system_clear_cache_submit (&$form_state, $form)
    Submit callback; clear system caches.
  • system_date_time_lookup ()
    Return the date for a given format string via Ajax.
  • system_date_time_settings ()
    Form builder; Configure the site date and time settings.
  • system_date_time_settings_submit ($form, &$form_state)
    Process system_date_time_settings form submissions.
  • system_error_reporting_settings ()
    Form builder; Configure error reporting settings.
  • system_file_system_settings ()
    Form builder; Configure the site file handling.
  • system_image_toolkit_settings ()
    Form builder; Configure site image toolkit usage.
  • system_logging_overview ()
    Menu callback; Menu page for the various logging options.
  • system_main_admin_page ($arg=NULL)
    Menu callback; Provide the administration overview page.
  • system_module_build_dependencies ($modules, $form_values)
    Generate a list of dependencies for modules that are going to be switched on.
  • system_modules ($form_state=array())
    Menu callback; provides module enable/disable interface.
  • system_modules_confirm_form ($modules, $storage)
    Display confirmation form for dependencies.
  • system_modules_disable ($form, $edit)
    Form process callback function to disable check boxes.
  • system_modules_submit ($form, &$form_state)
    Submit callback; handles modules form submission.
  • system_modules_uninstall ($form_state=NULL)
    Uninstall functions.
  • system_modules_uninstall_confirm_form ($storage)
    Confirm uninstall of selected modules.
  • system_modules_uninstall_submit ($form, &$form_state)
    Processes the submitted uninstall form.
  • system_modules_uninstall_validate ($form, &$form_state)
    Validates the submitted uninstall form.
  • system_performance_settings ()
    Form builder; Configure site performance settings.
  • system_php ()
    Menu callback: return information about PHP.
  • system_rss_feeds_settings ()
    Form builder; Configure how the site handles RSS feeds.
  • system_run_cron ()
    Menu callback: run cron manually.
  • system_settings_overview ()
    Menu callback; displays a module's settings page.
  • system_site_information_settings ()
    Form builder; The general site information form.
  • system_site_information_settings_validate ($form, &$form_state)
    Validate the submitted site-information form.
  • system_site_maintenance_settings ()
    Form builder; Configure the site's maintenance status.
  • system_sort_modules_by_info_name ($a, $b)
    Array sorting callback; sorts modules or themes by their name.
  • system_sql ()
    Menu callback: return information about the database.
  • system_status ($check=FALSE)
    Menu callback: displays the site status report.
  • system_theme_settings (&$form_state, $key= '')
    Form builder; display theme configuration for entire site and individual themes.
  • system_theme_settings_submit ($form, &$form_state)
    Process system_theme_settings form submissions.
  • system_themes_form ()
    Menu callback; displays a listing of all themes.
  • system_themes_form_submit ($form, &$form_state)
    Process system_themes_form form submissions.
  • theme_admin_block ($block)
    This function formats an administrative block for display.
  • theme_admin_block_content ($content)
    This function formats the content of an administrative block.
  • theme_admin_page ($blocks)
    This function formats an administrative page for viewing.
  • theme_status_report (&$requirements)
    Theme requirements status report.
  • theme_system_admin_by_module ($menu_items)
    Theme output of the dashboard page.
  • theme_system_modules ($form)
    Theme callback for the modules form.
  • theme_system_modules_uninstall ($form)
    Themes a table of currently disabled modules.
  • theme_system_theme_select_form ($form)
    Theme the theme select form.
  • theme_system_themes_form ($form)
    Theme function for the system themes form.

Function Documentation

_system_is_incompatible | ( | &$ | incompatible,
 |  | $ | files,
 |  | $ | file
 | ) |  |

Recursively check compatibility.

Parameters:
$incompatible | An associative array which at the end of the check contains all incompatible files as the keys, their values being TRUE.
$files | The set of files that will be tested.
$file | The file at which the check starts.
Returns:
Returns TRUE if an incompatible file is found, NULL (no return value) otherwise.

Definition at line 573 of file system.admin.inc.

References name.

Referenced by system_modules().

_system_sql | ( | $ | data,
 |  | $ | keys
 | ) |  |

Theme a SQL result table.

Parameters:
$data | The actual table data.
$keys | Data keys and descriptions.
Returns:
The output HTML.

Definition at line 1743 of file system.admin.inc.

References check_plain(), t(), and theme().

Referenced by system_sql().

system_admin_by_module ( )

Menu callback; prints a listing of admin tasks for each installed module.

Definition at line 99 of file system.admin.inc.

References drupal_help_arg(), l(), module_exists(), module_invoke(), module_rebuild_cache(), system_get_module_admin_tasks(), t(), and theme().

system_admin_compact_page ( $ mode = 'off' )

Menu callback; Sets whether the admin menu is in compact mode or not.

Parameters:
$mode Valid values are 'on' and 'off'.

Definition at line 90 of file system.admin.inc.

References $user, drupal_goto(), and user_save().

system_admin_menu_block_page ( )

Provide a single block from the administration menu as a page.

This function is often a destination for these blocks. For example, 'admin/content/types' needs to have a destination to be valid in the Drupal menu system, but too much information there might be hidden, so we supply the contents of the block.

Returns:
The output HTML.

Definition at line 73 of file system.admin.inc.

References $content, $item, $output, menu_get_item(), system_admin_menu_block(), t(), and theme().

system_batch_page ( )

Default page callback for batches.

Definition at line 1800 of file system.admin.inc.

References $output, _batch_page(), drupal_access_denied(), and theme().

system_date_time_lookup ( )

Return the date for a given format string via Ajax.

Definition at line 1620 of file system.admin.inc.

References $result, drupal_to_js(), exit, and format_date().

system_date_time_settings_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process system_date_time_settings form submissions.

Definition at line 1604 of file system.admin.inc.

References system_settings_form_submit().

system_logging_overview ( )

Menu callback; Menu page for the various logging options.

Definition at line 1238 of file system.admin.inc.

References $content, $item, $output, menu_get_item(), system_admin_menu_block(), and theme().

system_main_admin_page ( $ arg = NULL )

Menu callback; Provide the administration overview page.

Definition at line 12 of file system.admin.inc.

References $item, $result, _menu_link_translate(), db_fetch_array(), db_query(), drupal_not_found(), drupal_set_message(), system_admin_menu_block(), system_status(), t(), theme(), url(), and user_access().

system_module_build_dependencies | ( | $ | modules,
 |  | $ | form_values
 | ) |  |

Generate a list of dependencies for modules that are going to be switched on.

Parameters:
$modules | The list of modules to check.
$form_values | Submitted form values used to determine what modules have been enabled.
Returns:
An array of dependencies.

Definition at line 963 of file system.admin.inc.

References $name.

Referenced by system_modules_submit().

system_modules_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit callback; handles modules form submission.

Definition at line 853 of file system.admin.inc.

References $name, actions_synchronize(), db_query(), drupal_check_module(), drupal_clear_css_cache(), drupal_clear_js_cache(), drupal_get_installed_schema_version(), drupal_install_modules(), drupal_set_message(), module_disable(), module_enable(), module_invoke(), module_list(), system_module_build_dependencies(), and t().

system_modules_uninstall_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Processes the submitted uninstall form.

Definition at line 1101 of file system.admin.inc.

References $value, drupal_set_message(), drupal_uninstall_module(), and t().

system_modules_uninstall_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validates the submitted uninstall form.

Definition at line 1090 of file system.admin.inc.

References drupal_goto(), drupal_set_message(), and t().

system_php ( )

Menu callback: return information about PHP.

Definition at line 1728 of file system.admin.inc.

References exit.

system_run_cron ( )

Menu callback: run cron manually.

Definition at line 1713 of file system.admin.inc.

References drupal_cron_run(), drupal_goto(), drupal_set_message(), and t().

system_settings_overview ( )

Menu callback; displays a module's settings page.

Definition at line 133 of file system.admin.inc.

References $content, $item, $output, db_check_setup(), menu_get_item(), system_admin_menu_block(), and theme().

system_site_information_settings_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validate the submitted site-information form.

Definition at line 1183 of file system.admin.inc.

References $item, drupal_get_normal_path(), drupal_set_message(), form_set_error(), menu_valid_path(), t(), and user_validate_mail().

system_sort_modules_by_info_name | ( | $ | a,
 |  | $ | b
 | ) |  |

Array sorting callback; sorts modules or themes by their name.

Definition at line 778 of file system.admin.inc.

system_sql ( )

Menu callback: return information about the database.

Definition at line 1757 of file system.admin.inc.

References $output, $result, _system_sql(), db_fetch_object(), db_query(), and t().

system_status ( $ check = FALSE )

Menu callback: displays the site status report.

Can also be used as a pure check.

Parameters:
$check If true, only returns a boolean whether there are system status errors.

Definition at line 1691 of file system.admin.inc.

References db_query(), drupal_load_updates(), drupal_requirements_severity(), module_invoke_all(), and theme().

Referenced by system_main_admin_page().

system_theme_settings_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process system_theme_settings form submissions.

Definition at line 543 of file system.admin.inc.

References cache_clear_all(), drupal_set_message(), t(), variable_del(), and variable_set().

system_themes_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process system_themes_form form submissions.

Definition at line 265 of file system.admin.inc.

References $theme, db_query(), drupal_rebuild_theme_registry(), drupal_set_message(), list_themes(), menu_rebuild(), module_invoke(), system_initialize_theme_blocks(), t(), url(), variable_del(), variable_get(), and variable_set().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/system/system.install File Reference

modules » system

system.install File Reference

Go to the source code of this file.

Functions

  • system_install ()
    Implementation of hook_install().
  • system_requirements ($phase)
    Test and report Drupal installation requirements.
  • system_schema ()
    Implementation of hook_schema().
  • system_update_1022 ()
    Add index on users created column.
  • system_update_6000 ()
    Remove auto_increment from {boxes} to allow adding custom blocks with visibility settings.
  • system_update_6001 ()
    Add version id column to {term_node} to allow taxonomy module to use revisions.
  • system_update_6002 ()
    Increase the maximum length of variable names from 48 to 128.
  • system_update_6003 ()
    Add index on comments status column.
  • system_update_6004 ()
    This update used to add an index on users created column (#127941).
  • system_update_6005 ()
    Add language to url_alias table and modify indexes.
  • system_update_6006 ()
    Drop useless indices on node_counter table.
  • system_update_6007 ()
    Change the severity column in the watchdog table to the new values.
  • system_update_6008 ()
    Add info files to themes.
  • system_update_6009 ()
    The PHP filter is now a separate module.
  • system_update_6010 ()
    Add variable replacement for watchdog messages.
  • system_update_6011 ()
    Add language support to nodes.
  • system_update_6012 ()
    Add serialized field to cache tables.
  • system_update_6013 ()
    Rebuild cache data for theme system changes.
  • system_update_6014 ()
    Record that the installer is done, so it is not possible to run the installer on upgraded sites.
  • system_update_6015 ()
    Add the form cache table.
  • system_update_6016 ()
    Make {node}'s primary key be nid, change nid,vid to a unique key.
  • system_update_6017 ()
    Rename settings related to user.module email notifications.
  • system_update_6018 ()
    Add HTML corrector to HTML formats or replace the old module if it was in use.
  • system_update_6019 ()
    Reconcile small differences in the previous, manually created mysql and pgsql schemas so they are the same and can be represented by a single schema structure.
  • system_update_6020 ()
    Create the tables for the new menu system.
  • system_update_6021 ()
    Migrate the menu items from the old menu system to the new menu_links table.
  • system_update_6022 ()
    Update files tables to associate files to a uid by default instead of a nid.
  • system_update_6023 ()
  • system_update_6024 ()
    Add translation fields to nodes used by translation module.
  • system_update_6025 ()
    Increase the maximum length of node titles from 128 to 255.
  • system_update_6026 ()
    Display warning about new Update status module.
  • system_update_6027 ()
    Add block cache.
  • system_update_6028 ()
    Add the node load cache table.
  • system_update_6029 ()
    Enable the dblog module on sites that upgrade, since otherwise watchdog logging will stop unexpectedly.
  • system_update_6030 ()
    Add the tables required by actions.inc.
  • system_update_6031 ()
    Ensure that installer cannot be run again after updating from Drupal 5.x to 6.x Actually, this is already done by system_update_6014(), so this is now a no-op.
  • system_update_6032 ()
    profile_fields.name used to be nullable but is part of a unique key and so shouldn't be.
  • system_update_6033 ()
    Change node_comment_statistics to be not autoincrement.
  • system_update_6034 ()
    Rename permission "administer access control" to "administer permissions".
  • system_update_6035 ()
    Change index on system table for better performance.
  • system_update_6036 ()
    Change the search schema and indexing.
  • system_update_6037 ()
    Create consistent empty region for disabled blocks.
  • system_update_6038 ()
    Ensure that "Account" is not used as a Profile category.
  • system_update_6039 ()
    Rename permissions "edit foo content" to "edit any foo content".
  • system_update_6040 ()
    Add a weight column to the upload table.
  • system_update_6041 ()
    Change forum vocabulary not to be required by default and set the weight of the forum.module 1 higher than the taxonomy.module.
  • system_update_6042 ()
    Upgrade recolored theme stylesheets to new array structure.
  • system_update_6043 ()
    Update table indices to make them more rational and useful.
  • system_update_6044 ()
    RC1 to RC2 index cleanup.
  • system_update_6045 ()
    Update blog, book and locale module permissions.
  • system_update_6046 ()
    Ensure that the file_directory_path variable is set (using the old 5.x default, if necessary), so that the changed 6.x default won't break existing sites.
  • system_update_6047 ()
    Fix cache mode for blocks inserted in system_install() in fresh installs of previous RC.
  • system_update_last_removed ()

Function Documentation

system_install ( )

Implementation of hook_install().

Definition at line 302 of file system.install.

References db_query(), db_result(), drupal_install_schema(), and system_theme_data().

system_requirements ( $ phase )

Test and report Drupal installation requirements.

Parameters:
$phase The current system installation phase.
Returns:
An array of system requirements.

Definition at line 12 of file system.install.

References $db_type, base_path(), conf_path(), db_status_report(), drupal_get_installed_schema_version(), drupal_get_schema_versions(), drupal_set_message(), drupal_verify_install_file(), file_directory_path(), format_interval(), get_t(), l(), module_exists(), module_list(), parse_size(), unicode_requirements(), url(), user_access(), and variable_get().

system_schema ( )

Implementation of hook_schema().

Definition at line 412 of file system.install.

References t().

system_update_last_removed ( )

Definition at line 1096 of file system.install.

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/system/system.module File Reference

modules » system

system.module File Reference

Detailed Description

Configuration system that lets administrators modify the workings of the site.

Definition in file system.module.

Go to the source code of this file.

Enumerations

  • enum DRUPAL_CORE_COMPATIBILITY
    Core API compatibility. More...
  • enum DRUPAL_MAXIMUM_TEMP_FILE_AGE
    Maximum age of temporary files in seconds. More...
  • enum DRUPAL_MINIMUM_MYSQL
    Minimum supported version of MySQL, if it is used. More...
  • enum DRUPAL_MINIMUM_PGSQL
    Minimum supported version of PostgreSQL, if it is used. More...
  • enum DRUPAL_MINIMUM_PHP
    Minimum supported version of PHP. More...
  • enum DRUPAL_MINIMUM_PHP_MEMORY_LIMIT
    Minimum recommended value of PHP memory_limit. More...
  • enum VERSION
    The current system version. More...

Functions

  • _system_sort_requirements ($a, $b)
    Helper function to sort requirements.
  • _system_theme_data ()
    Helper function to scan and collect theme .info data and their engines.
  • _system_themes_access ($theme)
    Menu item access callback - only admin or enabled themes can be accessed.
  • _system_zonelist ()
    Generate an array of time zones and their local time&date.
  • confirm_form ($form, $question, $path, $description=NULL, $yes=NULL, $no=NULL, $name= 'confirm')
    Output a confirmation form.
  • system_action_delete_orphans_post ($orphaned)
    Post-deletion operations for deleting action orphans.
  • system_action_info ()
    Implementation of hook_action_info().
  • system_actions_configure ($form_state, $action=NULL)
    Menu callback.
  • system_actions_configure_submit ($form, &$form_state)
    Process system_actions_configure form submissions.
  • system_actions_configure_validate ($form, $form_state)
    Validate system_actions_configure form submissions.
  • system_actions_delete_form ($form_state, $action)
    Create the form for confirmation of deleting an action.
  • system_actions_delete_form_submit ($form, &$form_state)
    Process system_actions_delete form submissions.
  • system_actions_manage ()
    Menu callback.
  • system_actions_manage_form ($form_state, $options=array())
    Define the form for the actions overview page.
  • system_actions_manage_form_submit ($form, &$form_state)
    Process system_actions_manage form submissions.
  • system_actions_remove_orphans ()
    Remove actions that are in the database but not supported by any enabled module.
  • system_admin_compact_mode ()
    Determine if a user is in compact mode.
  • system_admin_menu_block ($item)
    Provide a single block on the administration overview page.
  • system_admin_theme_submit ($form, &$form_state)
    Process admin theme form submissions.
  • system_block ($op= 'list', $delta=0, $edit=NULL)
    Implementation of hook_block().
  • system_check_directory ($form_element)
    Checks the existence of the directory specified in $form_element.
  • system_check_http_request ()
    Checks whether the server is capable of issuing HTTP requests.
  • system_cron ()
    Implementation of hook_cron().
  • system_default_region ($theme)
    Get the name of the default region for a given theme.
  • system_elements ()
    Implementation of hook_elements().
  • system_find_base_theme ($themes, $key, $used_keys=array())
    Recursive function to find the top level base theme.
  • system_get_files_database (&$files, $type)
    Retrieves the current status of an array of files in the system table.
  • system_get_module_admin_tasks ($module)
    Generate a list of tasks offered by a specified module.
  • system_goto_action ($object, $context)
  • system_goto_action_form ($context)
    Implementation of a configurable Drupal action.
  • system_goto_action_submit ($form, $form_state)
  • system_help ($path, $arg)
    Implementation of hook_help().
  • system_hook_info ()
    Implementation of hook_hook_info().
  • system_init ()
    Implementation of hook_init().
  • system_initialize_theme_blocks ($theme)
    Assign an initial, default set of blocks for a theme.
  • system_mail ($key, &$message, $params)
    Implementation of hook_mail().
  • system_menu ()
    Implementation of hook_menu().
  • system_message_action (&$object, $context=array())
    A configurable Drupal action.
  • system_message_action_form ($context)
  • system_message_action_submit ($form, $form_state)
  • system_node_type ($op, $info)
    Implementation of hook_node_type().
  • system_perm ()
    Implementation of hook_perm().
  • system_region_list ($theme_key)
    Get a list of available regions from a specified theme.
  • system_send_email_action ($object, $context)
    Implementation of a configurable Drupal action.
  • system_send_email_action_form ($context)
    Return a form definition so the Send email action can be configured.
  • system_send_email_action_submit ($form, $form_state)
    Process system_send_email_action form submissions.
  • system_send_email_action_validate ($form, $form_state)
    Validate system_send_email_action form submissions.
  • system_settings_form ($form)
    Add default buttons to a form and set its prefix.
  • system_settings_form_submit ($form, &$form_state)
    Execute the system_settings_form.
  • system_theme ()
    Implementation of hook_theme().
  • system_theme_data ()
    Collect data about all currently available themes.
  • system_theme_default ()
    Prepare defaults for themes.
  • system_theme_select_form ($description= '', $default_value= '', $weight=0)
    Returns a fieldset containing the theme select form.
  • system_user ($type, $edit, &$user, $category=NULL)
    Implementation of hook_user().
  • theme_system_powered_by ($image_path)
    Format the Powered by Drupal text.

Enumeration Type Documentation

enum DRUPAL_CORE_COMPATIBILITY

Core API compatibility.

Definition at line 17 of file system.module.

enum DRUPAL_MAXIMUM_TEMP_FILE_AGE

Maximum age of temporary files in seconds.

Definition at line 42 of file system.module.

enum DRUPAL_MINIMUM_MYSQL

Minimum supported version of MySQL, if it is used.

Definition at line 32 of file system.module.

enum DRUPAL_MINIMUM_PGSQL

Minimum supported version of PostgreSQL, if it is used.

Definition at line 37 of file system.module.

enum DRUPAL_MINIMUM_PHP

Minimum supported version of PHP.

Definition at line 22 of file system.module.

enum DRUPAL_MINIMUM_PHP_MEMORY_LIMIT

Minimum recommended value of PHP memory_limit.

Definition at line 27 of file system.module.

enum VERSION

The current system version.

Definition at line 12 of file system.module.

Function Documentation

_system_sort_requirements | ( | $ | a,
 |  | $ | b
 | ) |  |

Helper function to sort requirements.

Definition at line 1064 of file system.module.

_system_theme_data ( )

Helper function to scan and collect theme .info data and their engines.

Returns:
An associative array of themes information.

Definition at line 825 of file system.module.

References $scripts, $theme, $theme_info, drupal_alter(), drupal_parse_info_file(), drupal_system_listing(), system_find_base_theme(), and system_theme_default().

Referenced by list_themes(), system_theme_data(), and template_preprocess_maintenance_page().

_system_themes_access ( $ theme )

Menu item access callback - only admin or enabled themes can be accessed.

Definition at line 516 of file system.module.

References $theme, and variable_get().

_system_zonelist ( )

Generate an array of time zones and their local time&date.

Definition at line 1832 of file system.module.

References format_date(), and variable_get().

Referenced by install_configure_form(), system_date_time_settings(), and system_user().

system_action_delete_orphans_post ( $ orphaned )

Post-deletion operations for deleting action orphans.

Parameters:
$orphaned An array of orphaned actions.

Definition at line 1537 of file system.module.

References drupal_set_message(), and t().

system_action_info ( )

Implementation of hook_action_info().

Definition at line 1250 of file system.module.

References t().

system_actions_configure | ( | $ | form_state,
 |  | $ | action = NULL
 | ) |  |

Menu callback.

Create the form for configuration of a single action.

We provide the "Description" field. The rest of the form is provided by the action. We then provide the Save button. Because we are combining unknown form elements with the action configuration form, we use actions_ prefix on our elements.

See also:
system_actions_configure_validate()

system_actions_configure_submit()

Parameters:
$action md5 hash of action ID or an integer. If it's an md5 hash, we are creating a new instance. If it's an integer, we're editing an existing instance.
Returns:
Form definition.

Definition at line 1399 of file system.module.

References $name, actions_actions_map(), actions_list(), db_fetch_object(), db_query(), drupal_goto(), and t().

system_actions_configure_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process system_actions_configure form submissions.

Definition at line 1482 of file system.module.

References actions_function_lookup(), actions_save(), drupal_set_message(), and t().

system_actions_configure_validate | ( | $ | form,
 |  | $ | form_state
 | ) |  |

Validate system_actions_configure form submissions.

Definition at line 1471 of file system.module.

References actions_function_lookup().

system_actions_delete_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process system_actions_delete form submissions.

Post-deletion operations for action deletion.

Definition at line 1521 of file system.module.

References actions_delete(), actions_load(), check_plain(), drupal_set_message(), t(), and watchdog().

system_actions_manage ( )

Menu callback.

Display an overview of available and configured actions.

Definition at line 1290 of file system.module.

References $header, $output, $pager, $result, $row, actions_actions_map(), actions_list(), actions_synchronize(), db_fetch_object(), db_query(), drupal_get_form(), l(), pager_query(), t(), tablesort_sql(), and theme().

system_actions_manage_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process system_actions_manage form submissions.

Definition at line 1376 of file system.module.

system_actions_remove_orphans ( )

Remove actions that are in the database but not supported by any enabled module.

Definition at line 1546 of file system.module.

References actions_list(), actions_synchronize(), and drupal_goto().

system_admin_compact_mode ( )

Determine if a user is in compact mode.

Definition at line 1156 of file system.module.

References $user, and variable_get().

Referenced by theme_admin_block_content(), and theme_admin_page().

system_admin_menu_block ( $ item )

Provide a single block on the administration overview page.

Parameters:
$item The menu item to be displayed.

Definition at line 615 of file system.module.

References $content, $item, $result, _menu_link_translate(), db_fetch_array(), and db_query().

Referenced by node_add_page(), system_admin_menu_block_page(), system_logging_overview(), system_main_admin_page(), and system_settings_overview().

system_admin_theme_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process admin theme form submissions.

Definition at line 646 of file system.module.

References $result, db_query(), db_result(), system_initialize_theme_blocks(), and variable_get().

system_block | ( | $ | op = 'list',
 |  | $ | delta = 0,
 |  | $ | edit = NULL
 | ) |  |

Implementation of hook_block().

Generate a block with a promotional link to Drupal.org.

Definition at line 572 of file system.module.

References $op, t(), theme(), variable_get(), and variable_set().

system_check_directory ( $ form_element )

Checks the existence of the directory specified in $form_element.

This function is called from the system_settings form to check both the file_directory_path and file_directory_temp directories. If validation fails, the form element is flagged with an error from within the file_check_directory function.

Parameters:
$form_element The form element containing the name of the directory to check.

Definition at line 728 of file system.module.

References file_check_directory().

system_check_http_request ( )

Checks whether the server is capable of issuing HTTP requests.

The function sets the drupal_http_request_fail system variable to TRUE if drupal_http_request() does not work and then the system status report page will contain an error.

Returns:
Whether the admin/reports/request-test page can be requested via HTTP and contains the same output as if called via the menu system.

Definition at line 1854 of file system.module.

References $result, drupal_http_request(), menu_execute_active_handler(), url(), and variable_set().

system_cron ( )

Implementation of hook_cron().

Remove older rows from flood and batch table. Remove old temporary files.

Definition at line 1211 of file system.module.

References $result, db_fetch_object(), db_query(), file_delete(), and watchdog().

system_default_region ( $ theme )

Get the name of the default region for a given theme.

Parameters:
$theme The name of a theme.
Returns:
A string that is the region name.

Definition at line 972 of file system.module.

References $theme, and system_region_list().

Referenced by system_initialize_theme_blocks().

system_elements ( )

Implementation of hook_elements().

Definition at line 164 of file system.module.

References $type, and request_uri().

system_find_base_theme | ( | $ | themes,
 |  | $ | key,
 |  | $ | used_keys = array()
 | ) |  |

Recursive function to find the top level base theme.

Themes can inherit templates and function implementations from earlier themes.

Parameters:
$themes | An array of available themes.
$key | The name of the theme whose base we are looking for.
$used_keys | A recursion parameter preventing endless loops.
Returns:
Returns the top level parent that has no ancestor or returns NULL if there isn't a valid parent.

Definition at line 925 of file system.module.

Referenced by _system_theme_data().

system_get_files_database | ( | &$ | files,
 |  | $ | type
 | ) |  |

Retrieves the current status of an array of files in the system table.

Parameters:
$files | An array of files to check.
$type | The type of the files.

Definition at line 741 of file system.module.

References $result, $type, $value, db_fetch_object(), db_query(), and name.

Referenced by module_rebuild_cache(), and system_theme_data().

system_get_module_admin_tasks ( $ module )

Generate a list of tasks offered by a specified module.

Parameters:
$module Module name.
Returns:
An array of task links.

Definition at line 1169 of file system.module.

References $item, $items, $result, _menu_link_translate(), db_fetch_array(), db_query(), l(), module_hook(), module_invoke(), t(), and user_access().

Referenced by help_page(), and system_admin_by_module().

system_goto_action | ( | $ | object,
 |  | $ | context
 | ) |  |

Definition at line 1825 of file system.module.

References drupal_goto().

system_goto_action_form ( $ context )

Implementation of a configurable Drupal action.

Redirect user to a URL.

Definition at line 1808 of file system.module.

References t().

system_goto_action_submit | ( | $ | form,
 |  | $ | form_state
 | ) |  |

Definition at line 1819 of file system.module.

system_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 47 of file system.module.

References $base_url, $output, $theme, module_exists(), t(), and url().

system_hook_info ( )

Implementation of hook_hook_info().

Definition at line 1235 of file system.module.

References t().

system_init ( )

Implementation of hook_init().

Definition at line 523 of file system.module.

References $custom_theme, arg(), drupal_add_css(), drupal_get_path(), and variable_get().

system_initialize_theme_blocks ( $ theme )

Assign an initial, default set of blocks for a theme.

This function is called the first time a new theme is enabled. The new theme gets a copy of the default theme's blocks, with the difference that if a particular region isn't available in the new theme, the block is assigned to the new theme's default region.

Parameters:
$theme The name of a theme.

Definition at line 988 of file system.module.

References $result, $theme, db_fetch_array(), db_query(), db_result(), system_default_region(), system_region_list(), and variable_get().

Referenced by system_admin_theme_submit(), and system_themes_form_submit().

system_mail | ( | $ | key,
 |  | &$ | message,
 |  | $ | params
 | ) |  |

Implementation of hook_mail().

Definition at line 1694 of file system.module.

References drupal_html_to_text(), name, nid, node_get_types(), taxonomy_vocabulary_load(), url(), and variable_get().

system_menu ( )

Implementation of hook_menu().

Definition at line 198 of file system.module.

References $items, $theme, list_themes(), and name.

system_message_action | ( | &$ | object,
 |  | $ | context = array()
 | ) |  |

A configurable Drupal action.

Sends a message to the current user's screen.

Definition at line 1751 of file system.module.

References $user, check_plain(), drupal_set_message(), filter_xss(), name, nid, node_get_types(), node_load(), t(), taxonomy_vocabulary_load(), url(), and variable_get().

system_message_action_form ( $ context )

Definition at line 1732 of file system.module.

References t().

system_message_action_submit | ( | $ | form,
 |  | $ | form_state
 | ) |  |

Definition at line 1744 of file system.module.

system_node_type | ( | $ | op,
 |  | $ | info
 | ) |  |

Implementation of hook_node_type().

Updates theme settings after a node type change.

Definition at line 1079 of file system.module.

References $new, $op, variable_get(), and variable_set().

system_perm ( )

Implementation of hook_perm().

Definition at line 157 of file system.module.

system_region_list ( $ theme_key )

Get a list of available regions from a specified theme.

Parameters:
$theme_key The name of a theme.
Returns:
An array of regions in the form $region['name'] = 'description'.

Definition at line 953 of file system.module.

References $theme_key, db_query(), and db_result().

Referenced by _block_compare(), _block_rehash(), block_admin_display_form(), system_default_region(), system_initialize_theme_blocks(), template_preprocess_block_admin_display_form(), and template_preprocess_page().

system_send_email_action | ( | $ | object,
 |  | $ | context
 | ) |  |

Implementation of a configurable Drupal action.

Sends an email.

Definition at line 1628 of file system.module.

References $language, $user, drupal_mail(), nid, node_load(), user_load(), user_preferred_language(), and watchdog().

system_send_email_action_form ( $ context )

Return a form definition so the Send email action can be configured.

See also:
system_send_email_action_validate()

system_send_email_action_submit()

Parameters:
$context Default values (if we are editing an existing action instance).
Returns:
Form definition.

Definition at line 1561 of file system.module.

References t().

system_send_email_action_submit | ( | $ | form,
 |  | $ | form_state
 | ) |  |

Process system_send_email_action form submissions.

Definition at line 1613 of file system.module.

system_send_email_action_validate | ( | $ | form,
 |  | $ | form_state
 | ) |  |

Validate system_send_email_action form submissions.

Definition at line 1601 of file system.module.

References form_set_error(), t(), and valid_email_address().

system_settings_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Execute the system_settings_form.

If you want node type configure style handling of your checkboxes, add an array_filter value to your form.

Definition at line 1033 of file system.module.

References $op, $value, cache_clear_all(), drupal_rebuild_theme_registry(), drupal_set_message(), t(), variable_del(), and variable_set().

Referenced by system_date_time_settings_submit(), and update_settings_submit().

system_theme ( )

Implementation of hook_theme().

Definition at line 110 of file system.module.

References drupal_common_theme().

system_theme_data ( )

Collect data about all currently available themes.

Returns:
Array of all available themes and their data.

Definition at line 799 of file system.module.

References $theme, _system_theme_data(), db_query(), name, and system_get_files_database().

Referenced by system_admin_theme_settings(), system_install(), system_theme_settings(), system_themes_form(), system_update_6008(), system_update_6013(), update_check_incompatibility(), and update_get_projects().

system_theme_default ( )

Prepare defaults for themes.

Returns:
An array of default themes settings.

Definition at line 762 of file system.module.

Referenced by _system_theme_data().

system_theme_select_form | ( | $ | description = '',
 |  | $ | default_value = '',
 |  | $ | weight = 0
 | ) |  |

Returns a fieldset containing the theme select form.

Parameters:
$description | description of the fieldset
$default_value | default value of theme radios
$weight | weight of the fieldset
Returns:
a form array

Definition at line 668 of file system.module.

References $theme, $theme_key, list_themes(), name, t(), theme(), user_access(), and variable_get().

Referenced by system_user().

system_user | ( | $ | type,
 |  | $ | edit,
 |  | &$ | user,
 |  | $ | category = NULL
 | ) |  |

Implementation of hook_user().

Allows users to individually set their theme and time zone.

Definition at line 542 of file system.module.

References $type, _system_zonelist(), system_theme_select_form(), t(), and variable_get().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/taxonomy/taxonomy.admin.inc File Reference

modules » taxonomy

taxonomy.admin.inc File Reference

Detailed Description

Administrative page callbacks for the taxonomy module.

Definition in file taxonomy.admin.inc.

Go to the source code of this file.

Functions

  • taxonomy_add_term_page ($vocabulary)
    Menu callback; return the edit form for a new term after setting the title.
  • taxonomy_admin_term_edit ($tid)
    Page to edit a vocabulary term.
  • taxonomy_admin_vocabulary_edit ($vocabulary)
    Page to edit a vocabulary.
  • taxonomy_form_term (&$form_state, $vocabulary, $edit=array())
    Form function for the term edit form.
  • taxonomy_form_term_submit ($form, &$form_state)
    Submit handler to insert or update a term.
  • taxonomy_form_term_validate ($form, &$form_state)
    Validation handler for the term edit form.
  • taxonomy_form_vocabulary (&$form_state, $edit=array())
    Display form for adding and editing vocabularies.
  • taxonomy_form_vocabulary_submit ($form, &$form_state)
    Accept the form submission for a vocabulary and save the results.
  • taxonomy_overview_terms (&$form_state, $vocabulary)
    Form builder for the taxonomy terms overview.
  • taxonomy_overview_terms_submit ($form, &$form_state)
    Submit handler for terms overview form.
  • taxonomy_overview_vocabularies ()
    Form builder to list and manage vocabularies.
  • taxonomy_overview_vocabularies_submit ($form, &$form_state)
    Submit handler for vocabularies overview.
  • taxonomy_term_confirm_delete (&$form_state, $tid)
    Form builder for the term delete form.
  • taxonomy_term_confirm_delete_submit ($form, &$form_state)
    Submit handler to delete a term after confirmation.
  • taxonomy_term_confirm_parents (&$form_state, $vocabulary)
    Form builder for the confirmation of multiple term parents.
  • taxonomy_vocabulary_confirm_delete (&$form_state, $vid)
    Form builder for the vocabulary delete confirmation form.
  • taxonomy_vocabulary_confirm_delete_submit ($form, &$form_state)
    Submit handler to delete a vocabulary after confirmation.
  • taxonomy_vocabulary_confirm_reset_alphabetical (&$form_state, $vid)
    Form builder to confirm reseting a vocabulary to alphabetical order.
  • taxonomy_vocabulary_confirm_reset_alphabetical_submit ($form, &$form_state)
    Submit handler to reset a vocabulary to alphabetical order after confirmation.
  • theme_taxonomy_overview_terms ($form)
    Theme the terms overview as a sortable list of terms.
  • theme_taxonomy_overview_vocabularies ($form)
    Theme the vocabulary overview as a sortable list of vocabularies.

Function Documentation

taxonomy_add_term_page ( $ vocabulary )

Menu callback; return the edit form for a new term after setting the title.

Definition at line 623 of file taxonomy.admin.inc.

References drupal_get_form(), drupal_set_title(), name, and t().

taxonomy_admin_term_edit ( $ tid )

Page to edit a vocabulary term.

Definition at line 229 of file taxonomy.admin.inc.

References drupal_get_form(), drupal_not_found(), taxonomy_get_term(), and taxonomy_vocabulary_load().

taxonomy_admin_vocabulary_edit ( $ vocabulary )

Page to edit a vocabulary.

Definition at line 219 of file taxonomy.admin.inc.

References drupal_get_form(), and t().

taxonomy_form_term_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit handler to insert or update a term.

See also:
taxonomy_form_term()

Definition at line 748 of file taxonomy.admin.inc.

References drupal_set_message(), l(), t(), taxonomy_check_vocabulary_hierarchy(), taxonomy_save_term(), taxonomy_save_vocabulary(), taxonomy_term_confirm_delete_submit(), and watchdog().

taxonomy_form_term_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validation handler for the term edit form.

Ensure numeric weight values.

See also:
taxonomy_form_term()

Definition at line 737 of file taxonomy.admin.inc.

References form_set_error(), and t().

taxonomy_form_vocabulary_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Accept the form submission for a vocabulary and save the results.

Definition at line 197 of file taxonomy.admin.inc.

References drupal_set_message(), l(), t(), taxonomy_save_vocabulary(), and watchdog().

taxonomy_overview_terms_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit handler for terms overview form.

Rather than using a textfield or weight field, this form depends entirely upon the order of form elements on the page to determine new weights.

Because there might be hundreds or thousands of taxonomy terms that need to be ordered, terms are weighted from 0 to the number of terms in the vocabulary, rather than the standard -10 to 10 scale. Numbers are sorted lowest to highest, but are not necessarily sequential. Numbers may be skipped when a term has children so that reordering is minimal when a child is added or removed from a term.

See also:
taxonomy_overview_terms()

Definition at line 444 of file taxonomy.admin.inc.

References t(), taxonomy_get_tree(), taxonomy_save_term(), taxonomy_save_vocabulary(), and taxonomy_vocabulary_confirm_reset_alphabetical_submit().

taxonomy_overview_vocabularies_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit handler for vocabularies overview.

Updates changed vocabulary weights.

See also:
taxonomy_overview_vocabularies()

Definition at line 50 of file taxonomy.admin.inc.

References taxonomy_save_vocabulary().

taxonomy_term_confirm_delete_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit handler to delete a term after confirmation.

See also:
taxonomy_term_confirm_delete()

Definition at line 851 of file taxonomy.admin.inc.

References drupal_set_message(), t(), taxonomy_check_vocabulary_hierarchy(), taxonomy_del_term(), and watchdog().

Referenced by taxonomy_form_term_submit().

taxonomy_vocabulary_confirm_delete_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit handler to delete a vocabulary after confirmation.

See also:
taxonomy_vocabulary_confirm_delete()

Definition at line 886 of file taxonomy.admin.inc.

References $status, drupal_set_message(), t(), taxonomy_del_vocabulary(), and watchdog().

taxonomy_vocabulary_confirm_reset_alphabetical_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit handler to reset a vocabulary to alphabetical order after confirmation.

See also:
taxonomy_vocabulary_confirm_reset_alphabetical()

Definition at line 921 of file taxonomy.admin.inc.

References db_query(), drupal_set_message(), t(), and watchdog().

Referenced by taxonomy_overview_terms_submit().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/taxonomy/taxonomy.install File Reference

modules » taxonomy

taxonomy.install File Reference

Go to the source code of this file.

Functions

  • taxonomy_schema ()
    Implementation of hook_schema().

Function Documentation

taxonomy_schema ( )

Implementation of hook_schema().

Definition at line 7 of file taxonomy.install.

References t().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/taxonomy/taxonomy.module File Reference

modules » taxonomy

taxonomy.module File Reference

Detailed Description

Enables the organization of content into categories.

Definition in file taxonomy.module.

Go to the source code of this file.

Functions

  • _taxonomy_get_tid_from_term ($term)
    Helper function for array_map purposes.
  • _taxonomy_term_children ($tid)
    Helper for taxonomy_term_count_nodes().
  • _taxonomy_term_select ($title, $name, $value, $vocabulary_id, $description, $multiple, $blank, $exclude=array())
  • taxonomy_check_vocabulary_hierarchy ($vocabulary, $changed_term)
    Dynamicly check and update the hierarachy flag of a vocabulary.
  • taxonomy_del_term ($tid)
    Delete a term.
  • taxonomy_del_vocabulary ($vid)
    Delete a vocabulary.
  • taxonomy_form ($vid, $value=0, $help=NULL, $name= 'taxonomy')
    Generate a form element for selecting terms from a vocabulary.
  • taxonomy_form_all ($free_tags=0)
    Generate a set of options for selecting a term from all vocabularies.
  • taxonomy_form_alter (&$form, $form_state, $form_id)
    Implementation of hook_form_alter().
  • taxonomy_get_children ($tid, $vid=0, $key= 'tid')
    Find all children of a term ID.
  • taxonomy_get_parents ($tid, $key= 'tid')
    Find all parents of a given term ID.
  • taxonomy_get_parents_all ($tid)
    Find all ancestors of a given term ID.
  • taxonomy_get_related ($tid, $key= 'tid')
    Find all term objects related to a given term ID.
  • taxonomy_get_synonym_root ($synonym)
    Return the term object that has the given string as a synonym.
  • taxonomy_get_synonyms ($tid)
    Return an array of synonyms of the given term ID.
  • taxonomy_get_term ($tid)
    Return the term object matching a term ID.
  • taxonomy_get_term_by_name ($name)
    Try to map a string to an existing term, as for glossary use.
  • taxonomy_get_tree ($vid, $parent=0, $depth=-1, $max_depth=NULL)
    Create a hierarchical representation of a vocabulary.
  • taxonomy_get_vocabularies ($type=NULL)
    Return an array of all vocabulary objects.
  • taxonomy_help ($path, $arg)
    Implementation of hook_help().
  • taxonomy_hook_info ()
    Implementation of hook_hook_info().
  • taxonomy_implode_tags ($tags, $vid=NULL)
    Implode a list of tags of a certain vocabulary into a string.
  • taxonomy_link ($type, $node=NULL)
    Implementation of hook_link().
  • taxonomy_menu ()
    Implementation of hook_menu().
  • taxonomy_node_delete ($node)
    Remove associations of a node to its terms.
  • taxonomy_node_delete_revision ($node)
    Remove associations of a node to its terms.
  • taxonomy_node_get_terms ($node, $key= 'tid')
    Find all terms associated with the given node, ordered by vocabulary and term weight.
  • taxonomy_node_get_terms_by_vocabulary ($node, $vid, $key= 'tid')
    Find all terms associated with the given node, within one vocabulary.
  • taxonomy_node_save ($node, $terms)
    Save term associations for a given node.
  • taxonomy_node_type ($op, $info)
    Implementation of hook_node_type().
  • taxonomy_node_update_index (&$node)
    Implementation of hook_nodeapi('update_index').
  • taxonomy_node_validate (&$node)
    Make sure incoming vids are free tagging enabled.
  • taxonomy_nodeapi ($node, $op, $arg=0)
    Implementation of hook_nodeapi().
  • taxonomy_perm ()
    Implementation of hook_perm().
  • taxonomy_preview_terms ($node)
    Helper function to convert terms after a preview.
  • taxonomy_render_nodes ($result)
    Accepts the result of a pager_query() call, such as that performed by taxonomy_select_nodes(), and formats each node along with a pager.
  • taxonomy_rss_item ($node)
    Provides category information for RSS feeds.
  • taxonomy_save_term (&$form_values)
    Helper function for taxonomy_form_term_submit().
  • taxonomy_save_vocabulary (&$edit)
  • taxonomy_select_nodes ($tids=array(), $operator= 'or', $depth=0, $pager=TRUE, $order= 'n.sticky DESC, n.created DESC')
    Finds all nodes that match selected taxonomy conditions.
  • taxonomy_term_count_nodes ($tid, $type=0)
    Count the number of published nodes classified by a term.
  • taxonomy_term_path ($term)
    For vocabularies not maintained by taxonomy.module, give the maintaining module a chance to provide a path for terms in that vocabulary.
  • taxonomy_terms_parse_string ($str_tids)
    Parses a comma or plus separated string of term IDs.
  • taxonomy_theme ()
    Implementation of hook_theme().
  • taxonomy_vocabulary_load ($vid)
    Return the vocabulary object matching a vocabulary ID.
  • theme_taxonomy_term_select ($element)
    Format the selection field for choosing terms (by deafult the default selection field is used).

Function Documentation

_taxonomy_get_tid_from_term ( $ term )

Helper function for array_map purposes.

Definition at line 1270 of file taxonomy.module.

_taxonomy_term_children ( $ tid )

Helper for taxonomy_term_count_nodes().

Used to find out which terms are children of a parent term.

Parameters:
$tid The parent term's ID
Returns:
array An array of term IDs representing the children of $tid. Results are statically cached.

Definition at line 930 of file taxonomy.module.

References $children, $result, db_fetch_object(), and db_query().

Referenced by taxonomy_term_count_nodes().

_taxonomy_term_select | ( | $ | title,
 |  | $ | name,
 |  | $ | value,
 |  | $ | vocabulary_id,
 |  | $ | description,
 |  | $ | multiple,
 |  | $ | blank,
 |  | $ | exclude = array()
 | ) |  |

Definition at line 1017 of file taxonomy.module.

References $title, $value, name, and taxonomy_get_tree().

Referenced by taxonomy_form(), and taxonomy_form_term().

taxonomy_check_vocabulary_hierarchy | ( | $ | vocabulary,
 |  | $ | changed_term
 | ) |  |

Dynamicly check and update the hierarachy flag of a vocabulary.

Checks the current parents of all terms in a vocabulary and updates the vocabularies hierarchy setting to the lowest possible level. A hierarchy with no parents in any of its terms will be given a hierarchy of 0. If terms contain at most a single parent, the vocabulary will be given a hierarchy of 1. If any term contain multiple parents, the vocabulary will be given a hieararchy of 2.

Parameters:
$vocabulary | An array of the vocabulary structure.
$changed_term | An array of the term structure that was updated.

Definition at line 267 of file taxonomy.module.

References taxonomy_get_tree(), and taxonomy_save_vocabulary().

Referenced by taxonomy_form_term_submit(), and taxonomy_term_confirm_delete_submit().

taxonomy_del_term ( $ tid )

Delete a term.

Parameters:
$tid The term ID.
Returns:
Status constant indicating deletion.

Definition at line 375 of file taxonomy.module.

References $children, cache_clear_all(), db_query(), module_invoke_all(), taxonomy_get_children(), taxonomy_get_parents(), and taxonomy_get_term().

Referenced by forum_confirm_delete_submit(), taxonomy_del_vocabulary(), taxonomy_save_term(), and taxonomy_term_confirm_delete_submit().

taxonomy_del_vocabulary ( $ vid )

Delete a vocabulary.

Parameters:
$vid A vocabulary ID.
Returns:
Constant indicating items were deleted.

Definition at line 235 of file taxonomy.module.

References $result, cache_clear_all(), db_fetch_object(), db_query(), module_invoke_all(), taxonomy_del_term(), and taxonomy_vocabulary_load().

Referenced by forum_uninstall(), taxonomy_save_vocabulary(), and taxonomy_vocabulary_confirm_delete_submit().

taxonomy_form | ( | $ | vid,
 |  | $ | value = 0,
 |  | $ | help = NULL,
 |  | $ | name = 'taxonomy'
 | ) |  |

Generate a form element for selecting terms from a vocabulary.

Definition at line 413 of file taxonomy.module.

References $name, $value, _taxonomy_term_select(), check_plain(), name, t(), and taxonomy_vocabulary_load().

Referenced by taxonomy_form_alter().

taxonomy_form_all ( $ free_tags = 0 )

Generate a set of options for selecting a term from all vocabularies.

Definition at line 430 of file taxonomy.module.

References taxonomy_get_tree(), and taxonomy_get_vocabularies().

taxonomy_form_alter | ( | &$ | form,
 |  | $ | form_state,
 |  | $ | form_id
 | ) |  |

Implementation of hook_form_alter().

Generate a form for selecting terms to associate with a node. We check for taxonomy_override_selector before loading the full vocabulary, so contrib modules can intercept before hook_form_alter and provide scalable alternatives.

Definition at line 486 of file taxonomy.module.

References db_fetch_object(), db_query(), db_rewrite_sql(), name, nid, t(), taxonomy_form(), taxonomy_implode_tags(), taxonomy_node_get_terms(), taxonomy_preview_terms(), and variable_get().

taxonomy_get_children | ( | $ | tid,
 |  | $ | vid = 0,
 |  | $ | key = 'tid'
 | ) |  |

Find all children of a term ID.

Definition at line 783 of file taxonomy.module.

References $children, $result, db_fetch_object(), db_query(), and db_rewrite_sql().

Referenced by taxonomy_del_term().

taxonomy_get_parents | ( | $ | tid,
 |  | $ | key = 'tid'
 | ) |  |

Find all parents of a given term ID.

Definition at line 750 of file taxonomy.module.

References $result, db_fetch_object(), db_query(), and db_rewrite_sql().

Referenced by _forum_parent_select(), taxonomy_del_term(), taxonomy_form_term(), taxonomy_get_parents_all(), and taxonomy_term_page().

taxonomy_get_parents_all ( $ tid )

Find all ancestors of a given term ID.

Definition at line 767 of file taxonomy.module.

References taxonomy_get_parents(), and taxonomy_get_term().

Referenced by forum_nodeapi(), and forum_page().

taxonomy_get_related | ( | $ | tid,
 |  | $ | key = 'tid'
 | ) |  |

Find all term objects related to a given term ID.

Definition at line 733 of file taxonomy.module.

References $result, db_fetch_object(), and db_query().

Referenced by taxonomy_form_term().

taxonomy_get_synonym_root ( $ synonym )

Return the term object that has the given string as a synonym.

Definition at line 878 of file taxonomy.module.

References db_fetch_object(), and db_query().

taxonomy_get_synonyms ( $ tid )

Return an array of synonyms of the given term ID.

Definition at line 861 of file taxonomy.module.

References $result, db_fetch_array(), and db_query().

Referenced by taxonomy_form_term().

taxonomy_get_term ( $ tid )

Return the term object matching a term ID.

Parameters:
$tid A term's ID
Returns:
Object A term object. Results are statically cached.

Definition at line 1007 of file taxonomy.module.

References db_fetch_object(), and db_query().

Referenced by forum_confirm_delete(), forum_get_topics(), forum_link_alter(), forum_nodeapi(), taxonomy_admin_term_edit(), taxonomy_del_term(), taxonomy_get_parents_all(), taxonomy_preview_terms(), taxonomy_select_nodes(), taxonomy_term_confirm_delete(), taxonomy_term_page(), and theme_taxonomy_term_page().

taxonomy_get_term_by_name ( $ name )

Try to map a string to an existing term, as for glossary use.

Provides a case-insensitive and trimmed mapping, to maximize the likelihood of a successful match.

Parameters:
name Name of the term to search for.
Returns:
An array of matching term objects.

Definition at line 954 of file taxonomy.module.

References $name, $result, db_fetch_object(), db_query(), and db_rewrite_sql().

Referenced by taxonomy_node_save().

taxonomy_get_tree | ( | $ | vid,
 |  | $ | parent = 0,
 |  | $ | depth = -1,
 |  | $ | max_depth = NULL
 | ) |  |

Create a hierarchical representation of a vocabulary.

Parameters:
$vid | Which vocabulary to generate the tree for.
$parent | The term ID under which to generate the tree. If 0, generate the tree for the entire vocabulary.
$depth | Internal use only.
$max_depth | The number of levels of the tree to return. Leave NULL to return all levels.
Returns:
An array of all term objects in the tree. Each term object is extended to have "depth" and "parents" attributes in addition to its normal ones. Results are statically cached.

Definition at line 818 of file taxonomy.module.

References $children, $depth, $result, db_fetch_object(), db_query(), db_rewrite_sql(), and drupal_clone().

Referenced by _forum_parent_select(), _taxonomy_term_select(), forum_get_forums(), forum_nodeapi(), taxonomy_check_vocabulary_hierarchy(), taxonomy_form_all(), taxonomy_form_term(), taxonomy_overview_terms(), taxonomy_overview_terms_submit(), and taxonomy_select_nodes().

taxonomy_get_vocabularies ( $ type = NULL )

Return an array of all vocabulary objects.

Parameters:
$type If set, return only those vocabularies associated with this node type.

Definition at line 452 of file taxonomy.module.

References $result, $type, db_fetch_object(), db_query(), and db_rewrite_sql().

Referenced by forum_update_6000(), taxonomy_form_all(), and taxonomy_overview_vocabularies().

taxonomy_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 1233 of file taxonomy.module.

References $output, drupal_ucfirst(), name, t(), and taxonomy_vocabulary_load().

taxonomy_hook_info ( )

Implementation of hook_hook_info().

Definition at line 1297 of file taxonomy.module.

References t().

taxonomy_implode_tags | ( | $ | tags,
 |  | $ | vid = NULL
 | ) |  |

Implode a list of tags of a certain vocabulary into a string.

Definition at line 1277 of file taxonomy.module.

References $tag, and name.

Referenced by taxonomy_form_alter().

taxonomy_link | ( | $ | type,
 |  | $ | node = NULL
 | ) |  |

Implementation of hook_link().

This hook is extended with $type = 'taxonomy terms' to allow themes to print lists of terms associated with a node. Themes can print taxonomy links with:

if (module_exists('taxonomy')) { $terms = taxonomy_link('taxonomy terms', $node); print theme('links', $terms); }

Definition at line 48 of file taxonomy.module.

References $links, $type, drupal_alter(), drupal_explode_tags(), name, taxonomy_preview_terms(), and taxonomy_term_path().

Referenced by chameleon_node(), and template_preprocess_node().

taxonomy_menu ( )

Implementation of hook_menu().

Definition at line 111 of file taxonomy.module.

References $items.

taxonomy_node_delete ( $ node )

Remove associations of a node to its terms.

Definition at line 707 of file taxonomy.module.

References db_query(), and nid.

Referenced by taxonomy_nodeapi().

taxonomy_node_delete_revision ( $ node )

Remove associations of a node to its terms.

Definition at line 714 of file taxonomy.module.

References db_query().

Referenced by taxonomy_node_save(), and taxonomy_nodeapi().

taxonomy_node_get_terms | ( | $ | node,
 |  | $ | key = 'tid'
 | ) |  |

Find all terms associated with the given node, ordered by vocabulary and term weight.

Definition at line 610 of file taxonomy.module.

References $result, db_fetch_object(), db_query(), and db_rewrite_sql().

Referenced by taxonomy_form_alter(), and taxonomy_nodeapi().

taxonomy_node_get_terms_by_vocabulary | ( | $ | node,
 |  | $ | vid,
 |  | $ | key = 'tid'
 | ) |  |

Find all terms associated with the given node, within one vocabulary.

Definition at line 598 of file taxonomy.module.

References $result, db_fetch_object(), db_query(), and db_rewrite_sql().

Referenced by forum_form(), and forum_nodeapi().

taxonomy_node_save | ( | $ | node,
 |  | $ | terms
 | ) |  |

Save term associations for a given node.

Definition at line 645 of file taxonomy.module.

References $status, db_query(), drupal_explode_tags(), nid, taxonomy_get_term_by_name(), taxonomy_node_delete_revision(), and taxonomy_save_term().

Referenced by taxonomy_nodeapi().

taxonomy_node_type | ( | $ | op,
 |  | $ | info
 | ) |  |

Implementation of hook_node_type().

Definition at line 721 of file taxonomy.module.

References $op, and db_query().

taxonomy_node_update_index ( &$ node )

Implementation of hook_nodeapi('update_index').

Definition at line 1182 of file taxonomy.module.

References $output.

Referenced by taxonomy_nodeapi().

taxonomy_node_validate ( &$ node )

Make sure incoming vids are free tagging enabled.

Definition at line 626 of file taxonomy.module.

References form_set_error(), name, t(), and taxonomy_vocabulary_load().

Referenced by taxonomy_nodeapi().

taxonomy_nodeapi | ( | $ | node,
 |  | $ | op,
 |  | $ | arg = 0
 | ) |  |

Implementation of hook_nodeapi().

Definition at line 1141 of file taxonomy.module.

References $op, $output, taxonomy_node_delete(), taxonomy_node_delete_revision(), taxonomy_node_get_terms(), taxonomy_node_save(), taxonomy_node_update_index(), taxonomy_node_validate(), and taxonomy_rss_item().

taxonomy_perm ( )

Implementation of hook_perm().

Definition at line 12 of file taxonomy.module.

taxonomy_preview_terms ( $ node )

Helper function to convert terms after a preview.

After preview the tags are an array instead of proper objects. This function converts them back to objects with the exception of 'free tagging' terms, because new tags can be added by the user before preview and those do not yet exist in the database. We therefore save those tags as a string so we can fill the form again after the preview.

Definition at line 568 of file taxonomy.module.

References taxonomy_get_term().

Referenced by taxonomy_form_alter(), and taxonomy_link().

taxonomy_render_nodes ( $ result )

Accepts the result of a pager_query() call, such as that performed by taxonomy_select_nodes(), and formats each node along with a pager.

Definition at line 1122 of file taxonomy.module.

References $output, $result, db_fetch_object(), nid, node_load(), node_view(), t(), theme(), and variable_get().

Referenced by theme_taxonomy_term_page().

taxonomy_rss_item ( $ node )

Provides category information for RSS feeds.

Definition at line 1220 of file taxonomy.module.

References $output, check_plain(), name, and url().

Referenced by taxonomy_nodeapi().

taxonomy_save_term ( &$ form_values )

Helper function for taxonomy_form_term_submit().

Parameters:
$form_state['values']
Returns:
Status constant indicating if term was inserted or updated.

Definition at line 300 of file taxonomy.module.

References $status, cache_clear_all(), db_query(), drupal_write_record(), module_invoke_all(), and taxonomy_del_term().

Referenced by forum_form_submit(), taxonomy_form_term_submit(), taxonomy_node_save(), and taxonomy_overview_terms_submit().

taxonomy_save_vocabulary ( &$ edit )

Definition at line 194 of file taxonomy.module.

References $status, $type, cache_clear_all(), db_query(), drupal_write_record(), module_invoke_all(), and taxonomy_del_vocabulary().

Referenced by forum_enable(), forum_update_6000(), taxonomy_check_vocabulary_hierarchy(), taxonomy_form_term_submit(), taxonomy_form_vocabulary_submit(), taxonomy_overview_terms_submit(), and taxonomy_overview_vocabularies_submit().

taxonomy_select_nodes | ( | $ | tids = array(),
 |  | $ | operator = 'or',
 |  | $ | depth = 0,
 |  | $ | pager = TRUE,
 |  | $ | order = 'n.sticky DESC,
 |  | n.created DESC' |
 | ) |  |

Finds all nodes that match selected taxonomy conditions.

Parameters:
$tids | An array of term IDs to match.
$operator | How to interpret multiple IDs in the array. Can be "or" or "and".
$depth | How many levels deep to traverse the taxonomy tree. Can be a nonnegative integer or "all".
$pager | Whether the nodes are to be used with a pager (the case on most Drupal pages) or not (in an XML feed, for example).
$order | The order clause for the query that retrieve the nodes.
Returns:
A resource identifier pointing to the query results.

Definition at line 1074 of file taxonomy.module.

References $depth, $pager, $result, db_placeholders(), db_query_range(), db_rewrite_sql(), pager_query(), taxonomy_get_term(), taxonomy_get_tree(), and variable_get().

Referenced by taxonomy_term_page().

taxonomy_term_count_nodes | ( | $ | tid,
 |  | $ | type = 0
 | ) |  |

Count the number of published nodes classified by a term.

Parameters:
$tid | The term's ID
$type | The $node->type. If given, taxonomy_term_count_nodes only counts nodes of $type that are classified with the term $tid.
Returns:
int An integer representing a number of nodes. Results are statically cached.

Definition at line 896 of file taxonomy.module.

References $result, $type, _taxonomy_term_children(), db_fetch_object(), db_query(), and db_rewrite_sql().

taxonomy_term_path ( $ term )

For vocabularies not maintained by taxonomy.module, give the maintaining module a chance to provide a path for terms in that vocabulary.

Parameters:
$term A term object.
Returns:
An internal Drupal path.

Definition at line 100 of file taxonomy.module.

References module, module_invoke(), and taxonomy_vocabulary_load().

Referenced by taxonomy_link().

taxonomy_terms_parse_string ( $ str_tids )

Parses a comma or plus separated string of term IDs.

Parameters:
$str_tids A string of term IDs, separated by plus or comma. comma (,) means AND plus (+) means OR
Returns:
an associative array with an operator key (either 'and' or 'or') and a tid key containing an array of the term ids.

Definition at line 1203 of file taxonomy.module.

Referenced by taxonomy_term_page().

taxonomy_theme ( )

Implementation of hook_theme().

Definition at line 19 of file taxonomy.module.

taxonomy_vocabulary_load ( $ vid )

Return the vocabulary object matching a vocabulary ID.

Parameters:
$vid The vocabulary's ID
Returns:
The vocabulary object with all of its metadata, if exists, NULL otherwise. Results are statically cached.

Definition at line 974 of file taxonomy.module.

References $result, db_fetch_object(), and db_query().

Referenced by forum_enable(), forum_nodeapi(), forum_overview(), hook_mail(), system_mail(), system_message_action(), taxonomy_admin_term_edit(), taxonomy_del_vocabulary(), taxonomy_form(), taxonomy_help(), taxonomy_node_validate(), taxonomy_term_path(), taxonomy_vocabulary_confirm_delete(), taxonomy_vocabulary_confirm_reset_alphabetical(), and template_preprocess_forums().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/taxonomy/taxonomy.pages.inc File Reference

modules » taxonomy

taxonomy.pages.inc File Reference

Detailed Description

Page callbacks for the taxonomy module.

Definition in file taxonomy.pages.inc.

Go to the source code of this file.

Functions

  • taxonomy_autocomplete ($vid, $string= '')
    Helper function for autocompletion.
  • taxonomy_term_page ($str_tids= '', $depth=0, $op= 'page')
    Menu callback; displays all nodes associated with a term.
  • theme_taxonomy_term_page ($tids, $result)
    Render a taxonomy term page HTML output.

Function Documentation

taxonomy_autocomplete | ( | $ | vid,
 |  | $ | string = ''
 | ) |  |

Helper function for autocompletion.

Definition at line 114 of file taxonomy.pages.inc.

References $result, $tag, check_plain(), db_fetch_object(), db_query_range(), db_rewrite_sql(), drupal_explode_tags(), drupal_json(), and name.

taxonomy_term_page | ( | $ | str_tids = '',
 |  | $ | depth = 0,
 |  | $ | op = 'page'
 | ) |  |

Menu callback; displays all nodes associated with a term.

Definition at line 12 of file taxonomy.pages.inc.

References $channel, $depth, $items, $op, $output, $result, $row, $title, check_plain(), db_fetch_object(), db_placeholders(), db_query(), db_rewrite_sql(), drupal_add_feed(), drupal_not_found(), drupal_set_breadcrumb(), drupal_set_title(), l(), name, node_feed(), t(), taxonomy_get_parents(), taxonomy_get_term(), taxonomy_select_nodes(), taxonomy_terms_parse_string(), theme(), url(), and variable_get().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/throttle/throttle.admin.inc File Reference

modules » throttle

throttle.admin.inc File Reference

Detailed Description

Admin page callbacks for the throttle module.

Definition in file throttle.admin.inc.

Go to the source code of this file.

Functions

  • throttle_admin_settings ()
    Form builder; Configure the throttle system.
  • throttle_admin_settings_validate ($form, &$form_state)

Function Documentation

throttle_admin_settings_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 48 of file throttle.admin.inc.

References form_set_error(), and t().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/throttle/throttle.module File Reference

modules » throttle

throttle.module File Reference

Detailed Description

Allows configuration of congestion control auto-throttle mechanism.

Definition in file throttle.module.

Go to the source code of this file.

Functions

  • throttle_exit ()
    Implementation of hook_exit().
  • throttle_help ($path, $arg)
    Implementation of hook_help().
  • throttle_menu ()
  • throttle_status ()
    Determine the current load on the site.

Function Documentation

throttle_exit ( )

Implementation of hook_exit().

Changes the current throttle level based on page hits.

Definition at line 49 of file throttle.module.

References cache_clear_all(), format_plural(), sess_count(), throttle_status(), variable_get(), variable_set(), and watchdog().

throttle_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 118 of file throttle.module.

References $output, and t().

throttle_menu ( )

Definition at line 9 of file throttle.module.

References $items.

throttle_status ( )

Determine the current load on the site.

Call the throttle_status() function from your own modules, themes, blocks, etc. as follows:

$throttle = module_invoke('throttle', 'status');

to determine the current throttle status. Use module_invoke() so the call will still work if the throttle module is disabled. For example, in your theme you might choose to disable pictures when your site is too busy (reducing bandwidth), or in your modules you might choose to disable some complicated logic when your site is too busy (reducing CPU utilization).

Returns:
0 or 1. 0 means that the throttle is currently disabled. 1 means that the throttle is currently enabled. When the throttle is enabled, CPU and bandwidth intensive functionality should be disabled.

Definition at line 40 of file throttle.module.

References variable_get().

Referenced by throttle_exit().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/tracker/tracker.module File Reference

modules » tracker

tracker.module File Reference

Detailed Description

Enables tracking of recent posts for users.

Definition in file tracker.module.

Go to the source code of this file.

Functions

  • tracker_help ($path, $arg)
    Implementation of hook_help().
  • tracker_menu ()
    Implementation of hook_menu().

Function Documentation

tracker_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 12 of file tracker.module.

References $output, and t().

tracker_menu ( )

Implementation of hook_menu().

Definition at line 25 of file tracker.module.

References $items.

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/tracker/tracker.pages.inc File Reference

modules » tracker

tracker.pages.inc File Reference

Detailed Description

User page callbacks for the tracker module.

Definition in file tracker.pages.inc.

Go to the source code of this file.

Functions

  • tracker_page ($account=NULL, $set_title=FALSE)
    Menu callback.

Function Documentation

tracker_page | ( | $ | account = NULL,
 |  | $ | set_title = FALSE
 | ) |  |

Menu callback.

Prints a listing of active nodes on the site.

Definition at line 13 of file tracker.pages.inc.

References $header, $new, $output, $result, check_plain(), comment_new_page_count(), comment_num_new(), db_fetch_object(), db_rewrite_sql(), drupal_add_css(), drupal_get_path(), drupal_set_title(), format_interval(), format_plural(), l(), name, nid, node_get_types(), node_mark(), pager_query(), t(), and theme().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/translation/translation.module File Reference

modules » translation

translation.module File Reference

Detailed Description

Manages content translations.

Translations are managed in sets of posts, which represent the same information in different languages. Only content types for which the administrator explicitly enabled translations could have translations associated. Translations are managed in sets with exactly one source post per set. The source post is used to translate to different languages, so if the source post is significantly updated, the editor can decide to mark all translations outdated.

The node table stores the values used by this module:

  • 'tnid' is the translation set id, which equals the node id of the source post.
  • 'translate' is a flag, either indicating that the translation is up to date (0) or needs to be updated (1).

Definition in file translation.module.

Go to the source code of this file.

Enumerations

  • enum TRANSLATION_ENABLED
    Identifies a content type which has translation support enabled. More...

Functions

  • _translation_tab_access ($node)
    Menu access callback.
  • translation_form_alter (&$form, $form_state, $form_id)
    Implementation of hook_form_alter().
  • translation_help ($path, $arg)
    Implementation of hook_help().
  • translation_link ($type, $node=NULL, $teaser=FALSE)
    Implementation of hook_link().
  • translation_menu ()
    Implementation of hook_menu().
  • translation_node_get_translations ($tnid)
    Get all nodes in a translation set, represented by $tnid.
  • translation_nodeapi (&$node, $op, $teaser, $page)
    Implementation of hook_nodeapi().
  • translation_path_get_translations ($path)
    Return paths of all translations of a node, based on its Drupal path.
  • translation_perm ()
    Implementation of hook_perm().
  • translation_remove_from_set ($node)
    Remove a node from its translation set (if any) and update the set accordingly.
  • translation_supported_type ($type)
    Returns whether the given content type has support for translations.
  • translation_translation_link_alter (&$links, $path)
    Implementation of hook_alter_translation_link().

Enumeration Type Documentation

enum TRANSLATION_ENABLED

Identifies a content type which has translation support enabled.

Definition at line 26 of file translation.module.

Function Documentation

_translation_tab_access ( $ node )

Menu access callback.

Only display translation tab for node types, which have translation enabled and where the current node is not language neutral (which should span all languages).

Definition at line 78 of file translation.module.

References language, translation_supported_type(), and user_access().

translation_form_alter | ( | &$ | form,
 |  | $ | form_state,
 |  | $ | form_id
 | ) |  |

Implementation of hook_form_alter().

  • Add translation option to content type form.
  • Alters language fields on node forms when a translation is about to be created.

Definition at line 99 of file translation.module.

References language, nid, t(), translation_node_get_translations(), translation_supported_type(), url(), and user_access().

translation_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 31 of file translation.module.

References $output, t(), and url().

translation_link | ( | $ | type,
 |  | $ | node = NULL,
 |  | $ | teaser = FALSE
 | ) |  |

Implementation of hook_link().

Display translation links with native language names, if this node is part of a translation set.

Definition at line 162 of file translation.module.

References $language, $links, $type, language, language_list(), and translation_node_get_translations().

translation_menu ( )

Implementation of hook_menu().

Definition at line 56 of file translation.module.

References $items.

translation_node_get_translations ( $ tnid )

Get all nodes in a translation set, represented by $tnid.

Parameters:
$tnid The translation source nid of the translation set, the identifier of the node used to derive all translations in the set.
Returns:
Array of partial node objects (nid, title, language) representing all nodes in the translation set, in effect all translations of node $tnid, including node $tnid itself. Because these are partial nodes, you need to node_load() the full node, if you need more properties. The array is indexed by language code.

Definition at line 275 of file translation.module.

References $result, db_fetch_object(), db_query(), and db_rewrite_sql().

Referenced by translation_form_alter(), translation_link(), translation_node_overview(), and translation_path_get_translations().

translation_nodeapi | ( | &$ | node,
 |  | $ | op,
 |  | $ | teaser,
 |  | $ | page
 | ) |  |

Implementation of hook_nodeapi().

Manages translation information for nodes.

Definition at line 185 of file translation.module.

References $language, $op, db_query(), language, nid, node_invoke_nodeapi(), node_load(), translation_remove_from_set(), translation_supported_type(), and user_access().

translation_path_get_translations ( $ path )

Return paths of all translations of a node, based on its Drupal path.

Parameters:
$path A Drupal path, for example node/432.
Returns:
An array of paths of translations of the node accessible to the current user keyed with language codes.

Definition at line 310 of file translation.module.

References $language, node_load(), and translation_node_get_translations().

Referenced by translation_translation_link_alter().

translation_perm ( )

Implementation of hook_perm().

Definition at line 88 of file translation.module.

translation_remove_from_set ( $ node )

Remove a node from its translation set (if any) and update the set accordingly.

Definition at line 243 of file translation.module.

References db_query(), db_result(), and nid.

Referenced by translation_nodeapi().

translation_supported_type ( $ type )

Returns whether the given content type has support for translations.

Returns:
Boolean value.

Definition at line 296 of file translation.module.

References $type, and variable_get().

Referenced by _translation_tab_access(), translation_form_alter(), and translation_nodeapi().

translation_translation_link_alter | ( | &$ | links,
 |  | $ | path
 | ) |  |

Implementation of hook_alter_translation_link().

Replaces links with pointers to translated versions of the content.

Definition at line 326 of file translation.module.

References $links, and translation_path_get_translations().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/translation/translation.pages.inc File Reference

modules » translation

translation.pages.inc File Reference

Detailed Description

User page callbacks for the translation module.

Definition in file translation.pages.inc.

Go to the source code of this file.

Functions

  • translation_node_overview ($node)
    Overview page for a node's translations.

Function Documentation

translation_node_overview ( $ node )

Overview page for a node's translations.

Parameters:
$node Node object.

Definition at line 15 of file translation.pages.inc.

References $header, $language, $status, $title, drupal_set_title(), l(), language, language_list(), nid, node_access(), node_load(), t(), theme(), and translation_node_get_translations().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/trigger/trigger.admin.inc File Reference

modules » trigger

trigger.admin.inc File Reference

Detailed Description

Admin page callbacks for the trigger module.

Definition in file trigger.admin.inc.

Go to the source code of this file.

Functions

  • _trigger_get_hook_actions ($hook, $op, $type=NULL)
    Get the actions that have already been defined for this type-hook-op combination.
  • theme_trigger_display ($element)
    Display actions assigned to this hook-op combination in a table.
  • trigger_assign ($type=NULL)
    Build the form that allows users to assign actions to hooks.
  • trigger_assign_form ($form_state, $hook, $op, $description)
    Create the form definition for assigning an action to a hook-op combination.
  • trigger_assign_form_submit ($form, $form_state)
    Submit function for trigger_assign_form().
  • trigger_assign_form_validate ($form, $form_state)
    Validation function for trigger_assign_form().
  • trigger_unassign ($form_state, $hook=NULL, $op=NULL, $aid=NULL)
    Confirm removal of an assigned action.
  • trigger_unassign_submit ($form, &$form_state)

Function Documentation

_trigger_get_hook_actions | ( | $ | hook,
 |  | $ | op,
 |  | $ | type = NULL
 | ) |  |

Get the actions that have already been defined for this type-hook-op combination.

Parameters:
$type | One of 'node', 'user', 'comment'.
$hook | The name of the hook for which actions have been assigned, e.g. 'nodeapi'.
$op | The hook operation for which the actions have been assigned, e.g., 'view'.
Returns:
An array of action descriptions keyed by action IDs.

Definition at line 273 of file trigger.admin.inc.

References $op, $result, $type, db_fetch_object(), and db_query().

Referenced by trigger_assign_form().

trigger_assign ( $ type = NULL )

Build the form that allows users to assign actions to hooks.

Parameters:
$type Name of hook.
Returns:
HTML form.

Definition at line 17 of file trigger.admin.inc.

References $op, $output, $type, drupal_get_form(), drupal_goto(), and module_invoke_all().

trigger_assign_form | ( | $ | form_state,
 |  | $ | hook,
 |  | $ | op,
 |  | $ | description
 | ) |  |

Create the form definition for assigning an action to a hook-op combination.

Parameters:
$form_state | Information about the current form.
$hook | The name of the hook, e.g., 'nodeapi'.
$op | The name of the hook operation, e.g., 'insert'.
$description | A plain English description of what this hook operation does.
Returns:
forms
See also:
trigger_assign_form_validate()

trigger_assign_form_submit()

Definition at line 114 of file trigger.admin.inc.

References $op, _trigger_get_hook_actions(), actions_actions_map(), actions_get_all_actions(), actions_list(), l(), and t().

trigger_assign_form_submit | ( | $ | form,
 |  | $ | form_state
 | ) |  |

Submit function for trigger_assign_form().

Definition at line 200 of file trigger.admin.inc.

References actions_function_lookup(), actions_list(), db_query(), db_result(), drupal_set_message(), and t().

trigger_assign_form_validate | ( | $ | form,
 |  | $ | form_state
 | ) |  |

Validation function for trigger_assign_form().

Makes sure that the user is not re-assigning an action to an event.

Definition at line 187 of file trigger.admin.inc.

References actions_function_lookup(), db_query(), db_result(), form_set_error(), and t().

trigger_unassign_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 81 of file trigger.admin.inc.

References actions_function_lookup(), actions_get_all_actions(), check_plain(), db_query(), drupal_goto(), drupal_set_message(), t(), and watchdog().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/trigger/trigger.install File Reference

modules » trigger

trigger.install File Reference

Go to the source code of this file.

Functions

  • trigger_install ()
    Implementation of hook_install().
  • trigger_schema ()
    Implementation of hook_schema().
  • trigger_uninstall ()
    Implementation of hook_uninstall().

Function Documentation

trigger_install ( )

Implementation of hook_install().

Definition at line 7 of file trigger.install.

References actions_list(), actions_synchronize(), and drupal_install_schema().

trigger_schema ( )

Implementation of hook_schema().

Definition at line 26 of file trigger.install.

References t().

trigger_uninstall ( )

Implementation of hook_uninstall().

Definition at line 18 of file trigger.install.

References drupal_uninstall_schema().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/trigger/trigger.module File Reference

modules » trigger

trigger.module File Reference

Detailed Description

Enables functions to be stored and executed at a later time when triggered by other modules or by one of Drupal's core API hooks.

Definition in file trigger.module.

Go to the source code of this file.

Functions

  • _trigger_get_hook_aids ($hook, $op= '')
    Get the aids of actions to be executed for a hook-op combination.
  • _trigger_normalize_comment_context ($type, $comment)
    When an action is called in a context that does not match its type, the object that the action expects must be retrieved.
  • _trigger_normalize_node_context ($type, $node)
    When an action is called in a context that does not match its type, the object that the action expects must be retrieved.
  • _trigger_normalize_user_context ($type, $account)
    When an action is called in a context that does not match its type, the object that the action expects must be retrieved.
  • trigger_access_check ($module)
    Access callback for menu system.
  • trigger_actions_delete ($aid)
    Implementation of hook_actions_delete().
  • trigger_comment ($a1, $op)
    Implementation of hook_comment().
  • trigger_cron ()
    Implementation of hook_cron().
  • trigger_forms ()
    Implementation of hook_forms().
  • trigger_help ($path, $arg)
    Implementation of hook_help().
  • trigger_menu ()
    Implementation of hook_menu().
  • trigger_nodeapi (&$node, $op, $a3, $a4)
    Implementation of hook_nodeapi().
  • trigger_options ($type= 'all')
    Often we generate a select field of all actions.
  • trigger_taxonomy ($op, $type, $array)
    Implementation of hook_taxonomy().
  • trigger_theme ()
    Implementation of hook_theme().
  • trigger_user ($op, &$edit, &$account, $category=NULL)
    Implementation of hook_user().

Function Documentation

_trigger_get_hook_aids | ( | $ | hook,
 |  | $ | op = ''
 | ) |  |

Get the aids of actions to be executed for a hook-op combination.

Parameters:
$hook | The name of the hook being fired.
$op | The name of the operation being executed. Defaults to an empty string because some hooks (e.g., hook_cron()) do not have operations.
Returns:
An array of action IDs.

Definition at line 140 of file trigger.module.

References $op, $result, db_fetch_object(), and db_query().

Referenced by trigger_comment(), trigger_cron(), trigger_nodeapi(), trigger_taxonomy(), and trigger_user().

_trigger_normalize_comment_context | ( | $ | type,
 |  | $ | comment
 | ) |  |

When an action is called in a context that does not match its type, the object that the action expects must be retrieved.

For example, when an action that works on nodes is called during the comment hook, the node object is not available since the comment hook doesn't pass it. So here we load the object the action expects.

Parameters:
$type | The type of action that is about to be called.
$comment | The comment that was passed via the comment hook.
Returns:
The object expected by the action that is about to be called.

Definition at line 261 of file trigger.module.

References $type, nid, node_load(), and user_load().

Referenced by trigger_comment().

_trigger_normalize_node_context | ( | $ | type,
 |  | $ | node
 | ) |  |

When an action is called in a context that does not match its type, the object that the action expects must be retrieved.

For example, when an action that works on users is called during the node hook, the user object is not available since the node hook doesn't pass it. So here we load the object the action expects.

Parameters:
$type | The type of action that is about to be called.
$node | The node that was passed via the nodeapi hook.
Returns:
The object expected by the action that is about to be called.

Definition at line 192 of file trigger.module.

References $type, and user_load().

Referenced by trigger_nodeapi().

_trigger_normalize_user_context | ( | $ | type,
 |  | $ | account
 | ) |  |

When an action is called in a context that does not match its type, the object that the action expects must be retrieved.

For example, when an action that works on nodes is called during the user hook, the node object is not available since the user hook doesn't pass it. So here we load the object the action expects.

Parameters:
$type | The type of action that is about to be called.
$account | The account object that was passed via the user hook.
Returns:
The object expected by the action that is about to be called.

Definition at line 336 of file trigger.module.

References $type, arg(), and node_load().

Referenced by trigger_user().

trigger_access_check ( $ module )

Access callback for menu system.

Definition at line 125 of file trigger.module.

References module_exists(), and user_access().

trigger_actions_delete ( $ aid )

Implementation of hook_actions_delete().

Remove all trigger entries for the given action, when deleted.

Definition at line 429 of file trigger.module.

References db_query().

trigger_comment | ( | $ | a1,
 |  | $ | op
 | ) |  |

Implementation of hook_comment().

Definition at line 276 of file trigger.module.

References $op, _trigger_get_hook_aids(), _trigger_normalize_comment_context(), and actions_do().

trigger_cron ( )

Implementation of hook_cron().

Definition at line 311 of file trigger.module.

References _trigger_get_hook_aids(), and actions_do().

trigger_forms ( )

Implementation of hook_forms().

We reuse code by using the same assignment form definition for each node-op combination.

Definition at line 165 of file trigger.module.

References $op, and module_invoke_all().

trigger_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 13 of file trigger.module.

References $output, t(), and url().

trigger_menu ( )

Implementation of hook_menu().

Definition at line 37 of file trigger.module.

References $items, db_query(), db_result(), and module_invoke_all().

trigger_nodeapi | ( | &$ | node,
 |  | $ | op,
 |  | $ | a3,
 |  | $ | a4
 | ) |  |

Implementation of hook_nodeapi().

Definition at line 209 of file trigger.module.

References $op, $result, _trigger_get_hook_aids(), _trigger_normalize_node_context(), and actions_do().

trigger_options ( $ type = 'all' )

Often we generate a select field of all actions.

This function generates the options for that select.

Parameters:
$type One of 'node', 'user', 'comment'.
Returns:
Array keyed by action ID.

Definition at line 410 of file trigger.module.

References $type, actions_actions_map(), actions_get_all_actions(), and t().

trigger_taxonomy | ( | $ | op,
 |  | $ | type,
 |  | $ | array
 | ) |  |

Implementation of hook_taxonomy().

Definition at line 386 of file trigger.module.

References $op, $type, _trigger_get_hook_aids(), and actions_do().

trigger_theme ( )

Implementation of hook_theme().

Definition at line 152 of file trigger.module.

trigger_user | ( | $ | op,
 |  | &$ | edit,
 |  | &$ | account,
 |  | $ | category = NULL
 | ) |  |

Implementation of hook_user().

Definition at line 356 of file trigger.module.

References $op, _trigger_get_hook_aids(), _trigger_normalize_user_context(), and actions_do().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/update/update.compare.inc File Reference

modules » update

update.compare.inc File Reference

Detailed Description

Code required only when comparing available updates to existing data.

Definition in file update.compare.inc.

Go to the source code of this file.

Functions

  • _update_process_info_list (&$projects, $list, $project_type)
    Populate an array of project data.
  • update_calculate_project_data ($available)
    Given the installed projects and the available release data retrieved from remote servers, calculate the current status.
  • update_get_project_name ($file)
    Given a $file object (as returned by system_get_files_database()), figure out what project it belongs to.
  • update_get_projects ()
    Fetch an array of installed and enabled projects.
  • update_process_project_info (&$projects)
    Process the list of projects on the system to figure out the currently installed versions, and other information that is required before we can compare against the available releases to produce the status report.
  • update_project_cache ($cid)
    Retrieve data from {cache_update} or empty the cache when necessary.

Function Documentation

_update_process_info_list | ( | &$ | projects,
 |  | $ | list,
 |  | $ | project_type
 | ) |  |

Populate an array of project data.

Definition at line 42 of file update.compare.inc.

References name, and update_get_project_name().

Referenced by update_get_projects().

update_calculate_project_data ( $ available )

Given the installed projects and the available release data retrieved from remote servers, calculate the current status.

This function is the heart of the update status feature. It iterates over every currently installed project. For each one, it first checks if the project has been flagged with a special status like "unsupported" or "insecure", or if the project node itself has been unpublished. In any of those cases, the project is marked with an error and the next project is considered.

If the project itself is valid, the function decides what major release series to consider. The project defines what the currently supported major versions are for each version of core, so the first step is to make sure the current version is still supported. If so, that's the target version. If the current version is unsupported, the project maintainer's recommended major version is used. There's also a check to make sure that this function never recommends an earlier release than the currently installed major version.

Given a target major version, it scans the available releases looking for the specific release to recommend (avoiding beta releases and development snapshots if possible). This is complicated to describe, but an example will help clarify. For the target major version, find the highest patch level. If there is a release at that patch level with no extra ("beta", etc), then we recommend the release at that patch level with the most recent release date. If every release at that patch level has extra (only betas), then recommend the latest release from the previous patch level. For example:

1.6-bugfix <-- recommended version because 1.6 already exists. 1.6

or

1.6-beta 1.5 <-- recommended version because no 1.6 exists. 1.4

It also looks for the latest release from the same major version, even a beta release, to display to the user as the "Latest version" option. Additionally, it finds the latest official release from any higher major versions that have been released to provide a set of "Also available" options.

Finally, and most importantly, it keeps scanning the release history until it gets to the currently installed release, searching for anything marked as a security update. If any security updates have been found between the recommended release and the installed version, all of the releases that included a security fix are recorded so that the site administrator can be warned their site is insecure, and links pointing to the release notes for each security update can be included (which, in turn, will link to the official security announcements for each vulnerability).

This function relies on the fact that the .xml release history data comes sorted based on major version and patch level, then finally by release date if there are multiple releases such as betas from the same major.patch version (e.g. 5.x-1.5-beta1, 5.x-1.5-beta2, and 5.x-1.5). Development snapshots for a given major version are always listed last.

Parameters:
$available Array of data about available project releases.
See also:
update_get_available()

update_get_projects()

update_process_project_info()

Definition at line 234 of file update.compare.inc.

References cache_set(), drupal_alter(), t(), update_get_projects(), update_process_project_info(), and update_project_cache().

Referenced by update_requirements(), and update_status().

update_get_project_name ( $ file )

Given a $file object (as returned by system_get_files_database()), figure out what project it belongs to.

See also:
system_get_files_database()

Definition at line 101 of file update.compare.inc.

References name.

Referenced by _update_process_info_list().

update_get_projects ( )

Fetch an array of installed and enabled projects.

This is only responsible for generating an array of projects (taking into account projects that include more than one module or theme). Other information like the specific version and install type (official release, dev snapshot, etc) is handled later in update_process_project_info() since that logic is only required when preparing the status report, not for fetching the available release data.

See also:
update_process_project_info()

update_calculate_project_data()

Definition at line 23 of file update.compare.inc.

References _update_process_info_list(), cache_set(), module_rebuild_cache(), system_theme_data(), and update_project_cache().

Referenced by _update_refresh(), update_calculate_project_data(), and update_get_available().

update_process_project_info ( &$ projects )

Process the list of projects on the system to figure out the currently installed versions, and other information that is required before we can compare against the available releases to produce the status report.

Parameters:
$projects Array of project information from update_get_projects().

Definition at line 125 of file update.compare.inc.

References t().

Referenced by update_calculate_project_data().

update_project_cache ( $ cid )

Retrieve data from {cache_update} or empty the cache when necessary.

Two very expensive arrays computed by this module are the list of all installed modules and themes (and .info data, project associations, etc), and the current status of the site relative to the currently available releases. These two arrays are cached in the {cache_update} table and used whenever possible. The cache is cleared whenever the administrator visits the status report, available updates report, or the module or theme administration pages, since we should always recompute the most current values on any of those pages.

Parameters:
$cid The cache id of data to return from the cache. Valid options are 'update_project_data' and 'update_project_projects'.
Returns:
The cached value of the $projects array generated by update_calculate_project_data() or update_get_projects(), or an empty array when the cache is cleared.

Definition at line 580 of file update.compare.inc.

References cache_clear_all(), and cache_get().

Referenced by update_calculate_project_data(), and update_get_projects().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/update/update.fetch.inc File Reference

modules » update

update.fetch.inc File Reference

Detailed Description

Code required only when fetching information about available updates.

Definition in file update.fetch.inc.

Go to the source code of this file.

Classes

  • class update_xml_parser
    XML Parser object to read Drupal's release history info files. More...

Functions

  • _update_build_fetch_url ($project, $site_key= '')
    Generates the URL to fetch information about project updates.
  • _update_cron_notify ()
    Perform any notifications that should be done once cron fetches new data.
  • _update_refresh ()
    Fetch project info via XML from a central server.
  • update_manual_status ()
    Callback to manually check the update status without cron.

Function Documentation

_update_build_fetch_url | ( | $ | project,
 |  | $ | site_key = ''
 | ) |  |

Generates the URL to fetch information about project updates.

This figures out the right URL to use, based on the project's .info file and the global defaults. Appends optional query arguments when the site is configured to report usage stats.

Parameters:
$project | The array of project information from update_get_projects().
$site_key | The anonymous site key hash (optional).
See also:
update_refresh()

update_get_projects()

Definition at line 81 of file update.fetch.inc.

References $name, $url, drupal_urlencode(), and variable_get().

Referenced by _update_refresh().

_update_cron_notify ( )

Perform any notifications that should be done once cron fetches new data.

This method checks the status of the site using the new data and depending on the configuration of the site, notifys administrators via email if there are new releases or missing security updates.

See also:
update_requirements()

Definition at line 110 of file update.fetch.inc.

References $status, $type, drupal_mail(), language_default(), update_requirements(), user_load(), user_preferred_language(), and variable_get().

Referenced by update_cron().

_update_refresh ( )

Fetch project info via XML from a central server.

Definition at line 25 of file update.fetch.inc.

References $base_url, $url, _update_build_fetch_url(), cache_set(), drupal_get_private_key(), drupal_http_request(), l(), module_invoke(), module_load_include(), update_get_projects(), update_invalidate_cache(), variable_get(), variable_set(), and watchdog().

Referenced by update_manual_status(), and update_refresh().

update_manual_status ( )

Callback to manually check the update status without cron.

Definition at line 12 of file update.fetch.inc.

References _update_refresh(), drupal_goto(), drupal_set_message(), and t().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/update/update.install File Reference

modules » update

update.install File Reference

Go to the source code of this file.

Functions

  • _update_remove_update_status_variables ()
    Private helper to clear out stale variables from update_status 5.x contrib.
  • update_install ()
    Implementation of hook_install().
  • update_schema ()
    Implementation of hook_schema().
  • update_uninstall ()
    Implementation of hook_uninstall().
  • update_update_6000 ()
    Clear out stale variables from update_status.

Function Documentation

_update_remove_update_status_variables ( )

Private helper to clear out stale variables from update_status 5.x contrib.

See also:
update_install()

update_update_6000()

Definition at line 49 of file update.install.

References variable_del().

Referenced by update_install(), and update_update_6000().

update_install ( )

Implementation of hook_install().

Definition at line 7 of file update.install.

References _update_remove_update_status_variables(), and drupal_install_schema().

update_schema ( )

Implementation of hook_schema().

Definition at line 37 of file update.install.

References drupal_get_schema_unprocessed(), and t().

update_uninstall ( )

Implementation of hook_uninstall().

Definition at line 17 of file update.install.

References drupal_uninstall_schema(), menu_rebuild(), and variable_del().

update_update_6000 ( )

Clear out stale variables from update_status.

Definition at line 61 of file update.install.

References _update_remove_update_status_variables().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/update/update.module File Reference

modules » update

update.module File Reference

Detailed Description

The "Update status" module checks for available updates of Drupal core and any installed contributed modules and themes.

It warns site administrators if newer releases are available via the system status report (admin/reports/status), the module and theme pages, and optionally via email.

Definition in file update.module.

Go to the source code of this file.

Enumerations

  • enum UPDATE_CURRENT
    Project is up to date. More...
  • enum UPDATE_DEFAULT_URL
    URL to check for updates, if a given project doesn't define its own. More...
  • enum UPDATE_NOT_CHECKED
    Project's status cannot be checked. More...
  • enum UPDATE_NOT_CURRENT
    Project has a new release available, but it is not a security release. More...
  • enum UPDATE_NOT_SECURE
    Project is missing security update(s). More...
  • enum UPDATE_NOT_SUPPORTED
    Current release is no longer supported by the project maintainer. More...
  • enum UPDATE_REVOKED
    Current release has been unpublished and is no longer available. More...
  • enum UPDATE_UNKNOWN
    No available update data was found for project. More...

Functions

  • _update_message_text ($msg_type, $msg_reason, $report_link=FALSE, $language=NULL)
    Helper function to return the appropriate message text when the site is out of date or missing a security update.
  • _update_no_data ()
    Prints a warning message when there is no data about available updates.
  • _update_project_status_sort ($a, $b)
    Private sort function to order projects based on their status.
  • _update_requirement_check ($project, $type)
    Private helper method to fill in the requirements array.
  • update_cron ()
    Implementation of hook_cron().
  • update_flush_caches ()
    Implementation of hook_flush_caches().
  • update_form_alter (&$form, $form_state, $form_id)
    Implementation of hook_form_alter().
  • update_get_available ($refresh=FALSE)
    Internal helper to try to get the update information from the cache if possible, and to refresh the cache when necessary.
  • update_help ($path, $arg)
    Implementation of hook_help().
  • update_invalidate_cache ()
    Invalidates any cached data relating to update status.
  • update_mail ($key, &$message, $params)
    Implementation of hook_mail().
  • update_menu ()
    Implementation of hook_menu().
  • update_refresh ()
    Wrapper to load the include file and then refresh the release data.
  • update_requirements ($phase)
    Implementation of hook_requirements.
  • update_theme ()
    Implementation of the hook_theme() registry.

Enumeration Type Documentation

enum UPDATE_CURRENT

Project is up to date.

Definition at line 42 of file update.module.

enum UPDATE_DEFAULT_URL

URL to check for updates, if a given project doesn't define its own.

Definition at line 15 of file update.module.

enum UPDATE_NOT_CHECKED

Project's status cannot be checked.

Definition at line 47 of file update.module.

enum UPDATE_NOT_CURRENT

Project has a new release available, but it is not a security release.

Definition at line 37 of file update.module.

enum UPDATE_NOT_SECURE

Project is missing security update(s).

Definition at line 22 of file update.module.

enum UPDATE_NOT_SUPPORTED

Current release is no longer supported by the project maintainer.

Definition at line 32 of file update.module.

enum UPDATE_REVOKED

Current release has been unpublished and is no longer available.

Definition at line 27 of file update.module.

enum UPDATE_UNKNOWN

No available update data was found for project.

Definition at line 52 of file update.module.

Function Documentation

_update_message_text | ( | $ | msg_type,
 |  | $ | msg_reason,
 |  | $ | report_link = FALSE,
 |  | $ | language = NULL
 | ) |  |

Helper function to return the appropriate message text when the site is out of date or missing a security update.

These error messages are shared by both update_requirements() for the site-wide status report at admin/reports/status and in the body of the notification emails generated by update_cron().

Parameters:
$msg_type | String to indicate what kind of message to generate. Can be either 'core' or 'contrib'.
$msg_reason | Integer constant specifying why message is generated.
$report_link | Boolean that controls if a link to the updates report should be added.
$language | An optional language object to use.
Returns:
The properly translated error message for the given key.

Definition at line 442 of file update.module.

References $language, t(), and url().

Referenced by _update_requirement_check(), and update_mail().

_update_no_data ( )

Prints a warning message when there is no data about available updates.

Definition at line 312 of file update.module.

References drupal_get_destination(), t(), and url().

Referenced by update_requirements(), and update_status().

_update_project_status_sort | ( | $ | a,
 |  | $ | b
 | ) |  |

Private sort function to order projects based on their status.

See also:
update_requirements()

uasort()

Definition at line 506 of file update.module.

_update_requirement_check | ( | $ | project,
 |  | $ | type
 | ) |  |

Private helper method to fill in the requirements array.

This is shared for both core and contrib to generate the right elements in the array for hook_requirements().

Parameters:
$project | Array of information about the project we're testing as returned by update_calculate_project_data().
$type | What kind of project is this ('core' or 'contrib').
Returns:
An array to be included in the nested $requirements array.
See also:
hook_requirements()

update_requirements()

update_calculate_project_data()

Definition at line 240 of file update.module.

References $status, $type, _update_message_text(), l(), t(), and variable_get().

Referenced by update_requirements().

update_cron ( )

Implementation of hook_cron().

Definition at line 286 of file update.module.

References _update_cron_notify(), update_refresh(), and variable_get().

update_flush_caches ( )

Implementation of hook_flush_caches().

The function update.php (among others) calls this hook to flush the caches. Since we're running update.php, we are likely to install a new version of something, in which case, we want to check for available update data again.

Definition at line 374 of file update.module.

update_form_alter | ( | &$ | form,
 |  | $ | form_state,
 |  | $ | form_id
 | ) |  |

Implementation of hook_form_alter().

Adds a submit handler to the system modules and themes forms, so that if a site admin saves either form, we invalidate the cache of available updates.

See also:
update_invalidate_cache()

Definition at line 303 of file update.module.

update_get_available ( $ refresh = FALSE )

Internal helper to try to get the update information from the cache if possible, and to refresh the cache when necessary.

In addition to checking the cache lifetime, this function also ensures that there are no .info files for enabled modules or themes that have a newer modification timestamp than the last time we checked for available update data. If any .info file was modified, it almost certainly means a new version of something was installed. Without fresh available update data, the logic in update_calculate_project_data() will be wrong and produce confusing, bogus results.

Parameters:
$refresh Boolean to indicate if this method should refresh the cache automatically if there's no data.
See also:
update_refresh()

update_get_projects()

Definition at line 339 of file update.module.

References cache_get(), module_load_include(), update_get_projects(), update_refresh(), and variable_get().

Referenced by update_requirements(), and update_status().

update_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 58 of file update.module.

References $output, $status, $type, arg(), drupal_set_message(), t(), update_requirements(), url(), and user_access().

update_invalidate_cache ( )

Invalidates any cached data relating to update status.

Definition at line 381 of file update.module.

References cache_clear_all().

Referenced by _update_refresh().

update_mail | ( | $ | key,
 |  | &$ | message,
 |  | $ | params
 | ) |  |

Implementation of hook_mail().

Constructs the email notification message when the site is out of date.

Parameters:
$key | Unique key to indicate what message to build, always 'status_notify'.
$message | Reference to the message array being built.
$params | Array of parameters to indicate what kind of text to include in the message body. This is a keyed array of message type ('core' or 'contrib') as the keys, and the status reason constant (UPDATE_NOT_SECURE, etc) for the values.
See also:
drupal_mail()

_update_cron_notify()

_update_message_text()

Definition at line 412 of file update.module.

References $language, _update_message_text(), t(), url(), and variable_get().

update_menu ( )

Implementation of hook_menu().

Definition at line 116 of file update.module.

References $items.

update_refresh ( )

Wrapper to load the include file and then refresh the release data.

Definition at line 388 of file update.module.

References _update_refresh(), and module_load_include().

Referenced by update_cron(), and update_get_available().

update_requirements ( $ phase )

Implementation of hook_requirements.

Returns:
An array describing the status of the site regarding available updates. If there is no update data, only one record will be returned, indicating that the status of core can't be determined. If data is available, there will be two records: one for core, and another for all of contrib (assuming there are any contributed modules or themes enabled on the site). In addition to the fields expected by hook_requirements ('value', 'severity', and optionally 'description'), this array will contain a 'reason' attribute, which is an integer constant to indicate why the given status is being returned (UPDATE_NOT_SECURE, UPDATE_NOT_CURRENT, or UPDATE_UNKNOWN). This is used for generating the appropriate e-mail notification messages during update_cron(), and might be useful for other modules that invoke update_requirements() to find out if the site is up to date or not.
See also:
_update_message_text()

_update_cron_notify()

Definition at line 191 of file update.module.

References _update_no_data(), _update_requirement_check(), module_load_include(), t(), update_calculate_project_data(), and update_get_available().

Referenced by _update_cron_notify(), and update_help().

update_theme ( )

Implementation of the hook_theme() registry.

Definition at line 156 of file update.module.

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/update/update.report.inc File Reference

modules » update

update.report.inc File Reference

Detailed Description

Code required only when rendering the available updates report.

Definition in file update.report.inc.

Go to the source code of this file.

Functions

  • theme_update_report ($data)
    Theme project status report.
  • theme_update_version ($version, $tag, $class)
    Theme the version display of a project.
  • update_status ()
    Menu callback.

Function Documentation

update_status ( )

Menu callback.

Generate a page about the update status of projects.

Definition at line 12 of file update.report.inc.

References _update_no_data(), module_load_include(), theme(), update_calculate_project_data(), and update_get_available().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/update/update.settings.inc File Reference

modules » update

update.settings.inc File Reference

Detailed Description

Code required only for the update status settings form.

Definition in file update.settings.inc.

Go to the source code of this file.

Functions

  • update_settings ()
    Form builder for the update settings tab.
  • update_settings_submit ($form, $form_state)
    Submit handler for the settings tab.
  • update_settings_validate ($form, &$form_state)
    Validation callback for the settings form.

Function Documentation

update_settings ( )

Form builder for the update settings tab.

Definition at line 12 of file update.settings.inc.

References system_settings_form(), t(), url(), and variable_get().

update_settings_submit | ( | $ | form,
 |  | $ | form_state
 | ) |  |

Submit handler for the settings tab.

Definition at line 91 of file update.settings.inc.

References $op, system_settings_form_submit(), t(), variable_del(), and variable_set().

update_settings_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validation callback for the settings form.

Validates the email addresses and ensures the field is formatted correctly.

Definition at line 61 of file update.settings.inc.

References form_set_error(), t(), and valid_email_address().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/upload/upload.admin.inc File Reference

modules » upload

upload.admin.inc File Reference

Go to the source code of this file.

Functions

  • upload_admin_settings ()
    Menu callback for the upload settings form.
  • upload_admin_settings_validate ($form, &$form_state)
    Form API callback to validate the upload settings form.

Function Documentation

upload_admin_settings ( )

Menu callback for the upload settings form.

Definition at line 57 of file upload.admin.inc.

References file_upload_max_size(), format_size(), system_settings_form(), t(), url(), user_roles(), and variable_get().

upload_admin_settings_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Form API callback to validate the upload settings form.

Definition at line 7 of file upload.admin.inc.

References file_upload_max_size(), form_set_error(), format_size(), and t().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/upload/upload.install File Reference

modules » upload

upload.install File Reference

Go to the source code of this file.

Functions

  • upload_install ()
    Implementation of hook_install().
  • upload_schema ()
    Implementation of hook_schema().
  • upload_uninstall ()
    Implementation of hook_uninstall().

Function Documentation

upload_install ( )

Implementation of hook_install().

Definition at line 7 of file upload.install.

References db_table_exists(), and drupal_install_schema().

upload_schema ( )

Implementation of hook_schema().

Definition at line 27 of file upload.install.

References t().

upload_uninstall ( )

Implementation of hook_uninstall().

Definition at line 19 of file upload.install.

References drupal_uninstall_schema().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/upload/upload.module File Reference

modules » upload

upload.module File Reference

Detailed Description

File-handling and attaching files to nodes.

Definition in file upload.module.

Go to the source code of this file.

Functions

  • _upload_file_limits ($user)
    Determine the limitations on files that a given user may upload.
  • _upload_form ($node)
  • theme_upload_attachments ($files)
    Displays file attachments in table.
  • theme_upload_form_current (&$form)
    Theme the attachments list.
  • theme_upload_form_new ($form)
    Theme the attachment form.
  • upload_delete ($node)
  • upload_delete_revision ($node)
  • upload_file_download ($file)
    Implementation of hook_file_download().
  • upload_form_alter (&$form, $form_state, $form_id)
  • upload_help ($path, $arg)
    Implementation of hook_help().
  • upload_js ()
    Menu-callback for JavaScript-based uploads.
  • upload_link ($type, $node=NULL, $teaser=FALSE)
    Implementation of hook_link().
  • upload_load ($node)
  • upload_menu ()
    Implementation of hook_menu().
  • upload_menu_alter (&$items)
  • upload_node_form_submit ($form, &$form_state)
    Save new uploads and store them in the session to be associated to the node on upload_save.
  • upload_nodeapi (&$node, $op, $teaser)
    Implementation of hook_nodeapi().
  • upload_perm ()
    Implementation of hook_perm().
  • upload_save (&$node)
  • upload_space_used ($uid)
    Determine how much disk space is occupied by a user's uploaded files.
  • upload_theme ()
    Implementation of hook_theme().
  • upload_total_space_used ()
    Determine how much disk space is occupied by uploaded files.

Function Documentation

_upload_file_limits ( $ user )

Determine the limitations on files that a given user may upload.

The user may be in multiple roles so we select the most permissive limitations from all of their roles.

Parameters:
$user A Drupal user object.
Returns:
An associative array with the following keys: 'extensions' A white space separated string containing all the file extensions this user may upload. 'file_size' The maximum size of a file upload in bytes. 'user_size' The total number of bytes for all for a user's files. 'resolution' A string specifying the maximum resolution of images.

Definition at line 120 of file upload.module.

References $name, $user, and variable_get().

Referenced by _upload_form(), and upload_node_form_submit().

_upload_form ( $ node )

Definition at line 469 of file upload.module.

References $user, _upload_file_limits(), check_plain(), file_create_url(), format_size(), t(), and user_access().

Referenced by upload_form_alter(), and upload_js().

upload_delete ( $ node )

Definition at line 434 of file upload.module.

References $result, db_fetch_object(), db_query(), file_delete(), and nid.

Referenced by upload_nodeapi().

upload_delete_revision ( $ node )

Definition at line 451 of file upload.module.

References db_query(), db_result(), and file_delete().

Referenced by upload_nodeapi().

upload_file_download ( $ file )

Implementation of hook_file_download().

Definition at line 147 of file upload.module.

References $result, db_fetch_object(), db_query(), file_create_path(), and user_access().

upload_form_alter | ( | &$ | form,
 |  | $ | form_state,
 |  | $ | form_id
 | ) |  |

Definition at line 208 of file upload.module.

References _upload_form(), file_check_directory(), file_directory_path(), file_directory_temp(), t(), url(), user_access(), and variable_get().

upload_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 13 of file upload.module.

References $output, t(), and url().

upload_js ( )

Menu-callback for JavaScript-based uploads.

Definition at line 578 of file upload.module.

References $output, _upload_form(), cache_get(), cache_set(), drupal_alter(), drupal_render(), drupal_to_js(), exit, form_builder(), theme(), upload_load(), and upload_node_form_submit().

upload_link | ( | $ | type,
 |  | $ | node = NULL,
 |  | $ | teaser = FALSE
 | ) |  |

Implementation of hook_link().

Definition at line 52 of file upload.module.

References $links, $type, format_plural(), t(), and user_access().

upload_load ( $ node )

Definition at line 562 of file upload.module.

References $result, db_fetch_object(), and db_query().

Referenced by upload_js(), and upload_nodeapi().

upload_menu ( )

Implementation of hook_menu().

Definition at line 79 of file upload.module.

References $items.

upload_menu_alter ( &$ items )

Definition at line 97 of file upload.module.

References $items.

upload_node_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Save new uploads and store them in the session to be associated to the node on upload_save.

Parameters:
$node A node object to associate with uploaded files.

Definition at line 168 of file upload.module.

References $user, _upload_file_limits(), file_directory_path(), file_save_upload(), user_access(), and variable_get().

Referenced by upload_js().

upload_nodeapi | ( | &$ | node,
 |  | $ | op,
 |  | $ | teaser
 | ) |  |

Implementation of hook_nodeapi().

Definition at line 266 of file upload.module.

References $op, $output, file_create_url(), format_plural(), theme(), upload_delete(), upload_delete_revision(), upload_load(), upload_save(), user_access(), and variable_get().

upload_perm ( )

Implementation of hook_perm().

Definition at line 45 of file upload.module.

upload_save ( &$ node )

Definition at line 390 of file upload.module.

References db_query(), db_result(), file_delete(), file_set_status(), and nid.

Referenced by upload_nodeapi().

upload_space_used ( $ uid )

Determine how much disk space is occupied by a user's uploaded files.

Parameters:
$uid The integer user id of a user.
Returns:
The amount of disk space used by the user in bytes.

Definition at line 376 of file upload.module.

References file_space_used().

upload_theme ( )

Implementation of hook_theme().

Definition at line 28 of file upload.module.

upload_total_space_used ( )

Determine how much disk space is occupied by uploaded files.

Returns:
The amount of disk space used by uploaded files in bytes.

Definition at line 386 of file upload.module.

References db_query(), and db_result().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/user/user-picture.tpl.php File Reference

modules » user

user-picture.tpl.php File Reference

Detailed Description

Default theme implementation to present an picture configured for the user's account.

Available variables:

  • $picture: Image set by the user or the site's default. Will be linked depending on the viewer's permission to view the users profile page.
  • $account: Array of account information. Potentially unsafe. Be sure to check_plain() before use.

See also:
template_preprocess_user_picture()

Definition in file user-picture.tpl.php.

Go to the source code of this file.

Variables

  • print $picture

Variable Documentation

print $picture

Definition at line 19 of file user-picture.tpl.php.

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/user/user-profile-category.tpl.php File Reference

modules » user

user-profile-category.tpl.php File Reference

Detailed Description

Default theme implementation to present profile categories (groups of profile items).

Categories are defined when configuring user profile fields for the site. It can also be defined by modules. All profile items for a category will be output through the $profile_items variable.

See also:
user-profile-item.tpl.php where each profile item is rendered. It is implemented as a definition list by default.

user-profile.tpl.php where all items and categories are collected and printed out.

Available variables:
  • $title: Category title for the group of items.
  • $profile_items: All the items for the group rendered through user-profile-item.tpl.php.
  • $attributes: HTML attributes. Usually renders classes.

See also:
template_preprocess_user_profile_category()

Definition in file user-profile-category.tpl.php.

Go to the source code of this file.

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/user/user-profile-item.tpl.php File Reference

modules » user

user-profile-item.tpl.php File Reference

Detailed Description

Default theme implementation to present profile items (values from user account profile fields or modules).

This template is used to loop through and render each field configured for the user's account. It can also be the data from modules. The output is grouped by categories.

See also:
user-profile-category.tpl.php for the parent markup. Implemented as a definition list by default.

user-profile.tpl.php where all items and categories are collected and printed out.

Available variables:
  • $title: Field title for the profile item.
  • $value: User defined value for the profile item or data from a module.
  • $attributes: HTML attributes. Usually renders classes.

See also:
template_preprocess_user_profile_item()

Definition in file user-profile-item.tpl.php.

Go to the source code of this file.

Variables

  • print $attributes
  • print $title
  • print $value

Variable Documentation

print $attributes

Definition at line 26 of file user-profile-item.tpl.php.

Referenced by _theme_table_cell(), aggregator_element_start(), db_add_column(), db_change_column(), dblog_event(), drupal_add_link(), drupal_attributes(), template_preprocess_user_picture(), theme_image(), theme_item_list(), theme_links(), theme_pager_link(), and theme_table().

print $title

Definition at line 26 of file user-profile-item.tpl.php.

print $value

Definition at line 27 of file user-profile-item.tpl.php.

Referenced by _comment_get_display_setting(), _filter_htmlcorrector(), _form_set_value(), _form_validate(), _locale_import_one_string(), _locale_prepare_predefined_list(), _locale_translate_seek(), _menu_load_objects(), _menu_overview_tree_form(), _node_mass_update_helper(), _openid_create_message(), _poll_choice_form(), _taxonomy_term_select(), aggregator_block(), aggregator_filter_xss(), aggregator_parse_feed(), aggregator_refresh(), aggregator_save_feed(), color_scheme_form(), comment_admin_overview(), comment_admin_overview_submit(), comment_multiple_delete_confirm(), comment_multiple_delete_confirm_submit(), comment_update_6002(), dblog_build_filter_query(), drupal_attributes(), drupal_get_token(), drupal_html_to_text(), drupal_http_request(), drupal_mail_send(), drupal_map_assoc(), drupal_parse_info_file(), drupal_query_string_encode(), drupal_unpack(), drupal_unset_globals(), drupal_valid_token(), expand_checkboxes(), expand_hidden_array(), filter_form(), form_options_flatten(), form_set_value(), form_type_checkboxes_value(), format_interval(), format_xml_elements(), image_gd_settings_validate(), locale_translate_edit_form_submit(), multipage_form_example_custom_submit(), node_build_filter_query(), node_filter_form(), node_load(), node_multiple_delete_confirm(), node_multiple_delete_confirm_submit(), node_type_form_submit(), node_type_reset(), openid_redirect_form(), pager_load_array(), profile_admin_overview(), profile_browse(), profile_view_field(), profile_view_profile(), sess_write(), st(), system_get_files_database(), system_modules_uninstall_confirm_form(), system_modules_uninstall_submit(), system_settings_form_submit(), t(), taxonomy_form(), template_preprocess_block_admin_display_form(), theme_item_list(), theme_table(), theme_update_report(), user_build_filter_query(), user_filter_form(), user_load(), user_multiple_delete_confirm(), user_multiple_delete_confirm_submit(), user_save(), user_set_authmaps(), user_user_operations(), variable_init(), variable_set(), xmlrpc_message_set(), xmlrpc_message_tag_close(), xmlrpc_value(), and xmlrpc_value_get_xml().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/user/user-profile.tpl.php File Reference

modules » user

user-profile.tpl.php File Reference

Detailed Description

Default theme implementation to present all user profile data.

This template is used when viewing a registered member's profile page, e.g., example.com/user/123. 123 being the users ID.

By default, all user profile data is printed out with the $user_profile variable. If there is a need to break it up you can use $profile instead. It is keyed to the name of each category or other data attached to the account. If it is a category it will contain all the profile items. By default $profile['summary'] is provided which contains data on the user's history. Other data can be included by modules. $profile['picture'] is available by default showing the account picture.

Also keep in mind that profile items and their categories can be defined by site administrators. They are also available within $profile. For example, if a site is configured with a category of "contact" with fields for of addresses, phone numbers and other related info, then doing a straight print of $profile['contact'] will output everything in the category. This is useful for altering source order and adding custom markup for the group.

To check for all available data within $profile, use the code below.

<?php print '

'. check_plain(print_r($profile, 1)) .'
'; ?>

See also:
user-profile-category.tpl.php where the html is handled for the group.

user-profile-field.tpl.php where the html is handled for each item in the group.

Available variables:
  • $user_profile: All user profile data. Ready for print.
  • $profile: Keyed array of profile categories and their items or other data provided by modules.

See also:
template_preprocess_user_profile()

Definition in file user-profile.tpl.php.

Go to the source code of this file.

Variables

  • print $user_profile

Variable Documentation

print $user_profile

Definition at line 45 of file user-profile.tpl.php.

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/user/user.admin.inc File Reference

modules » user

user.admin.inc File Reference

Detailed Description

Admin page callback file for the user module.

Definition in file user.admin.inc.

Go to the source code of this file.

Functions

  • theme_user_admin_account ($form)
    Theme user administration overview.
  • theme_user_admin_new_role ($form)
    Theme the new-role form.
  • theme_user_admin_perm ($form)
    Theme the administer permissions page.
  • theme_user_filter_form ($form)
    Theme user administration filter form.
  • theme_user_filters ($form)
    Theme user administration filter selector.
  • user_admin ($callback_arg= '')
  • user_admin_access ()
    Menu callback: list all access rules.
  • user_admin_access_add ($mask=NULL, $type=NULL)
    Menu callback: add an access rule.
  • user_admin_access_check ()
    Menu callback: list all access rules.
  • user_admin_access_check_submit ($form, &$form_state)
  • user_admin_access_check_validate ($form, &$form_state)
  • user_admin_access_delete_confirm ($form_state, $aid=0)
    Menu callback: delete an access rule.
  • user_admin_access_delete_confirm_submit ($form, &$form_state)
  • user_admin_access_edit ($aid=0)
    Menu callback: edit an access rule.
  • user_admin_access_form (&$form_state, $edit, $submit)
    Form builder; Configure access rules.
  • user_admin_account ()
    Form builder; User administration page.
  • user_admin_account_submit ($form, &$form_state)
    Submit the user administration update form.
  • user_admin_account_validate ($form, &$form_state)
  • user_admin_check_host ()
  • user_admin_check_mail ()
  • user_admin_check_user ()
  • user_admin_perm ($form_state, $rid=NULL)
    Menu callback: administer permissions.
  • user_admin_perm_submit ($form, &$form_state)
  • user_admin_role ()
    Menu callback: administer roles.
  • user_admin_role_submit ($form, &$form_state)
  • user_admin_role_validate ($form, &$form_state)
  • user_admin_settings ()
    Form builder; Configure user settings for this site.
  • user_filter_form ()
    Form builder; Return form for user administration filters.
  • user_filter_form_submit ($form, &$form_state)
    Process result from user administration filter form.

Function Documentation

user_admin ( $ callback_arg = '' )

Definition at line 9 of file user.admin.inc.

References $op, $output, drupal_get_form(), and t().

user_admin_access ( )

Menu callback: list all access rules.

Definition at line 885 of file user.admin.inc.

References $header, $result, db_fetch_object(), db_query(), l(), t(), tablesort_sql(), and theme().

user_admin_access_add | ( | $ | mask = NULL,
 |  | $ | type = NULL
 | ) |  |

Menu callback: add an access rule.

Definition at line 712 of file user.admin.inc.

References $type, db_last_insert_id(), db_query(), drupal_get_form(), drupal_goto(), drupal_set_message(), form_set_error(), and t().

user_admin_access_check ( )

Menu callback: list all access rules.

Definition at line 702 of file user.admin.inc.

References $output, and drupal_get_form().

user_admin_access_check_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 823 of file user.admin.inc.

References drupal_is_denied(), drupal_set_message(), and t().

user_admin_access_check_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 784 of file user.admin.inc.

References form_set_error(), and t().

user_admin_access_delete_confirm_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 875 of file user.admin.inc.

References db_query(), drupal_set_message(), and t().

user_admin_access_edit ( $ aid = 0 )

Menu callback: edit an access rule.

Definition at line 734 of file user.admin.inc.

References db_fetch_array(), db_query(), drupal_get_form(), drupal_goto(), drupal_set_message(), form_set_error(), and t().

user_admin_account_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit the user administration update form.

Definition at line 199 of file user.admin.inc.

References drupal_set_message(), module_invoke_all(), and t().

user_admin_account_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 218 of file user.admin.inc.

References form_set_error(), and t().

user_admin_check_host ( )

Definition at line 812 of file user.admin.inc.

References t().

user_admin_check_mail ( )

Definition at line 801 of file user.admin.inc.

References t().

user_admin_check_user ( )

Definition at line 790 of file user.admin.inc.

References t().

user_admin_perm_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 548 of file user.admin.inc.

References $result, cache_clear_all(), db_fetch_object(), db_query(), drupal_set_message(), and t().

user_admin_role_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 678 of file user.admin.inc.

References db_query(), drupal_set_message(), and t().

user_admin_role_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 660 of file user.admin.inc.

References db_query(), db_result(), form_set_error(), and t().

user_filter_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Process result from user administration filter form.

Definition at line 94 of file user.admin.inc.

References $op, t(), and user_filters().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/user/user.install File Reference

modules » user

user.install File Reference

Go to the source code of this file.

Functions

  • user_schema ()
    Implementation of hook_schema().

Function Documentation

user_schema ( )

Implementation of hook_schema().

Definition at line 7 of file user.install.

References t().

Generated on Tue Feb 12 15:30:48 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/user/user.module File Reference

modules » user

user.module File Reference

Detailed Description

Enables the user registration and login system.

Definition in file user.module.

Go to the source code of this file.

Enumerations

  • enum EMAIL_MAX_LENGTH
  • enum USERNAME_MAX_LENGTH

Functions

  • _user_categories ($account)
    Retrieve a list of all user setting/information categories and sort them by weight.
  • _user_edit_submit ($uid, &$edit)
  • _user_edit_validate ($uid, &$edit)
  • _user_forms (&$edit, $account, $category, $hook= 'form')
    Retrieve a list of all form elements for the specified category.
  • _user_mail_notify ($op, $account, $language=NULL)
    Conditionally create and send a notification email when a certain operation happens on the given user account.
  • _user_mail_text ($key, $language=NULL, $variables=array())
    Returns a mail string for a variable name.
  • _user_password_dynamic_validation ()
    Add javascript and string translations for dynamic password validation (strength and confirmation checking).
  • _user_sort ($a, $b)
  • template_preprocess_user_picture (&$variables)
    Process variables for user-picture.tpl.php.
  • theme_user_list ($users, $title=NULL)
    Make a list of users.
  • theme_user_signature ($signature)
    Theme output of user signature.
  • user_access ($string, $account=NULL, $reset=FALSE)
    Determine whether the user has a given privilege.
  • user_action_info ()
    Implementation of hook_action_info().
  • user_authenticate ($form_values=array())
    Try to log in the user locally.
  • user_authenticate_finalize (&$edit)
    Finalize the login process.
  • user_block ($op= 'list', $delta=0, $edit=array())
    Implementation of hook_block().
  • user_block_ip_action ()
    Implementation of a Drupal action.
  • user_block_user_action (&$object, $context=array())
    Implementation of a Drupal action.
  • user_build_content (&$account)
    Builds a structured array representing the profile content.
  • user_build_filter_query ()
    Build query for user administration filters based on session.
  • user_category_load ($uid, &$map, $index)
    Return a user object after checking if any profile category in the path exists.
  • user_comment (&$comment, $op)
    Implementation of hook_comment().
  • user_current_load ($arg)
  • user_current_to_arg ($arg)
    Returns the user id of the currently logged in user.
  • user_delete ($edit, $uid)
    Delete a user.
  • user_edit_access ($account)
  • user_edit_form (&$form_state, $uid, $edit, $register=FALSE)
  • user_elements ()
    Implementation of hook_elements().
  • user_external_load ($authname)
  • user_external_login ($account, $edit=array())
    Perform standard Drupal login operations for a user object.
  • user_external_login_register ($name, $module)
    Helper function for authentication modules.
  • user_fields ()
  • user_file_download ($file)
    Implementation of hook_file_download().
  • user_filters ()
    List user administration filters that can be applied.
  • user_forms ()
    Implementation of hook_forms().
  • user_get_authmaps ($authname=NULL)
    Discover which external authentication module(s) authenticated a username.
  • user_help ($path, $arg)
    Implementation of hook_help().
  • user_hook_info ()
    Implementation of hook_hook_info().
  • user_init ()
  • user_is_anonymous ()
  • user_is_blocked ($name)
    Checks for usernames blocked by user administration.
  • user_is_logged_in ()
  • user_load ($array=array())
    Fetch a user object.
  • user_load_self ($arg)
  • user_login (&$form_state, $msg= '')
    Form builder; the main user login form.
  • user_login_authenticate_validate ($form, &$form_state)
    A validate handler on the login form.
  • user_login_block ()
  • user_login_default_validators ()
    Set up a series for validators which check for blocked/denied users, then authenticate against local database, then return an error if authentication fails.
  • user_login_final_validate ($form, &$form_state)
    A validate handler on the login form.
  • user_login_name_validate ($form, &$form_state)
    A FAPI validate handler.
  • user_login_submit ($form, &$form_state)
    Submit handler for the login form.
  • user_mail ($key, &$message, $params)
    Implementation of hook_mail().
  • user_mail_tokens ($account, $language)
    Return an array of token to value mappings for user e-mail messages.
  • user_menu ()
    Implementation of hook_menu().
  • user_module_invoke ($type, &$array, &$user, $category=NULL)
    Invokes hook_user() in every module.
  • user_multiple_delete_confirm (&$form_state)
  • user_multiple_delete_confirm_submit ($form, &$form_state)
  • user_multiple_role_edit ($accounts, $operation, $rid)
    Callback function for admin mass adding/deleting a user role.
  • user_page_title ($account)
    Menu item title callback - use the user name if it's not the current user.
  • user_pass_rehash ($password, $timestamp, $login)
  • user_pass_reset_url ($account)
  • user_password ($length=10)
    Generate a random alphanumeric password.
  • user_perm ()
    Implementation of hook_perm().
  • user_preferred_language ($account, $default=NULL)
    Get the language object preferred by the user.
  • user_register ()
    Form builder; The user registration form.
  • user_register_access ()
  • user_register_submit ($form, &$form_state)
    Submit handler for the user registration form.
  • user_register_validate ($form, &$form_state)
  • user_roles ($membersonly=FALSE, $permission=NULL)
    Retrieve an array of roles matching specified conditions.
  • user_save ($account, $array=array(), $category= 'account')
    Save changes to a user account or add a new user.
  • user_search ($op= 'search', $keys=NULL, $skip_access_check=FALSE)
    Implementation of hook_search().
  • user_set_authmaps ($account, $authmaps)
    Save mappings of which external authentication module(s) authenticated a user.
  • user_theme ()
    Implementation of hook_theme().
  • user_user ($type, &$edit, &$account, $category=NULL)
    Implementation of hook_user().
  • user_user_operations ($form_state=array())
    Implementation of hook_user_operations().
  • user_user_operations_block ($accounts)
    Callback function for admin mass blocking users.
  • user_user_operations_unblock ($accounts)
    Callback function for admin mass unblocking users.
  • user_validate_mail ($mail)
  • user_validate_name ($name)
    Verify the syntax of the given name.
  • user_validate_picture (&$form, &$form_state)
  • user_view_access ($account)

Enumeration Type Documentation

enum EMAIL_MAX_LENGTH

Definition at line 10 of file user.module.

enum USERNAME_MAX_LENGTH

Definition at line 9 of file user.module.

Function Documentation

_user_categories ( $ account )

Retrieve a list of all user setting/information categories and sort them by weight.

Definition at line 1899 of file user.module.

References module_invoke(), and module_list().

Referenced by user_category_load(), and user_menu().

_user_edit_submit | ( | $ | uid,
 |  | &$ | edit
 | ) |  |

Definition at line 1549 of file user.module.

References $user, file_delete(), and user_load().

Referenced by user_user().

_user_edit_validate | ( | $ | uid,
 |  | &$ | edit
 | ) |  |

Definition at line 1522 of file user.module.

References $user, db_query(), db_result(), drupal_is_denied(), form_set_error(), t(), url(), user_access(), user_load(), user_validate_mail(), and user_validate_name().

Referenced by user_user().

_user_forms | ( | &$ | edit,
 |  | $ | account,
 |  | $ | category,
 |  | $ | hook = 'form'
 | ) |  |

Retrieve a list of all form elements for the specified category.

Definition at line 2438 of file user.module.

References module_invoke(), and module_list().

Referenced by user_profile_form(), and user_register().

_user_mail_notify | ( | $ | op,
 |  | $ | account,
 |  | $ | language = NULL
 | ) |  |

Conditionally create and send a notification email when a certain operation happens on the given user account.

See also:
user_mail_tokens()

drupal_mail()

Parameters:
$op | The operation being performed on the account. Possible values: 'register_admin_created': Welcome message for user created by the admin 'register_no_approval_required': Welcome message when user self-registers 'register_pending_approval': Welcome message, user pending admin approval 'password_reset': Password recovery request 'status_activated': Account activated 'status_blocked': Account blocked 'status_deleted': Account deleted
$account | The user object of the account being notified. Must contain at least the fields 'uid', 'name', and 'mail'.
$language | Optional language to use for the notification, overriding account language.
Returns:
The return value from drupal_mail_send(), if ends up being called.

Definition at line 2116 of file user.module.

References $language, $op, drupal_mail(), language_default(), user_preferred_language(), and variable_get().

Referenced by user_delete(), user_pass_submit(), user_register_submit(), and user_save().

_user_mail_text | ( | $ | key,
 |  | $ | language = NULL,
 |  | $ | variables = array()
 | ) |  |

Returns a mail string for a variable name.

Used by user_mail() and the settings forms to retrieve strings.

Definition at line 1614 of file user.module.

References $language, t(), and variable_get().

Referenced by user_admin_settings(), and user_mail().

_user_password_dynamic_validation ( )

Add javascript and string translations for dynamic password validation (strength and confirmation checking).

This is an internal function that makes it easier to manage the translation strings that need to be passed to the javascript code.

Definition at line 2140 of file user.module.

References $user, drupal_add_js(), drupal_get_path(), name, and t().

Referenced by install_tasks(), and user_edit_form().

_user_sort | ( | $ | a,
 |  | $ | b
 | ) |  |

Definition at line 1913 of file user.module.

template_preprocess_user_picture ( &$ variables )

Process variables for user-picture.tpl.php.

The $variables array contains the following arguments:

  • $account

See also:
user-picture.tpl.php

Definition at line 804 of file user.module.

References $attributes, $picture, file_create_url(), l(), name, t(), theme(), user_access(), and variable_get().

user_access | ( | $ | string,
 |  | $ | account = NULL,
 |  | $ | reset = FALSE
 | ) |  |

Determine whether the user has a given privilege.

Parameters:
$string | The permission, such as "administer nodes", being checked for.
$account | (optional) The account to check, if not given use currently logged in user.
$reset | (optional) Resets the user's permissions cache, which will result in a recalculation of the user's permissions. This is necessary to support dynamically added user roles.
Returns:
Boolean TRUE if the current user has the requested permission.
All permission checks in Drupal should go through this function. This way, we guarantee consistent behavior, and ensure that the superuser can perform all actions.

Definition at line 480 of file user.module.

References $result, $row, $user, db_fetch_object(), db_placeholders(), and db_query().

Referenced by _aggregator_has_categories(), _aggregator_page_list(), _block_themes_access(), _book_add_form_elements(), _book_outline_access(), _contact_user_tab_access(), _menu_check_access(), _menu_site_is_offline(), _node_access_join_sql(), _node_access_where_sql(), _node_revision_access(), _poll_choice_form(), _poll_menu_access(), _profile_get_fields(), _translation_tab_access(), _upload_form(), _user_edit_validate(), aggregator_block(), aggregator_categorize_items_validate(), block_admin_configure(), blog_access(), blog_block(), blog_page_last(), blog_page_user(), blog_user(), blogapi_blogger_edit_post(), blogapi_blogger_new_post(), blogapi_validate_user(), book_export_html(), book_form_alter(), book_link(), book_nodeapi(), comment_access(), comment_block(), comment_form(), comment_form_alter(), comment_link(), comment_links(), comment_render(), comment_reply(), comment_save(), fileupload_access(), fileupload_file_download(), fileupload_menu(), filter_access(), filter_formats(), forum_access(), forum_block(), hook_access(), hook_file_download(), hook_link(), hook_node_grants(), hook_nodeapi(), locale_user(), menu_form_alter(), node_access(), node_access_example_node_grants(), node_content_access(), node_example_access(), node_form(), node_form_alter(), node_help(), node_revision_overview(), node_submit(), node_validate(), path_admin_delete_confirm(), path_form_alter(), path_nodeapi(), poll_access(), poll_block(), poll_form(), poll_insert(), poll_load(), profile_block(), profile_browse(), profile_category_access(), profile_validate_profile(), profile_view_field(), profile_view_profile(), statistics_block(), statistics_link(), system_get_module_admin_tasks(), system_main_admin_page(), system_requirements(), system_theme_select_form(), template_preprocess(), template_preprocess_aggregator_feed_source(), template_preprocess_poll_results(), template_preprocess_user_picture(), theme_aggregator_block_item(), theme_book_admin_table(), theme_get_settings(), theme_username(), translation_form_alter(), translation_nodeapi(), trigger_access_check(), update_help(), upload_file_download(), upload_form_alter(), upload_link(), upload_node_form_submit(), upload_nodeapi(), user_block(), user_build_filter_query(), user_edit_access(), user_edit_form(), user_edit_validate(), user_profile_form(), user_profile_form_validate(), user_register(), user_register_submit(), user_save(), user_search(), user_user_operations(), and user_view_access().

user_action_info ( )

Implementation of hook_action_info().

Definition at line 2201 of file user.module.

References t().

user_authenticate ( $ form_values = array() )

Try to log in the user locally.

Parameters:
$form_values Form values with at least 'name' and 'pass' keys, as well as anything else which should be passed along to hook_user op 'login'.
Returns:
A $user object, if successful.

Definition at line 1328 of file user.module.

References $user, user_authenticate_finalize(), and user_load().

Referenced by blogapi_validate_user(), install_configure_form_submit(), user_login_authenticate_validate(), and user_register_submit().

user_authenticate_finalize ( &$ edit )

Finalize the login process.

Must be called when logging in a user.

The function records a watchdog message about the new session, saves the login timestamp, calls hook_user op 'login' and generates a new session.

$param $edit This array is passed to hook_user op login.

Definition at line 1349 of file user.module.

References $user, db_query(), name, sess_regenerate(), user_module_invoke(), and watchdog().

Referenced by user_authenticate(), user_external_login(), and user_pass_reset().

user_block | ( | $ | op = 'list',
 |  | $ | delta = 0,
 |  | $ | edit = array()
 | ) |  |

Implementation of hook_block().

Definition at line 677 of file user.module.

References $items, $op, $output, $result, $user, arg(), check_plain(), db_fetch_object(), db_query(), db_query_range(), drupal_get_form(), drupal_map_assoc(), format_plural(), menu_tree(), name, sess_count(), t(), theme(), user_access(), variable_get(), and variable_set().

user_block_ip_action ( )

Implementation of a Drupal action.

Adds an access rule that blocks the user's IP address.

Definition at line 2242 of file user.module.

References db_query(), ip_address(), and watchdog().

user_block_user_action | ( | &$ | object,
 |  | $ | context = array()
 | ) |  |

Implementation of a Drupal action.

Blocks the current user.

Definition at line 2222 of file user.module.

References $user, check_plain(), db_query(), name, sess_destroy_uid(), and watchdog().

user_build_content ( &$ account )

Builds a structured array representing the profile content.

Parameters:
$account A user object.
Returns:
A structured array containing the individual elements of the profile.

Definition at line 1590 of file user.module.

References drupal_alter(), and user_module_invoke().

Referenced by user_view().

user_build_filter_query ( )

Build query for user administration filters based on session.

Definition at line 1965 of file user.module.

References $value, user_access(), and user_filters().

Referenced by user_admin_account().

user_category_load | ( | $ | uid,
 |  | &$ | map,
 |  | $ | index
 | ) |  |

Return a user object after checking if any profile category in the path exists.

Definition at line 1120 of file user.module.

References _user_categories(), and user_load().

user_comment | ( | &$ | comment,
 |  | $ | op
 | ) |  |

Implementation of hook_comment().

Definition at line 2009 of file user.module.

References $op, check_markup(), and variable_get().

user_current_load ( $ arg )

Definition at line 1113 of file user.module.

References user_load().

user_current_to_arg ( $ arg )

Returns the user id of the currently logged in user.

Definition at line 1159 of file user.module.

user_delete | ( | $ | edit,
 |  | $ | uid
 | ) |  |

Delete a user.

Parameters:
$edit | An array of submitted form values.
$uid | The user ID of the user to delete.

Definition at line 1569 of file user.module.

References _user_mail_notify(), db_query(), module_invoke_all(), name, sess_destroy_uid(), user_load(), and watchdog().

Referenced by user_confirm_delete_submit(), and user_multiple_delete_confirm_submit().

user_edit_access ( $ account )

Definition at line 870 of file user.module.

References user_access().

user_edit_form | ( | &$ | form_state,
 |  | $ | uid,
 |  | $ | edit,
 |  | $ | register = FALSE
 | ) |  |

Definition at line 1413 of file user.module.

References $picture, _user_password_dynamic_validation(), module_exists(), t(), theme(), user_access(), user_roles(), and variable_get().

Referenced by user_register(), and user_user().

user_elements ( )

Implementation of hook_elements().

Definition at line 594 of file user.module.

user_external_load ( $ authname )

Definition at line 80 of file user.module.

References $result, $user, db_fetch_array(), db_query(), and user_load().

Referenced by openid_authentication().

user_external_login | ( | $ | account,
 |  | $ | edit = array()
 | ) |  |

Perform standard Drupal login operations for a user object.

The user object must already be authenticated. This function verifies that the user account is not blocked/denied and then performs the login, updates the login timestamp in the database, invokes hook_user('login'), and regenerates the session.

Parameters:
$account | An authenticated user object to be set as the currently logged in user.
$edit | The array of form values submitted by the user, if any. This array is passed to hook_user op login.
Returns:
boolean TRUE if the login succeeds, FALSE otherwise.

Definition at line 108 of file user.module.

References $user, drupal_get_form(), form_get_errors(), user_authenticate_finalize(), and user_login_name_validate().

Referenced by openid_authentication().

user_external_login_register | ( | $ | name,
 |  | $ | module
 | ) |  |

Helper function for authentication modules.

Either login in or registers the current user, based on username. Either way, the global $user object is populated based on $name.

Definition at line 1379 of file user.module.

References $name, $user, drupal_set_message(), l(), t(), user_load(), user_password(), user_save(), and watchdog().

user_fields ( )

Definition at line 523 of file user.module.

References $result, db_fetch_array(), and db_query().

Referenced by profile_field_form_validate(), and user_save().

user_file_download ( $ file )

Implementation of hook_file_download().

Ensure that user pictures (avatars) are always downloadable.

Definition at line 552 of file user.module.

References file_create_path(), image_get_info(), and variable_get().

user_filters ( )

List user administration filters that can be applied.

Definition at line 1922 of file user.module.

References module_invoke(), module_list(), t(), and user_roles().

Referenced by user_build_filter_query(), user_filter_form(), and user_filter_form_submit().

user_forms ( )

Implementation of hook_forms().

Definition at line 1999 of file user.module.

user_get_authmaps ( $ authname = NULL )

Discover which external authentication module(s) authenticated a username.

Parameters:
$authname A username used by an external authentication module.
Returns:
An associative array with module as key and username as value.

Definition at line 1184 of file user.module.

References $result, db_fetch_object(), and db_query().

user_help | ( | $ | path,
 |  | $ | arg
 | ) |  |

Implementation of hook_help().

Definition at line 1866 of file user.module.

References $output, $user, t(), and url().

user_hook_info ( )

Implementation of hook_hook_info().

Definition at line 2171 of file user.module.

References t().

user_init ( )

Definition at line 1109 of file user.module.

References drupal_add_css(), and drupal_get_path().

user_is_anonymous ( )

Definition at line 845 of file user.module.

Referenced by _menu_site_is_offline(), and user_register_access().

user_is_blocked ( $ name )

Checks for usernames blocked by user administration.

Returns:
boolean TRUE for blocked users, FALSE for active.

Definition at line 517 of file user.module.

References $name, db_fetch_object(), and db_query().

Referenced by user_login_name_validate().

user_is_logged_in ( )

Definition at line 850 of file user.module.

user_load ( $ array = array() )

Fetch a user object.

Parameters:
$array An associative array of attributes to search for in selecting the user, such as user name or e-mail address.
Returns:
A fully-loaded $user object upon successful user load or FALSE if user cannot be loaded.

Definition at line 141 of file user.module.

References $result, $user, $value, db_fetch_object(), db_query(), drupal_unpack(), and user_module_invoke().

Referenced by _comment_form_submit(), _trigger_normalize_comment_context(), _trigger_normalize_node_context(), _update_cron_notify(), _user_edit_submit(), _user_edit_validate(), comment_form_add_preview(), comment_validate(), install_configure_form_submit(), node_preview(), node_submit(), node_validate(), profile_block(), profile_browse(), statistics_user_tracker(), system_send_email_action(), user_authenticate(), user_category_load(), user_current_load(), user_delete(), user_external_load(), user_external_login_register(), user_load_self(), user_multiple_role_edit(), user_pass_reset(), user_pass_validate(), user_save(), user_user_operations_block(), and user_user_operations_unblock().

user_load_self ( $ arg )

Definition at line 874 of file user.module.

References user_load().

user_login_authenticate_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

A validate handler on the login form.

Check supplied username/password against local users table. If successful, sets the global $user object.

Definition at line 1302 of file user.module.

References user_authenticate().

user_login_block ( )

Definition at line 643 of file user.module.

References $items, drupal_get_destination(), l(), t(), theme(), url(), user_login_default_validators(), and variable_get().

user_login_default_validators ( )

Set up a series for validators which check for blocked/denied users, then authenticate against local database, then return an error if authentication fails.

Distributed authentication modules are welcome to use hook_form_alter() to change this series in order to authenticate against their user database instead of the local users table.

We use three validators instead of one since external authentication modules usually only need to alter the second validator.

See also:
user_login_name_validate()

user_login_authenticate_validate()

user_login_final_validate()

Returns:
array A simple list of validate functions.

Definition at line 1277 of file user.module.

Referenced by user_login(), and user_login_block().

user_login_final_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

A validate handler on the login form.

Should be the last validator. Sets an error if user has not been authenticated yet.

Definition at line 1310 of file user.module.

References $user, form_set_error(), t(), url(), and watchdog().

user_login_name_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

A FAPI validate handler.

Sets an error if supplied username has been blocked or denied access.

Definition at line 1285 of file user.module.

References drupal_is_denied(), form_set_error(), t(), and user_is_blocked().

Referenced by user_external_login().

user_login_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit handler for the login form.

Redirects the user to a page.

The user is redirected to the My Account page. Setting the destination in the query string (as done by the user login block) overrides the redirect.

Definition at line 1366 of file user.module.

References $user.

user_mail | ( | $ | key,
 |  | &$ | message,
 |  | $ | params
 | ) |  |

Implementation of hook_mail().

Definition at line 1602 of file user.module.

References $language, _user_mail_text(), and user_mail_tokens().

user_mail_tokens | ( | $ | account,
 |  | $ | language
 | ) |  |

Return an array of token to value mappings for user e-mail messages.

Parameters:
$account | The user object of the account being notified. Must contain at least the fields 'uid', 'name', and 'mail'.
$language | Language object to generate the tokens with.
Returns:
Array of mappings from token names to values (for use with strtr()).

Definition at line 2049 of file user.module.

References $base_url, $language, format_date(), language, name, url(), user_pass_reset_url(), and variable_get().

Referenced by user_mail().

user_menu ( )

Implementation of hook_menu().

Definition at line 882 of file user.module.

References $items, _user_categories(), and drupal_get_path().

user_module_invoke | ( | $ | type,
 |  | &$ | array,
 |  | &$ | user,
 |  | $ | category = NULL
 | ) |  |

Invokes hook_user() in every module.

We cannot use module_invoke() for this, because the arguments need to be passed by reference.

Definition at line 18 of file user.module.

References $type, $user, and module_list().

Referenced by user_authenticate_finalize(), user_build_content(), user_edit_submit(), user_edit_validate(), user_load(), user_profile_form_submit(), user_profile_form_validate(), user_register_validate(), and user_save().

user_multiple_delete_confirm ( &$ form_state )

Definition at line 1835 of file user.module.

References $user, $value, check_plain(), confirm_form(), db_query(), db_result(), and t().

user_multiple_delete_confirm_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 1852 of file user.module.

References $value, drupal_set_message(), t(), and user_delete().

user_multiple_role_edit | ( | $ | accounts,
 |  | $ | operation,
 |  | $ | rid
 | ) |  |

Callback function for admin mass adding/deleting a user role.

Definition at line 1806 of file user.module.

References db_query(), db_result(), user_load(), and user_save().

user_page_title ( $ account )

Menu item title callback - use the user name if it's not the current user.

Definition at line 1169 of file user.module.

References t().

user_pass_rehash | ( | $ | password,
 |  | $ | timestamp,
 |  | $ | login
 | ) |  |

Definition at line 1409 of file user.module.

Referenced by user_pass_reset(), and user_pass_reset_url().

user_pass_reset_url ( $ account )

Definition at line 1404 of file user.module.

References url(), and user_pass_rehash().

Referenced by user_mail_tokens().

user_password ( $ length = 10 )

Generate a random alphanumeric password.

Definition at line 437 of file user.module.

Referenced by openid_authentication(), openid_form_alter(), user_external_login_register(), and user_register_submit().

user_perm ( )

Implementation of hook_perm().

Definition at line 543 of file user.module.

user_preferred_language | ( | $ | account,
 |  | $ | default = NULL
 | ) |  |

Get the language object preferred by the user.

This user preference can be set on the user account editing page, and is only available if there are more than one languages enabled on the site. If the user did not choose a preferred language, or is the anonymous user, the $default value, or if it is not set, the site default language will be returned.

Parameters:
$account | User account to look up language for.
$default | Optional default language object to return if the account has no valid language.

Definition at line 2081 of file user.module.

References language, language_default(), and language_list().

Referenced by _update_cron_notify(), _user_mail_notify(), contact_mail_user_submit(), locale_user(), and system_send_email_action().

user_register_access ( )

Definition at line 854 of file user.module.

References user_is_anonymous(), and variable_get().

user_register_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit handler for the user registration form.

This function is shared by the installation form and the normal registration form, which is why it can't be in the user.pages.inc file.

Definition at line 2254 of file user.module.

References $base_url, $name, $op, _user_mail_notify(), drupal_set_message(), l(), name, t(), url(), user_access(), user_authenticate(), user_password(), user_save(), variable_get(), and watchdog().

user_register_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 2431 of file user.module.

References user_module_invoke().

user_roles | ( | $ | membersonly = FALSE,
 |  | $ | permission = NULL
 | ) |  |

Retrieve an array of roles matching specified conditions.

Parameters:
$membersonly | Set this to TRUE to exclude the 'anonymous' role.
$permission | A string containing a permission. If set, only roles containing that permission are returned.
Returns:
An associative array with the role id as the key and the role name as value.

Definition at line 1674 of file user.module.

References $result, db_fetch_object(), db_query(), name, and t().

Referenced by filter_admin_format_form(), filter_admin_format_form_submit(), filter_admin_overview(), theme_comment_post_forbidden(), theme_user_admin_new_role(), theme_user_admin_perm(), upload_admin_settings(), user_admin_account(), user_admin_perm(), user_edit_form(), user_filters(), and user_user_operations().

user_save | ( | $ | account,
 |  | $ | array = array(),
 |  | $ | category = 'account'
 | ) |  |

Save changes to a user account or add a new user.

Parameters:
$account | The $user object for the user to modify or add. If $user->uid is omitted, a new user will be added.
$array | (optional) An array of fields and values to save. For example, array('name' => 'My name'); Setting a field to NULL deletes it from the data column.
$category | (optional) The category for storing profile information in.
Returns:
A fully-loaded $user object upon successful save or FALSE if the save failed.

Definition at line 210 of file user.module.

References $op, $user, $value, _user_mail_notify(), db_last_insert_id(), db_query(), db_result(), sess_destroy_uid(), sess_regenerate(), user_access(), user_fields(), user_load(), user_module_invoke(), and user_set_authmaps().

Referenced by comment_controls_submit(), install_configure_form_submit(), openid_authentication(), system_admin_compact_page(), user_edit_submit(), user_external_login_register(), user_multiple_role_edit(), user_profile_form_submit(), user_register_submit(), user_user_operations_block(), and user_user_operations_unblock().

user_search | ( | $ | op = 'search',
 |  | $ | keys = NULL,
 |  | $ | skip_access_check = FALSE
 | ) |  |

Implementation of hook_search().

Definition at line 562 of file user.module.

References $op, $result, db_fetch_object(), name, pager_query(), t(), url(), and user_access().

user_set_authmaps | ( | $ | account,
 |  | $ | authmaps
 | ) |  |

Save mappings of which external authentication module(s) authenticated a user.

Maps external usernames to user ids in the users table.

Parameters:
$account | A user object.
$authmaps | An associative array with a compound key and the username as the value. The key is made up of 'authname_' plus the name of the external authentication module.
See also:
user_external_login_register()

Definition at line 1207 of file user.module.

References $value, db_affected_rows(), and db_query().

Referenced by user_save().

user_theme ( )

Implementation of hook_theme().

Definition at line 30 of file user.module.

user_user | ( | $ | type,
 |  | &$ | edit,
 |  | &$ | account,
 |  | $ | category = NULL
 | ) |  |

Implementation of hook_user().

Definition at line 604 of file user.module.

References $type, _user_edit_submit(), _user_edit_validate(), arg(), content, format_interval(), t(), theme(), and user_edit_form().

user_user_operations ( $ form_state = array() )

Implementation of hook_user_operations().

Definition at line 1711 of file user.module.

References $value, t(), user_access(), user_roles(), and watchdog().

user_user_operations_block ( $ accounts )

Callback function for admin mass blocking users.

Definition at line 1793 of file user.module.

References user_load(), and user_save().

user_user_operations_unblock ( $ accounts )

Callback function for admin mass unblocking users.

Definition at line 1780 of file user.module.

References user_load(), and user_save().

user_validate_mail ( $ mail )

Definition at line 400 of file user.module.

References t(), and valid_email_address().

Referenced by _user_edit_validate(), install_configure_form_validate(), and system_site_information_settings_validate().

user_validate_name ( $ name )

Verify the syntax of the given name.

Definition at line 378 of file user.module.

References $name, and t().

Referenced by _user_edit_validate(), and install_configure_form_validate().

user_validate_picture | ( | &$ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 407 of file user.module.

References file_copy(), file_delete(), file_save_upload(), form_set_error(), image_get_info(), t(), and variable_get().

user_view_access ( $ account )

Definition at line 858 of file user.module.

References user_access().

Generated on Tue Feb 12 15:30:49 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/user/user.pages.inc File Reference

modules » user

user.pages.inc File Reference

Detailed Description

User page callback file for the user module.

Definition in file user.pages.inc.

Go to the source code of this file.

Functions

  • template_preprocess_user_profile (&$variables)
    Process variables for user-profile.tpl.php.
  • template_preprocess_user_profile_category (&$variables)
    Process variables for user-profile-category.tpl.php.
  • template_preprocess_user_profile_item (&$variables)
    Process variables for user-profile-item.tpl.php.
  • user_autocomplete ($string= '')
    Menu callback; Retrieve a JSON object containing autocomplete suggestions for existing users.
  • user_confirm_delete (&$form_state, $account)
    Form builder; confirm form for user deletion.
  • user_confirm_delete_submit ($form, &$form_state)
    Submit function for the confirm form for user deletion.
  • user_edit ($account, $category= 'account')
    Form builder; Present the form to edit a given user or profile category.
  • user_edit_delete_submit ($form, &$form_state)
    Submit function for the 'Delete' button on the user edit form.
  • user_edit_submit ($form, &$form_state)
  • user_edit_validate ($form, &$form_state)
  • user_logout ()
    Menu callback; logs the current user out, and redirects to the home page.
  • user_page ()
    Access callback for path /user.
  • user_pass ()
    Form builder; Request a password reset.
  • user_pass_reset (&$form_state, $uid, $timestamp, $hashed_pass, $action=NULL)
    Menu callback; process one time login link and redirects to the user page on success.
  • user_pass_submit ($form, &$form_state)
  • user_pass_validate ($form, &$form_state)
  • user_profile_form ($form_state, $account, $category= 'account')
    Form builder; edit a user account or one of their profile categories.
  • user_profile_form_submit ($form, &$form_state)
    Submit function for the user account and profile editing form.
  • user_profile_form_validate ($form, &$form_state)
    Validation function for the user account and profile editing form.
  • user_view ($account)
    Menu callback; Displays a user or user profile page.

Function Documentation

template_preprocess_user_profile ( &$ variables )

Process variables for user-profile.tpl.php.

The $variables array contains the following arguments:

  • $account

See also:
user-picture.tpl.php

Definition at line 167 of file user.pages.inc.

References content, drupal_render(), and element_children().

template_preprocess_user_profile_category ( &$ variables )

Process variables for user-profile-category.tpl.php.

The $variables array contains the following arguments:

  • $element

See also:
user-profile-category.tpl.php

Definition at line 204 of file user.pages.inc.

References check_plain(), and drupal_attributes().

template_preprocess_user_profile_item ( &$ variables )

Process variables for user-profile-item.tpl.php.

The $variables array contains the following arguments:

  • $element

See also:
user-profile-item.tpl.php

Definition at line 187 of file user.pages.inc.

References drupal_attributes().

user_autocomplete ( $ string = '' )

Menu callback; Retrieve a JSON object containing autocomplete suggestions for existing users.

Definition at line 12 of file user.pages.inc.

References $result, $user, check_plain(), db_fetch_object(), db_query_range(), drupal_json(), and name.

user_confirm_delete_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit function for the confirm form for user deletion.

Definition at line 317 of file user.pages.inc.

References drupal_set_message(), name, t(), and user_delete().

user_edit_delete_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit function for the 'Delete' button on the user edit form.

Definition at line 287 of file user.pages.inc.

References drupal_get_destination().

user_edit_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 336 of file user.pages.inc.

References cache_clear_all(), drupal_set_message(), t(), user_module_invoke(), and user_save().

user_edit_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 326 of file user.pages.inc.

References form_set_error(), t(), user_access(), user_module_invoke(), and watchdog().

user_logout ( )

Menu callback; logs the current user out, and redirects to the home page.

Definition at line 131 of file user.pages.inc.

References $user, drupal_anonymous_user(), drupal_goto(), module_invoke_all(), name, and watchdog().

Referenced by _menu_site_is_offline().

user_page ( )

Access callback for path /user.

Displays user profile if user is logged in, or login form for anonymous users.

Definition at line 356 of file user.pages.inc.

References $user, drupal_get_form(), menu_execute_active_handler(), and menu_set_active_item().

user_pass_reset | ( | &$ | form_state,
 |  | $ | uid,
 |  | $ | timestamp,
 |  | $ | hashed_pass,
 |  | $ | action = NULL
 | ) |  |

Menu callback; process one time login link and redirects to the user page on success.

Definition at line 76 of file user.pages.inc.

References $user, drupal_access_denied(), drupal_goto(), drupal_set_message(), format_date(), name, t(), url(), user_authenticate_finalize(), user_load(), user_pass_rehash(), and watchdog().

user_pass_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 60 of file user.pages.inc.

References $language, _user_mail_notify(), drupal_set_message(), name, t(), and watchdog().

user_pass_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Definition at line 44 of file user.pages.inc.

References $name, form_set_error(), form_set_value(), t(), and user_load().

user_profile_form_submit | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Submit function for the user account and profile editing form.

Definition at line 270 of file user.pages.inc.

References cache_clear_all(), drupal_set_message(), t(), user_module_invoke(), and user_save().

user_profile_form_validate | ( | $ | form,
 |  | &$ | form_state
 | ) |  |

Validation function for the user account and profile editing form.

Definition at line 257 of file user.pages.inc.

References form_set_error(), t(), user_access(), user_module_invoke(), and watchdog().

user_view ( $ account )

Menu callback; Displays a user or user profile page.

Definition at line 149 of file user.pages.inc.

References check_plain(), drupal_set_title(), name, theme(), and user_build_content().

Generated on Tue Feb 12 15:30:49 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: profiles/default/default.profile File Reference

profiles » default

default.profile File Reference

Go to the source code of this file.

Functions

  • default_form_alter (&$form, $form_state, $form_id)
    Implementation of hook_form_alter().
  • default_profile_details ()
    Return a description of the profile for the initial installation screen.
  • default_profile_modules ()
    Return an array of the modules to be enabled when this profile is installed.
  • default_profile_task_list ()
    Return a list of tasks that this profile supports.
  • default_profile_tasks (&$task, $url)
    Perform any final installation tasks for this profile.

Function Documentation

default_form_alter | ( | &$ | form,
 |  | $ | form_state,
 |  | $ | form_id
 | ) |  |

Implementation of hook_form_alter().

Allows the profile to alter the site-configuration form. This is called through custom invocation, so $form_state is not populated.

Definition at line 146 of file default.profile.

default_profile_details ( )

Return a description of the profile for the initial installation screen.

Returns:
An array with keys 'name' and 'description' describing this profile, and optional 'language' to override the language selection for language-specific profiles.

Definition at line 22 of file default.profile.

default_profile_modules ( )

Return an array of the modules to be enabled when this profile is installed.

Returns:
An array of modules to enable.

Definition at line 10 of file default.profile.

default_profile_task_list ( )

Return a list of tasks that this profile supports.

Returns:
A keyed array of tasks the profile will perform during the final stage. The keys of the array will be used internally, while the values will be displayed to the user in the installer task list.

Definition at line 38 of file default.profile.

default_profile_tasks | ( | &$ | task,
 |  | $ | url
 | ) |  |

Perform any final installation tasks for this profile.

The installer goes through the profile-select -> locale-select -> requirements -> database -> profile-install-batch -> locale-initial-batch -> configure -> locale-remaining-batch -> finished -> done tasks, in this order, if you don't implement this function in your profile.

If this function is implemented, you can have any number of custom tasks to perform after 'configure', implementing a state machine here to walk the user through those tasks. First time, this function gets called with $task set to 'profile', and you can advance to further tasks by setting $task to your tasks' identifiers, used as array keys in the hook_profile_task_list() above. You must avoid the reserved tasks listed in install_reserved_tasks(). If you implement your custom tasks, this function will get called in every HTTP request (for form processing, printing your information screens and so on) until you advance to the 'profile-finished' task, with which you hand control back to the installer. Each custom page you return needs to provide a way to continue, such as a form submission or a link. You should also set custom page titles.

You should define the list of custom tasks you implement by returning an array of them in hook_profile_task_list(), as these show up in the list of tasks on the installer user interface.

Remember that the user will be able to reload the pages multiple times, so you might want to use variable_set() and variable_get() to remember your data and control further processing, if $task is insufficient. Should a profile want to display a form here, it can; the form should set 'redirect' to FALSE, and rely on an action in the submit handler, such as variable_set(), to detect submission and proceed to further tasks. See the configuration form handling code in install_tasks() for an example.

Important: Any temporary variables should be removed using variable_del() before advancing to the 'profile-finished' phase.

Parameters:
$task | The current $task of the install system. When hook_profile_tasks() is first called, this is 'profile'.
$url | Complete URL to be used for a link or form action on a custom page, if providing any, to allow the user to proceed with the installation.
Returns:
An optional HTML string to display to the user. Only used if you modify the $task, otherwise discarded.

Definition at line 92 of file default.profile.

References $type, _node_type_set_defaults(), menu_rebuild(), node_type_save(), st(), variable_get(), and variable_set().

Generated on Tue Feb 12 15:30:49 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/bluemarine/block.tpl.php File Reference

themes » bluemarine

block.tpl.php File Reference

Go to the source code of this file.

Variables

  • print $block content
  • print $block delta
  • print $block module
  • print $block subject

Variable Documentation

print $block content

Definition at line 6 of file block.tpl.php.

Referenced by _node_index_node(), block_list(), book_node_export(), node_search(), node_view(), poll_block(), profile_view_profile(), template_preprocess_user_profile(), theme_admin_block(), and user_user().

print $block delta

Definition at line 4 of file block.tpl.php.

print block module

Definition at line 4 of file block.tpl.php.

Referenced by _filter_tips(), _node_types_build(), block_list(), block_user(), check_markup(), filter_admin_configure(), filter_admin_format_form(), filter_list_format(), node_get_types(), node_perm(), node_type_form(), node_type_save(), and taxonomy_term_path().

print $block subject

Definition at line 5 of file block.tpl.php.

Referenced by _comment_delete_thread(), block_list(), chameleon_comment(), comment_admin_overview(), comment_admin_overview_submit(), comment_confirm_delete(), comment_nodeapi(), comment_unpublish_by_keyword_action(), template_preprocess_comment(), template_preprocess_comment_folded(), and theme_comment_block().

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/bluemarine/box.tpl.php File Reference

themes » bluemarine

box.tpl.php File Reference

Go to the source code of this file.

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/bluemarine/comment.tpl.php File Reference

themes » bluemarine

comment.tpl.php File Reference

Go to the source code of this file.

Variables

  • print $status

Variable Documentation

print $status

Definition at line 4 of file comment.tpl.php.

Referenced by _block_compare(), _locale_import_po(), _locale_rebuild_js(), _update_cron_notify(), _update_requirement_check(), chameleon_comment(), comment_admin_overview(), comment_form(), file_set_status(), forum_form_submit(), node_configure(), node_type_form_submit(), page_get_cache(), search_admin_settings(), session_save_session(), system_modules(), system_modules_confirm_form(), system_themes_form(), taxonomy_node_save(), taxonomy_save_term(), taxonomy_save_vocabulary(), taxonomy_vocabulary_confirm_delete_submit(), theme_system_modules(), theme_system_themes_form(), translation_node_overview(), update_help(), user_admin_account(), and user_admin_perm().

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/bluemarine/node.tpl.php File Reference

themes » bluemarine

node.tpl.php File Reference

Go to the source code of this file.

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/bluemarine/page.tpl.php File Reference

themes » bluemarine

page.tpl.php File Reference

Go to the source code of this file.

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/chameleon/chameleon.theme File Reference

themes » chameleon

chameleon.theme File Reference

Detailed Description

A slim, CSS-driven theme which does not depend on a template engine like phptemplate.

Definition in file chameleon.theme.

Go to the source code of this file.

Functions

  • chameleon_comment ($comment, $node, $links=array())
  • chameleon_help ()
  • chameleon_node ($node, $teaser=0, $page=0)
  • chameleon_page ($content, $show_blocks=TRUE, $show_messages=TRUE)
  • chameleon_theme ($existing, $type, $theme, $path)
    Implementation of hook_theme.

Function Documentation

chameleon_comment | ( | $ | comment,
 |  | $ | node,
 |  | $ | links = array()
 | ) |  |

Definition at line 156 of file chameleon.theme.

References $links, $output, $status, format_date(), l(), subject, t(), and theme().

chameleon_help ( )

Definition at line 177 of file chameleon.theme.

References menu_get_active_help().

chameleon_node | ( | $ | node,
 |  | $ | teaser = 0,
 |  | $ | page = 0
 | ) |  |

Definition at line 115 of file chameleon.theme.

References $links, $output, check_plain(), format_date(), l(), module_exists(), t(), taxonomy_link(), theme(), and theme_get_setting().

chameleon_page | ( | $ | content,
 |  | $ | show_blocks = TRUE,
 |  | $ | show_messages = TRUE
 | ) |  |

Definition at line 16 of file chameleon.theme.

References $content, $language, $logo, $output, $title, check_url(), drupal_get_breadcrumb(), drupal_get_css(), drupal_get_feeds(), drupal_get_html_head(), drupal_get_js(), drupal_get_title(), drupal_set_html_head(), l(), menu_primary_links(), menu_secondary_links(), t(), theme(), theme_blocks(), theme_closure(), theme_get_setting(), url(), and variable_get().

chameleon_theme | ( | $ | existing,
 |  | $ | type,
 |  | $ | theme,
 |  | $ | path
 | ) |  |

Implementation of hook_theme.

Auto-discover theme functions.

Definition at line 12 of file chameleon.theme.

References $theme, and drupal_find_theme_functions().

Generated on Tue Feb 12 15:30:49 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/engines/phptemplate/phptemplate.engine File Reference

themes » engines » phptemplate

phptemplate.engine File Reference

Detailed Description

Handles integration of templates written in pure php with the Drupal theme system.

Definition in file phptemplate.engine.

Go to the source code of this file.

Functions

  • phptemplate_init ($template)
  • phptemplate_theme ($existing, $type, $theme, $path)
    Implementation of hook_theme to tell Drupal what templates the engine and the current theme use.

Function Documentation

phptemplate_init ( $ template )

Definition at line 9 of file phptemplate.engine.

phptemplate_theme | ( | $ | existing,
 |  | $ | type,
 |  | $ | theme,
 |  | $ | path
 | ) |  |

Implementation of hook_theme to tell Drupal what templates the engine and the current theme use.

The $existing argument will contain hooks pre-defined by Drupal so that we can use that information if we need to.

Definition at line 22 of file phptemplate.engine.

References $theme, drupal_find_theme_functions(), and drupal_find_theme_templates().

Generated on Tue Feb 12 15:30:49 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/block.tpl.php File Reference

themes » garland

block.tpl.php File Reference

Go to the source code of this file.

Variables

  • print $block module $block delta

Variable Documentation

print $block module $block delta

Definition at line 4 of file block.tpl.php.

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/comment.tpl.php File Reference

themes » garland

comment.tpl.php File Reference

Go to the source code of this file.

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/maintenance-page.tpl.php File Reference

themes » garland

maintenance-page.tpl.php File Reference

Go to the source code of this file.

Variables

  • print $header
  • $site_fields = array()
  • $site_title = implode(' ', $site_fields)

Variable Documentation

print $header

Definition at line 29 of file maintenance-page.tpl.php.

$site_fields = array()

Definition at line 38 of file maintenance-page.tpl.php.

$site_title = implode(' ', $site_fields)

Definition at line 45 of file maintenance-page.tpl.php.

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/node.tpl.php File Reference

themes » garland

node.tpl.php File Reference

Go to the source code of this file.

Variables

  • print $node nid

Variable Documentation

print $node nid

Definition at line 4 of file node.tpl.php.

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/page.tpl.php File Reference

themes » garland

page.tpl.php File Reference

Go to the source code of this file.

Variables

  • print $header
  • $site_fields = array()
  • $site_title = implode(' ', $site_fields)

Variable Documentation

print $header

Definition at line 18 of file page.tpl.php.

$site_fields = array()

Definition at line 27 of file page.tpl.php.

$site_title = implode(' ', $site_fields)

Definition at line 34 of file page.tpl.php.

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/template.php File Reference

themes » garland

template.php File Reference

Go to the source code of this file.

Functions

  • phptemplate_body_class ($left, $right)
    Sets the body-tag class attribute.
  • phptemplate_breadcrumb ($breadcrumb)
    Return a themed breadcrumb trail.
  • phptemplate_comment_submitted ($comment)
  • phptemplate_comment_wrapper ($content, $node)
    Allow themable wrapping of all comments.
  • phptemplate_get_ie_styles ()
    Generates IE CSS links for LTR and RTL languages.
  • phptemplate_menu_local_tasks ()
    Returns the rendered local tasks.
  • phptemplate_node_submitted ($node)
  • phptemplate_preprocess_page (&$vars)
    Override or insert PHPTemplate variables into the templates.

Function Documentation

phptemplate_body_class | ( | $ | left,
 |  | $ | right
 | ) |  |

Sets the body-tag class attribute.

Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.

Definition at line 9 of file template.php.

phptemplate_breadcrumb ( $ breadcrumb )

Return a themed breadcrumb trail.

Parameters:
$breadcrumb An array containing the breadcrumb links.
Returns:
a string containing the breadcrumb output.

Definition at line 34 of file template.php.

phptemplate_comment_submitted ( $ comment )

Definition at line 74 of file template.php.

References format_date(), t(), and theme().

phptemplate_comment_wrapper | ( | $ | content,
 |  | $ | node
 | ) |  |

Allow themable wrapping of all comments.

Definition at line 43 of file template.php.

References $content, and t().

phptemplate_get_ie_styles ( )

Generates IE CSS links for LTR and RTL languages.

Definition at line 93 of file template.php.

References $language, base_path(), and path_to_theme().

phptemplate_node_submitted ( $ node )

Definition at line 82 of file template.php.

References format_date(), t(), and theme().

phptemplate_preprocess_page ( &$ vars )

Override or insert PHPTemplate variables into the templates.

Definition at line 55 of file template.php.

References _color_page_alter(), menu_secondary_local_tasks(), and module_exists().

Generated on Tue Feb 12 15:30:49 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/color/color.inc File Reference

themes » garland » color

color.inc File Reference

Go to the source code of this file.

Generated on Tue Feb 12 15:30:49 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/minnelli/color/color.inc File Reference

themes » garland » minnelli » color

color.inc File Reference

Go to the source code of this file.

Generated on Tue Feb 12 15:30:49 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/pushbutton/block.tpl.php File Reference

themes » pushbutton

block.tpl.php File Reference

Go to the source code of this file.

Variables

  • print block block $block
    module print block $block
    module $block delta

Variable Documentation

print block block $block module print block $block module $block delta

Definition at line 4 of file block.tpl.php.

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/pushbutton/box.tpl.php File Reference

themes » pushbutton

box.tpl.php File Reference

Go to the source code of this file.

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/pushbutton/comment.tpl.php File Reference

themes » pushbutton

comment.tpl.php File Reference

Go to the source code of this file.

Variables

  • print $status

Variable Documentation

print $status

Definition at line 4 of file comment.tpl.php.

Generated on Tue Feb 12 15:30:45 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/pushbutton/node.tpl.php File Reference

themes » pushbutton

node.tpl.php File Reference

Go to the source code of this file.

Generated on Tue Feb 12 15:30:46 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/pushbutton/page.tpl.php File Reference

themes » pushbutton

page.tpl.php File Reference

Go to the source code of this file.

Generated on Tue Feb 12 15:30:47 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- $ -

  • $active_db : globals.php
  • $attributes : user-profile-item.tpl.php
  • $base_path : globals.php
  • $base_root : globals.php
  • $base_theme_info : globals.php
  • $base_url : globals.php , book-export-html.tpl.php
  • $body_classes : maintenance-page.tpl.php , page.tpl.php
  • $channel : globals.php
  • $children : book-node-export-html.tpl.php
  • $conf : globals.php
  • $content : profile-wrapper.tpl.php , aggregator-wrapper.tpl.php , book-node-export-html.tpl.php , comment-wrapper.tpl.php
  • $cookie_domain : globals.php
  • $custom_theme : globals.php
  • $db_prefix : globals.php
  • $db_type : globals.php
  • $db_url : globals.php
  • $depth : book-node-export-html.tpl.php
  • $element : globals.php
  • $exp : openid.inc
  • $feed_age : aggregator-summary-item.tpl.php
  • $feed_title : aggregator-item.tpl.php , aggregator-summary-item.tpl.php
  • $feed_url : aggregator-item.tpl.php , aggregator-summary-item.tpl.php
  • $forum_id : forum-list.tpl.php
  • $forum_topic_list_header : globals.php
  • $forums : forums.tpl.php
  • $head : book-export-html.tpl.php , maintenance-page.tpl.php , page.tpl.php
  • $head_title : maintenance-page.tpl.php , page.tpl.php
  • $header : forum-topic-list.tpl.php , maintenance-page.tpl.php , page.tpl.php
  • $id : globals.php
  • $image : globals.php
  • $install_locale : globals.php
  • $installed_profile : globals.php
  • $item : globals.php
  • $items : globals.php
  • $language : globals.php
  • $last_checked : aggregator-feed-source.tpl.php
  • $last_result : globals.php
  • $links : poll-results-block.tpl.php
  • $logo : maintenance-page.tpl.php , page.tpl.php
  • $menu_admin : globals.php
  • $messages : update.php
  • $module_list : update.php
  • $multibyte : globals.php
  • $name : profile-listing.tpl.php
  • $new : comment-folded.tpl.php
  • $nid : globals.php
  • $op : update.php
  • $output : update.php
  • $pager : search-results.tpl.php , aggregator-wrapper.tpl.php
  • $pager_page_array : globals.php
  • $pager_total : globals.php
  • $pager_total_items : globals.php
  • $percentage : poll-bar-block.tpl.php , poll-bar.tpl.php
  • $picture : profile-block.tpl.php , user-picture.tpl.php , profile-listing.tpl.php
  • $profile : globals.php
  • $queries : globals.php
  • $recent_activity : globals.php
  • $result : openid.inc
  • $results : poll-results.tpl.php
  • $return : index.php
  • $row : block-admin-display-form.tpl.php
  • $scripts : maintenance-page.tpl.php , page.tpl.php
  • $search_form : search-block-form.tpl.php , search-theme-form.tpl.php
  • $search_results : search-results.tpl.php
  • $site_fields : maintenance-page.tpl.php , page.tpl.php
  • $site_name : maintenance-page.tpl.php , page.tpl.php
  • $site_title : maintenance-page.tpl.php , page.tpl.php
  • $source_description : aggregator-feed-source.tpl.php
  • $source_icon : aggregator-feed-source.tpl.php
  • $source_image : aggregator-feed-source.tpl.php
  • $source_url : aggregator-feed-source.tpl.php , aggregator-summary-items.tpl.php
  • $square : openid.inc
  • $status : comment.tpl.php
  • $styles : maintenance-page.tpl.php , page.tpl.php
  • $summary_list : aggregator-summary-items.tpl.php
  • $tag : globals.php
  • $theme : globals.php
  • $theme_engine : globals.php
  • $theme_info : globals.php
  • $theme_key : globals.php
  • $theme_path : globals.php
  • $timers : globals.php
  • $title : book-export-html.tpl.php , search-result.tpl.php , user-profile-item.tpl.php , poll-bar.tpl.php , book-node-export-html.tpl.php , poll-bar-block.tpl.php , aggregator-summary-items.tpl.php
  • $topic_id : forum-topic-list.tpl.php
  • $topics : forums.tpl.php
  • $type : search-results.tpl.php
  • $update_free_access : globals.php
  • $update_mode : globals.php
  • $url : search-result.tpl.php
  • $user : globals.php
  • $user_profile : user-profile.tpl.php
  • $value : user-profile-item.tpl.php
  • $xrds_current_service : xrds.inc , globals.php
  • $xrds_open_elements : globals.php , xrds.inc
  • $xrds_services : globals.php , xrds.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Directory Hierarchy

Directories

This directory hierarchy is sorted roughly, but not completely, alphabetically:
  • docs
    • examples
    • hooks
  • includes
  • modules
    • aggregator
    • block
    • blog
    • blogapi
    • book
    • color
    • comment
    • contact
    • dblog
    • filter
    • forum
    • help
    • locale
    • menu
    • node
    • openid
    • path
    • php
    • ping
    • poll
    • profile
    • search
    • statistics
    • syslog
    • system
    • taxonomy
    • throttle
    • tracker
    • translation
    • trigger
    • update
    • upload
    • user
  • profiles
    • default
  • themes
    • bluemarine
    • chameleon
    • engines
      • phptemplate
    • garland
      • color
      • minnelli
        • color
    • pushbutton
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/ Directory Reference

docs

docs Directory Reference

Directories

  • directory examples
  • directory hooks

Files

  • file example.profile [code]
  • file globals.php [code]
    These are the global variables that Drupal uses.

  • file index.php [code]
Generated on Tue Feb 12 15:30:55 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/ Directory Reference

docs » examples

examples Directory Reference

Files

  • file batch_example.install [code]
  • file batch_example.module [code]
    This is an example outlining how a module can define batches.

  • file block_example.module [code]
    This is an example outlining how a module can define blocks to be displayed on each page.

  • file example_element.module [code]
    This is an example demonstrating how a module can define custom form elements.

  • file fileupload.module [code]
    This is an example to demonstrate how to make a Drupal node support file uploads.

  • file filter_example.module [code]
    This is an example outlining how a module can be used to define a filter to be run on user-submitted content before it is output to the browser.

  • file multipage_form_example.module [code]
  • file node_access_example.install [code]
  • file node_access_example.module [code]
    This is an example illustrating how to restrict access to nodes based on some criterion associated with the user.

  • file node_example.install [code]
  • file node_example.module [code]
    This is an example outlining how a module can be used to define a new node type.

  • file nodeapi_example.install [code]
  • file nodeapi_example.module [code]
    This is an example outlining how a module can be used to extend existing content types.

  • file page_example.module [code]
    This is an example outlining how a module can be used to display a custom page at a given URL.

  • file xmlrpc_example.module [code]
    This is an example of how to implement XML-RPC callbacks by implementing a validation suite.

Generated on Tue Feb 12 15:30:55 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/hooks/ Directory Reference

docs » hooks

hooks Directory Reference

Files

  • file core.php [code]
    These are the hooks that are invoked by the Drupal core.

  • file install.php [code]
    Documentation for the installation and update system.

  • file node.php [code]
    These hooks are defined by node modules, modules that define a new kind of node.

Generated on Tue Feb 12 15:30:56 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/ Directory Reference

includes

includes Directory Reference

Files

  • file actions.inc [code]
    This is the actions engine for executing stored actions.

  • file batch.inc [code]
    Batch processing API for processes to run in multiple HTTP requests.

  • file bootstrap.inc [code]
    Functions that need to be loaded on every Drupal request.

  • file cache-install.inc [code]
  • file cache.inc [code]
  • file common.inc [code]
    Common functions that many Drupal modules will need to reference.

  • file database.inc [code]
    Wrapper for database interface code.

  • file database.mysql-common.inc [code]
    Functions shared between mysql and mysqli database engines.

  • file database.mysql.inc [code]
    Database interface code for MySQL database servers.

  • file database.mysqli.inc [code]
    Database interface code for MySQL database servers using the mysqli client libraries.

  • file database.pgsql.inc [code]
    Database interface code for PostgreSQL database servers.

  • file file.inc [code]
    API for handling file uploads and server file management.

  • file form.inc [code]
  • file image.gd.inc [code]
    GD2 toolkit for image manipulation within Drupal.

  • file image.inc [code]
    API for manipulating images.

  • file install.inc [code]
  • file install.mysql.inc [code]
  • file install.mysqli.inc [code]
  • file install.pgsql.inc [code]
  • file language.inc [code]
    Multiple language handling functionality.

  • file locale.inc [code]
    Administration functions for locale.module.

  • file mail.inc [code]
  • file menu.inc [code]
    API for the Drupal menu system.

  • file module.inc [code]
    API for loading and interacting with Drupal modules.

  • file pager.inc [code]
    Functions to aid in presenting database results as a set of pages.

  • file path.inc [code]
    Functions to handle paths in Drupal, including path aliasing.

  • file session.inc [code]
    User session handling functions.

  • file tablesort.inc [code]
    Functions to aid in the creation of sortable tables.

  • file theme.inc [code]
    The theme system, which controls the output of Drupal.

  • file theme.maintenance.inc [code]
    Theming for maintenance pages.

  • file unicode.inc [code]
  • file xmlrpc.inc [code]
    Drupal XML-RPC library.

  • file xmlrpcs.inc [code]
Generated on Tue Feb 12 15:30:57 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/ Directory Reference

modules

modules Directory Reference

Directories

  • directory aggregator
  • directory block
  • directory blog
  • directory blogapi
  • directory book
  • directory color
  • directory comment
  • directory contact
  • directory dblog
  • directory filter
  • directory forum
  • directory help
  • directory locale
  • directory menu
  • directory node
  • directory openid
  • directory path
  • directory php
  • directory ping
  • directory poll
  • directory profile
  • directory search
  • directory statistics
  • directory syslog
  • directory system
  • directory taxonomy
  • directory throttle
  • directory tracker
  • directory translation
  • directory trigger
  • directory update
  • directory upload
  • directory user
Generated on Tue Feb 12 15:30:57 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/ Directory Reference

modules » aggregator

aggregator Directory Reference

Files

  • file aggregator-feed-source.tpl.php [code]
    Default theme implementation to present the source of the feed.

  • file aggregator-item.tpl.php [code]
    Default theme implementation to format an individual feed item for display on the aggregator page.

  • file aggregator-summary-item.tpl.php [code]
    Default theme implementation to present a linked feed item for summaries.

  • file aggregator-summary-items.tpl.php [code]
    Default theme implementation to present feeds as list items.

  • file aggregator-wrapper.tpl.php [code]
  • file aggregator.admin.inc [code]
    Admin page callbacks for the aggregator module.

  • file aggregator.install [code]
  • file aggregator.module [code]
    Used to aggregate syndicated content (RSS, RDF, and Atom).

  • file aggregator.pages.inc [code]
    User page callbacks for the aggregator module.

Generated on Tue Feb 12 15:30:52 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/block/ Directory Reference

modules » block

block Directory Reference

Files

  • file block-admin-display-form.tpl.php [code]
    Default theme implementation to configure blocks.

  • file block.admin.inc [code]
    Admin page callbacks for the block module.

  • file block.install [code]
  • file block.module [code]
    Controls the boxes that are displayed around the main content.

Generated on Tue Feb 12 15:30:52 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/blog/ Directory Reference

modules » blog

blog Directory Reference

Files

  • file blog.module [code]
    Enables keeping an easily and regularly updated web page or a blog.

  • file blog.pages.inc [code]
    Page callback file for the blog module.

Generated on Tue Feb 12 15:30:52 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/blogapi/ Directory Reference

modules » blogapi

blogapi Directory Reference

Files

  • file blogapi.install [code]
  • file blogapi.module [code]
    Enable users to post using applications that support XML-RPC blog APIs.

Generated on Tue Feb 12 15:30:53 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/book/ Directory Reference

modules » book

book Directory Reference

Files

  • file book-all-books-block.tpl.php [code]
    Default theme implementation for rendering book outlines within a block.

  • file book-export-html.tpl.php [code]
    Default theme implementation for printed version of book outline.

  • file book-navigation.tpl.php [code]
    Default theme implementation to navigate books.

  • file book-node-export-html.tpl.php [code]
    Default theme implementation for rendering a single node in a printer friendly outline.

  • file book.admin.inc [code]
    Admin page callbacks for the book module.

  • file book.install [code]
  • file book.module [code]
    Allows users to structure the pages of a site in a hierarchy or outline.

  • file book.pages.inc [code]
    User page callbacks for the book module.

Generated on Tue Feb 12 15:30:53 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/color/ Directory Reference

modules » color

color Directory Reference

Files

  • file color.install [code]
  • file color.module [code]
Generated on Tue Feb 12 15:30:54 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/comment/ Directory Reference

modules » comment

comment Directory Reference

Files

  • file comment-folded.tpl.php [code]
    Default theme implementation for folded comments.

  • file comment-wrapper.tpl.php [code]
    Default theme implementation to wrap aggregator content.

  • file comment.admin.inc [code]
    Admin page callbacks for the comment module.

  • file comment.install [code]
  • file comment.module [code]
    Enables users to comment on published content.

  • file comment.pages.inc [code]
    User page callbacks for the comment module.

  • file comment.tpl.php [code]
Generated on Tue Feb 12 15:30:54 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/contact/ Directory Reference

modules » contact

contact Directory Reference

Files

  • file contact.admin.inc [code]
    Admin page callbacks for the contact module.

  • file contact.install [code]
  • file contact.module [code]
    Enables the use of personal and site-wide contact forms.

  • file contact.pages.inc [code]
    User page callbacks for the contact module.

Generated on Tue Feb 12 15:30:54 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/dblog/ Directory Reference

modules » dblog

dblog Directory Reference

Files

  • file dblog.admin.inc [code]
    Administrative page callbacks for the dblog module.

  • file dblog.install [code]
  • file dblog.module [code]
    System monitoring and logging for administrators.

Generated on Tue Feb 12 15:30:54 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/filter/ Directory Reference

modules » filter

filter Directory Reference

Files

  • file filter.admin.inc [code]
    Admin page callbacks for the filter module.

  • file filter.install [code]
  • file filter.module [code]
    Framework for handling filtering of content.

  • file filter.pages.inc [code]
    User page callbacks for the filter module.

Generated on Tue Feb 12 15:30:55 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/ Directory Reference

modules » forum

forum Directory Reference

Files

  • file forum-icon.tpl.php [code]
    Display an appropriate icon for a forum post.

  • file forum-list.tpl.php [code]
    Default theme implementation to display a list of forums and containers.

  • file forum-submitted.tpl.php [code]
    Default theme implementation to format a simple string indicated when and by whom a topic was submitted.

  • file forum-topic-list.tpl.php [code]
    Theme implementation to display a list of forum topics.

  • file forum-topic-navigation.tpl.php [code]
    Default theme implementation to display the topic navigation string at the bottom of all forum topics.

  • file forum.admin.inc [code]
    Administrative page callbacks for the forum module.

  • file forum.install [code]
  • file forum.module [code]
    Enable threaded discussions about general topics.

  • file forum.pages.inc [code]
    User page callbacks for the forum module.

  • file forums.tpl.php [code]
    Default theme implementation to display a forum which may contain forum containers as well as forum topics.

Generated on Tue Feb 12 15:30:55 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/help/ Directory Reference

modules » help

help Directory Reference

Files

  • file help.admin.inc [code]
    Admin page callbacks for the help module.

  • file help.module [code]
    Manages displaying online help.

Generated on Tue Feb 12 15:30:56 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/locale/ Directory Reference

modules » locale

locale Directory Reference

Files

  • file locale.install [code]
  • file locale.module [code]
    Add language handling functionality and enables the translation of the user interface to languages other than English.

Generated on Tue Feb 12 15:30:57 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/menu/ Directory Reference

modules » menu

menu Directory Reference

Files

  • file menu.admin.inc [code]
    Administrative page callbaks for menu module.

  • file menu.install [code]
  • file menu.module [code]
    Allows administrators to customize the site navigation menu.

Generated on Tue Feb 12 15:30:57 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/node/ Directory Reference

modules » node

node Directory Reference

Files

  • file content_types.inc [code]
    Content type editing UI.

  • file node.admin.inc [code]
    Content administration and module settings UI.

  • file node.install [code]
  • file node.module [code]
    The core that allows content to be submitted to the site.

  • file node.pages.inc [code]
    Page callbacks for adding, editing, deleting, and revisions management for content.

  • file node.tpl.php [code]
Generated on Tue Feb 12 15:30:58 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/openid/ Directory Reference

modules » openid

openid Directory Reference

Files

  • file openid.inc [code]
    OpenID utility functions.

  • file openid.install [code]
  • file openid.module [code]
    Implement OpenID Relying Party support for Drupal.

  • file openid.pages.inc [code]
    User page callbacks for the openid module.

  • file xrds.inc [code]
Generated on Tue Feb 12 15:30:58 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/path/ Directory Reference

modules » path

path Directory Reference

Files

  • file path.admin.inc [code]
    Administrative page callbacks for the path module.

  • file path.module [code]
    Enables users to rename URLs.

Generated on Tue Feb 12 15:30:58 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/php/ Directory Reference

modules » php

php Directory Reference

Files

  • file php.install [code]
  • file php.module [code]
    Additional filter for PHP input.

Generated on Tue Feb 12 15:30:58 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/ping/ Directory Reference

modules » ping

ping Directory Reference

Files

  • file ping.module [code]
    Alerts other sites that your site has been updated.

Generated on Tue Feb 12 15:30:59 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/poll/ Directory Reference

modules » poll

poll Directory Reference

Files

  • file poll-bar-block.tpl.php [code]
    Display the bar for a single choice in a poll.

  • file poll-bar.tpl.php [code]
    Display the bar for a single choice in a poll.

  • file poll-results-block.tpl.php [code]
    Display the poll results in a block.

  • file poll-results.tpl.php [code]
  • file poll-vote.tpl.php [code]
    Voting form for a poll.

  • file poll.install [code]
  • file poll.module [code]
    Enables your site to capture votes on different topics in the form of multiple choice questions.

  • file poll.pages.inc [code]
    User page callbacks for the poll module.

Generated on Tue Feb 12 15:30:59 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/profile/ Directory Reference

modules » profile

profile Directory Reference

Files

  • file profile-block.tpl.php [code]
    Default theme implementation for displaying a users profile within a block.

  • file profile-listing.tpl.php [code]
    Default theme implementation for displaying a user and their profile data for member listing pages.

  • file profile-wrapper.tpl.php [code]
    Default theme implementation for wrapping member listings and their profiles.

  • file profile.admin.inc [code]
    Administrative page callbacks for the profile module.

  • file profile.install [code]
  • file profile.module [code]
    Support for configurable user profiles.

  • file profile.pages.inc [code]
    User page callbacks for the profile module.

Generated on Tue Feb 12 15:30:59 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/search/ Directory Reference

modules » search

search Directory Reference

Files

  • file search-block-form.tpl.php [code]
    Default theme implementation for displaying a search form within a block region.

  • file search-result.tpl.php [code]
    Default theme implementation for displaying a single search result.

  • file search-results.tpl.php [code]
    Default theme implementation for displaying search results.

  • file search-theme-form.tpl.php [code]
    Default theme implementation for displaying a search form directly into the theme layout.

  • file search.admin.inc [code]
    Admin page callbacks for the search module.

  • file search.install [code]
  • file search.module [code]
    Enables site-wide keyword searching.

  • file search.pages.inc [code]
    User page callbacks for the search module.

Generated on Tue Feb 12 15:31:00 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/statistics/ Directory Reference

modules » statistics

statistics Directory Reference

Files

  • file statistics.admin.inc [code]
    Admin page callbacks for the statistics module.

  • file statistics.install [code]
  • file statistics.module [code]
    Logs access statistics for your site.

  • file statistics.pages.inc [code]
    User page callbacks for the statistics module.

Generated on Tue Feb 12 15:31:00 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/syslog/ Directory Reference

modules » syslog

syslog Directory Reference

Files

  • file syslog.module [code]
    Redirects logging messages to syslog.

Generated on Tue Feb 12 15:31:00 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/system/ Directory Reference

modules » system

system Directory Reference

Files

  • file block.tpl.php [code]
  • file box.tpl.php [code]
  • file maintenance-page.tpl.php [code]
  • file page.tpl.php [code]
  • file system.admin.inc [code]
    Admin page callbacks for the system module.

  • file system.install [code]
  • file system.module [code]
    Configuration system that lets administrators modify the workings of the site.

Generated on Tue Feb 12 15:31:00 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/taxonomy/ Directory Reference

modules » taxonomy

taxonomy Directory Reference

Files

  • file taxonomy.admin.inc [code]
    Administrative page callbacks for the taxonomy module.

  • file taxonomy.install [code]
  • file taxonomy.module [code]
    Enables the organization of content into categories.

  • file taxonomy.pages.inc [code]
    Page callbacks for the taxonomy module.

Generated on Tue Feb 12 15:31:01 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/throttle/ Directory Reference

modules » throttle

throttle Directory Reference

Files

  • file throttle.admin.inc [code]
    Admin page callbacks for the throttle module.

  • file throttle.module [code]
    Allows configuration of congestion control auto-throttle mechanism.

Generated on Tue Feb 12 15:31:01 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/tracker/ Directory Reference

modules » tracker

tracker Directory Reference

Files

  • file tracker.module [code]
    Enables tracking of recent posts for users.

  • file tracker.pages.inc [code]
    User page callbacks for the tracker module.

Generated on Tue Feb 12 15:31:01 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/translation/ Directory Reference

modules » translation

translation Directory Reference

Files

  • file translation.module [code]
    Manages content translations.

  • file translation.pages.inc [code]
    User page callbacks for the translation module.

Generated on Tue Feb 12 15:31:01 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/trigger/ Directory Reference

modules » trigger

trigger Directory Reference

Files

  • file trigger.admin.inc [code]
    Admin page callbacks for the trigger module.

  • file trigger.install [code]
  • file trigger.module [code]
    Enables functions to be stored and executed at a later time when triggered by other modules or by one of Drupal's core API hooks.

Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/update/ Directory Reference

modules » update

update Directory Reference

Files

  • file update.compare.inc [code]
    Code required only when comparing available updates to existing data.

  • file update.fetch.inc [code]
    Code required only when fetching information about available updates.

  • file update.install [code]
  • file update.module [code]
    The "Update status" module checks for available updates of Drupal core and any installed contributed modules and themes.

  • file update.report.inc [code]
    Code required only when rendering the available updates report.

  • file update.settings.inc [code]
    Code required only for the update status settings form.

Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/upload/ Directory Reference

modules » upload

upload Directory Reference

Files

  • file upload.admin.inc [code]
  • file upload.install [code]
  • file upload.module [code]
    File-handling and attaching files to nodes.

Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/user/ Directory Reference

modules » user

user Directory Reference

Files

  • file user-picture.tpl.php [code]
    Default theme implementation to present an picture configured for the user's account.

  • file user-profile-category.tpl.php [code]
    Default theme implementation to present profile categories (groups of profile items).

  • file user-profile-item.tpl.php [code]
    Default theme implementation to present profile items (values from user account profile fields or modules).

  • file user-profile.tpl.php [code]
    Default theme implementation to present all user profile data.

  • file user.admin.inc [code]
    Admin page callback file for the user module.

  • file user.install [code]
  • file user.module [code]
    Enables the user registration and login system.

  • file user.pages.inc [code]
    User page callback file for the user module.

Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: profiles/ Directory Reference

profiles

profiles Directory Reference

Directories

  • directory default
Generated on Tue Feb 12 15:30:59 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: profiles/default/ Directory Reference

profiles » default

default Directory Reference

Files

  • file default.profile [code]
Generated on Tue Feb 12 15:30:55 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/ Directory Reference

themes

themes Directory Reference

Directories

  • directory bluemarine
  • directory chameleon
  • directory engines
  • directory garland
  • directory pushbutton
Generated on Tue Feb 12 15:31:01 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/bluemarine/ Directory Reference

themes » bluemarine

bluemarine Directory Reference

Files

  • file block.tpl.php [code]
  • file box.tpl.php [code]
  • file comment.tpl.php [code]
  • file node.tpl.php [code]
  • file page.tpl.php [code]
Generated on Tue Feb 12 15:30:53 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/chameleon/ Directory Reference

themes » chameleon

chameleon Directory Reference

Files

  • file chameleon.theme [code]
    A slim, CSS-driven theme which does not depend on a template engine like phptemplate.

Generated on Tue Feb 12 15:30:53 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/engines/ Directory Reference

themes » engines

engines Directory Reference

Directories

  • directory phptemplate
Generated on Tue Feb 12 15:30:55 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/engines/phptemplate/ Directory Reference

themes » engines » phptemplate

phptemplate Directory Reference

Files

  • file phptemplate.engine [code]
    Handles integration of templates written in pure php with the Drupal theme system.

Generated on Tue Feb 12 15:30:58 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/ Directory Reference

themes » garland

garland Directory Reference

Directories

  • directory color
  • directory minnelli

Files

  • file block.tpl.php [code]
  • file comment.tpl.php [code]
  • file maintenance-page.tpl.php [code]
  • file node.tpl.php [code]
  • file page.tpl.php [code]
  • file template.php [code]
Generated on Tue Feb 12 15:30:56 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/color/ Directory Reference

themes » garland » color

color Directory Reference

Files

  • file color.inc [code]
Generated on Tue Feb 12 15:30:54 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/minnelli/ Directory Reference

themes » garland » minnelli

minnelli Directory Reference

Directories

  • directory color
Generated on Tue Feb 12 15:30:57 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/minnelli/color/ Directory Reference

themes » garland » minnelli » color

color Directory Reference

Files

  • file color.inc [code]
Generated on Tue Feb 12 15:30:53 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/pushbutton/ Directory Reference

themes » pushbutton

pushbutton Directory Reference

Files

  • file block.tpl.php [code]
  • file box.tpl.php [code]
  • file comment.tpl.php [code]
  • file node.tpl.php [code]
  • file page.tpl.php [code]
Generated on Tue Feb 12 15:30:59 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class List

  • Alphabetical List
  • Class List
  • Class Members

Class List

Here are the classes, structs, unions and interfaces with brief descriptions:
update_xml_parser XML Parser object to read Drupal's release history info files
Generated on Tue Feb 12 15:30:51 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: update_xml_parser Class Reference

  • Alphabetical List
  • Class List
  • Class Members

update_xml_parser Class Reference

List of all members.

Detailed Description

XML Parser object to read Drupal's release history info files.

This uses PHP4's lame XML parsing, but it works.

Definition at line 142 of file update.fetch.inc.

Public Member Functions

  • data ($parser, $data)
  • end ($parser, $name)
  • parse ($data)
    Parse an array of XML data files.
  • start ($parser, $name, $attr)

Public Attributes

  • $current_object
  • $current_project
  • $current_release
  • $current_tag
  • $current_term
  • $projects = array()

Member Function Documentation

update_xml_parser::data | ( | $ | parser,
 |  | $ | data
 | ) |  |

Definition at line 220 of file update.fetch.inc.

References $tag.

update_xml_parser::end | ( | $ | parser,
 |  | $ | name
 | ) |  |

Definition at line 186 of file update.fetch.inc.

References $name.

update_xml_parser::parse ( $ data )

Parse an array of XML data files.

Definition at line 153 of file update.fetch.inc.

update_xml_parser::start | ( | $ | parser,
 |  | $ | name,
 |  | $ | attr
 | ) |  |

Definition at line 165 of file update.fetch.inc.

References $name.

Member Data Documentation

update_xml_parser::$current_object

Definition at line 148 of file update.fetch.inc.

update_xml_parser::$current_project

Definition at line 144 of file update.fetch.inc.

update_xml_parser::$current_release

Definition at line 145 of file update.fetch.inc.

update_xml_parser::$current_tag

Definition at line 147 of file update.fetch.inc.

update_xml_parser::$current_term

Definition at line 146 of file update.fetch.inc.

update_xml_parser::$projects = array()

Definition at line 143 of file update.fetch.inc.

The documentation for this class was generated from the following file:
  • modules/update/update.fetch.inc
Generated on Tue Feb 12 15:30:51 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • Alphabetical List
  • Class List
  • Class Members
  • All
  • Functions
  • Variables
Here is a list of all class members with links to the classes they belong to:

  • $current_object : update_xml_parser
  • $current_project : update_xml_parser
  • $current_release : update_xml_parser
  • $current_tag : update_xml_parser
  • $current_term : update_xml_parser
  • $projects : update_xml_parser
  • data() : update_xml_parser
  • end() : update_xml_parser
  • parse() : update_xml_parser
  • start() : update_xml_parser
Generated on Tue Feb 12 15:30:51 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Todo List

Todo List

Member aggregator_form_category_submit
Add delete confirmation dialog.

Member aggregator_form_feed_submit
Add delete confirmation dialog.

Member block_list
Now that the blocks table has a primary key, we should use that as the array key instead of module_delta.
Generated on Tue Feb 12 15:30:49 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/actions.inc Source File

includes

actions.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: actions.inc,v 1.8 2007/12/31 14:51:04 goba Exp $
00003
00042 function actions_do($action_ids, &$object, $context = NULL, $a1 = NULL, $a2 = NULL) {
00043   static $stack;
00044   $stack++;
00045   if ($stack > variable_get('actions_max_stack', 35)) {
00046     watchdog('actions', 'Stack overflow: too many calls to actions_do(). Aborting to prevent infinite recursion.', WATCHDOG_ERROR);
00047     return;
00048   }
00049   $actions = array();
00050   $available_actions = actions_list();
00051   $result = array();
00052   if (is_array($action_ids)) {
00053     $where = array();
00054     $where_values = array();
00055     foreach ($action_ids as $action_id) {
00056       if (is_numeric($action_id)) {
00057         $where[] = 'OR aid = %d';
00058         $where_values[] = $action_id;
00059       }
00060       elseif (isset($available_actions[$action_id])) {
00061         $actions[$action_id] = $available_actions[$action_id];
00062       }
00063     }
00064
00065     // When we have action instances we must go to the database to
00066     // retrieve instance data.
00067     if ($where) {
00068       $where_clause = implode(' ', $where);
00069       // Strip off leading 'OR '.
00070       $where_clause = '('. strstr($where_clause, " ") .')';
00071       $result_db = db_query('SELECT * FROM {actions} WHERE '. $where_clause, $where_values);
00072       while ($action = db_fetch_object($result_db)) {
00073         $actions[$action->aid] = $action->parameters ? unserialize($action->parameters) : array();
00074         $actions[$action->aid]['callback'] = $action->callback;
00075         $actions[$action->aid]['type'] = $action->type;
00076       }
00077     }
00078
00079     // Fire actions, in no particular order.
00080     foreach ($actions as $action_id => $params) {
00081       if (is_numeric($action_id)) { // Configurable actions need parameters.
00082         $function = $params['callback'];
00083         $context = array_merge($context, $params);
00084         $result[$action_id] = $function($object, $context, $a1, $a2);
00085       }
00086       // Singleton action; $action_id is the function name.
00087       else {
00088         $result[$action_id] = $action_id($object, $context, $a1, $a2);
00089       }
00090     }
00091   }
00092   // Optimized execution of single action.
00093   else {
00094     // If it's a configurable action, retrieve stored parameters.
00095     if (is_numeric($action_ids)) {
00096       $action = db_fetch_object(db_query("SELECT * FROM {actions} WHERE aid = %d", $action_ids));
00097       $function = $action->callback;
00098       $context = array_merge($context, unserialize($action->parameters));
00099       $result[$action_ids] = $function($object, $context, $a1, $a2);
00100     }
00101     // Singleton action; $action_ids is the function name.
00102     else {
00103       $result[$action_ids] = $action_ids($object, $context, $a1, $a2);
00104     }
00105   }
00106   return $result;
00107 }
00108
00109
00154 function actions_list($reset = FALSE) {
00155   static $actions;
00156   if (!isset($actions) || $reset) {
00157     $actions = module_invoke_all('action_info');
00158     drupal_alter('action_info', $actions);
00159   }
00160
00161   // See module_implements for explanations of this cast.
00162   return (array)$actions;
00163 }
00164
00178 function actions_get_all_actions() {
00179   $actions = array();
00180   $result = db_query("SELECT * FROM {actions}");
00181   while ($action = db_fetch_object($result)) {
00182     $actions[$action->aid] = array(
00183       'callback' => $action->callback,
00184       'description' => $action->description,
00185       'type' => $action->type,
00186       'configurable' => (bool) $action->parameters,
00187     );
00188   }
00189   return $actions;
00190 }
00191
00209 function actions_actions_map($actions) {
00210   $actions_map = array();
00211   foreach ($actions as $callback => $array) {
00212     $key = md5($callback);
00213     $actions_map[$key]['callback']     = isset($array['callback']) ? $array['callback'] : $callback;
00214     $actions_map[$key]['description']  = $array['description'];
00215     $actions_map[$key]['type']         = $array['type'];
00216     $actions_map[$key]['configurable'] = $array['configurable'];
00217   }
00218   return $actions_map;
00219 }
00220
00232 function actions_function_lookup($hash) {
00233   $actions_list = actions_list();
00234   foreach ($actions_list as $function => $array) {
00235     if (md5($function) == $hash) {
00236       return $function;
00237     }
00238   }
00239
00240   // Must be an instance; must check database.
00241   $aid = db_result(db_query("SELECT aid FROM {actions} WHERE MD5(aid) = '%s' AND parameters != ''", $hash));
00242   return $aid;
00243 }
00244
00253 function actions_synchronize($actions_in_code = array(), $delete_orphans = FALSE) {
00254   if (!$actions_in_code) {
00255     $actions_in_code = actions_list();
00256   }
00257   $actions_in_db = array();
00258   $result = db_query("SELECT * FROM {actions} WHERE parameters = ''");
00259   while ($action = db_fetch_object($result)) {
00260     $actions_in_db[$action->callback] = array('aid' => $action->aid, 'description' => $action->description);
00261   }
00262
00263   // Go through all the actions provided by modules.
00264   foreach ($actions_in_code as $callback => $array) {
00265     // Ignore configurable actions since their instances get put in
00266     // when the user adds the action.
00267     if (!$array['configurable']) {
00268       // If we already have an action ID for this action, no need to assign aid.
00269       if (array_key_exists($callback, $actions_in_db)) {
00270         unset($actions_in_db[$callback]);
00271       }
00272       else {
00273         // This is a new singleton that we don't have an aid for; assign one.
00274         db_query("INSERT INTO {actions} (aid, type, callback, parameters, description) VALUES ('%s', '%s', '%s', '%s', '%s')", $callback, $array['type'], $callback, '', $array['description']);
00275         watchdog('actions', "Action '%action' added.", array('%action' => filter_xss_admin($array['description'])));
00276       }
00277     }
00278   }
00279
00280   // Any actions that we have left in $actions_in_db are orphaned.
00281   if ($actions_in_db) {
00282     $orphaned = array();
00283     $placeholder = array();
00284
00285     foreach ($actions_in_db as $callback => $array) {
00286       $orphaned[] = $callback;
00287       $placeholder[] = "'%s'";
00288     }
00289
00290     $orphans = implode(', ', $orphaned);
00291
00292     if ($delete_orphans) {
00293       $placeholders = implode(', ', $placeholder);
00294       $results = db_query("SELECT a.aid, a.description FROM {actions} a WHERE callback IN ($placeholders)", $orphaned);
00295       while ($action = db_fetch_object($results)) {
00296         actions_delete($action->aid);
00297         watchdog('actions', "Removed orphaned action '%action' from database.", array('%action' => filter_xss_admin($action->description)));
00298       }
00299     }
00300     else {
00301       $link = l(t('Remove orphaned actions'), 'admin/build/actions/orphan');
00302       $count = count($actions_in_db);
00303       watchdog('actions', format_plural($count, 'One orphaned action (%orphans) exists in the actions table. !link', '@count orphaned actions (%orphans) exist in the actions table. !link', array('@count' => $count, '%orphans' => $orphans, '!link' => $link), 'warning'));
00304     }
00305   }
00306 }
00307
00325 function actions_save($function, $type, $params, $desc, $aid = NULL) {
00326   $serialized = serialize($params);
00327   if ($aid) {
00328     db_query("UPDATE {actions} SET callback = '%s', type = '%s', parameters = '%s', description = '%s' WHERE aid = %d", $function, $type, $serialized, $desc, $aid);
00329     watchdog('actions', 'Action %action saved.', array('%action' => $desc));
00330   }
00331   else {
00332     // aid is the callback for singleton actions so we need to keep a
00333     // separate table for numeric aids.
00334     db_query('INSERT INTO {actions_aid} VALUES (default)');
00335     $aid = db_last_insert_id('actions_aid', 'aid');
00336     db_query("INSERT INTO {actions} (aid, callback, type, parameters, description) VALUES (%d, '%s', '%s', '%s', '%s')", $aid, $function, $type, $serialized, $desc);
00337     watchdog('actions', 'Action %action created.', array('%action' => $desc));
00338   }
00339
00340   return $aid;
00341 }
00342
00352 function actions_load($aid) {
00353   return db_fetch_object(db_query("SELECT * FROM {actions} WHERE aid = %d", $aid));
00354 }
00355
00362 function actions_delete($aid) {
00363   db_query("DELETE FROM {actions} WHERE aid = %d", $aid);
00364   module_invoke_all('actions_delete', $aid);
00365 }
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator-feed-source.tpl.php Source File

modules » aggregator

aggregator-feed-source.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: aggregator-feed-source.tpl.php,v 1.1 2007/09/13 08:02:38 goba Exp $
00003
00022 ?>
00023 <div class="feed-source">
00024   <?php print $source_icon; ?>
00025   <?php print $source_image; ?>
00026   <div class="feed-description">
00027     <?php print $source_description; ?>
00028   </div>
00029   <div class="feed-url">
00030     <em><?php print t('URL:'); ?></em> <a href="<?php print $source_url; ?>"><?php print $source_url; ?></a>
00031   </div>
00032   <div class="feed-updated">
00033     <em><?php print t('Updated:'); ?></em> <?php print $last_checked; ?>
00034   </div>
00035 </div>
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator-item.tpl.php Source File

modules » aggregator

aggregator-item.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: aggregator-item.tpl.php,v 1.1 2007/09/13 08:02:38 goba Exp $
00003
00021 ?>
00022 <div class="feed-item">
00023   <h3 class="feed-item-title">
00024     <a href="<?php print $feed_url; ?>"><?php print $feed_title; ?></a>
00025   </h3>
00026
00027   <div class="feed-item-meta">
00028   <?php if ($source_url) : ?>
00029     <a href="<?php print $source_url; ?>" class="feed-item-source"><?php print $source_title; ?></a> -
00030   <?php endif; ?>
00031     <span class="feed-item-date"><?php print $source_date; ?></span>
00032   </div>
00033
00034 <?php if ($content) : ?>
00035   <div class="feed-item-body">
00036     <?php print $content; ?>
00037   </div>
00038 <?php endif; ?>
00039
00040 <?php if ($categories) : ?>
00041   <div class="feed-item-categories">
00042     <?php print t('Categories'); ?>: <?php print implode(', ', $categories); ?>
00043   </div>
00044 <?php endif ;?>
00045
00046 </div>
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator-summary-item.tpl.php Source File

modules » aggregator

aggregator-summary-item.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: aggregator-summary-item.tpl.php,v 1.1 2007/09/13 08:02:38 goba Exp $
00003
00018 ?>
00019 <a href="<?php print $feed_url; ?>"><?php print $feed_title; ?></a> <span class="age"><?php print $feed_age; ?></span><?php if ($source_url) : ?>, <span class="source"><a href="<?php print $source_url; ?>"><?php print $source_title; ?></a></span><?php endif; ?>
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator-summary-items.tpl.php Source File

modules » aggregator

aggregator-summary-items.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: aggregator-summary-items.tpl.php,v 1.1 2007/09/13 08:02:38 goba Exp $
00003
00019 ?>
00020 <h2><?php print $title; ?></h2>
00021 <?php print $summary_list; ?>
00022 <div class="links">
00023   <a href="<?php print $source_url; ?>"><?php print t('More'); ?></a>
00024 </div>
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator-wrapper.tpl.php Source File

modules » aggregator

aggregator-wrapper.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: aggregator-wrapper.tpl.php,v 1.1 2007/09/13 08:02:38 goba Exp $
00003
00015 ?>
00016 <div id="aggregator">
00017   <?php print $content; ?>
00018   <?php print $pager; ?>
00019 </div>
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator.admin.inc Source File

modules » aggregator

aggregator.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: aggregator.admin.inc,v 1.7 2008/01/10 22:47:17 goba Exp $
00003
00012 function aggregator_admin_overview() {
00013   return aggregator_view();
00014 }
00015
00022 function aggregator_view() {
00023   $result = db_query('SELECT f.*, COUNT(i.iid) AS items FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY f.fid, f.title, f.url, f.refresh, f.checked, f.link, f.description, f.etag, f.modified, f.image, f.block ORDER BY f.title');
00024
00025   $output = '<h3>'. t('Feed overview') .'</h3>';
00026
00027   $header = array(t('Title'), t('Items'), t('Last update'), t('Next update'), array('data' => t('Operations'), 'colspan' => '3'));
00028   $rows = array();
00029   while ($feed = db_fetch_object($result)) {
00030     $rows[] = array(l($feed->title, "aggregator/sources/$feed->fid"), format_plural($feed->items, '1 item', '@count items'), ($feed->checked ? t('@time ago', array('@time' => format_interval(time() - $feed->checked))) : t('never')), ($feed->checked ? t('%time left', array('%time' => format_interval($feed->checked + $feed->refresh - time()))) : t('never')), l(t('edit'), "admin/content/aggregator/edit/feed/$feed->fid"), l(t('remove items'), "admin/content/aggregator/remove/$feed->fid"), l(t('update items'), "admin/content/aggregator/update/$feed->fid"));
00031   }
00032   $output .= theme('table', $header, $rows);
00033
00034   $result = db_query('SELECT c.cid, c.title, count(ci.iid) as items FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid GROUP BY c.cid, c.title ORDER BY title');
00035
00036   $output .= '<h3>'. t('Category overview') .'</h3>';
00037
00038   $header = array(t('Title'), t('Items'), t('Operations'));
00039   $rows = array();
00040   while ($category = db_fetch_object($result)) {
00041     $rows[] = array(l($category->title, "aggregator/categories/$category->cid"), format_plural($category->items, '1 item', '@count items'), l(t('edit'), "admin/content/aggregator/edit/category/$category->cid"));
00042   }
00043   $output .= theme('table', $header, $rows);
00044
00045   return $output;
00046 }
00047
00055 function aggregator_form_feed(&$form_state, $edit = array('refresh' => 900, 'title' => '', 'url' => '', 'fid' => NULL)) {
00056   $period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
00057
00058   if ($edit['refresh'] == '') {
00059     $edit['refresh'] = 3600;
00060   }
00061
00062   $form['title'] = array('#type' => 'textfield',
00063     '#title' => t('Title'),
00064     '#default_value' => $edit['title'],
00065     '#maxlength' => 255,
00066     '#description' => t('The name of the feed (or the name of the website providing the feed).'),
00067     '#required' => TRUE,
00068   );
00069   $form['url'] = array('#type' => 'textfield',
00070     '#title' => t('URL'),
00071     '#default_value' => $edit['url'],
00072     '#maxlength' => 255,
00073     '#description' => t('The fully-qualified URL of the feed.'),
00074     '#required' => TRUE,
00075   );
00076   $form['refresh'] = array('#type' => 'select',
00077     '#title' => t('Update interval'),
00078     '#default_value' => $edit['refresh'],
00079     '#options' => $period,
00080     '#description' => t('The length of time between feed updates. (Requires a correctly configured <a href="@cron">cron maintenance task</a>.)', array('@cron' => url('admin/reports/status'))),
00081   );
00082
00083   // Handling of categories:
00084   $options = array();
00085   $values = array();
00086   $categories = db_query('SELECT c.cid, c.title, f.fid FROM {aggregator_category} c LEFT JOIN {aggregator_category_feed} f ON c.cid = f.cid AND f.fid = %d ORDER BY title', $edit['fid']);
00087   while ($category = db_fetch_object($categories)) {
00088     $options[$category->cid] = check_plain($category->title);
00089     if ($category->fid) $values[] = $category->cid;
00090   }
00091   if ($options) {
00092     $form['category'] = array('#type' => 'checkboxes',
00093       '#title' => t('Categorize news items'),
00094       '#default_value' => $values,
00095       '#options' => $options,
00096       '#description' => t('New feed items are automatically filed in the checked categories.'),
00097     );
00098   }
00099   $form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
00100
00101   if ($edit['fid']) {
00102     $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
00103     $form['fid'] = array('#type' => 'hidden', '#value' => $edit['fid']);
00104   }
00105
00106   return $form;
00107 }
00108
00112 function aggregator_form_feed_validate($form, &$form_state) {
00113   if ($form_state['values']['op'] == t('Save')) {
00114     // Ensure URL is valid.
00115     if (!valid_url($form_state['values']['url'], TRUE)) {
00116       form_set_error('url', t('The URL %url is invalid. Please enter a fully-qualified URL, such as http://www.example.com/feed.xml.', array('%url' => $form_state['values']['url'])));
00117     }
00118     // Check for duplicate titles.
00119     if (isset($form_state['values']['fid'])) {
00120       $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE (title = '%s' OR url='%s') AND fid != %d", $form_state['values']['title'], $form_state['values']['url'], $form_state['values']['fid']);
00121     }
00122     else {
00123       $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE title = '%s' OR url='%s'", $form_state['values']['title'], $form_state['values']['url']);
00124     }
00125     while ($feed = db_fetch_object($result)) {
00126       if (strcasecmp($feed->title, $form_state['values']['title']) == 0) {
00127         form_set_error('title', t('A feed named %feed already exists. Please enter a unique title.', array('%feed' => $form_state['values']['title'])));
00128       }
00129       if (strcasecmp($feed->url, $form_state['values']['url']) == 0) {
00130         form_set_error('url', t('A feed with this URL %url already exists. Please enter a unique URL.', array('%url' => $form_state['values']['url'])));
00131       }
00132     }
00133   }
00134 }
00135
00141 function aggregator_form_feed_submit($form, &$form_state) {
00142   if ($form_state['values']['op'] == t('Delete')) {
00143     $title = $form_state['values']['title'];
00144     // Unset the title:
00145     unset($form_state['values']['title']);
00146   }
00147   aggregator_save_feed($form_state['values']);
00148   if (isset($form_state['values']['fid'])) {
00149     if (isset($form_state['values']['title'])) {
00150       drupal_set_message(t('The feed %feed has been updated.', array('%feed' => $form_state['values']['title'])));
00151       if (arg(0) == 'admin') {
00152         $form_state['redirect'] = 'admin/content/aggregator/';
00153         return;
00154       }
00155       else {
00156         $form_state['redirect'] = 'aggregator/sources/'. $form_state['values']['fid'];
00157         return;
00158       }
00159     }
00160     else {
00161       watchdog('aggregator', 'Feed %feed deleted.', array('%feed' => $title));
00162       drupal_set_message(t('The feed %feed has been deleted.', array('%feed' => $title)));
00163       if (arg(0) == 'admin') {
00164         $form_state['redirect'] = 'admin/content/aggregator/';
00165         return;
00166       }
00167       else {
00168         $form_state['redirect'] = 'aggregator/sources/';
00169         return;
00170       }
00171     }
00172   }
00173   else {
00174     watchdog('aggregator', 'Feed %feed added.', array('%feed' => $form_state['values']['title']), WATCHDOG_NOTICE, l(t('view'), 'admin/content/aggregator'));
00175     drupal_set_message(t('The feed %feed has been added.', array('%feed' => $form_state['values']['title'])));
00176   }
00177 }
00178
00179 function aggregator_admin_remove_feed($form_state, $feed) {
00180   return confirm_form(
00181     array(
00182       'feed' => array(
00183         '#type' => 'value',
00184         '#value' => $feed,
00185       ),
00186     ),
00187     t('Are you sure you want to remove all items from the feed %feed?', array('%feed' => $feed['title'])),
00188     'admin/content/aggregator',
00189     t('This action cannot be undone.'),
00190     t('Remove items'),
00191     t('Cancel')
00192   );
00193 }
00194
00201 function aggregator_admin_remove_feed_submit($form, &$form_state) {
00202   aggregator_remove($form_state['values']['feed']);
00203   $form_state['redirect'] = 'admin/content/aggregator';
00204 }
00205
00212 function aggregator_admin_refresh_feed($feed) {
00213   aggregator_refresh($feed);
00214   drupal_goto('admin/content/aggregator');
00215 }
00216
00223 function aggregator_admin_settings() {
00224   $items = array(0 => t('none')) + drupal_map_assoc(array(3, 5, 10, 15, 20, 25), '_aggregator_items');
00225   $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
00226
00227   $form['aggregator_allowed_html_tags'] = array(
00228     '#type' => 'textfield', '#title' => t('Allowed HTML tags'), '#size' => 80, '#maxlength' => 255,
00229     '#default_value' => variable_get('aggregator_allowed_html_tags', '<a> <b> <br> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>'),
00230     '#description' => t('A space-separated list of HTML tags allowed in the content of feed items. (Tags in this list are not removed by Drupal.)')
00231   );
00232
00233   $form['aggregator_summary_items'] = array(
00234     '#type' => 'select', '#title' => t('Items shown in sources and categories pages') ,
00235     '#default_value' => variable_get('aggregator_summary_items', 3), '#options' => $items,
00236     '#description' => t('Number of feed items displayed in feed and category summary pages.')
00237   );
00238
00239   $form['aggregator_clear'] = array(
00240     '#type' => 'select', '#title' => t('Discard items older than'),
00241     '#default_value' => variable_get('aggregator_clear', 9676800), '#options' => $period,
00242     '#description' => t('The length of time to retain feed items before discarding. (Requires a correctly configured <a href="@cron">cron maintenance task</a>.)', array('@cron' => url('admin/reports/status')))
00243   );
00244
00245   $form['aggregator_category_selector'] = array(
00246     '#type' => 'radios', '#title' => t('Category selection type'), '#default_value' => variable_get('aggregator_category_selector', 'checkboxes'),
00247     '#options' => array('checkboxes' => t('checkboxes'), 'select' => t('multiple selector')),
00248     '#description' => t('The type of category selection widget displayed on categorization pages. (For a small number of categories, checkboxes are easier to use, while a multiple selector work well with large numbers of categories.)')
00249   );
00250
00251   return system_settings_form($form);
00252 }
00253
00261 function aggregator_form_category(&$form_state, $edit = array('title' => '', 'description' => '', 'cid' => NULL)) {
00262   $form['title'] = array('#type' => 'textfield',
00263     '#title' => t('Title'),
00264     '#default_value' => $edit['title'],
00265     '#maxlength' => 64,
00266     '#required' => TRUE,
00267   );
00268   $form['description'] = array('#type' => 'textarea',
00269     '#title' => t('Description'),
00270     '#default_value' => $edit['description'],
00271   );
00272   $form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
00273
00274   if ($edit['cid']) {
00275     $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
00276     $form['cid'] = array('#type' => 'hidden', '#value' => $edit['cid']);
00277   }
00278
00279   return $form;
00280 }
00281
00285 function aggregator_form_category_validate($form, &$form_state) {
00286   if ($form_state['values']['op'] == t('Save')) {
00287     // Check for duplicate titles
00288     if (isset($form_state['values']['cid'])) {
00289       $category = db_fetch_object(db_query("SELECT cid FROM {aggregator_category} WHERE title = '%s' AND cid != %d", $form_state['values']['title'], $form_state['values']['cid']));
00290     }
00291     else {
00292       $category = db_fetch_object(db_query("SELECT cid FROM {aggregator_category} WHERE title = '%s'", $form_state['values']['title']));
00293     }
00294     if ($category) {
00295       form_set_error('title', t('A category named %category already exists. Please enter a unique title.', array('%category' => $form_state['values']['title'])));
00296     }
00297   }
00298 }
00299
00305 function aggregator_form_category_submit($form, &$form_state) {
00306   if ($form_state['values']['op'] == t('Delete')) {
00307     $title = $form_state['values']['title'];
00308     // Unset the title:
00309     unset($form_state['values']['title']);
00310   }
00311   aggregator_save_category($form_state['values']);
00312   if (isset($form_state['values']['cid'])) {
00313     if (isset($form_state['values']['title'])) {
00314       drupal_set_message(t('The category %category has been updated.', array('%category' => $form_state['values']['title'])));
00315       if (arg(0) == 'admin') {
00316         $form_state['redirect'] = 'admin/content/aggregator/';
00317         return;
00318       }
00319       else {
00320         $form_state['redirect'] = 'aggregator/categories/'. $form_state['values']['cid'];
00321         return;
00322       }
00323     }
00324     else {
00325       watchdog('aggregator', 'Category %category deleted.', array('%category' => $title));
00326       drupal_set_message(t('The category %category has been deleted.', array('%category' => $title)));
00327       if (arg(0) == 'admin') {
00328         $form_state['redirect'] = 'admin/content/aggregator/';
00329         return;
00330       }
00331       else {
00332         $form_state['redirect'] = 'aggregator/categories/';
00333         return;
00334       }
00335     }
00336   }
00337   else {
00338     watchdog('aggregator', 'Category %category added.', array('%category' => $form_state['values']['title']), WATCHDOG_NOTICE, l(t('view'), 'admin/content/aggregator'));
00339     drupal_set_message(t('The category %category has been added.', array('%category' => $form_state['values']['title'])));
00340   }
00341 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator.install Source File

modules » aggregator

aggregator.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: aggregator.install,v 1.14 2007/12/18 12:59:20 dries Exp $
00003
00007 function aggregator_install() {
00008   // Create tables.
00009   drupal_install_schema('aggregator');
00010 }
00011
00015 function aggregator_uninstall() {
00016   // Remove tables.
00017   drupal_uninstall_schema('aggregator');
00018
00019   variable_del('aggregator_allowed_html_tags');
00020   variable_del('aggregator_summary_items');
00021   variable_del('aggregator_clear');
00022   variable_del('aggregator_category_selector');
00023 }
00024
00028 function aggregator_schema() {
00029   $schema['aggregator_category'] = array(
00030     'description' => t('Stores categories for aggregator feeds and feed items.'),
00031     'fields' => array(
00032       'cid'  => array(
00033         'type' => 'serial',
00034         'not null' => TRUE,
00035         'description' => t('Primary Key: Unique aggregator category ID.'),
00036       ),
00037       'title' => array(
00038         'type' => 'varchar',
00039         'length' => 255,
00040         'not null' => TRUE,
00041         'default' => '',
00042         'description' => t('Title of the category.'),
00043       ),
00044       'description' => array(
00045         'type' => 'text',
00046         'not null' => TRUE,
00047         'size' => 'big',
00048         'description' => t('Description of the category'),
00049       ),
00050       'block' => array(
00051         'type' => 'int',
00052         'not null' => TRUE,
00053         'default' => 0,
00054         'size' => 'tiny',
00055         'description' => t('The number of recent items to show within the category block.'),
00056       )
00057     ),
00058     'primary key' => array('cid'),
00059     'unique keys' => array('title' => array('title')),
00060   );
00061
00062   $schema['aggregator_category_feed'] = array(
00063     'description' => t('Bridge table; maps feeds to categories.'),
00064     'fields' => array(
00065       'fid' => array(
00066         'type' => 'int',
00067         'not null' => TRUE,
00068         'default' => 0,
00069         'description' => t("The feed's {aggregator_feed}.fid."),
00070       ),
00071       'cid' => array(
00072         'type' => 'int',
00073         'not null' => TRUE,
00074         'default' => 0,
00075         'description' => t('The {aggregator_category}.cid to which the feed is being assigned.'),
00076       )
00077     ),
00078     'primary key' => array('cid', 'fid'),
00079     'indexes' => array('fid' => array('fid')),
00080   );
00081
00082   $schema['aggregator_category_item'] = array(
00083     'description' => t('Bridge table; maps feed items to categories.'),
00084     'fields' => array(
00085       'iid' => array(
00086         'type' => 'int',
00087         'not null' => TRUE,
00088         'default' => 0,
00089         'description' => t("The feed item's {aggregator_item}.iid."),
00090       ),
00091       'cid' => array(
00092         'type' => 'int',
00093         'not null' => TRUE,
00094         'default' => 0,
00095         'description' => t('The {aggregator_category}.cid to which the feed item is being assigned.'),
00096       )
00097     ),
00098     'primary key' => array('cid', 'iid'),
00099     'indexes' => array('iid' => array('iid')),
00100   );
00101
00102   $schema['aggregator_feed'] = array(
00103     'description' => t('Stores feeds to be parsed by the aggregator.'),
00104     'fields' => array(
00105       'fid' => array(
00106         'type' => 'serial',
00107         'not null' => TRUE,
00108         'description' => t('Primary Key: Unique feed ID.'),
00109       ),
00110       'title' => array(
00111         'type' => 'varchar',
00112         'length' => 255,
00113         'not null' => TRUE,
00114         'default' => '',
00115         'description' => t('Title of the feed.'),
00116       ),
00117       'url' => array(
00118         'type' => 'varchar',
00119         'length' => 255,
00120         'not null' => TRUE,
00121         'default' => '',
00122         'description' => t('URL to the feed.'),
00123       ),
00124       'refresh' => array(
00125         'type' => 'int',
00126         'not null' => TRUE,
00127         'default' => 0,
00128         'description' => t('How often to check for new feed items, in seconds.'),
00129       ),
00130       'checked' => array(
00131         'type' => 'int',
00132         'not null' => TRUE,
00133         'default' => 0,
00134         'description' => t('Last time feed was checked for new items, as Unix timestamp.'),
00135       ),
00136       'link' => array(
00137         'type' => 'varchar',
00138         'length' => 255,
00139         'not null' => TRUE,
00140         'default' => '',
00141         'description' => t('The parent website of the feed; comes from the <link> element in the feed.'),
00142       ),
00143       'description' => array(
00144         'type' => 'text',
00145         'not null' => TRUE,
00146         'size' => 'big',
00147         'description' => t("The parent website's description; comes from the <description> element in the feed."),
00148       ),
00149       'image' => array(
00150         'type' => 'text',
00151         'not null' => TRUE,
00152         'size' => 'big',
00153         'description' => t('An image representing the feed.'),
00154       ),
00155       'etag' => array(
00156         'type' => 'varchar',
00157         'length' => 255,
00158         'not null' => TRUE,
00159         'default' => '',
00160         'description' => t('Entity tag HTTP response header, used for validating cache.'),
00161       ),
00162       'modified' => array(
00163         'type' => 'int',
00164         'not null' => TRUE,
00165         'default' => 0,
00166         'description' => t('When the feed was last modified, as a Unix timestamp.'),
00167       ),
00168       'block' => array(
00169         'type' => 'int',
00170         'not null' => TRUE,
00171         'default' => 0,
00172         'size' => 'tiny',
00173         'description' => t("Number of items to display in the feed's block."),
00174       )
00175     ),
00176     'primary key' => array('fid'),
00177     'unique keys' => array(
00178       'url'  => array('url'),
00179       'title' => array('title'),
00180     ),
00181   );
00182
00183   $schema['aggregator_item'] = array(
00184     'description' => t('Stores the individual items imported from feeds.'),
00185     'fields' => array(
00186       'iid'  => array(
00187         'type' => 'serial',
00188         'not null' => TRUE,
00189         'description' => t('Primary Key: Unique ID for feed item.'),
00190       ),
00191       'fid' => array(
00192         'type' => 'int',
00193         'not null' => TRUE,
00194         'default' => 0,
00195         'description' => t('The {aggregator_feed}.fid to which this item belongs.'),
00196       ),
00197       'title' => array(
00198         'type' => 'varchar',
00199         'length' => 255,
00200         'not null' => TRUE,
00201         'default' => '',
00202         'description' => t('Title of the feed item.'),
00203       ),
00204       'link' => array(
00205         'type' => 'varchar',
00206         'length' => 255,
00207         'not null' => TRUE,
00208         'default' => '',
00209         'description' => t('Link to the feed item.'),
00210       ),
00211       'author' => array(
00212         'type' => 'varchar',
00213         'length' => 255,
00214         'not null' => TRUE,
00215         'default' => '',
00216         'description' => t('Author of the feed item.'),
00217       ),
00218       'description' => array(
00219         'type' => 'text',
00220         'not null' => TRUE,
00221         'size' => 'big',
00222         'description' => t('Body of the feed item.'),
00223       ),
00224       'timestamp' => array(
00225         'type' => 'int',
00226         'not null' => FALSE,
00227         'description' => t('Post date of feed item, as a Unix timestamp.'),
00228       ),
00229       'guid' => array(
00230         'type' => 'varchar',
00231         'length' => 255,
00232         'not null' => FALSE,
00233         'description' => t('Unique identifier for the feed item.'),
00234       )
00235     ),
00236     'primary key' => array('iid'),
00237     'indexes' => array('fid' => array('fid')),
00238   );
00239
00240   return $schema;
00241 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator.module Source File

modules » aggregator

aggregator.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: aggregator.module,v 1.374 2008/01/15 08:06:32 dries Exp $
00003
00012 function aggregator_help($path, $arg) {
00013   switch ($path) {
00014     case 'admin/help#aggregator':
00015       $output = '<p>'. t('The aggregator is a powerful on-site syndicator and news reader that gathers fresh content from RSS-, RDF-, and Atom-based feeds made available across the web. Thousands of sites (particularly news sites and blogs) publish their latest headlines and posts in feeds, using a number of standardized XML-based formats. Formats supported by the aggregator include <a href="@rss">RSS</a>, <a href="@rdf">RDF</a>, and <a href="@atom">Atom</a>.', array('@rss' => 'http://cyber.law.harvard.edu/rss/', '@rdf' => 'http://www.w3.org/RDF/', '@atom' => 'http://www.atomenabled.org')) .'</p>';
00016       $output .= '<p>'. t('Feeds contain feed items, or individual posts published by the site providing the feed. Feeds may be grouped in categories, generally by topic. Users view feed items in the <a href="@aggregator">main aggregator display</a> or by <a href="@aggregator-sources">their source</a>. Administrators can <a href="@feededit">add, edit and delete feeds</a> and choose how often to check each feed for newly updated items. The most recent items in either a feed or category can be displayed as a block through the <a href="@admin-block">blocks administration page</a>. A <a href="@aggregator-opml">machine-readable OPML file</a> of all feeds is available. A correctly configured <a href="@cron">cron maintenance task</a> is required to update feeds automatically.', array('@aggregator' => url('aggregator'), '@aggregator-sources' => url('aggregator/sources'), '@feededit' => url('admin/content/aggregator'), '@admin-block' => url('admin/build/block'), '@aggregator-opml' => url('aggregator/opml'), '@cron' => url('admin/reports/status'))) .'</p>';
00017       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@aggregator">Aggregator module</a>.', array('@aggregator' => 'http://drupal.org/handbook/modules/aggregator/')) .'</p>';
00018       return $output;
00019     case 'admin/content/aggregator':
00020       $output = '<p>'. t('Thousands of sites (particularly news sites and blogs) publish their latest headlines and posts in feeds, using a number of standardized XML-based formats. Formats supported by the aggregator include <a href="@rss">RSS</a>, <a href="@rdf">RDF</a>, and <a href="@atom">Atom</a>.', array('@rss' => 'http://cyber.law.harvard.edu/rss/', '@rdf' => 'hsttp://www.w3.org/RDF/', '@atom' => 'http://www.atomenabled.org')) .'</p>';
00021       $output .= '<p>'. t('Current feeds are listed below, and <a href="@addfeed">new feeds may be added</a>. For each feed or feed category, the <em>latest items</em> block may be enabled at the <a href="@block">blocks administration page</a>.', array('@addfeed' => url('admin/content/aggregator/add/feed'), '@block' => url('admin/build/block'))) .'</p>';
00022       return $output;
00023     case 'admin/content/aggregator/add/feed':
00024       return '<p>'. t('Add a feed in RSS, RDF or Atom format. A feed may only have one entry.') .'</p>';
00025     case 'admin/content/aggregator/add/category':
00026       return '<p>'. t('Categories allow feed items from different feeds to be grouped together. For example, several sport-related feeds may belong to a category named <em>Sports</em>. Feed items may be grouped automatically (by selecting a category when creating or editing a feed) or manually (via the <em>Categorize</em> page available from feed item listings). Each category provides its own feed page and block.') .'</p>';
00027   }
00028 }
00029
00033 function aggregator_theme() {
00034   return array(
00035     'aggregator_wrapper' => array(
00036       'arguments' => array('content' => NULL),
00037       'file' => 'aggregator.pages.inc',
00038       'template' => 'aggregator-wrapper',
00039     ),
00040     'aggregator_categorize_items' => array(
00041       'arguments' => array('form' => NULL),
00042       'file' => 'aggregator.pages.inc',
00043     ),
00044     'aggregator_feed_source' => array(
00045       'arguments' => array('feed' => NULL),
00046       'file' => 'aggregator.pages.inc',
00047       'template' => 'aggregator-feed-source',
00048     ),
00049     'aggregator_block_item' => array(
00050       'arguments' => array('item' => NULL, 'feed' => 0),
00051     ),
00052     'aggregator_summary_items' => array(
00053       'arguments' => array('summary_items' => NULL, 'source' => NULL),
00054       'file' => 'aggregator.pages.inc',
00055       'template' => 'aggregator-summary-items',
00056     ),
00057     'aggregator_summary_item' => array(
00058       'arguments' => array('item' => NULL),
00059       'file' => 'aggregator.pages.inc',
00060       'template' => 'aggregator-summary-item',
00061     ),
00062     'aggregator_item' => array(
00063       'arguments' => array('item' => NULL),
00064       'file' => 'aggregator.pages.inc',
00065       'template' => 'aggregator-item',
00066     ),
00067     'aggregator_page_opml' => array(
00068       'arguments' => array('feeds' => NULL),
00069       'file' => 'aggregator.pages.inc',
00070     ),
00071     'aggregator_page_rss' => array(
00072       'arguments' => array('feeds' => NULL, 'category' => NULL),
00073       'file' => 'aggregator.pages.inc',
00074     ),
00075   );
00076 }
00077
00081 function aggregator_menu() {
00082   $items['admin/content/aggregator'] = array(
00083     'title' => 'Feed aggregator',
00084     'description' => "Configure which content your site aggregates from other sites, how often it polls them, and how they're categorized.",
00085     'page callback' => 'aggregator_admin_overview',
00086     'access arguments' => array('administer news feeds'),
00087     'file' => 'aggregator.admin.inc',
00088   );
00089   $items['admin/content/aggregator/add/feed'] = array(
00090     'title' => 'Add feed',
00091     'page callback' => 'drupal_get_form',
00092     'page arguments' => array('aggregator_form_feed'),
00093     'access arguments' => array('administer news feeds'),
00094     'type' => MENU_LOCAL_TASK,
00095     'parent' => 'admin/content/aggregator',
00096     'file' => 'aggregator.admin.inc',
00097   );
00098   $items['admin/content/aggregator/add/category'] = array(
00099     'title' => 'Add category',
00100     'page callback' => 'drupal_get_form',
00101     'page arguments' => array('aggregator_form_category'),
00102     'access arguments' => array('administer news feeds'),
00103     'type' => MENU_LOCAL_TASK,
00104     'parent' => 'admin/content/aggregator',
00105     'file' => 'aggregator.admin.inc',
00106   );
00107   $items['admin/content/aggregator/remove/%aggregator_feed'] = array(
00108     'title' => 'Remove items',
00109     'page callback' => 'drupal_get_form',
00110     'page arguments' => array('aggregator_admin_remove_feed', 4),
00111     'access arguments' => array('administer news feeds'),
00112     'type' => MENU_CALLBACK,
00113     'file' => 'aggregator.admin.inc',
00114   );
00115   $items['admin/content/aggregator/update/%aggregator_feed'] = array(
00116     'title' => 'Update items',
00117     'page callback' => 'aggregator_admin_refresh_feed',
00118     'page arguments' => array(4),
00119     'access arguments' => array('administer news feeds'),
00120     'type' => MENU_CALLBACK,
00121     'file' => 'aggregator.admin.inc',
00122   );
00123   $items['admin/content/aggregator/list'] = array(
00124     'title' => 'List',
00125     'type' => MENU_DEFAULT_LOCAL_TASK,
00126     'weight' => -10,
00127   );
00128   $items['admin/content/aggregator/settings'] = array(
00129     'title' => 'Settings',
00130     'page callback' => 'drupal_get_form',
00131     'page arguments' => array('aggregator_admin_settings'),
00132     'type' => MENU_LOCAL_TASK,
00133     'weight' => 10,
00134     'access arguments' => array('administer news feeds'),
00135     'file' => 'aggregator.admin.inc',
00136   );
00137   $items['aggregator'] = array(
00138     'title' => 'Feed aggregator',
00139     'page callback' => 'aggregator_page_last',
00140     'access arguments' => array('access news feeds'),
00141     'weight' => 5,
00142     'file' => 'aggregator.pages.inc',
00143   );
00144   $items['aggregator/sources'] = array(
00145     'title' => 'Sources',
00146     'page callback' => 'aggregator_page_sources',
00147     'access arguments' => array('access news feeds'),
00148     'file' => 'aggregator.pages.inc',
00149   );
00150   $items['aggregator/categories'] = array(
00151     'title' => 'Categories',
00152     'page callback' => 'aggregator_page_categories',
00153     'access callback' => '_aggregator_has_categories',
00154     'file' => 'aggregator.pages.inc',
00155   );
00156   $items['aggregator/rss'] = array(
00157     'title' => 'RSS feed',
00158     'page callback' => 'aggregator_page_rss',
00159     'access arguments' => array('access news feeds'),
00160     'type' => MENU_CALLBACK,
00161     'file' => 'aggregator.pages.inc',
00162   );
00163   $items['aggregator/opml'] = array(
00164     'title' => 'OPML feed',
00165     'page callback' => 'aggregator_page_opml',
00166     'access arguments' => array('access news feeds'),
00167     'type' => MENU_CALLBACK,
00168     'file' => 'aggregator.pages.inc',
00169   );
00170   $items['aggregator/categories/%aggregator_category'] = array(
00171     'title callback' => '_aggregator_category_title',
00172     'title arguments' => array(2),
00173     'page callback' => 'aggregator_page_category',
00174     'page arguments' => array(2),
00175     'access callback' => 'user_access',
00176     'access arguments' => array('access news feeds'),
00177     'file' => 'aggregator.pages.inc',
00178   );
00179   $items['aggregator/categories/%aggregator_category/view'] = array(
00180     'title' => 'View',
00181     'type' => MENU_DEFAULT_LOCAL_TASK,
00182     'weight' => -10,
00183   );
00184   $items['aggregator/categories/%aggregator_category/categorize'] = array(
00185     'title' => 'Categorize',
00186     'page callback' => 'drupal_get_form',
00187     'page arguments' => array('aggregator_page_category', 2),
00188     'access arguments' => array('administer news feeds'),
00189     'type' => MENU_LOCAL_TASK,
00190     'file' => 'aggregator.pages.inc',
00191   );
00192   $items['aggregator/categories/%aggregator_category/configure'] = array(
00193     'title' => 'Configure',
00194     'page callback' => 'drupal_get_form',
00195     'page arguments' => array('aggregator_form_category', 2),
00196     'access arguments' => array('administer news feeds'),
00197     'type' => MENU_LOCAL_TASK,
00198     'weight' => 1,
00199     'file' => 'aggregator.admin.inc',
00200   );
00201   $items['aggregator/sources/%aggregator_feed'] = array(
00202     'page callback' => 'aggregator_page_source',
00203     'page arguments' => array(2),
00204     'type' => MENU_CALLBACK,
00205     'file' => 'aggregator.pages.inc',
00206   );
00207   $items['aggregator/sources/%aggregator_feed/view'] = array(
00208     'title' => 'View',
00209     'type' => MENU_DEFAULT_LOCAL_TASK,
00210     'weight' => -10,
00211   );
00212   $items['aggregator/sources/%aggregator_feed/categorize'] = array(
00213     'title' => 'Categorize',
00214     'page callback' => 'drupal_get_form',
00215     'page arguments' => array('aggregator_page_source', 2),
00216     'access arguments' => array('administer news feeds'),
00217     'type' => MENU_LOCAL_TASK,
00218     'file' => 'aggregator.pages.inc',
00219   );
00220   $items['aggregator/sources/%aggregator_feed/configure'] = array(
00221     'title' => 'Configure',
00222     'page callback' => 'drupal_get_form',
00223     'page arguments' => array('aggregator_form_feed', 2),
00224     'access arguments' => array('administer news feeds'),
00225     'type' => MENU_LOCAL_TASK,
00226     'weight' => 1,
00227     'file' => 'aggregator.admin.inc',
00228   );
00229   $items['admin/content/aggregator/edit/feed/%aggregator_feed'] = array(
00230     'title' => 'Edit feed',
00231     'page callback' => 'drupal_get_form',
00232     'page arguments' => array('aggregator_form_feed', 5),
00233     'access arguments' => array('administer news feeds'),
00234     'type' => MENU_CALLBACK,
00235     'file' => 'aggregator.admin.inc',
00236   );
00237   $items['admin/content/aggregator/edit/category/%aggregator_category'] = array(
00238     'title' => 'Edit category',
00239     'page callback' => 'drupal_get_form',
00240     'page arguments' => array('aggregator_form_category', 5),
00241     'access arguments' => array('administer news feeds'),
00242     'type' => MENU_CALLBACK,
00243     'file' => 'aggregator.admin.inc',
00244   );
00245
00246   return $items;
00247 }
00248
00255 function _aggregator_category_title($category) {
00256   return $category['title'];
00257 }
00258
00262 function aggregator_init() {
00263   drupal_add_css(drupal_get_path('module', 'aggregator') .'/aggregator.css');
00264 }
00265
00272 function _aggregator_has_categories() {
00273   return user_access('access news feeds') && db_result(db_query('SELECT COUNT(*) FROM {aggregator_category}'));
00274 }
00275
00279 function aggregator_perm() {
00280   return array('administer news feeds', 'access news feeds');
00281 }
00282
00288 function aggregator_cron() {
00289   $result = db_query('SELECT * FROM {aggregator_feed} WHERE checked + refresh < %d', time());
00290   while ($feed = db_fetch_array($result)) {
00291     aggregator_refresh($feed);
00292   }
00293 }
00294
00300 function aggregator_block($op = 'list', $delta = 0, $edit = array()) {
00301   if (user_access('access news feeds')) {
00302     if ($op == 'list') {
00303       $result = db_query('SELECT cid, title FROM {aggregator_category} ORDER BY title');
00304       while ($category = db_fetch_object($result)) {
00305         $block['category-'. $category->cid]['info'] = t('!title category latest items', array('!title' => $category->title));
00306       }
00307       $result = db_query('SELECT fid, title FROM {aggregator_feed} ORDER BY fid');
00308       while ($feed = db_fetch_object($result)) {
00309         $block['feed-'. $feed->fid]['info'] = t('!title feed latest items', array('!title' => $feed->title));
00310       }
00311     }
00312     else if ($op == 'configure') {
00313       list($type, $id) = explode('-', $delta);
00314       if ($type == 'category') {
00315         $value = db_result(db_query('SELECT block FROM {aggregator_category} WHERE cid = %d', $id));
00316       }
00317       else {
00318         $value = db_result(db_query('SELECT block FROM {aggregator_feed} WHERE fid = %d', $id));
00319       }
00320       $form['block'] = array('#type' => 'select', '#title' => t('Number of news items in block'), '#default_value' => $value, '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)));
00321       return $form;
00322     }
00323     else if ($op == 'save') {
00324       list($type, $id) = explode('-', $delta);
00325       if ($type == 'category') {
00326         $value = db_query('UPDATE {aggregator_category} SET block = %d WHERE cid = %d', $edit['block'], $id);
00327       }
00328       else {
00329         $value = db_query('UPDATE {aggregator_feed} SET block = %d WHERE fid = %d', $edit['block'], $id);
00330       }
00331     }
00332     else if ($op == 'view') {
00333       list($type, $id) = explode('-', $delta);
00334       switch ($type) {
00335         case 'feed':
00336           if ($feed = db_fetch_object(db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE fid = %d', $id))) {
00337             $block['subject'] = check_plain($feed->title);
00338             $result = db_query_range('SELECT * FROM {aggregator_item} WHERE fid = %d ORDER BY timestamp DESC, iid DESC', $feed->fid, 0, $feed->block);
00339             $read_more = theme('more_link', url('aggregator/sources/'. $feed->fid), t("View this feed's recent news."));
00340           }
00341           break;
00342
00343         case 'category':
00344           if ($category = db_fetch_object(db_query('SELECT cid, title, block FROM {aggregator_category} WHERE cid = %d', $id))) {
00345             $block['subject'] = check_plain($category->title);
00346             $result = db_query_range('SELECT i.* FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON ci.iid = i.iid WHERE ci.cid = %d ORDER BY i.timestamp DESC, i.iid DESC', $category->cid, 0, $category->block);
00347             $read_more = theme('more_link', url('aggregator/categories/'. $category->cid), t("View this category's recent news."));
00348           }
00349           break;
00350       }
00351       $items = array();
00352       while ($item = db_fetch_object($result)) {
00353         $items[] = theme('aggregator_block_item', $item);
00354       }
00355
00356       // Only display the block if there are items to show.
00357       if (count($items) > 0) {
00358         $block['content'] = theme('item_list', $items) . $read_more;
00359       }
00360     }
00361     if (isset($block)) {
00362       return $block;
00363     }
00364   }
00365 }
00366
00373 function aggregator_save_category($edit) {
00374   $link_path = 'aggregator/categories/';
00375   if (!empty($edit['cid'])) {
00376     $link_path .= $edit['cid'];
00377     if (!empty($edit['title'])) {
00378       db_query("UPDATE {aggregator_category} SET title = '%s', description = '%s' WHERE cid = %d", $edit['title'], $edit['description'], $edit['cid']);
00379       $op = 'update';
00380     }
00381     else {
00382       db_query('DELETE FROM {aggregator_category} WHERE cid = %d', $edit['cid']);
00383       $edit['title'] = '';
00384       $op = 'delete';
00385     }
00386   }
00387   else if (!empty($edit['title'])) {
00388     // A single unique id for bundles and feeds, to use in blocks
00389     db_query("INSERT INTO {aggregator_category} (title, description, block) VALUES ('%s', '%s', 5)", $edit['title'], $edit['description']);
00390     $link_path .= db_last_insert_id('aggregator', 'cid');
00391     $op = 'insert';
00392   }
00393   if (isset($op)) {
00394     menu_link_maintain('aggregator', $op, $link_path, $edit['title']);
00395   }
00396 }
00397
00404 function aggregator_save_feed($edit) {
00405   if (!empty($edit['fid'])) {
00406     // An existing feed is being modified, delete the category listings.
00407     db_query('DELETE FROM {aggregator_category_feed} WHERE fid = %d', $edit['fid']);
00408   }
00409   if (!empty($edit['fid']) && !empty($edit['title'])) {
00410     db_query("UPDATE {aggregator_feed} SET title = '%s', url = '%s', refresh = %d WHERE fid = %d", $edit['title'], $edit['url'], $edit['refresh'], $edit['fid']);
00411   }
00412   else if (!empty($edit['fid'])) {
00413     $items = array();
00414     $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d', $edit['fid']);
00415     while ($item = db_fetch_object($result)) {
00416       $items[] = "iid = $item->iid";
00417     }
00418     if (!empty($items)) {
00419       db_query('DELETE FROM {aggregator_category_item} WHERE '. implode(' OR ', $items));
00420     }
00421     db_query('DELETE FROM {aggregator_feed} WHERE fid = %d', $edit['fid']);
00422     db_query('DELETE FROM {aggregator_item} WHERE fid = %d', $edit['fid']);
00423   }
00424   else if (!empty($edit['title'])) {
00425     db_query("INSERT INTO {aggregator_feed} (title, url, refresh, block, description, image) VALUES ('%s', '%s', %d, 5, '', '')", $edit['title'], $edit['url'], $edit['refresh']);
00426     // A single unique id for bundles and feeds, to use in blocks.
00427     $edit['fid'] = db_last_insert_id('aggregator_feed', 'fid');
00428   }
00429   if (!empty($edit['title'])) {
00430     // The feed is being saved, save the categories as well.
00431     if (!empty($edit['category'])) {
00432       foreach ($edit['category'] as $cid => $value) {
00433         if ($value) {
00434           db_query('INSERT INTO {aggregator_category_feed} (fid, cid) VALUES (%d, %d)', $edit['fid'], $cid);
00435         }
00436       }
00437     }
00438   }
00439 }
00440
00447 function aggregator_remove($feed) {
00448   $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d', $feed['fid']);
00449   while ($item = db_fetch_object($result)) {
00450     $items[] = "iid = $item->iid";
00451   }
00452   if (!empty($items)) {
00453     db_query('DELETE FROM {aggregator_category_item} WHERE '. implode(' OR ', $items));
00454   }
00455   db_query('DELETE FROM {aggregator_item} WHERE fid = %d', $feed['fid']);
00456   db_query("UPDATE {aggregator_feed} SET checked = 0, etag = '', modified = 0 WHERE fid = %d", $feed['fid']);
00457   drupal_set_message(t('The news items from %site have been removed.', array('%site' => $feed['title'])));
00458 }
00459
00463 function aggregator_element_start($parser, $name, $attributes) {
00464   global $item, $element, $tag, $items, $channel;
00465
00466   switch ($name) {
00467     case 'IMAGE':
00468     case 'TEXTINPUT':
00469     case 'CONTENT':
00470     case 'SUMMARY':
00471     case 'TAGLINE':
00472     case 'SUBTITLE':
00473     case 'LOGO':
00474     case 'INFO':
00475       $element = $name;
00476       break;
00477     case 'ID':
00478       if ($element != 'ITEM') {
00479         $element = $name;
00480       }
00481     case 'LINK':
00482       if (!empty($attributes['REL']) && $attributes['REL'] == 'alternate') {
00483         if ($element == 'ITEM') {
00484           $items[$item]['LINK'] = $attributes['HREF'];
00485         }
00486         else {
00487           $channel['LINK'] = $attributes['HREF'];
00488         }
00489       }
00490       break;
00491     case 'ITEM':
00492       $element = $name;
00493       $item += 1;
00494       break;
00495     case 'ENTRY':
00496       $element = 'ITEM';
00497       $item += 1;
00498       break;
00499   }
00500
00501   $tag = $name;
00502 }
00503
00507 function aggregator_element_end($parser, $name) {
00508   global $element;
00509
00510   switch ($name) {
00511     case 'IMAGE':
00512     case 'TEXTINPUT':
00513     case 'ITEM':
00514     case 'ENTRY':
00515     case 'CONTENT':
00516     case 'INFO':
00517       $element = '';
00518       break;
00519     case 'ID':
00520       if ($element == 'ID') {
00521         $element = '';
00522       }
00523   }
00524 }
00525
00529 function aggregator_element_data($parser, $data) {
00530   global $channel, $element, $items, $item, $image, $tag;
00531   $items += array($item => array());
00532   switch ($element) {
00533     case 'ITEM':
00534       $items[$item] += array($tag => '');
00535       $items[$item][$tag] .= $data;
00536       break;
00537     case 'IMAGE':
00538     case 'LOGO':
00539       $image += array($tag => '');
00540       $image[$tag] .= $data;
00541       break;
00542     case 'LINK':
00543       if ($data) {
00544         $items[$item] += array($tag => '');
00545         $items[$item][$tag] .= $data;
00546       }
00547       break;
00548     case 'CONTENT':
00549       $items[$item] += array('CONTENT' => '');
00550       $items[$item]['CONTENT'] .= $data;
00551       break;
00552     case 'SUMMARY':
00553       $items[$item] += array('SUMMARY' => '');
00554       $items[$item]['SUMMARY'] .= $data;
00555       break;
00556     case 'TAGLINE':
00557     case 'SUBTITLE':
00558       $channel += array('DESCRIPTION' => '');
00559       $channel['DESCRIPTION'] .= $data;
00560       break;
00561     case 'INFO':
00562     case 'ID':
00563     case 'TEXTINPUT':
00564       // The sub-element is not supported. However, we must recognize
00565       // it or its contents will end up in the item array.
00566       break;
00567     default:
00568       $channel += array($tag => '');
00569       $channel[$tag] .= $data;
00570   }
00571 }
00572
00579 function aggregator_refresh($feed) {
00580   global $channel, $image;
00581
00582   // Generate conditional GET headers.
00583   $headers = array();
00584   if ($feed['etag']) {
00585     $headers['If-None-Match'] = $feed['etag'];
00586   }
00587   if ($feed['modified']) {
00588     $headers['If-Modified-Since'] = gmdate('D, d M Y H:i:s', $feed['modified']) .' GMT';
00589   }
00590
00591   // Request feed.
00592   $result = drupal_http_request($feed['url'], $headers);
00593
00594   // Process HTTP response code.
00595   switch ($result->code) {
00596     case 304:
00597       db_query('UPDATE {aggregator_feed} SET checked = %d WHERE fid = %d', time(), $feed['fid']);
00598       drupal_set_message(t('There is no new syndicated content from %site.', array('%site' => $feed['title'])));
00599       break;
00600     case 301:
00601       $feed['url'] = $result->redirect_url;
00602       watchdog('aggregator', 'Updated URL for feed %title to %url.', array('%title' => $feed['title'], '%url' => $feed['url']));
00603       // Deliberate no break.
00604     case 200:
00605     case 302:
00606     case 307:
00607       // Filter the input data:
00608       if (aggregator_parse_feed($result->data, $feed)) {
00609         $modified = empty($result->headers['Last-Modified']) ? 0 : strtotime($result->headers['Last-Modified']);
00610
00611         // Prepare the channel data.
00612         foreach ($channel as $key => $value) {
00613           $channel[$key] = trim($value);
00614         }
00615
00616         // Prepare the image data (if any).
00617         foreach ($image as $key => $value) {
00618           $image[$key] = trim($value);
00619         }
00620
00621         if (!empty($image['LINK']) && !empty($image['URL']) && !empty($image['TITLE'])) {
00622           // Note, we should really use theme_image() here but that only works with local images it won't work with images fetched with a URL unless PHP version > 5
00623           $image = '<a href="'. check_url($image['LINK']) .'" class="feed-image"><img src="'. check_url($image['URL']) .'" alt="'. check_plain($image['TITLE']) .'" /></a>';
00624         }
00625         else {
00626           $image = NULL;
00627         }
00628
00629         $etag = empty($result->headers['ETag']) ? '' : $result->headers['ETag'];
00630         // Update the feed data.
00631         db_query("UPDATE {aggregator_feed} SET url = '%s', checked = %d, link = '%s', description = '%s', image = '%s', etag = '%s', modified = %d WHERE fid = %d", $feed['url'], time(), $channel['LINK'], $channel['DESCRIPTION'], $image, $etag, $modified, $feed['fid']);
00632
00633         // Clear the cache.
00634         cache_clear_all();
00635
00636         watchdog('aggregator', 'There is new syndicated content from %site.', array('%site' => $feed['title']));
00637         drupal_set_message(t('There is new syndicated content from %site.', array('%site' => $feed['title'])));
00638         break;
00639       }
00640       $result->error = t('feed not parseable');
00641       // Deliberate no break.
00642     default:
00643       watchdog('aggregator', 'The feed from %site seems to be broken, due to "%error".', array('%site' => $feed['title'], '%error' => $result->code .' '. $result->error), WATCHDOG_WARNING);
00644       drupal_set_message(t('The feed from %site seems to be broken, because of error "%error".', array('%site' => $feed['title'], '%error' => $result->code .' '. $result->error)));
00645       module_invoke('system', 'check_http_request');
00646   }
00647 }
00648
00660 function aggregator_parse_w3cdtf($date_str) {
00661   if (preg_match('/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/', $date_str, $match)) {
00662     list($year, $month, $day, $hours, $minutes, $seconds) = array($match[1], $match[2], $match[3], $match[4], $match[5], $match[6]);
00663     // calc epoch for current date assuming GMT
00664     $epoch = gmmktime($hours, $minutes, $seconds, $month, $day, $year);
00665     if ($match[10] != 'Z') { // Z is zulu time, aka GMT
00666       list($tz_mod, $tz_hour, $tz_min) = array($match[8], $match[9], $match[10]);
00667       // zero out the variables
00668       if (!$tz_hour) {
00669         $tz_hour = 0;
00670       }
00671       if (!$tz_min) {
00672         $tz_min = 0;
00673       }
00674       $offset_secs = (($tz_hour * 60) + $tz_min) * 60;
00675       // is timezone ahead of GMT?  then subtract offset
00676       if ($tz_mod == '+') {
00677         $offset_secs *= -1;
00678       }
00679       $epoch += $offset_secs;
00680     }
00681     return $epoch;
00682   }
00683   else {
00684     return FALSE;
00685   }
00686 }
00687
00698 function aggregator_parse_feed(&$data, $feed) {
00699   global $items, $image, $channel;
00700
00701   // Unset the global variables before we use them:
00702   unset($GLOBALS['element'], $GLOBALS['item'], $GLOBALS['tag']);
00703   $items = array();
00704   $image = array();
00705   $channel = array();
00706
00707   // parse the data:
00708   $xml_parser = drupal_xml_parser_create($data);
00709   xml_set_element_handler($xml_parser, 'aggregator_element_start', 'aggregator_element_end');
00710   xml_set_character_data_handler($xml_parser, 'aggregator_element_data');
00711
00712   if (!xml_parse($xml_parser, $data, 1)) {
00713     watchdog('aggregator', 'The feed from %site seems to be broken, due to an error "%error" on line %line.', array('%site' => $feed['title'], '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser)), WATCHDOG_WARNING);
00714     drupal_set_message(t('The feed from %site seems to be broken, because of error "%error" on line %line.', array('%site' => $feed['title'], '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser))), 'error');
00715     return 0;
00716   }
00717   xml_parser_free($xml_parser);
00718
00719   // We reverse the array such that we store the first item last, and the last
00720   // item first. In the database, the newest item should be at the top.
00721   $items = array_reverse($items);
00722
00723   // Initialize variables.
00724   $title = $link = $author = $description = $guid = NULL;
00725   foreach ($items as $item) {
00726     unset($title, $link, $author, $description, $guid);
00727
00728     // Prepare the item:
00729     foreach ($item as $key => $value) {
00730       $item[$key] = trim($value);
00731     }
00732
00733     // Resolve the item's title. If no title is found, we use up to 40
00734     // characters of the description ending at a word boundary but not
00735     // splitting potential entities.
00736     if (!empty($item['TITLE'])) {
00737       $title = $item['TITLE'];
00738     }
00739     elseif (!empty($item['DESCRIPTION'])) {
00740       $title = preg_replace('/^(.*)[^\w;&].*?$/', "\\1", truncate_utf8($item['DESCRIPTION'], 40));
00741     }
00742     else {
00743       $title = '';
00744     }
00745
00746     // Resolve the items link.
00747     if (!empty($item['LINK'])) {
00748       $link = $item['LINK'];
00749     }
00750     else {
00751       $link = $feed['link'];
00752     }
00753     $guid = isset($item['GUID']) ? $item['GUID'] : '';
00754
00755     // Atom feeds have a CONTENT and/or SUMMARY tag instead of a DESCRIPTION tag.
00756     if (!empty($item['CONTENT:ENCODED'])) {
00757       $item['DESCRIPTION'] = $item['CONTENT:ENCODED'];
00758     }
00759     else if (!empty($item['SUMMARY'])) {
00760       $item['DESCRIPTION'] = $item['SUMMARY'];
00761     }
00762     else if (!empty($item['CONTENT'])) {
00763       $item['DESCRIPTION'] = $item['CONTENT'];
00764     }
00765
00766     // Try to resolve and parse the item's publication date. If no date is
00767     // found, we use the current date instead.
00768     $date = 'now';
00769     foreach (array('PUBDATE', 'DC:DATE', 'DCTERMS:ISSUED', 'DCTERMS:CREATED', 'DCTERMS:MODIFIED', 'ISSUED', 'CREATED', 'MODIFIED', 'PUBLISHED', 'UPDATED') as $key) {
00770       if (!empty($item[$key])) {
00771         $date = $item[$key];
00772         break;
00773       }
00774     }
00775
00776     $timestamp = strtotime($date); // As of PHP 5.1.0, strtotime returns FALSE on failure instead of -1.
00777     if ($timestamp <= 0) {
00778       $timestamp = aggregator_parse_w3cdtf($date); // Returns FALSE on failure
00779       if (!$timestamp) {
00780         $timestamp = time(); // better than nothing
00781       }
00782     }
00783
00784     // Save this item. Try to avoid duplicate entries as much as possible. If
00785     // we find a duplicate entry, we resolve it and pass along its ID is such
00786     // that we can update it if needed.
00787     if (!empty($guid)) {
00788       $entry = db_fetch_object(db_query("SELECT iid FROM {aggregator_item} WHERE fid = %d AND guid = '%s'", $feed['fid'], $guid));
00789     }
00790     else if ($link && $link != $feed['link'] && $link != $feed['url']) {
00791       $entry = db_fetch_object(db_query("SELECT iid FROM {aggregator_item} WHERE fid = %d AND link = '%s'", $feed['fid'], $link));
00792     }
00793     else {
00794       $entry = db_fetch_object(db_query("SELECT iid FROM {aggregator_item} WHERE fid = %d AND title = '%s'", $feed['fid'], $title));
00795     }
00796     $item += array('AUTHOR' => '', 'DESCRIPTION' => '');
00797     aggregator_save_item(array('iid' => (isset($entry->iid) ? $entry->iid:  ''), 'fid' => $feed['fid'], 'timestamp' => $timestamp, 'title' => $title, 'link' => $link, 'author' => $item['AUTHOR'], 'description' => $item['DESCRIPTION'], 'guid' => $guid));
00798   }
00799
00800   // Remove all items that are older than flush item timer.
00801   $age = time() - variable_get('aggregator_clear', 9676800);
00802   $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
00803
00804   $items = array();
00805   $num_rows = FALSE;
00806   while ($item = db_fetch_object($result)) {
00807     $items[] = $item->iid;
00808     $num_rows = TRUE;
00809   }
00810   if ($num_rows) {
00811     db_query('DELETE FROM {aggregator_category_item} WHERE iid IN ('. implode(', ', $items) .')');
00812     db_query('DELETE FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
00813   }
00814
00815   return 1;
00816 }
00817
00824 function aggregator_save_item($edit) {
00825   if ($edit['iid'] && $edit['title']) {
00826     db_query("UPDATE {aggregator_item} SET title = '%s', link = '%s', author = '%s', description = '%s', guid = '%s', timestamp = %d WHERE iid = %d", $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['guid'], $edit['timestamp'], $edit['iid']);
00827   }
00828   else if ($edit['iid']) {
00829     db_query('DELETE FROM {aggregator_item} WHERE iid = %d', $edit['iid']);
00830     db_query('DELETE FROM {aggregator_category_item} WHERE iid = %d', $edit['iid']);
00831   }
00832   else if ($edit['title'] && $edit['link']) {
00833     db_query("INSERT INTO {aggregator_item} (fid, title, link, author, description, timestamp, guid) VALUES (%d, '%s', '%s', '%s', '%s', %d, '%s')", $edit['fid'], $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['timestamp'], $edit['guid']);
00834     $edit['iid'] = db_last_insert_id('aggregator_item', 'iid');
00835     // file the items in the categories indicated by the feed
00836     $categories = db_query('SELECT cid FROM {aggregator_category_feed} WHERE fid = %d', $edit['fid']);
00837     while ($category = db_fetch_object($categories)) {
00838       db_query('INSERT INTO {aggregator_category_item} (cid, iid) VALUES (%d, %d)', $category->cid, $edit['iid']);
00839     }
00840   }
00841 }
00842
00851 function aggregator_feed_load($fid) {
00852   static $feeds;
00853   if (!isset($feeds[$fid])) {
00854     $feeds[$fid] = db_fetch_array(db_query('SELECT * FROM {aggregator_feed} WHERE fid = %d', $fid));
00855   }
00856   return $feeds[$fid];
00857 }
00858
00867 function aggregator_category_load($cid) {
00868   static $categories;
00869   if (!isset($categories[$cid])) {
00870     $categories[$cid] = db_fetch_array(db_query('SELECT * FROM {aggregator_category} WHERE cid = %d', $cid));
00871   }
00872   return $categories[$cid];
00873 }
00874
00886 function theme_aggregator_block_item($item, $feed = 0) {
00887   global $user;
00888
00889   $output = '';
00890   if ($user->uid && module_exists('blog') && user_access('create blog entries')) {
00891     if ($image = theme('image', 'misc/blog.png', t('blog it'), t('blog it'))) {
00892       $output .= '<div class="icon">'. l($image, 'node/add/blog', array('attributes' => array('title' => t('Comment on this news item in your personal blog.'), 'class' => 'blog-it'), 'query' => "iid=$item->iid", 'html' => TRUE)) .'</div>';
00893     }
00894   }
00895
00896   // Display the external link to the item.
00897   $output .= '<a href="'. check_url($item->link) .'">'. check_plain($item->title) ."</a>\n";
00898
00899   return $output;
00900 }
00901
00910 function aggregator_filter_xss($value) {
00911   return filter_xss($value, preg_split('/\s+|<|>/', variable_get('aggregator_allowed_html_tags', '<a> <b> <br> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>'), -1, PREG_SPLIT_NO_EMPTY));
00912 }
00913
00922 function _aggregator_items($count) {
00923   return format_plural($count, '1 item', '@count items');
00924 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/aggregator/aggregator.pages.inc Source File

modules » aggregator

aggregator.pages.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: aggregator.pages.inc,v 1.12 2008/01/08 10:35:40 goba Exp $
00003
00015 function aggregator_page_last() {
00016   drupal_add_feed(url('aggregator/rss'), variable_get('site_name', 'Drupal') .' '. t('aggregator'));
00017
00018   $items = aggregator_feed_items_load('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_item} i INNER JOIN {aggregator_feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC');
00019
00020   return _aggregator_page_list($items, arg(1));
00021 }
00022
00035 function aggregator_page_source($arg1, $arg2 = NULL) {
00036   // If there are two arguments then this function is the categorize form, and
00037   // $arg1 is $form_state and $arg2 is $feed. Otherwise, $arg1 is $feed.
00038   $feed = is_array($arg2) ? $arg2 : $arg1;
00039   $feed = (object)$feed;
00040   drupal_set_title(check_plain($feed->title));
00041   $feed_source = theme('aggregator_feed_source', $feed);
00042
00043   // It is safe to include the fid in the query because it's loaded from the
00044   // database by aggregator_feed_load.
00045   $items = aggregator_feed_items_load('SELECT * FROM {aggregator_item} WHERE fid = '. $feed->fid .' ORDER BY timestamp DESC, iid DESC');
00046
00047   return _aggregator_page_list($items, arg(3), $feed_source);
00048 }
00049
00062 function aggregator_page_category($arg1, $arg2 = NULL) {
00063   drupal_set_breadcrumb(array_merge(drupal_get_breadcrumb(), array(l(t('Categories'), 'aggregator/categories'))));
00064   // If there are two arguments then we are called as a form, $arg1 is
00065   // $form_state and $arg2 is $category. Otherwise, $arg1 is $category.
00066   $category = is_array($arg2) ? $arg2 : $arg1;
00067
00068   drupal_add_feed(url('aggregator/rss/'. $category['cid']), variable_get('site_name', 'Drupal') .' '. t('aggregator - @title', array('@title' => $category['title'])));
00069
00070   // It is safe to include the cid in the query because it's loaded from the
00071   // database by aggregator_category_load.
00072   $items = aggregator_feed_items_load('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = '. $category['cid'] .' ORDER BY timestamp DESC, i.iid DESC');
00073
00074   return _aggregator_page_list($items, arg(3));
00075 }
00076
00085 function aggregator_feed_items_load($sql) {
00086   $items = array();
00087   if (isset($sql)) {
00088     $result = pager_query($sql, 20);
00089     while ($item = db_fetch_object($result)) {
00090       $result_category = db_query('SELECT c.title, c.cid FROM {aggregator_category_item} ci LEFT JOIN {aggregator_category} c ON ci.cid = c.cid WHERE ci.iid = %d ORDER BY c.title', $item->iid);
00091       $item->categories = array();
00092       while ($item_categories = db_fetch_object($result_category)) {
00093         $item->categories[] = $item_categories;
00094       }
00095       $items[$item->iid] = $item;
00096     }
00097   }
00098   return $items;
00099 }
00100
00115 function _aggregator_page_list($items, $op, $feed_source = '') {
00116   if (user_access('administer news feeds') && ($op == 'categorize')) {
00117     // Get form data.
00118     $output = aggregator_categorize_items($items, $feed_source);
00119   }
00120   else {
00121     // Assemble themed output.
00122     $output = $feed_source;
00123     foreach ($items as $item) {
00124       $output .= theme('aggregator_item', $item);
00125     }
00126     $output = theme('aggregator_wrapper', $output);
00127   }
00128   return $output;
00129 }
00130
00144 function aggregator_categorize_items($items, $feed_source = '') {
00145   $form['#submit'][] = 'aggregator_categorize_items_submit';
00146   $form['#validate'][] = 'aggregator_categorize_items_validate';
00147   $form['#theme'] = 'aggregator_categorize_items';
00148   $form['feed_source'] = array('#value' => $feed_source);
00149   $categories = array();
00150   $done = FALSE;
00151   $form['items'] = array();
00152   $form['categories'] = array('#tree' => TRUE);
00153   foreach ($items as $item) {
00154     $form['items'][$item->iid] = array('#value' => theme('aggregator_item', $item));
00155     $form['categories'][$item->iid] = array();
00156     $categories_result = db_query('SELECT c.cid, c.title, ci.iid FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid AND ci.iid = %d', $item->iid);
00157     $selected = array();
00158     while ($category = db_fetch_object($categories_result)) {
00159       if (!$done) {
00160         $categories[$category->cid] = check_plain($category->title);
00161       }
00162       if ($category->iid) {
00163         $selected[] = $category->cid;
00164       }
00165     }
00166     $done = TRUE;
00167     $form['categories'][$item->iid] = array(
00168       '#type' => variable_get('aggregator_category_selector', 'checkboxes'),
00169       '#default_value' => $selected,
00170       '#options' => $categories,
00171       '#size' => 10,
00172       '#multiple' => TRUE
00173     );
00174   }
00175   $form['submit'] = array('#type' => 'submit', '#value' => t('Save categories'));
00176
00177   return $form;
00178 }
00179
00183 function aggregator_categorize_items_validate($form, &$form_state) {
00184   if (!user_access('administer news feeds')) {
00185     form_error($form, t('You are not allowed to categorize this feed item.'));
00186   }
00187 }
00188
00192 function aggregator_categorize_items_submit($form, &$form_state) {
00193   if (!empty($form_state['values']['categories'])) {
00194     foreach ($form_state['values']['categories'] as $iid => $selection) {
00195       db_query('DELETE FROM {aggregator_category_item} WHERE iid = %d', $iid);
00196       foreach ($selection as $cid) {
00197         if ($cid) {
00198           db_query('INSERT INTO {aggregator_category_item} (cid, iid) VALUES (%d, %d)', $cid, $iid);
00199         }
00200       }
00201     }
00202   }
00203   drupal_set_message(t('The categories have been saved.'));
00204 }
00205
00215 function theme_aggregator_categorize_items($form) {
00216   $output = drupal_render($form['feed_source']);
00217   $rows = array();
00218   if ($form['items']) {
00219     foreach (element_children($form['items']) as $key) {
00220       if (is_array($form['items'][$key])) {
00221         $rows[] = array(
00222           drupal_render($form['items'][$key]),
00223           array('data' => drupal_render($form['categories'][$key]), 'class' => 'categorize-item'),
00224         );
00225       }
00226     }
00227   }
00228   $output .= theme('table', array('', t('Categorize')), $rows);
00229   $output .= drupal_render($form['submit']);
00230   $output .= drupal_render($form);
00231   return theme('aggregator_wrapper', $output);
00232 }
00233
00239 function template_preprocess_aggregator_wrapper(&$variables) {
00240   $variables['pager'] = theme('pager', NULL, 20, 0);
00241 }
00242
00248 function template_preprocess_aggregator_item(&$variables) {
00249   $item = $variables['item'];
00250
00251   $variables['feed_url'] = check_url($item->link);
00252   $variables['feed_title'] = check_plain($item->title);
00253   $variables['content'] = aggregator_filter_xss($item->description);
00254
00255   $variables['source_url'] = '';
00256   $variables['source_title'] = '';
00257   if (isset($item->ftitle) && isset($item->fid)) {
00258     $variables['source_url'] = url("aggregator/sources/$item->fid");
00259     $variables['source_title'] = check_plain($item->ftitle);
00260   }
00261   if (date('Ymd', $item->timestamp) == date('Ymd')) {
00262     $variables['source_date'] = t('%ago ago', array('%ago' => format_interval(time() - $item->timestamp)));
00263   }
00264   else {
00265     $variables['source_date'] = format_date($item->timestamp, 'custom', variable_get('date_format_medium', 'D, m/d/Y - H:i'));
00266   }
00267
00268   $variables['categories'] = array();
00269   foreach ($item->categories as $category) {
00270     $variables['categories'][$category->cid] = l($category->title, 'aggregator/categories/'. $category->cid);
00271   }
00272 }
00273
00277 function aggregator_page_sources() {
00278   $result = db_query('SELECT f.fid, f.title, f.description, f.image, MAX(i.timestamp) AS last FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY f.fid, f.title, f.description, f.image ORDER BY last DESC, f.title');
00279
00280   $output = '';
00281   while ($feed = db_fetch_object($result)) {
00282     // Most recent items:
00283     $summary_items = array();
00284     if (variable_get('aggregator_summary_items', 3)) {
00285       $items = db_query_range('SELECT i.title, i.timestamp, i.link FROM {aggregator_item} i WHERE i.fid = %d ORDER BY i.timestamp DESC', $feed->fid, 0, variable_get('aggregator_summary_items', 3));
00286       while ($item = db_fetch_object($items)) {
00287         $summary_items[] = theme('aggregator_summary_item', $item);
00288       }
00289     }
00290     $feed->url = url('aggregator/sources/'. $feed->fid);
00291     $output .= theme('aggregator_summary_items', $summary_items, $feed);
00292   }
00293   $output .= theme('feed_icon', url('aggregator/opml'), t('OPML feed'));
00294
00295   return theme('aggregator_wrapper', $output);
00296 }
00297
00301 function aggregator_page_categories() {
00302   $result = db_query('SELECT c.cid, c.title, c.description FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid LEFT JOIN {aggregator_item} i ON ci.iid = i.iid GROUP BY c.cid, c.title, c.description');
00303
00304   $output = '';
00305   while ($category = db_fetch_object($result)) {
00306     if (variable_get('aggregator_summary_items', 3)) {
00307       $summary_items = array();
00308       $items = db_query_range('SELECT i.title, i.timestamp, i.link, f.title as feed_title, f.link as feed_link FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON i.iid = ci.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE ci.cid = %d ORDER BY i.timestamp DESC', $category->cid, 0, variable_get('aggregator_summary_items', 3));
00309       while ($item = db_fetch_object($items)) {
00310         $summary_items[] = theme('aggregator_summary_item', $item);
00311       }
00312     }
00313     $category->url = url('aggregator/categories/'. $category->cid);
00314     $output .= theme('aggregator_summary_items', $summary_items, $category);
00315   }
00316
00317   return theme('aggregator_wrapper', $output);
00318 }
00319
00323 function aggregator_page_rss() {
00324   $result = NULL;
00325   // arg(2) is the passed cid, only select for that category
00326   if (arg(2)) {
00327     $category = db_fetch_object(db_query('SELECT cid, title FROM {aggregator_category} WHERE cid = %d', arg(2)));
00328     $sql = 'SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = %d ORDER BY timestamp DESC, i.iid DESC';
00329     $result = db_query_range($sql, $category->cid, 0, variable_get('feed_default_items', 10));
00330   }
00331   // or, get the default aggregator items
00332   else {
00333     $category = NULL;
00334     $sql = 'SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_item} i INNER JOIN {aggregator_feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC';
00335     $result = db_query_range($sql, 0, variable_get('feed_default_items', 10));
00336   }
00337
00338   $feeds = array();
00339   while ($item = db_fetch_object($result)) {
00340     $feeds[] = $item;
00341   }
00342   return theme('aggregator_page_rss', $feeds, $category);
00343 }
00344
00354 function theme_aggregator_page_rss($feeds, $category = NULL) {
00355   drupal_set_header('Content-Type: application/rss+xml; charset=utf-8');
00356
00357   $items = '';
00358   $feed_length = variable_get('feed_item_length', 'teaser');
00359   foreach ($feeds as $feed) {
00360     switch ($feed_length) {
00361       case 'teaser':
00362         $teaser = node_teaser($feed->description);
00363         if ($teaser != $feed->description) {
00364           $teaser .= '<p><a href="'. check_url($feed->link) .'">'. t('read more') ."</a></p>\n";
00365         }
00366         $feed->description = $teaser;
00367         break;
00368       case 'title':
00369         $feed->description = '';
00370         break;
00371     }
00372     $items .= format_rss_item($feed->ftitle .': '. $feed->title, $feed->link, $feed->description, array('pubDate' => date('r', $feed->timestamp)));
00373   }
00374
00375   $site_name = variable_get('site_name', 'Drupal');
00376   $url = url((isset($category) ? 'aggregator/categories/'. $category->cid : 'aggregator'), array('absolute' => TRUE));
00377   $description = isset($category) ? t('@site_name - aggregated feeds in category @title', array('@site_name' => $site_name, '@title' => $category->title)) : t('@site_name - aggregated feeds', array('@site_name' => $site_name));
00378
00379   $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
00380   $output .= "<rss version=\"2.0\">\n";
00381   $output .= format_rss_channel(t('@site_name aggregator', array('@site_name' => $site_name)), $url, $description, $items);
00382   $output .= "</rss>\n";
00383
00384   print $output;
00385 }
00386
00395 function aggregator_page_opml($cid = NULL) {
00396   if ($cid) {
00397     $result = db_query('SELECT f.title, f.url FROM {aggregator_feed} f LEFT JOIN {aggregator_category_feed} c on f.fid = c.fid WHERE c.cid = %d ORDER BY title', $cid);
00398   }
00399   else {
00400     $result = db_query('SELECT * FROM {aggregator_feed} ORDER BY title');
00401   }
00402
00403   $feeds = array();
00404   while ($item = db_fetch_object($result)) {
00405     $feeds[] = $item;
00406   }
00407
00408   return theme('aggregator_page_opml', $feeds);
00409 }
00410
00418 function theme_aggregator_page_opml($feeds) {
00419
00420   drupal_set_header('Content-Type: text/xml; charset=utf-8');
00421
00422   $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
00423   $output .= "<opml version=\"1.1\">\n";
00424   $output .= "<head>\n";
00425   $output .= '<title>'. check_plain(variable_get('site_name', 'Drupal')) ."</title>\n";
00426   $output .= '<dateModified>'. gmdate('r') ."</dateModified>\n";
00427   $output .= "</head>\n";
00428   $output .= "<body>\n";
00429   foreach ($feeds as $feed) {
00430     $output .= '<outline text="'. check_plain($feed->title) .'" xmlUrl="'. check_url($feed->url) ."\" />\n";
00431   }
00432   $output .= "</body>\n";
00433   $output .= "</opml>\n";
00434
00435   print $output;
00436 }
00437
00443 function template_preprocess_aggregator_summary_items(&$variables) {
00444   $variables['title'] = check_plain($variables['source']->title);
00445   $variables['summary_list'] = theme('item_list', $variables['summary_items']);
00446   $variables['source_url'] = $variables['source']->url;
00447 }
00448
00454 function template_preprocess_aggregator_summary_item(&$variables) {
00455   $item = $variables['item'];
00456
00457   $variables['feed_url'] = check_url($item->link);
00458   $variables['feed_title'] = check_plain($item->title);
00459   $variables['feed_age'] = t('%age old', array('%age' => format_interval(time() - $item->timestamp)));
00460
00461   $variables['source_url'] = '';
00462   $variables['source_title'] = '';
00463   if (!empty($item->feed_link)) {
00464     $variables['source_url'] = check_url($item->feed_link);
00465     $variables['source_title'] = check_plain($item->feed_title);
00466   }
00467 }
00468
00474 function template_preprocess_aggregator_feed_source(&$variables) {
00475   $feed = $variables['feed'];
00476
00477   $variables['source_icon'] = theme('feed_icon', $feed->url, t('!title feed', array('!title' => $feed->title)));
00478   $variables['source_image'] = $feed->image;
00479   $variables['source_description'] = aggregator_filter_xss($feed->description);
00480   $variables['source_url'] = check_url(url($feed->link, array('absolute' => TRUE)));
00481
00482   if ($feed->checked) {
00483     $variables['last_checked'] = t('@time ago', array('@time' => format_interval(time() - $feed->checked)));
00484   }
00485   else {
00486     $variables['last_checked'] = t('never');
00487   }
00488
00489   if (user_access('administer news feeds')) {
00490     $variables['last_checked'] = l($variables['last_checked'], 'admin/content/aggregator');
00491   }
00492 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/batch.inc Source File

includes

batch.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: batch.inc,v 1.14 2007/12/20 11:57:20 goba Exp $
00003
00012 function _batch_page() {
00013   $batch =& batch_get();
00014
00015   // Retrieve the current state of batch from db.
00016   if (isset($_REQUEST['id']) && $data = db_result(db_query("SELECT batch FROM {batch} WHERE bid = %d AND token = '%s'", $_REQUEST['id'], drupal_get_token($_REQUEST['id'])))) {
00017     $batch = unserialize($data);
00018   }
00019   else {
00020     return FALSE;
00021   }
00022
00023   // Register database update for end of processing.
00024   register_shutdown_function('_batch_shutdown');
00025
00026   $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
00027   $output = NULL;
00028   switch ($op) {
00029     case 'start':
00030       $output = _batch_start();
00031       break;
00032
00033     case 'do':
00034       // JS-version AJAX callback.
00035       _batch_do();
00036       break;
00037
00038     case 'do_nojs':
00039       // Non-JS progress page.
00040       $output = _batch_progress_page_nojs();
00041       break;
00042
00043     case 'finished':
00044       $output = _batch_finished();
00045       break;
00046   }
00047
00048   return $output;
00049 }
00050
00054 function _batch_start() {
00055   // Choose between the JS and non-JS version.
00056   // JS-enabled users are identified through the 'has_js' cookie set in drupal.js.
00057   // If the user did not visit any JS enabled page during his browser session,
00058   // he gets the non-JS version...
00059   if (isset($_COOKIE['has_js']) && $_COOKIE['has_js']) {
00060     return _batch_progress_page_js();
00061   }
00062   else {
00063     return _batch_progress_page_nojs();
00064   }
00065 }
00066
00070 function _batch_progress_page_js() {
00071   $batch = batch_get();
00072
00073   // The first batch set gets to set the page title
00074   // and the initialization and error messages.
00075   $current_set = _batch_current_set();
00076   drupal_set_title($current_set['title']);
00077   drupal_add_js('misc/progress.js', 'core', 'header', FALSE, FALSE);
00078
00079   $url = url($batch['url'], array('query' => array('id' => $batch['id'])));
00080   $js_setting = array(
00081     'batch' => array(
00082       'errorMessage' => $current_set['error_message'] .'<br/>'. $batch['error_message'],
00083       'initMessage' => $current_set['init_message'],
00084       'uri' => $url,
00085     ),
00086   );
00087   drupal_add_js($js_setting, 'setting');
00088   drupal_add_js('misc/batch.js', 'core', 'header', FALSE, FALSE);
00089
00090   $output = '<div id="progress"></div>';
00091   return $output;
00092 }
00093
00098 function _batch_do() {
00099   // HTTP POST required
00100   if ($_SERVER['REQUEST_METHOD'] != 'POST') {
00101     drupal_set_message(t('HTTP POST is required.'), 'error');
00102     drupal_set_title(t('Error'));
00103     return '';
00104   }
00105
00106   // Perform actual processing.
00107   list($percentage, $message) = _batch_process();
00108
00109   drupal_json(array('status' => TRUE, 'percentage' => $percentage, 'message' => $message));
00110 }
00111
00115 function _batch_progress_page_nojs() {
00116   $batch =& batch_get();
00117   $current_set = _batch_current_set();
00118
00119   drupal_set_title($current_set['title']);
00120
00121   $new_op = 'do_nojs';
00122
00123   if (!isset($batch['running'])) {
00124     // This is the first page so we return some output immediately.
00125     $percentage = 0;
00126     $message = $current_set['init_message'];
00127     $batch['running'] = TRUE;
00128   }
00129   else {
00130     // This is one of the later requests: do some processing first.
00131
00132     // Error handling: if PHP dies due to a fatal error (e.g. non-existant
00133     // function), it will output whatever is in the output buffer,
00134     // followed by the error message.
00135     ob_start();
00136     $fallback = $current_set['error_message'] .'<br/>'. $batch['error_message'];
00137     $fallback = theme('maintenance_page', $fallback, FALSE, FALSE);
00138
00139     // We strip the end of the page using a marker in the template, so any
00140     // additional HTML output by PHP shows up inside the page rather than
00141     // below it. While this causes invalid HTML, the same would be true if
00142     // we didn't, as content is not allowed to appear after </html> anyway.
00143     list($fallback) = explode('<!--partial-->', $fallback);
00144     print $fallback;
00145
00146     // Perform actual processing.
00147     list($percentage, $message) = _batch_process($batch);
00148     if ($percentage == 100) {
00149       $new_op = 'finished';
00150     }
00151
00152     // PHP did not die : remove the fallback output.
00153     ob_end_clean();
00154   }
00155
00156   $url = url($batch['url'], array('query' => array('id' => $batch['id'], 'op' => $new_op)));
00157   drupal_set_html_head('<meta http-equiv="Refresh" content="0; URL='. $url .'">');
00158   $output = theme('progress_bar', $percentage, $message);
00159   return $output;
00160 }
00161
00166 function _batch_process() {
00167   $batch =& batch_get();
00168   $current_set =& _batch_current_set();
00169   $set_changed = TRUE;
00170
00171   if ($batch['progressive']) {
00172     timer_start('batch_processing');
00173   }
00174
00175   while (!$current_set['success']) {
00176     // If this is the first time we iterate this batch set in the current
00177     // request, we check if it requires an additional file for functions
00178     // definitions.
00179     if ($set_changed && isset($current_set['file']) && is_file($current_set['file'])) {
00180       include_once($current_set['file']);
00181     }
00182
00183     $finished = 1;
00184     $task_message = '';
00185     if ((list($function, $args) = reset($current_set['operations'])) && function_exists($function)) {
00186       // Build the 'context' array, execute the function call,
00187       // and retrieve the user message.
00188       $batch_context = array('sandbox' => &$current_set['sandbox'], 'results' => &$current_set['results'], 'finished' => &$finished, 'message' => &$task_message);
00189       // Process the current operation.
00190       call_user_func_array($function, array_merge($args, array(&$batch_context)));
00191     }
00192
00193     if ($finished == 1) {
00194       // Make sure this step isn't counted double when computing $current.
00195       $finished = 0;
00196       // Remove the operation and clear the sandbox.
00197       array_shift($current_set['operations']);
00198       $current_set['sandbox'] = array();
00199     }
00200
00201     // If the batch set is completed, browse through the remaining sets,
00202     // executing 'control sets' (stored form submit handlers) along the way -
00203     // this might in turn insert new batch sets.
00204     // Stop when we find a set that actually has operations.
00205     $set_changed = FALSE;
00206     $old_set = $current_set;
00207     while (empty($current_set['operations']) && ($current_set['success'] = TRUE) && _batch_next_set()) {
00208       $current_set =& _batch_current_set();
00209       $set_changed = TRUE;
00210     }
00211     // At this point, either $current_set is a 'real' batch set (has operations),
00212     // or all sets have been completed.
00213
00214     // If we're in progressive mode, stop after 1 second.
00215     if ($batch['progressive'] && timer_read('batch_processing') > 1000) {
00216       break;
00217     }
00218   }
00219
00220   if ($batch['progressive']) {
00221     // Gather progress information.
00222
00223     // Reporting 100% progress will cause the whole batch to be considered
00224     // processed. If processing was paused right after moving to a new set,
00225     // we have to use the info from the new (unprocessed) one.
00226     if ($set_changed && isset($current_set['operations'])) {
00227       // Processing will continue with a fresh batch set.
00228       $remaining = count($current_set['operations']);
00229       $total = $current_set['total'];
00230       $progress_message = $current_set['init_message'];
00231       $task_message = '';
00232     }
00233     else {
00234       $remaining = count($old_set['operations']);
00235       $total = $old_set['total'];
00236       $progress_message = $old_set['progress_message'];
00237     }
00238
00239     $current    = $total - $remaining + $finished;
00240     $percentage = $total ? floor($current / $total * 100) : 100;
00241     $values = array(
00242       '@remaining'  => $remaining,
00243       '@total'      => $total,
00244       '@current'    => floor($current),
00245       '@percentage' => $percentage,
00246       );
00247     $message = strtr($progress_message, $values) .'<br/>';
00248     $message .= $task_message ? $task_message : '&nbsp';
00249
00250     return array($percentage, $message);
00251   }
00252   else {
00253     // If we're not in progressive mode, the whole batch has been processed by now.
00254     return _batch_finished();
00255   }
00256
00257 }
00258
00262 function &_batch_current_set() {
00263   $batch =& batch_get();
00264   return $batch['sets'][$batch['current_set']];
00265 }
00266
00272 function _batch_next_set() {
00273   $batch =& batch_get();
00274   if (isset($batch['sets'][$batch['current_set'] + 1])) {
00275     $batch['current_set']++;
00276     $current_set =& _batch_current_set();
00277     if (isset($current_set['form_submit']) && ($function = $current_set['form_submit']) && function_exists($function)) {
00278       // We use our stored copies of $form and $form_state, to account for
00279       // possible alteration by the submit handlers.
00280       $function($batch['form'], $batch['form_state']);
00281     }
00282     return TRUE;
00283   }
00284 }
00285
00291 function _batch_finished() {
00292   $batch =& batch_get();
00293
00294   // Execute the 'finished' callbacks for each batch set.
00295   foreach ($batch['sets'] as $key => $batch_set) {
00296     if (isset($batch_set['finished'])) {
00297       // Check if the set requires an additional file for functions definitions.
00298       if (isset($batch_set['file']) && is_file($batch_set['file'])) {
00299         include_once($batch_set['file']);
00300       }
00301       if (function_exists($batch_set['finished'])) {
00302         $batch_set['finished']($batch_set['success'], $batch_set['results'], $batch_set['operations']);
00303       }
00304     }
00305   }
00306
00307   // Cleanup the batch table and unset the global $batch variable.
00308   if ($batch['progressive']) {
00309     db_query("DELETE FROM {batch} WHERE bid = %d", $batch['id']);
00310   }
00311   $_batch = $batch;
00312   $batch = NULL;
00313
00314   // Redirect if needed.
00315   if ($_batch['progressive']) {
00316     // Put back the 'destination' that was saved in batch_process().
00317     if (isset($_batch['destination'])) {
00318       $_REQUEST['destination'] = $_batch['destination'];
00319     }
00320
00321     // Use $_batch['form_state']['redirect'], or $_batch['redirect'],
00322     // or $_batch['source_page'].
00323     if (isset($_batch['form_state']['redirect'])) {
00324       $redirect = $_batch['form_state']['redirect'];
00325     }
00326     elseif (isset($_batch['redirect'])) {
00327       $redirect = $_batch['redirect'];
00328     }
00329     else {
00330       $redirect = $_batch['source_page'];
00331     }
00332
00333     // Let drupal_redirect_form handle redirection logic.
00334     $form = isset($batch['form']) ? $batch['form'] : array();
00335     if (empty($_batch['form_state']['rebuild']) && empty($_batch['form_state']['storage'])) {
00336       drupal_redirect_form($form, $redirect);
00337     }
00338
00339     // We get here if $form['#redirect'] was FALSE, or if the form is a
00340     // multi-step form. We save the final $form_state value to be retrieved
00341     // by drupal_get_form, and we redirect to the originating page.
00342     $_SESSION['batch_form_state'] = $_batch['form_state'];
00343     drupal_goto($_batch['source_page']);
00344   }
00345 }
00346
00351 function _batch_shutdown() {
00352   if ($batch = batch_get()) {
00353     db_query("UPDATE {batch} SET batch = '%s' WHERE bid = %d", serialize($batch), $batch['id']);
00354   }
00355 }
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/batch_example.install Source File

docs » examples

batch_example.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: batch_example.install,v 1.3 2007/10/05 16:11:36 drewish Exp $
00003
00004 /*
00005  * Example of multipart update function.
00006  * The only difference with pre-Drupal 6 multipart updates is the existence
00007  * of the $sandbox param, which provides a cleaner and safer way to store progression
00008  * than the previous use of $_SESSION-sored custom values.
00009  *
00010  * This dummy 'udpate' function does nothing harmful, simply
00011  * loads each node...
00012  */
00013 function batch_test_update_1(&$sandbox) {
00014   $ret = array();
00015
00016   // Use the sandbox at your convenience to store the information needed
00017   // to track progression between successive calls to the function.
00018   if (!isset($sandbox['progress'])) {
00019     $sandbox['progress'] = 0;
00020     $sandbox['curr_node'] = 0;
00021     $sandbox['max'] = db_result(db_query('SELECT COUNT(DISTINCT nid) FROM {node}'));
00022   }
00023
00024   // Process nodes by groups of 5 (arbitrary value).
00025   // When a group of five is processed, the batch update engine determines
00026   // whether it should continue processing in the same request or provide
00027   // progress feedback to the user and wait for the next request.
00028   $limit = 5;
00029
00030   // Retrieve the next group of nids.
00031   $result = db_query_range("SELECT nid FROM {node} WHERE nid > %d ORDER BY nid ASC", $sandbox['curr_node'], 0, $limit);
00032   while ($row = db_fetch_array($result)) {
00033     // Here we actually perform our dummy 'update' on the current node.
00034     $ret[] = update_sql('SELECT * FROM {node} WHERE nid = '. $row['nid']);
00035
00036     // Update our progress information.
00037     $sandbox['progress']++;
00038     $sandbox['curr_node'] = $row['nid'];
00039   }
00040
00041   // Inform the batch update engine that we are not finished,
00042   // and provide an estimation of the completion level we reached.
00043   if ($sandbox['progress'] != $sandbox['max']) {
00044     $ret['#finished'] = $sandbox['progress'] / $sandbox['max'];
00045   }
00046   return $ret;
00047 }
00048
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/batch_example.module Source File

docs » examples

batch_example.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: batch_example.module,v 1.3 2007/10/05 16:11:36 drewish Exp $
00003
00033 function batch_example_menu() {
00034   $items = array();
00035   $items['batch_example'] = array(
00036     'title' => 'Batch example',
00037     'page callback' => 'drupal_get_form',
00038     'page arguments' => array('batch_example_simple_form'),
00039     'access callback' => TRUE,
00040   );
00041   $items['batch_example/example_1'] = array(
00042     'title' => 'Simple form',
00043     'type' => MENU_DEFAULT_LOCAL_TASK,
00044     'weight' => 0,
00045   );
00046   $items['batch_example/example_2'] = array(
00047     'title' => 'Multistep form',
00048     'page callback' => 'drupal_get_form',
00049     'page arguments' => array('batch_example_multistep_form'),
00050     'access callback' => TRUE,
00051     'type' => MENU_LOCAL_TASK,
00052     'weight' => 1,
00053   );
00054   $items['batch_example/example_3'] = array(
00055     'title' => 'No form',
00056     'page callback' => 'batch_example_page',
00057     'access callback' => TRUE,
00058     'type' => MENU_LOCAL_TASK,
00059     'weight' => 2,
00060   );
00061   return $items;
00062 }
00063
00068 function batch_example_simple_form() {
00069   $form['batch'] = array(
00070     '#type' => 'select',
00071     '#title' => 'Choose batch',
00072     '#options' => array(
00073       'batch_1' => 'batch 1 - load a node 100 times',
00074       'batch_2' => 'batch 2 - load all nodes, 20 times')
00075   );
00076   $form['submit'] = array(
00077     '#type' => 'submit',
00078     '#value' => 'Go',
00079   );
00080
00081   return $form;
00082 }
00083
00084 function batch_example_simple_form_submit($form, &$form_state) {
00085   $values =& $form_state['values'];
00086
00087   $function = 'batch_example_'. $values['batch'];
00088   $batch = $function();
00089   batch_set($batch);
00090
00091   // Redirection takes place as usual.
00092   $form_state['redirect'] = 'batch_example/example_2';
00093 }
00094
00095
00099 function batch_example_multistep_form($form_state = NULL) {
00100   $step = isset($form_state['storage']['step']) ? $form_state['storage']['step'] : 1;
00101
00102   $form['step_display'] = array(
00103     '#type' => 'item',
00104     '#value' => 'step '. $step,
00105   );
00106
00107   if ($step < 3) {
00108     $form['submit'] = array(
00109       '#type' => 'submit',
00110       '#value' => 'Go',
00111     );
00112   }
00113
00114   return $form;
00115 }
00116
00117 function batch_example_multistep_form_submit($form, &$form_state) {
00118   $step = isset($form_state['storage']['step']) ? $form_state['storage']['step'] : 1;
00119
00120   switch ($step) {
00121     case 1:
00122       drupal_set_message('step 1 submitted');
00123       batch_set(batch_example_batch_1());
00124       break;
00125     case 2:
00126       drupal_set_message('step 2 submitted');
00127       batch_set(batch_example_batch_2());
00128       // this does not seem to work ?
00129       $form_state['redirect'] = 'batch_example/example_3';
00130       break;
00131   }
00132
00133   $form_state['storage']['step'] = $step + 1;
00134 }
00135
00136 function batch_example_page() {
00137   batch_set(batch_example_batch_1());
00138
00139   // We're not inside a form submission workflow, so we have to manually
00140   // trigger the batch processing - this issues a drupal_goto and thus ends
00141   // current request.
00142   // We also specify here where we want to redirect after batch processing.
00143   batch_process('batch_example/example_1');
00144 }
00145
00146
00147
00157 function batch_example_batch_1() {
00158   $nid = db_result(db_query_range("SELECT nid FROM {node} ORDER BY nid ASC", 0, 1));
00159
00160   $operations = array();
00161   for ($i = 0; $i<100; $i++) {
00162     $operations[] = array('batch_example_op_1', array($nid));
00163   }
00164   $batch = array(
00165     'operations' => $operations,
00166     'finished' => 'batch_example_finished',
00167   );
00168   return $batch;
00169 }
00170
00174 function batch_example_op_1($nid, &$context) {
00175   $node = node_load($nid, NULL, TRUE);
00176
00177   // Store some result for post-processing in the finished callback.
00178   $context['results'][] = $node->nid .' : '. $node->title;
00179
00180   // Optional message displayed under the progressbar.
00181   $context['message'] = 'Loading '. $node->title;
00182 }
00183
00187 function batch_example_batch_2() {
00188   $operations = array();
00189   for ($i = 0; $i<20; $i++) {
00190     $operations[] = array('batch_example_op_2', array());
00191   }
00192   $batch = array(
00193     'operations' => $operations,
00194     'finished' => 'batch_example_finished',
00195     // We can define custom messages instead of the default ones.
00196     'title' => t('Processing batch 2'),
00197     'init_message' => t('Batch 2 is starting.'),
00198     'progress_message' => t('Processed @current out of @total.'),
00199     'error_message' => t('Batch 1 has encountered an error.'),
00200   );
00201   return $batch;
00202 }
00203
00208 function batch_example_op_2(&$context) {
00209   // Use the $context['sandbox'] at your convenience to store the
00210   // information needed to track progression between successive calls.
00211   if (!isset($context['sandbox']['progress'])) {
00212     $context['sandbox']['progress'] = 0;
00213     $context['sandbox']['current_node'] = 0;
00214     $context['sandbox']['max'] = db_result(db_query('SELECT COUNT(DISTINCT nid) FROM {node}'));
00215   }
00216
00217   // Process nodes by groups of 5 (arbitrary value).
00218   // When a group of five is processed, the batch update engine determines
00219   // whether it should continue processing in the same request or provide
00220   // progress feedback to the user and wait for the next request.
00221   $limit = 5;
00222
00223   // Retrieve the next group of nids.
00224   $result = db_query_range("SELECT nid FROM {node} WHERE nid > %d ORDER BY nid ASC", $context['sandbox']['current_node'], 0, $limit);
00225   while ($row = db_fetch_array($result)) {
00226     // Here we actually perform our dummy 'processing' on the current node.
00227     $node = node_load($row['nid'], NULL, TRUE);
00228
00229     // Store some result for post-processing in the finished callback.
00230     $context['results'][] = $node->nid .' : '. $node->title;
00231
00232     // Update our progress information.
00233     $context['sandbox']['progress']++;
00234     $context['sandbox']['current_node'] = $node->nid;
00235     $context['message'] = $node->title;
00236   }
00237
00238   // Inform the batch engine that we are not finished,
00239   // and provide an estimation of the completion level we reached.
00240   if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
00241     $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
00242   }
00243 }
00244
00248 function batch_example_finished($success, $results, $operations) {
00249   if ($success) {
00250     // Here we could do something meaningful with the results.
00251     // We just display the number of nodes we processed...
00252     $message = count($results) .' processed.';
00253   }
00254   else {
00255     // An error occurred.
00256     // $operations contains the operations that remained unprocessed.
00257     $error_operation = reset($operations);
00258     $message = 'An error occurred while processing '. $error_operation[0] .' with arguments :'. print_r($error_operation[0], TRUE);
00259   }
00260   drupal_set_message($message);
00261 }
00262
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/block/block-admin-display-form.tpl.php Source File

modules » block

block-admin-display-form.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: block-admin-display-form.tpl.php,v 1.3 2008/01/16 22:57:26 goba Exp $
00003
00028 ?>
00029 <?php
00030   // Add table javascript.
00031   drupal_add_js('misc/tableheader.js');
00032   drupal_add_js(drupal_get_path('module', 'block') .'/block.js');
00033   foreach ($block_regions as $region => $title) {
00034     drupal_add_tabledrag('blocks', 'match', 'sibling', 'block-region-select', 'block-region-'. $region, NULL, FALSE);
00035     drupal_add_tabledrag('blocks', 'order', 'sibling', 'block-weight', 'block-weight-'. $region);
00036   }
00037 ?>
00038 <table id="blocks" class="sticky-enabled">
00039   <thead>
00040     <tr>
00041       <th><?php print t('Block'); ?></th>
00042       <th><?php print t('Region'); ?></th>
00043       <th><?php print t('Weight'); ?></th>
00044       <?php if ($throttle): ?>
00045         <th><?php print t('Throttle'); ?></th>
00046       <?php endif; ?>
00047       <th colspan="2"><?php print t('Operations'); ?></th>
00048     </tr>
00049   </thead>
00050   <tbody>
00051     <?php $row = 0; ?>
00052     <?php foreach ($block_regions as $region => $title): ?>
00053       <tr class="region region-<?php print $region?>">
00054         <td colspan="<?php print $throttle ? '6' : '5'; ?>" class="region"><?php print $title; ?></td>
00055       </tr>
00056       <tr class="region-message region-<?php print $region?>-message <?php print empty($block_listing[$region]) ? 'region-empty' : 'region-populated'; ?>">
00057         <td colspan="<?php print $throttle ? '6' : '5'; ?>"><em><?php print t('No blocks in this region'); ?></em></td>
00058       </tr>
00059       <?php foreach ($block_listing[$region] as $delta => $data): ?>
00060       <tr class="draggable <?php print $row % 2 == 0 ? 'odd' : 'even'; ?><?php print $data->row_class ? ' '. $data->row_class : ''; ?>">
00061         <td class="block"><?php print $data->block_title; ?></td>
00062         <td><?php print $data->region_select; ?></td>
00063         <td><?php print $data->weight_select; ?></td>
00064         <?php if ($throttle): ?>
00065           <td><?php print $data->throttle_check; ?></td>
00066         <?php endif; ?>
00067         <td><?php print $data->configure_link; ?></td>
00068         <td><?php print $data->delete_link; ?></td>
00069       </tr>
00070       <?php $row++; ?>
00071       <?php endforeach; ?>
00072     <?php endforeach; ?>
00073   </tbody>
00074 </table>
00075
00076 <?php print $form_submit; ?>
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/block/block.admin.inc Source File

modules » block

block.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: block.admin.inc,v 1.14 2007/12/22 23:24:24 goba Exp $
00003
00012 function block_admin_display($theme = NULL) {
00013   global $custom_theme;
00014
00015   // If non-default theme configuration has been selected, set the custom theme.
00016   $custom_theme = isset($theme) ? $theme : variable_get('theme_default', 'garland');
00017
00018   // Fetch and sort blocks
00019   $blocks = _block_rehash();
00020   usort($blocks, '_block_compare');
00021
00022   return drupal_get_form('block_admin_display_form', $blocks, $theme);
00023 }
00024
00028 function block_admin_display_form(&$form_state, $blocks, $theme = NULL) {
00029   global $theme_key, $custom_theme;
00030
00031   // Add CSS
00032   drupal_add_css(drupal_get_path('module', 'block') .'/block.css', 'module', 'all', FALSE);
00033
00034   // If non-default theme configuration has been selected, set the custom theme.
00035   $custom_theme = isset($theme) ? $theme : variable_get('theme_default', 'garland');
00036   init_theme();
00037
00038   $throttle = module_exists('throttle');
00039   $block_regions = system_region_list($theme_key) + array(BLOCK_REGION_NONE => '<'. t('none') .'>');
00040
00041   // Build form tree
00042   $form = array(
00043     '#action' => arg(3) ? url('admin/build/block/list/'. $theme_key) : url('admin/build/block'),
00044     '#tree' => TRUE,
00045   );
00046
00047   foreach ($blocks as $i => $block) {
00048     $key = $block['module'] .'_'. $block['delta'];
00049     $form[$key]['module'] = array(
00050       '#type' => 'value',
00051       '#value' => $block['module'],
00052     );
00053     $form[$key]['delta'] = array(
00054       '#type' => 'value',
00055       '#value' => $block['delta'],
00056     );
00057     $form[$key]['info'] = array(
00058       '#value' => check_plain($block['info'])
00059     );
00060     $form[$key]['theme'] = array(
00061       '#type' => 'hidden',
00062       '#value' => $theme_key
00063     );
00064     $form[$key]['weight'] = array(
00065       '#type' => 'weight',
00066       '#default_value' => $block['weight'],
00067     );
00068     $form[$key]['region'] = array(
00069       '#type' => 'select',
00070       '#default_value' => $block['region'],
00071       '#options' => $block_regions,
00072     );
00073
00074     if ($throttle) {
00075       $form[$key]['throttle'] = array('#type' => 'checkbox', '#default_value' => isset($block['throttle']) ? $block['throttle'] : FALSE);
00076     }
00077     $form[$key]['configure'] = array('#value' => l(t('configure'), 'admin/build/block/configure/'. $block['module'] .'/'. $block['delta']));
00078     if ($block['module'] == 'block') {
00079       $form[$key]['delete'] = array('#value' => l(t('delete'), 'admin/build/block/delete/'. $block['delta']));
00080     }
00081   }
00082
00083   $form['submit'] = array(
00084     '#type' => 'submit',
00085     '#value' => t('Save blocks'),
00086   );
00087
00088   return $form;
00089 }
00090
00094 function block_admin_display_form_submit($form, &$form_state) {
00095   foreach ($form_state['values'] as $block) {
00096     $block['status'] = $block['region'] != BLOCK_REGION_NONE;
00097     $block['region'] = $block['status'] ? $block['region'] : '';
00098     db_query("UPDATE {blocks} SET status = %d, weight = %d, region = '%s', throttle = %d WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $block['status'], $block['weight'], $block['region'], isset($block['throttle']) ? $block['throttle'] : 0, $block['module'], $block['delta'], $block['theme']);
00099   }
00100   drupal_set_message(t('The block settings have been updated.'));
00101   cache_clear_all();
00102 }
00103
00110 function _block_compare($a, $b) {
00111   global $theme_key;
00112   static $regions;
00113
00114   // We need the region list to correctly order by region.
00115   if (!isset($regions)) {
00116     $regions = array_flip(array_keys(system_region_list($theme_key)));
00117     $regions[BLOCK_REGION_NONE] = count($regions);
00118   }
00119
00120   // Separate enabled from disabled.
00121   $status = $b['status'] - $a['status'];
00122   if ($status) {
00123     return $status;
00124   }
00125   // Sort by region (in the order defined by theme .info file).
00126   $place = $regions[$a['region']] - $regions[$b['region']];
00127   if ($place) {
00128     return $place;
00129   }
00130   // Sort by weight.
00131   $weight = $a['weight'] - $b['weight'];
00132   if ($weight) {
00133     return $weight;
00134   }
00135   // Sort by title.
00136   return strcmp($a['info'], $b['info']);
00137 }
00138
00142 function block_admin_configure(&$form_state, $module = NULL, $delta = 0) {
00143
00144   $form['module'] = array('#type' => 'value', '#value' => $module);
00145   $form['delta'] = array('#type' => 'value', '#value' => $delta);
00146
00147   $edit = db_fetch_array(db_query("SELECT pages, visibility, custom, title FROM {blocks} WHERE module = '%s' AND delta = '%s'", $module, $delta));
00148
00149   $form['block_settings'] = array(
00150     '#type' => 'fieldset',
00151     '#title' => t('Block specific settings'),
00152     '#collapsible' => TRUE,
00153   );
00154   $form['block_settings']['title'] = array(
00155     '#type' => 'textfield',
00156     '#title' => t('Block title'),
00157     '#maxlength' => 64,
00158     '#description' => $module == 'block' ? t('The title of the block as shown to the user.') : t('Override the default title for the block. Use <em>&lt;none&gt;</em> to display no title, or leave blank to use the default block title.'),
00159     '#default_value' => $edit['title'],
00160     '#weight' => -18,
00161   );
00162
00163
00164   // Module-specific block configurations.
00165   if ($settings = module_invoke($module, 'block', 'configure', $delta)) {
00166     foreach ($settings as $k => $v) {
00167       $form['block_settings'][$k] = $v;
00168     }
00169   }
00170
00171   // Get the block subject for the page title.
00172   $info = module_invoke($module, 'block', 'list');
00173   if (isset($info[$delta])) {
00174     drupal_set_title(t("'%name' block", array('%name' => $info[$delta]['info'])));
00175   }
00176
00177   // Standard block configurations.
00178   $form['user_vis_settings'] = array(
00179     '#type' => 'fieldset',
00180     '#title' => t('User specific visibility settings'),
00181     '#collapsible' => TRUE,
00182   );
00183   $form['user_vis_settings']['custom'] = array(
00184     '#type' => 'radios',
00185     '#title' => t('Custom visibility settings'),
00186     '#options' => array(
00187       t('Users cannot control whether or not they see this block.'),
00188       t('Show this block by default, but let individual users hide it.'),
00189       t('Hide this block by default but let individual users show it.')
00190     ),
00191     '#description' => t('Allow individual users to customize the visibility of this block in their account settings.'),
00192     '#default_value' => $edit['custom'],
00193   );
00194
00195   // Role-based visibility settings
00196   $default_role_options = array();
00197   $result = db_query("SELECT rid FROM {blocks_roles} WHERE module = '%s' AND delta = '%s'", $module, $delta);
00198   while ($role = db_fetch_object($result)) {
00199     $default_role_options[] = $role->rid;
00200   }
00201   $result = db_query('SELECT rid, name FROM {role} ORDER BY name');
00202   $role_options = array();
00203   while ($role = db_fetch_object($result)) {
00204     $role_options[$role->rid] = $role->name;
00205   }
00206   $form['role_vis_settings'] = array(
00207     '#type' => 'fieldset',
00208     '#title' => t('Role specific visibility settings'),
00209     '#collapsible' => TRUE,
00210   );
00211   $form['role_vis_settings']['roles'] = array(
00212     '#type' => 'checkboxes',
00213     '#title' => t('Show block for specific roles'),
00214     '#default_value' => $default_role_options,
00215     '#options' => $role_options,
00216     '#description' => t('Show this block only for the selected role(s). If you select no roles, the block will be visible to all users.'),
00217   );
00218
00219   $form['page_vis_settings'] = array(
00220     '#type' => 'fieldset',
00221     '#title' => t('Page specific visibility settings'),
00222     '#collapsible' => TRUE,
00223   );
00224   $access = user_access('use PHP for block visibility');
00225
00226   if ($edit['visibility'] == 2 && !$access) {
00227     $form['page_vis_settings'] = array();
00228     $form['page_vis_settings']['visibility'] = array('#type' => 'value', '#value' => 2);
00229     $form['page_vis_settings']['pages'] = array('#type' => 'value', '#value' => $edit['pages']);
00230   }
00231   else {
00232     $options = array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.'));
00233     $description = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>'));
00234
00235     if ($access) {
00236       $options[] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
00237       $description .= ' '. t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '<?php ?>'));
00238     }
00239     $form['page_vis_settings']['visibility'] = array(
00240       '#type' => 'radios',
00241       '#title' => t('Show block on specific pages'),
00242       '#options' => $options,
00243       '#default_value' => $edit['visibility'],
00244     );
00245     $form['page_vis_settings']['pages'] = array(
00246       '#type' => 'textarea',
00247       '#title' => t('Pages'),
00248       '#default_value' => $edit['pages'],
00249       '#description' => $description,
00250     );
00251   }
00252
00253   $form['submit'] = array(
00254     '#type' => 'submit',
00255     '#value' => t('Save block'),
00256   );
00257
00258   return $form;
00259 }
00260
00261 function block_admin_configure_validate($form, &$form_state) {
00262   if ($form_state['values']['module'] == 'block') {
00263     if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM {boxes} WHERE bid != %d AND info = '%s'", $form_state['values']['delta'], $form_state['values']['info']))) {
00264       form_set_error('info', t('Please ensure that each block description is unique.'));
00265     }
00266   }
00267 }
00268
00269 function block_admin_configure_submit($form, &$form_state) {
00270   if (!form_get_errors()) {
00271     db_query("UPDATE {blocks} SET visibility = %d, pages = '%s', custom = %d, title = '%s' WHERE module = '%s' AND delta = '%s'", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $form_state['values']['delta']);
00272     db_query("DELETE FROM {blocks_roles} WHERE module = '%s' AND delta = '%s'", $form_state['values']['module'], $form_state['values']['delta']);
00273     foreach (array_filter($form_state['values']['roles']) as $rid) {
00274       db_query("INSERT INTO {blocks_roles} (rid, module, delta) VALUES (%d, '%s', '%s')", $rid, $form_state['values']['module'], $form_state['values']['delta']);
00275     }
00276     module_invoke($form_state['values']['module'], 'block', 'save', $form_state['values']['delta'], $form_state['values']);
00277     drupal_set_message(t('The block configuration has been saved.'));
00278     cache_clear_all();
00279     $form_state['redirect'] = 'admin/build/block';
00280     return;
00281   }
00282 }
00283
00287 function block_add_block_form(&$form_state) {
00288   return block_admin_configure($form_state, 'block', NULL);
00289 }
00290
00291 function block_add_block_form_validate($form, &$form_state) {
00292   if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM {boxes} WHERE info = '%s'", $form_state['values']['info']))) {
00293     form_set_error('info', t('Please ensure that each block description is unique.'));
00294   }
00295 }
00296
00300 function block_add_block_form_submit($form, &$form_state) {
00301   db_query("INSERT INTO {boxes} (body, info, format) VALUES ('%s', '%s', %d)", $form_state['values']['body'], $form_state['values']['info'], $form_state['values']['format']);
00302   $delta = db_last_insert_id('boxes', 'bid');
00303
00304   foreach (list_themes() as $key => $theme) {
00305     if ($theme->status) {
00306       db_query("INSERT INTO {blocks} (visibility, pages, custom, title, module, theme, status, weight, delta, cache) VALUES(%d, '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d)", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $theme->name, 0, 0, $delta, BLOCK_NO_CACHE);
00307     }
00308   }
00309
00310   foreach (array_filter($form_state['values']['roles']) as $rid) {
00311     db_query("INSERT INTO {blocks_roles} (rid, module, delta) VALUES (%d, '%s', '%s')", $rid, $form_state['values']['module'], $delta);
00312   }
00313
00314   drupal_set_message(t('The block has been created.'));
00315   cache_clear_all();
00316
00317   $form_state['redirect'] = 'admin/build/block';
00318   return;
00319 }
00320
00324 function block_box_delete(&$form_state, $bid = 0) {
00325   $box = block_box_get($bid);
00326   $form['info'] = array('#type' => 'hidden', '#value' => $box['info'] ? $box['info'] : $box['title']);
00327   $form['bid'] = array('#type' => 'hidden', '#value' => $bid);
00328
00329   return confirm_form($form, t('Are you sure you want to delete the block %name?', array('%name' => $box['info'])), 'admin/build/block', '', t('Delete'), t('Cancel'));
00330 }
00331
00335 function block_box_delete_submit($form, &$form_state) {
00336   db_query('DELETE FROM {boxes} WHERE bid = %d', $form_state['values']['bid']);
00337   db_query("DELETE FROM {blocks} WHERE module = 'block' AND delta = %d", $form_state['values']['bid']);
00338   drupal_set_message(t('The block %name has been removed.', array('%name' => $form_state['values']['info'])));
00339   cache_clear_all();
00340   $form_state['redirect'] = 'admin/build/block';
00341   return;
00342 }
00343
00353 function template_preprocess_block_admin_display_form(&$variables) {
00354   global $theme_key;
00355
00356   $block_regions = system_region_list($theme_key);
00357   $variables['throttle'] = module_exists('throttle');
00358   $variables['block_regions'] = $block_regions + array(BLOCK_REGION_NONE => t('Disabled'));
00359
00360   foreach ($block_regions as $key => $value) {
00361     // Highlight regions on page to provide visual reference.
00362     drupal_set_content($key, '<div class="block-region">'. $value .'</div>');
00363     // Initialize an empty array for the region.
00364     $variables['block_listing'][$key] = array();
00365   }
00366
00367   // Initialize disabled blocks array.
00368   $variables['block_listing'][BLOCK_REGION_NONE] = array();
00369
00370   // Set up to track previous region in loop.
00371   $last_region = '';
00372   foreach (element_children($variables['form']) as $i) {
00373     $block = &$variables['form'][$i];
00374
00375     // Only take form elements that are blocks.
00376     if (isset($block['info'])) {
00377       // Fetch region for current block.
00378       $region = $block['region']['#default_value'];
00379
00380       // Set special classes needed for table drag and drop.
00381       $variables['form'][$i]['region']['#attributes']['class'] = 'block-region-select block-region-'. $region;
00382       $variables['form'][$i]['weight']['#attributes']['class'] = 'block-weight block-weight-'. $region;
00383
00384       $variables['block_listing'][$region][$i]->row_class = isset($block['#attributes']['class']) ? $block['#attributes']['class'] : '';
00385       $variables['block_listing'][$region][$i]->block_modified = isset($block['#attributes']['class']) && strpos($block['#attributes']['class'], 'block-modified') !== FALSE ? TRUE : FALSE;
00386       $variables['block_listing'][$region][$i]->block_title =  drupal_render($block['info']);
00387       $variables['block_listing'][$region][$i]->region_select = drupal_render($block['region']) . drupal_render($block['theme']);
00388       $variables['block_listing'][$region][$i]->weight_select = drupal_render($block['weight']);
00389       $variables['block_listing'][$region][$i]->throttle_check = $variables['throttle'] ? drupal_render($block['throttle']) : '';
00390       $variables['block_listing'][$region][$i]->configure_link = drupal_render($block['configure']);
00391       $variables['block_listing'][$region][$i]->delete_link = !empty($block['delete']) ? drupal_render($block['delete']) : '';
00392       $variables['block_listing'][$region][$i]->printed = FALSE;
00393
00394       $last_region = $region;
00395     }
00396   }
00397
00398   $variables['form_submit'] = drupal_render($variables['form']);
00399 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/block/block.install Source File

modules » block

block.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: block.install,v 1.8 2007/12/18 12:59:20 dries Exp $
00003
00007 function block_schema() {
00008   $schema['blocks'] = array(
00009     'description' => t('Stores block settings, such as region and visibility settings.'),
00010     'fields' => array(
00011       'bid' => array(
00012         'type' => 'serial',
00013         'not null' => TRUE,
00014         'description' => t('Primary Key: Unique block ID.'),
00015       ),
00016       'module' => array(
00017         'type' => 'varchar',
00018         'length' => 64,
00019         'not null' => TRUE,
00020         'default' => '',
00021         'description' => t("The module from which the block originates; for example, 'user' for the Who's Online block, and 'block' for any custom blocks."),
00022       ),
00023       'delta' => array(
00024         'type' => 'varchar',
00025         'length' => 32,
00026         'not null' => TRUE,
00027         'default' => '0',
00028         'description' => t('Unique ID for block within a module.'),
00029       ),
00030       'theme' => array(
00031         'type' => 'varchar',
00032         'length' => 64,
00033         'not null' => TRUE,
00034         'default' => '',
00035         'description' => t('The theme under which the block settings apply.'),
00036       ),
00037       'status' => array(
00038         'type' => 'int',
00039         'not null' => TRUE,
00040         'default' => 0,
00041         'size' => 'tiny',
00042         'description' => t('Block enabled status. (1 = enabled, 0 = disabled)'),
00043       ),
00044       'weight' => array(
00045         'type' => 'int',
00046         'not null' => TRUE,
00047         'default' => 0,
00048         'size' => 'tiny',
00049         'description' => t('Block weight within region.'),
00050       ),
00051       'region' => array(
00052         'type' => 'varchar',
00053         'length' => 64,
00054         'not null' => TRUE,
00055         'default' => '',
00056         'description' => t('Theme region within which the block is set.'),
00057       ),
00058       'custom' => array(
00059         'type' => 'int',
00060         'not null' => TRUE,
00061         'default' => 0,
00062         'size' => 'tiny',
00063         'description' => t('Flag to indicate how users may control visibility of the block. (0 = Users cannot control, 1 = On by default, but can be hidden, 2 = Hidden by default, but can be shown)'),
00064       ),
00065       'throttle' => array(
00066         'type' => 'int',
00067         'not null' => TRUE,
00068         'default' => 0,
00069         'size' => 'tiny',
00070         'description' => t('Flag to indicate whether or not to remove block when website traffic is high. (1 = throttle, 0 = do not throttle)'),
00071       ),
00072       'visibility' => array(
00073         'type' => 'int',
00074         'not null' => TRUE,
00075         'default' => 0,
00076         'size' => 'tiny',
00077         'description' => t('Flag to indicate how to show blocks on pages. (0 = Show on all pages except listed pages, 1 = Show only on listed pages, 2 = Use custom PHP code to determine visibility)'),
00078       ),
00079       'pages' => array(
00080         'type' => 'text',
00081         'not null' => TRUE,
00082         'description' => t('Contents of the "Pages" block; contains either a list of paths on which to include/exclude the block or PHP code, depending on "visibility" setting.'),
00083       ),
00084       'title' => array(
00085         'type' => 'varchar',
00086         'length' => 64,
00087         'not null' => TRUE,
00088         'default' => '',
00089         'description' => t('Custom title for the block. (Empty string will use block default title, <none> will remove the title, text will cause block to use specified title.)'),
00090       ),
00091       'cache' => array(
00092         'type' => 'int',
00093         'not null' => TRUE,
00094         'default' => 1,
00095         'size' => 'tiny',
00096         'description' => t('Binary flag to indicate block cache mode. (-1: Do not cache, 1: Cache per role, 2: Cache per user, 4: Cache per page, 8: Block cache global) See BLOCK_CACHE_* constants in block.module for more detailed information.'),
00097       ),
00098     ),
00099     'primary key' => array('bid'),
00100     'unique keys' => array(
00101       'tmd' => array('theme', 'module', 'delta'),
00102     ),
00103     'indexes' => array(
00104       'list' => array('theme', 'status', 'region', 'weight', 'module'),
00105     ),
00106   );
00107
00108   $schema['blocks_roles'] = array(
00109     'description' => t('Sets up access permissions for blocks based on user roles'),
00110     'fields' => array(
00111       'module' => array(
00112         'type' => 'varchar',
00113         'length' => 64,
00114         'not null' => TRUE,
00115         'description' => t("The block's origin module, from {blocks}.module."),
00116       ),
00117       'delta'  => array(
00118         'type' => 'varchar',
00119         'length' => 32,
00120         'not null' => TRUE,
00121         'description' => t("The block's unique delta within module, from {blocks}.delta."),
00122       ),
00123       'rid' => array(
00124         'type' => 'int',
00125         'unsigned' => TRUE,
00126         'not null' => TRUE,
00127         'description' => t("The user's role ID from {users_roles}.rid."),
00128       ),
00129     ),
00130     'primary key' => array(
00131       'module',
00132       'delta',
00133       'rid'
00134     ),
00135     'indexes' => array(
00136       'rid' => array('rid'),
00137     ),
00138   );
00139
00140   $schema['boxes'] = array(
00141     'description' => t('Stores contents of custom-made blocks.'),
00142     'fields' => array(
00143       'bid' => array(
00144         'type' => 'serial',
00145   'unsigned' => TRUE,
00146         'not null' => TRUE,
00147         'description' => t("The block's {blocks}.bid."),
00148       ),
00149       'body' => array(
00150         'type' => 'text',
00151         'not null' => FALSE,
00152         'size' => 'big',
00153         'description' => t('Block contents.'),
00154       ),
00155       'info' => array(
00156         'type' => 'varchar',
00157         'length' => 128,
00158         'not null' => TRUE,
00159         'default' => '',
00160         'description' => t('Block description.'),
00161       ),
00162       'format' => array(
00163         'type' => 'int',
00164         'size' => 'small',
00165         'not null' => TRUE,
00166         'default' => 0,
00167         'description' => t("Block body's {filter_formats}.format; for example, 1 = Filtered HTML."),
00168       )
00169     ),
00170     'unique keys' => array('info' => array('info')),
00171     'primary key' => array('bid'),
00172   );
00173
00174   $schema['cache_block'] = drupal_get_schema_unprocessed('system', 'cache');
00175   $schema['cache_block']['description'] = t('Cache table for the Block module to store already built blocks, identified by module, delta, and various contexts which may change the block, such as theme, locale, and caching mode defined for the block.');
00176
00177   return $schema;
00178 }
00179
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/block/block.module Source File

modules » block

block.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: block.module,v 1.299 2008/02/03 19:12:57 goba Exp $
00003
00013 define('BLOCK_REGION_NONE', -1);
00014
00039 define('BLOCK_NO_CACHE', -1);
00040
00045 define('BLOCK_CACHE_PER_ROLE', 0x0001);
00046
00052 define('BLOCK_CACHE_PER_USER', 0x0002);
00053
00057 define('BLOCK_CACHE_PER_PAGE', 0x0004);
00058
00062 define('BLOCK_CACHE_GLOBAL', 0x0008);
00063
00067 function block_help($path, $arg) {
00068   switch ($path) {
00069     case 'admin/help#block':
00070       $output = '<p>'. t('Blocks are boxes of content rendered into an area, or region, of a web page. The default theme Garland, for example, implements the regions "left sidebar", "right sidebar", "content", "header", and "footer", and a block may appear in any one of these areas. The <a href="@blocks">blocks administration page</a> provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions.', array('@blocks' => url('admin/build/block'))) .'</p>';
00071       $output .= '<p>'. t('Although blocks are usually generated automatically by modules (like the <em>User login</em> block, for example), administrators can also define custom blocks. Custom blocks have a title, description, and body. The body of the block can be as long as necessary, and can contain content supported by any available <a href="@input-format">input format</a>.', array('@input-format' => url('admin/settings/filters'))) .'</p>';
00072       $output .= '<p>'. t('When working with blocks, remember that:') .'</p>';
00073       $output .= '<ul><li>'. t('since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis.') .'</li>';
00074       $output .= '<li>'. t('disabled blocks, or blocks not in a region, are never shown.') .'</li>';
00075       $output .= '<li>'. t('when throttle module is enabled, throttled blocks (blocks with the <em>Throttle</em> checkbox selected) are hidden during high server loads.') .'</li>';
00076       $output .= '<li>'. t('blocks can be configured to be visible only on certain pages.') .'</li>';
00077       $output .= '<li>'. t('blocks can be configured to be visible only when specific conditions are true.') .'</li>';
00078       $output .= '<li>'. t('blocks can be configured to be visible only for certain user roles.') .'</li>';
00079       $output .= '<li>'. t('when allowed by an administrator, specific blocks may be enabled or disabled on a per-user basis using the <em>My account</em> page.') .'</li>';
00080       $output .= '<li>'. t('some dynamic blocks, such as those generated by modules, will be displayed only on certain pages.') .'</li></ul>';
00081       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@block">Block module</a>.', array('@block' => 'http://drupal.org/handbook/modules/block/')) .'</p>';
00082       return $output;
00083     case 'admin/build/block':
00084       $throttle = module_exists('throttle');
00085       $output = '<p>'. t('This page provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions. To change the region or order of a block, grab a drag-and-drop handle under the <em>Block</em> column and drag the block to a new location in the list. (Grab a handle by clicking and holding the mouse while hovering over a handle icon.) Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. Remember that your changes will not be saved until you click the <em>Save blocks</em> button at the bottom of the page.') .'</p>';
00086       if ($throttle) {
00087         $output .= '<p>'. t('To reduce CPU usage, database traffic or bandwidth, blocks may be automatically disabled during high server loads by selecting their <em>Throttle</em> checkbox. Adjust throttle thresholds on the <a href="@throttleconfig">throttle configuration page</a>.', array('@throttleconfig' => url('admin/settings/throttle'))) .'</p>';
00088       }
00089       $output .= '<p>'. t('Click the <em>configure</em> link next to each block to configure its specific title and visibility settings. Use the <a href="@add-block">add block page</a> to create a custom block.', array('@add-block' => url('admin/build/block/add'))) .'</p>';
00090       return $output;
00091     case 'admin/build/block/add':
00092       return '<p>'. t('Use this page to create a new custom block. New blocks are disabled by default, and must be moved to a region on the <a href="@blocks">blocks administration page</a> to be visible.', array('@blocks' => url('admin/build/block'))) .'</p>';
00093   }
00094 }
00095
00099 function block_theme() {
00100   return array(
00101     'block_admin_display_form' => array(
00102       'template' => 'block-admin-display-form',
00103       'file' => 'block.admin.inc',
00104       'arguments' => array('form' => NULL),
00105     ),
00106   );
00107 }
00108
00112 function block_perm() {
00113   return array('administer blocks', 'use PHP for block visibility');
00114 }
00115
00119 function block_menu() {
00120   $items['admin/build/block'] = array(
00121     'title' => 'Blocks',
00122     'description' => 'Configure what block content appears in your site\'s sidebars and other regions.',
00123     'page callback' => 'block_admin_display',
00124     'access arguments' => array('administer blocks'),
00125     'file' => 'block.admin.inc',
00126   );
00127   $items['admin/build/block/list'] = array(
00128     'title' => 'List',
00129     'type' => MENU_DEFAULT_LOCAL_TASK,
00130     'weight' => -10,
00131   );
00132   $items['admin/build/block/list/js'] = array(
00133     'title' => 'JavaScript List Form',
00134     'page callback' => 'block_admin_display_js',
00135     'type' => MENU_CALLBACK,
00136     'file' => 'block.admin.inc',
00137   );
00138   $items['admin/build/block/configure'] = array(
00139     'title' => 'Configure block',
00140     'page callback' => 'drupal_get_form',
00141     'page arguments' => array('block_admin_configure'),
00142     'type' => MENU_CALLBACK,
00143     'file' => 'block.admin.inc',
00144   );
00145   $items['admin/build/block/delete'] = array(
00146     'title' => 'Delete block',
00147     'page callback' => 'drupal_get_form',
00148     'page arguments' => array('block_box_delete'),
00149     'type' => MENU_CALLBACK,
00150     'file' => 'block.admin.inc',
00151   );
00152   $items['admin/build/block/add'] = array(
00153     'title' => 'Add block',
00154     'page callback' => 'drupal_get_form',
00155     'page arguments' => array('block_add_block_form'),
00156     'type' => MENU_LOCAL_TASK,
00157     'file' => 'block.admin.inc',
00158   );
00159   $default = variable_get('theme_default', 'garland');
00160   foreach (list_themes() as $key => $theme) {
00161     $items['admin/build/block/list/'. $key] = array(
00162       'title' => check_plain($theme->info['name']),
00163       'page arguments' => array($key),
00164       'type' => $key == $default ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
00165       'weight' => $key == $default ? -10 : 0,
00166       'file' => 'block.admin.inc',
00167       'access callback' => '_block_themes_access',
00168       'access arguments' => array($theme),
00169     );
00170   }
00171   return $items;
00172 }
00173
00177 function _block_themes_access($theme) {
00178   return user_access('administer blocks') && ($theme->status || $theme->name == variable_get('admin_theme', '0'));
00179 }
00180
00186 function block_block($op = 'list', $delta = 0, $edit = array()) {
00187   switch ($op) {
00188     case 'list':
00189       $blocks = array();
00190
00191       $result = db_query('SELECT bid, info FROM {boxes} ORDER BY info');
00192       while ($block = db_fetch_object($result)) {
00193         $blocks[$block->bid]['info'] = $block->info;
00194         // Not worth caching.
00195         $blocks[$block->bid]['cache'] = BLOCK_NO_CACHE;
00196       }
00197       return $blocks;
00198
00199     case 'configure':
00200       $box = array('format' => FILTER_FORMAT_DEFAULT);
00201       if ($delta) {
00202         $box = block_box_get($delta);
00203       }
00204       if (filter_access($box['format'])) {
00205         return block_box_form($box);
00206       }
00207       break;
00208
00209     case 'save':
00210       block_box_save($edit, $delta);
00211       break;
00212
00213     case 'view':
00214       $block = db_fetch_object(db_query('SELECT body, format FROM {boxes} WHERE bid = %d', $delta));
00215       $data['content'] = check_markup($block->body, $block->format, FALSE);
00216       return $data;
00217   }
00218 }
00219
00226 function _block_rehash() {
00227   global $theme_key;
00228
00229   init_theme();
00230
00231   $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $theme_key);
00232   $old_blocks = array();
00233   while ($old_block = db_fetch_array($result)) {
00234     $old_blocks[$old_block['module']][$old_block['delta']] = $old_block;
00235   }
00236
00237   $blocks = array();
00238   // Valid region names for the theme.
00239   $regions = system_region_list($theme_key);
00240
00241   foreach (module_list() as $module) {
00242     $module_blocks = module_invoke($module, 'block', 'list');
00243     if ($module_blocks) {
00244       foreach ($module_blocks as $delta => $block) {
00245         if (empty($old_blocks[$module][$delta])) {
00246           // If it's a new block, add identifiers.
00247           $block['module'] = $module;
00248           $block['delta']  = $delta;
00249           $block['theme']  = $theme_key;
00250           if (!isset($block['pages'])) {
00251             // {block}.pages is type 'text', so it cannot have a
00252             // default value, and not null, so we need to provide
00253             // value if the module did not.
00254             $block['pages']  = '';
00255           }
00256           // Add defaults and save it into the database.
00257           drupal_write_record('blocks', $block);
00258           // Set region to none if not enabled.
00259           $block['region'] = $block['status'] ? $block['region'] : BLOCK_REGION_NONE;
00260           // Add to the list of blocks we return.
00261           $blocks[] = $block;
00262         }
00263         else {
00264           // If it's an existing block, database settings should overwrite
00265           // the code. But aside from 'info' everything that's definable in
00266           // code is stored in the database and we do not store 'info', so we
00267           // do not need to update the database here.
00268           // Add 'info' to this block.
00269           $old_blocks[$module][$delta]['info'] = $block['info'];
00270           // If the region name does not exist, disable the block and assign it to none.
00271           if (!empty($old_blocks[$module][$delta]['region']) && !isset($regions[$old_blocks[$module][$delta]['region']])) {
00272             drupal_set_message(t('The block %info was assigned to the invalid region %region and has been disabled.', array('%info' => $old_blocks[$module][$delta]['info'], '%region' => $old_blocks[$module][$delta]['region'])), 'warning');
00273             $old_blocks[$module][$delta]['status'] = 0;
00274             $old_blocks[$module][$delta]['region'] = BLOCK_REGION_NONE;
00275           }
00276           else {
00277             $old_blocks[$module][$delta]['region'] = $old_blocks[$module][$delta]['status'] ? $old_blocks[$module][$delta]['region'] : BLOCK_REGION_NONE;
00278           }
00279           // Add this block to the list of blocks we return.
00280           $blocks[] = $old_blocks[$module][$delta];
00281           // Remove this block from the list of blocks to be deleted.
00282           unset($old_blocks[$module][$delta]);
00283         }
00284       }
00285     }
00286   }
00287
00288   // Remove blocks that are no longer defined by the code from the database.
00289   foreach ($old_blocks as $module => $old_module_blocks) {
00290     foreach ($old_module_blocks as $delta => $block) {
00291       db_query("DELETE FROM {blocks} WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $module, $delta, $theme_key);
00292     }
00293   }
00294   return $blocks;
00295 }
00296
00297 function block_box_get($bid) {
00298   return db_fetch_array(db_query("SELECT bx.*, bl.title FROM {boxes} bx INNER JOIN {blocks} bl ON bx.bid = bl.delta WHERE bl.module = 'block' AND bx.bid = %d", $bid));
00299 }
00300
00304 function block_box_form($edit = array()) {
00305   $edit += array(
00306     'info' => '',
00307     'body' => '',
00308   );
00309   $form['info'] = array(
00310     '#type' => 'textfield',
00311     '#title' => t('Block description'),
00312     '#default_value' => $edit['info'],
00313     '#maxlength' => 64,
00314     '#description' => t('A brief description of your block. Used on the <a href="@overview">block overview page</a>.', array('@overview' => url('admin/build/block'))),
00315     '#required' => TRUE,
00316     '#weight' => -19,
00317   );
00318   $form['body_field']['#weight'] = -17;
00319   $form['body_field']['body'] = array(
00320     '#type' => 'textarea',
00321     '#title' => t('Block body'),
00322     '#default_value' => $edit['body'],
00323     '#rows' => 15,
00324     '#description' => t('The content of the block as shown to the user.'),
00325     '#weight' => -17,
00326   );
00327   if (!isset($edit['format'])) {
00328     $edit['format'] = FILTER_FORMAT_DEFAULT;
00329   }
00330   $form['body_field']['format'] = filter_form($edit['format'], -16);
00331
00332   return $form;
00333 }
00334
00335 function block_box_save($edit, $delta) {
00336   if (!filter_access($edit['format'])) {
00337     $edit['format'] = FILTER_FORMAT_DEFAULT;
00338   }
00339
00340   db_query("UPDATE {boxes} SET body = '%s', info = '%s', format = %d WHERE bid = %d", $edit['body'], $edit['info'], $edit['format'], $delta);
00341
00342   return TRUE;
00343 }
00344
00351 function block_user($type, $edit, &$account, $category = NULL) {
00352   switch ($type) {
00353     case 'form':
00354       if ($category == 'account') {
00355         $rids = array_keys($account->roles);
00356         $result = db_query("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.status = 1 AND b.custom != 0 AND (r.rid IN (". db_placeholders($rids) .") OR r.rid IS NULL) ORDER BY b.weight, b.module", $rids);
00357         $form['block'] = array('#type' => 'fieldset', '#title' => t('Block configuration'), '#weight' => 3, '#collapsible' => TRUE, '#tree' => TRUE);
00358         while ($block = db_fetch_object($result)) {
00359           $data = module_invoke($block->module, 'block', 'list');
00360           if ($data[$block->delta]['info']) {
00361             $return = TRUE;
00362             $form['block'][$block->module][$block->delta] = array('#type' => 'checkbox', '#title' => check_plain($data[$block->delta]['info']), '#default_value' => isset($account->block[$block->module][$block->delta]) ? $account->block[$block->module][$block->delta] : ($block->custom == 1));
00363           }
00364         }
00365
00366         if (!empty($return)) {
00367           return $form;
00368         }
00369       }
00370
00371       break;
00372     case 'validate':
00373       if (empty($edit['block'])) {
00374         $edit['block'] = array();
00375       }
00376       return $edit;
00377   }
00378 }
00379
00396 function block_list($region) {
00397   global $user, $theme_key;
00398
00399   static $blocks = array();
00400
00401   if (!count($blocks)) {
00402     $rids = array_keys($user->roles);
00403     $result = db_query(db_rewrite_sql("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = '%s' AND b.status = 1 AND (r.rid IN (". db_placeholders($rids) .") OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module", 'b', 'bid'), array_merge(array($theme_key), $rids));
00404     while ($block = db_fetch_object($result)) {
00405       if (!isset($blocks[$block->region])) {
00406         $blocks[$block->region] = array();
00407       }
00408       // Use the user's block visibility setting, if necessary
00409       if ($block->custom != 0) {
00410         if ($user->uid && isset($user->block[$block->module][$block->delta])) {
00411           $enabled = $user->block[$block->module][$block->delta];
00412         }
00413         else {
00414           $enabled = ($block->custom == 1);
00415         }
00416       }
00417       else {
00418         $enabled = TRUE;
00419       }
00420
00421       // Match path if necessary
00422       if ($block->pages) {
00423         if ($block->visibility < 2) {
00424           $path = drupal_get_path_alias($_GET['q']);
00425           // Compare with the internal and path alias (if any).
00426           $page_match = drupal_match_path($path, $block->pages);
00427           if ($path != $_GET['q']) {
00428             $page_match = $page_match || drupal_match_path($_GET['q'], $block->pages);
00429           }
00430           // When $block->visibility has a value of 0, the block is displayed on
00431           // all pages except those listed in $block->pages. When set to 1, it
00432           // is displayed only on those pages listed in $block->pages.
00433           $page_match = !($block->visibility xor $page_match);
00434         }
00435         else {
00436           $page_match = drupal_eval($block->pages);
00437         }
00438       }
00439       else {
00440         $page_match = TRUE;
00441       }
00442
00443       if ($enabled && $page_match) {
00444         // Check the current throttle status and see if block should be displayed
00445         // based on server load.
00446         if (!($block->throttle && (module_invoke('throttle', 'status') > 0))) {
00447           // Try fetching the block from cache. Block caching is not compatible with
00448           // node_access modules. We also preserve the submission of forms in blocks,
00449           // by fetching from cache only if the request method is 'GET'.
00450           if (!count(module_implements('node_grants')) && $_SERVER['REQUEST_METHOD'] == 'GET' && ($cid = _block_get_cache_id($block)) && ($cache = cache_get($cid, 'cache_block'))) {
00451             $array = $cache->data;
00452           }
00453           else {
00454             $array = module_invoke($block->module, 'block', 'view', $block->delta);
00455             if (isset($cid)) {
00456               cache_set($cid, $array, 'cache_block', CACHE_TEMPORARY);
00457             }
00458           }
00459
00460           if (isset($array) && is_array($array)) {
00461             foreach ($array as $k => $v) {
00462               $block->$k = $v;
00463             }
00464           }
00465         }
00466         if (isset($block->content) && $block->content) {
00467           // Override default block title if a custom display title is present.
00468           if ($block->title) {
00469             // Check plain here to allow module generated titles to keep any markup.
00470             $block->subject = $block->title == '<none>' ? '' : check_plain($block->title);
00471           }
00472           if (!isset($block->subject)) {
00473             $block->subject = '';
00474           }
00475           $blocks[$block->region]["{$block->module}_{$block->delta}"] = $block;
00476         }
00477       }
00478     }
00479   }
00480   // Create an empty array if there were no entries
00481   if (!isset($blocks[$region])) {
00482     $blocks[$region] = array();
00483   }
00484   return $blocks[$region];
00485 }
00486
00502 function _block_get_cache_id($block) {
00503   global $theme, $base_root, $user;
00504
00505   // User 1 being out of the regular 'roles define permissions' schema,
00506   // it brings too many chances of having unwanted output get in the cache
00507   // and later be served to other users. We therefore exclude user 1 from
00508   // block caching.
00509   if (variable_get('block_cache', 0) && $block->cache != BLOCK_NO_CACHE && $user->uid != 1) {
00510     $cid_parts = array();
00511
00512     // Start with common sub-patterns: block identification, theme, language.
00513     $cid_parts[] = $block->module;
00514     $cid_parts[] = $block->delta;
00515     $cid_parts[] = $theme;
00516     if (module_exists('locale')) {
00517       global $language;
00518       $cid_parts[] = $language->language;
00519     }
00520
00521     // 'PER_ROLE' and 'PER_USER' are mutually exclusive. 'PER_USER' can be a
00522     // resource drag for sites with many users, so when a module is being
00523     // equivocal, we favor the less expensive 'PER_ROLE' pattern.
00524     if ($block->cache & BLOCK_CACHE_PER_ROLE) {
00525       $cid_parts[] = 'r.'. implode(',', array_keys($user->roles));
00526     }
00527     elseif ($block->cache & BLOCK_CACHE_PER_USER) {
00528       $cid_parts[] = "u.$user->uid";
00529     }
00530
00531     if ($block->cache & BLOCK_CACHE_PER_PAGE) {
00532       $cid_parts[] = $base_root . request_uri();
00533     }
00534
00535     return implode(':', $cid_parts);
00536   }
00537 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/block_example.module Source File

docs » examples

block_example.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: block_example.module,v 1.9 2007/07/06 18:16:15 drewish Exp $
00003
00016 function block_example_block($op = 'list', $delta = 0, $edit = array()) {
00017   // The $op parameter determines what piece of information is being requested.
00018   switch ($op) {
00019     case 'list':
00020       // If $op is "list", we just need to return a list of block descriptions.
00021       // This is used to provide a list of possible blocks to the administrator,
00022       // end users will not see these descriptions.
00023       $blocks[0] = array(
00024         'info'       => t('Example: configurable text string'),
00025       );
00026       // A block can provide default settings. In this case we'll enable the
00027       // block and make it visible only on the 'node/*' pages.
00028       $blocks[1] = array(
00029         'info'       => t('Example: empty block'),
00030         'status'     => TRUE,
00031         'weight'     => 0,
00032         'visibility' => 1,
00033         'pages'      => 'node/*',
00034       );
00035       return $blocks;
00036     case 'configure':
00037       // If $op is "configure", we need to provide the administrator with a
00038       // configuration form. The $delta parameter tells us which block is being
00039       // configured. In this example, we'll allow the administrator to customize
00040       // the text of the first block.
00041       $form = array();
00042       if ($delta == 0) {
00043         // All we need to provide is a text field, Drupal will take care of
00044         // the other block configuration options and the save button.
00045         $form['block_example_string'] = array(
00046           '#type' => 'textfield',
00047           '#title' => t('Block contents'),
00048           '#size' => 60,
00049           '#description' => t('This string will appear in the example block.'),
00050           '#default_value' => variable_get('block_example_string',  t('Some example content.')),
00051         );
00052       }
00053       return $form;
00054     case 'save':
00055       // If $op is "save", we need to save settings from the configuration form.
00056       // Since the first block is the only one that allows configuration, we
00057       // need to check $delta to make sure we only save it.
00058       if ($delta == 0) {
00059         // Have Drupal save the string to the database.
00060         variable_set('block_example_string', $edit['block_example_string']);
00061       }
00062       return;
00063     case 'view': default:
00064       // If $op is "view", then we need to generate the block for display
00065       // purposes. The $delta parameter tells us which block is being requested.
00066       switch ($delta) {
00067         case 0:
00068           // The subject is displayed at the top of the block. Note that it
00069           // should be passed through t() for translation.
00070           $block['subject'] = t('Title of block #1');
00071           // The content of the block is typically generated by calling a custom
00072           // function.
00073           $block['content'] = block_example_contents(1);
00074           break;
00075         case 1:
00076           $block['subject'] = t('Title of block #2');
00077           $block['content'] = block_example_contents(2);
00078           break;
00079       }
00080       return $block;
00081   }
00082 }
00083
00087 function block_example_contents($which_block) {
00088   switch ($which_block) {
00089     case 1:
00090       // Modules would typically perform some database queries to fetch the
00091       // content for their blocks. Here, we'll just use the variable set in the
00092       // block configuration or, if none has set, a default value.
00093       return variable_get('block_example_string',  t('A default value.'));
00094
00095     case 2:
00096       // It is possible that your block will not have any content, since it is
00097       // probably dynamically constructed. In this case, Drupal will not display
00098       // the block at all.
00099       return;
00100   }
00101 }
00102
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/blog/blog.module Source File

modules » blog

blog.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: blog.module,v 1.297 2008/01/09 09:51:34 goba Exp $
00003
00012 function blog_node_info() {
00013   return array(
00014     'blog' => array(
00015       'name' => t('Blog entry'),
00016       'module' => 'blog',
00017       'description' => t('A <em>blog entry</em> is a single post to an online journal, or <em>blog</em>.'),
00018     )
00019   );
00020 }
00021
00025 function blog_perm() {
00026   return array('create blog entries', 'delete own blog entries', 'delete any blog entry', 'edit own blog entries', 'edit any blog entry');
00027 }
00028
00032 function blog_access($op, $node, $account) {
00033   switch ($op) {
00034     case 'create':
00035       // Anonymous users cannot post even if they have the permission.
00036       return user_access('create blog entries', $account) && $account->uid;
00037     case 'update':
00038       return user_access('edit any blog entry', $account) || (user_access('edit own blog entries', $account) && ($node->uid == $account->uid));
00039     case 'delete':
00040       return user_access('delete any blog entry', $account) || (user_access('delete own blog entries', $account) && ($node->uid == $account->uid));
00041   }
00042 }
00043
00047 function blog_user($type, &$edit, &$user) {
00048   if ($type == 'view' && user_access('create blog entries', $user)) {
00049     $user->content['summary']['blog'] =  array(
00050       '#type' => 'user_profile_item',
00051       '#title' => t('Blog'),
00052       '#value' => l(t('View recent blog entries'), "blog/$user->uid", array('title' => t("Read @username's latest blog entries.", array('@username' => $user->name)))),
00053       '#attributes' => array('class' => 'blog'),
00054     );
00055   }
00056 }
00057
00061 function blog_help($path, $arg) {
00062   switch ($path) {
00063     case 'admin/help#blog':
00064       $output = '<p>'. t('The blog module allows registered users to maintain an online journal, or <em>blog</em>. Blogs are made up of individual <em>blog entries</em>, and the blog entries are most often displayed in descending order by creation time.') .'</p>';
00065       $output .= '<p>'. t('There is an (optional) <em>Blogs</em> menu item added to the Navigation menu, which displays all blogs available on your site, and a <em>My blog</em> item displaying the current user\'s blog entries. The <em>Blog entry</em> menu item under <em>Create content</em> allows new blog entries to be created.') .'</p>';
00066       $output .= '<p>'. t('Each blog entry is displayed with an automatic link to other blogs created by the same user. By default, blog entries have comments enabled and are automatically promoted to the site front page. The blog module also creates a <em>Recent blog posts</em> block that may be enabled at the <a href="@blocks">blocks administration page</a>.', array('@blocks' => url('admin/build/block'))) .'</p>';
00067       $output .= '<p>'. t('When using the aggregator module an automatic <em>blog it</em> icon is displayed next to the items in a feed\'s <em>latest items</em> block. Clicking this icon populates a <em>blog entry</em> with a title (the title of the feed item) and body (a link to the source item on its original site and illustrative content suitable for use in a block quote). Blog authors can use this feature to easily comment on items of interest that appear in aggregator feeds from other sites. To use this feature, be sure to <a href="@modules">enable</a> the aggregator module, <a href="@feeds">add and configure</a> a feed from another site, and <a href="@blocks">position</a> the feed\'s <em>latest items</em> block.', array('@modules' => url('admin/build/modules'), '@feeds' => url('admin/content/aggregator'), '@blocks' => url('admin/build/block'))) .'</p>';
00068       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@blog">Blog module</a>.', array('@blog' => 'http://drupal.org/handbook/modules/blog/')) .'</p>';
00069       return $output;
00070   }
00071 }
00072
00076 function blog_form(&$node) {
00077   global $nid;
00078   $iid = isset($_GET['iid']) ? (int)$_GET['iid'] : 0;
00079   $type = node_get_types('type', $node);
00080
00081
00082   if (empty($node->body)) {
00083     // If the user clicked a "blog it" link, we load the data from the
00084     // database and quote it in the blog.
00085     if ($nid && $blog = node_load($nid)) {
00086       $node->body = '<em>'. $blog->body .'</em> ['. l($blog->name, "node/$nid") .']';
00087     }
00088
00089     if ($iid && $item = db_fetch_object(db_query('SELECT i.*, f.title as ftitle, f.link as flink FROM {aggregator_item} i, {aggregator_feed} f WHERE i.iid = %d AND i.fid = f.fid', $iid))) {
00090       $node->title = $item->title;
00091       // Note: $item->description has been validated on aggregation.
00092       $node->body = '<a href="'. check_url($item->link) .'">'. check_plain($item->title) .'</a> - <em>'. $item->description .'</em> [<a href="'. check_url($item->flink) .'">'. check_plain($item->ftitle) ."</a>]\n";
00093     }
00094
00095   }
00096
00097   $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => !empty($node->title) ? $node->title : NULL, '#weight' => -5);
00098   $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
00099   return $form;
00100 }
00101
00105 function blog_view($node, $teaser = FALSE, $page = FALSE) {
00106   if ($page) {
00107     // Breadcrumb navigation
00108     drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Blogs'), 'blog'), l(t("@name's blog", array('@name' => $node->name)), 'blog/'. $node->uid)));
00109   }
00110   return node_prepare($node, $teaser);
00111 }
00112
00116 function blog_link($type, $node = NULL, $teaser = FALSE) {
00117   $links = array();
00118
00119   if ($type == 'node' && $node->type == 'blog') {
00120     if (arg(0) != 'blog' || arg(1) != $node->uid) {
00121       $links['blog_usernames_blog'] = array(
00122         'title' => t("@username's blog", array('@username' => $node->name)),
00123         'href' => "blog/$node->uid",
00124         'attributes' => array('title' => t("Read @username's latest blog entries.", array('@username' => $node->name)))
00125       );
00126     }
00127   }
00128
00129   return $links;
00130 }
00131
00135 function blog_menu() {
00136   $items['blog'] = array(
00137     'title' => 'Blogs',
00138     'page callback' => 'blog_page_last',
00139     'access arguments' => array('access content'),
00140     'type' => MENU_SUGGESTED_ITEM,
00141     'file' => 'blog.pages.inc',
00142   );
00143   $items['blog/%user_current'] = array(
00144     'title' => 'My blog',
00145     'page callback' => 'blog_page_user',
00146     'page arguments' => array(1),
00147     'access callback' => 'user_access',
00148     'access arguments' => array('create blog entries', 1),
00149     'file' => 'blog.pages.inc',
00150   );
00151   $items['blog/%user/feed'] = array(
00152     'title' => 'Blogs',
00153     'page callback' => 'blog_feed_user',
00154     'page arguments' => array(1),
00155     'access arguments' => array('access content'),
00156     'type' => MENU_CALLBACK,
00157     'file' => 'blog.pages.inc',
00158   );
00159   $items['blog/feed'] = array(
00160     'title' => 'Blogs',
00161     'page callback' => 'blog_feed_last',
00162     'access arguments' => array('access content'),
00163     'type' => MENU_CALLBACK,
00164     'file' => 'blog.pages.inc',
00165   );
00166
00167   return $items;
00168 }
00169
00175 function blog_block($op = 'list', $delta = 0) {
00176   global $user;
00177   if ($op == 'list') {
00178     $block[0]['info'] = t('Recent blog posts');
00179     return $block;
00180   }
00181   else if ($op == 'view') {
00182     if (user_access('access content')) {
00183       $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, 10);
00184       if ($node_title_list = node_title_list($result)) {
00185         $block['content'] = $node_title_list;
00186         $block['content'] .= theme('more_link', url('blog'), t('Read the latest blog entries.'));
00187         $block['subject'] = t('Recent blog posts');
00188         return $block;
00189       }
00190     }
00191   }
00192 }
00193
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/blog/blog.pages.inc Source File

modules » blog

blog.pages.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: blog.pages.inc,v 1.6.2.1 2008/02/08 21:15:12 goba Exp $
00003
00012 function blog_page_user($account) {
00013   global $user;
00014
00015   drupal_set_title($title = t("@name's blog", array('@name' => $account->name)));
00016
00017   $items = array();
00018
00019   if (($account->uid == $user->uid) && user_access('create blog entries')) {
00020     $items[] = l(t('Post new blog entry.'), "node/add/blog");
00021   }
00022   else if ($account->uid == $user->uid) {
00023     $items[] = t('You are not allowed to post a new blog entry.');
00024   }
00025
00026   $output = theme('item_list', $items);
00027
00028   $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $account->uid);
00029   $has_posts = FALSE;
00030
00031   while ($node = db_fetch_object($result)) {
00032     $output .= node_view(node_load($node->nid), 1);
00033     $has_posts = TRUE;
00034   }
00035
00036   if ($has_posts) {
00037     $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
00038   }
00039   else {
00040     if ($account->uid == $user->uid) {
00041       drupal_set_message(t('You have not created any blog entries.'));
00042     }
00043     else {
00044       drupal_set_message(t('!author has not created any blog entries.', array('!author' => theme('username', $account))));
00045     }
00046   }
00047   drupal_add_feed(url('blog/'. $account->uid .'/feed'), t('RSS - !title', array('!title' => $title)));
00048
00049   return $output;
00050 }
00051
00055 function blog_page_last() {
00056   global $user;
00057
00058   $output = '';
00059   $items = array();
00060
00061   if (user_access('edit own blog')) {
00062     $items[] = l(t('Create new blog entry.'), "node/add/blog");
00063   }
00064
00065   $output = theme('item_list', $items);
00066
00067   $result = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10));
00068   $has_posts = FALSE;
00069
00070   while ($node = db_fetch_object($result)) {
00071     $output .= node_view(node_load($node->nid), 1);
00072     $has_posts = TRUE;
00073   }
00074
00075   if ($has_posts) {
00076     $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
00077   }
00078   else {
00079     drupal_set_message(t('No blog entries have been created.'));
00080   }
00081   drupal_add_feed(url('blog/feed'), t('RSS - blogs'));
00082
00083   return $output;
00084 }
00085
00089 function blog_feed_user($account) {
00090   $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n  WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.created DESC"), $account->uid, 0, variable_get('feed_default_items', 10));
00091   $channel['title'] = $account->name ."'s blog";
00092   $channel['link'] = url('blog/'. $account->uid, array('absolute' => TRUE));
00093
00094   $items = array();
00095   while ($row = db_fetch_object($result)) {
00096     $items[] = $row->nid;
00097   }
00098   node_feed($items, $channel);
00099 }
00100
00104 function blog_feed_last() {
00105   $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, variable_get('feed_default_items', 10));
00106   $channel['title'] = variable_get('site_name', 'Drupal') .' blogs';
00107   $channel['link'] = url('blog', array('absolute' => TRUE));
00108
00109   $items = array();
00110   while ($row = db_fetch_object($result)) {
00111     $items[] = $row->nid;
00112   }
00113
00114   node_feed($items, $channel);
00115 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/blogapi/blogapi.install Source File

modules » blogapi

blogapi.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: blogapi.install,v 1.1 2008/01/09 09:51:34 goba Exp $
00003
00012 function blogapi_update_6000() {
00013   drupal_set_message("Blog API module does not depend on blog module's permissions anymore, but provides its own 'administer content with blog api' permission instead. Until <a href=\"". url('admin/user/permissions', array('fragment' => 'module-blogapi')) .'">this permission is assigned</a> to at least one user role, only the site administrator will be able to use Blog API features.');
00014   return array();
00015 }
00016
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/blogapi/blogapi.module Source File

modules » blogapi

blogapi.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: blogapi.module,v 1.115.2.1 2008/02/07 20:11:02 goba Exp $
00003
00012 function blogapi_help($path, $arg) {
00013   switch ($path) {
00014     case 'admin/help#blogapi':
00015       $output = '<p>'. t("The Blog API module allows your site's users to access and post to their blogs from external blogging clients. External blogging clients are available for a wide range of desktop operating systems, and generally provide a feature-rich graphical environment for creating and editing posts.") .'</p>';
00016       $output .= '<p>'. t('<a href="@ecto-link">Ecto</a>, a blogging client available for both Mac OS X and Microsoft Windows, can be used with Blog API. Blog API also supports <a href="@blogger-api">Blogger API</a>, <a href="@metaweblog-api">MetaWeblog API</a>, and most of the <a href="@movabletype-api">Movable Type API</a>. Blogging clients and other services (e.g. <a href="@flickr">Flickr\'s</a> "post to blog") that support these APIs may also be compatible.', array('@ecto-link' => url('http://infinite-sushi.com/software/ecto/'), '@blogger-api' => url('http://www.blogger.com/developers/api/1_docs/'), '@metaweblog-api' => url('http://www.xmlrpc.com/metaWeblogApi'), '@movabletype-api' => url('http://www.movabletype.org/docs/mtmanual_programmatic.html'), '@flickr' => url('http://www.flickr.com'))) .'</p>';
00017       $output .= '<p>'. t('Select the content types available to external clients on the <a href="@blogapi-settings">Blog API settings page</a>. If supported and available, each content type will be displayed as a separate "blog" by the external client.', array('@blogapi-settings' => url('admin/settings/blogapi'))) .'</p>';
00018       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@blogapi">Blog API module</a>.', array('@blogapi' => url('http://drupal.org/handbook/modules/blogapi/'))) .'</p>';
00019       return $output;
00020   }
00021 }
00022
00026 function blogapi_perm() {
00027   return array('administer content with blog api');
00028 }
00029
00033 function blogapi_xmlrpc() {
00034   return array(
00035     array(
00036       'blogger.getUsersBlogs',
00037       'blogapi_blogger_get_users_blogs',
00038       array('array', 'string', 'string', 'string'),
00039       t('Returns a list of blogs to which an author has posting privileges.')),
00040     array(
00041       'blogger.getUserInfo',
00042       'blogapi_blogger_get_user_info',
00043       array('struct', 'string', 'string', 'string'),
00044       t('Returns information about an author in the system.')),
00045     array(
00046       'blogger.newPost',
00047       'blogapi_blogger_new_post',
00048       array('string', 'string', 'string', 'string', 'string', 'string', 'boolean'),
00049       t('Creates a new post, and optionally publishes it.')),
00050     array(
00051       'blogger.editPost',
00052       'blogapi_blogger_edit_post',
00053       array('boolean', 'string', 'string', 'string', 'string', 'string', 'boolean'),
00054       t('Updates the information about an existing post.')),
00055     array(
00056       'blogger.getPost',
00057       'blogapi_blogger_get_post',
00058       array('struct', 'string', 'string', 'string', 'string'),
00059       t('Returns information about a specific post.')),
00060     array(
00061       'blogger.deletePost',
00062       'blogapi_blogger_delete_post',
00063       array('boolean', 'string', 'string', 'string', 'string', 'boolean'),
00064       t('Deletes a post.')),
00065     array(
00066       'blogger.getRecentPosts',
00067       'blogapi_blogger_get_recent_posts',
00068       array('array', 'string', 'string', 'string', 'string', 'int'),
00069       t('Returns a list of the most recent posts in the system.')),
00070     array(
00071       'metaWeblog.newPost',
00072       'blogapi_metaweblog_new_post',
00073       array('string', 'string', 'string', 'string', 'struct', 'boolean'),
00074       t('Creates a new post, and optionally publishes it.')),
00075     array(
00076       'metaWeblog.editPost',
00077       'blogapi_metaweblog_edit_post',
00078       array('boolean', 'string', 'string', 'string', 'struct', 'boolean'),
00079       t('Updates information about an existing post.')),
00080     array(
00081       'metaWeblog.getPost',
00082       'blogapi_metaweblog_get_post',
00083       array('struct', 'string', 'string', 'string'),
00084       t('Returns information about a specific post.')),
00085     array(
00086       'metaWeblog.newMediaObject',
00087       'blogapi_metaweblog_new_media_object',
00088       array('string', 'string', 'string', 'string', 'struct'),
00089       t('Uploads a file to your webserver.')),
00090     array(
00091       'metaWeblog.getCategories',
00092       'blogapi_metaweblog_get_category_list',
00093       array('struct', 'string', 'string', 'string'),
00094       t('Returns a list of all categories to which the post is assigned.')),
00095     array(
00096       'metaWeblog.getRecentPosts',
00097       'blogapi_metaweblog_get_recent_posts',
00098       array('array', 'string', 'string', 'string', 'int'),
00099       t('Returns a list of the most recent posts in the system.')),
00100     array(
00101       'mt.getRecentPostTitles',
00102       'blogapi_mt_get_recent_post_titles',
00103       array('array', 'string', 'string', 'string', 'int'),
00104       t('Returns a bandwidth-friendly list of the most recent posts in the system.')),
00105     array(
00106       'mt.getCategoryList',
00107       'blogapi_mt_get_category_list',
00108       array('array', 'string', 'string', 'string'),
00109       t('Returns a list of all categories defined in the blog.')),
00110     array(
00111       'mt.getPostCategories',
00112       'blogapi_mt_get_post_categories',
00113       array('array', 'string', 'string', 'string'),
00114       t('Returns a list of all categories to which the post is assigned.')),
00115     array(
00116       'mt.setPostCategories',
00117       'blogapi_mt_set_post_categories',
00118       array('boolean', 'string', 'string', 'string', 'array'),
00119       t('Sets the categories for a post.')),
00120     array(
00121       'mt.supportedMethods',
00122       'xmlrpc_server_list_methods',
00123       array('array'),
00124       t('Retrieve information about the XML-RPC methods supported by the server.')),
00125     array(
00126       'mt.supportedTextFilters',
00127       'blogapi_mt_supported_text_filters',
00128       array('array'),
00129       t('Retrieve information about the text formatting plugins supported by the server.')),
00130     array(
00131       'mt.publishPost',
00132       'blogap_mti_publish_post',
00133       array('boolean', 'string', 'string', 'string'),
00134       t('Publish (rebuild) all of the static files related to an entry from your blog. Equivalent to saving an entry in the system (but without the ping).')));
00135 }
00136
00141 function blogapi_blogger_get_users_blogs($appid, $username, $password) {
00142
00143   $user = blogapi_validate_user($username, $password);
00144   if ($user->uid) {
00145     $types = _blogapi_get_node_types();
00146     $structs = array();
00147     foreach ($types as $type) {
00148       $structs[] = array('url' => url('blog/'. $user->uid, array('absolute' => TRUE)), 'blogid' => $type, 'blogName' => $user->name .": ". $type);
00149     }
00150     return $structs;
00151   }
00152   else {
00153     return blogapi_error($user);
00154   }
00155 }
00156
00160 function blogapi_blogger_get_user_info($appkey, $username, $password) {
00161   $user = blogapi_validate_user($username, $password);
00162
00163   if ($user->uid) {
00164     $name = explode(' ', $user->realname ? $user->realname : $user->name, 2);
00165     return array(
00166       'userid' => $user->uid,
00167       'lastname' => $name[1],
00168       'firstname' => $name[0],
00169       'nickname' => $user->name,
00170       'email' => $user->mail,
00171       'url' => url('blog/'. $user->uid, array('absolute' => TRUE)));
00172   }
00173   else {
00174     return blogapi_error($user);
00175   }
00176 }
00177
00181 function blogapi_blogger_new_post($appkey, $blogid, $username, $password, $content, $publish) {
00182   $user = blogapi_validate_user($username, $password);
00183   if (!$user->uid) {
00184     return blogapi_error($user);
00185   }
00186
00187   if (($error = _blogapi_validate_blogid($blogid)) !== TRUE) {
00188     // Return an error if not configured type.
00189     return $error;
00190   }
00191
00192   $edit = array();
00193   $edit['type'] = $blogid;
00194   // get the node type defaults
00195   $node_type_default = variable_get('node_options_'. $edit['type'], array('status', 'promote'));
00196   $edit['uid'] = $user->uid;
00197   $edit['name'] = $user->name;
00198   $edit['promote'] = in_array('promote', $node_type_default);
00199   $edit['comment'] = variable_get('comment_'. $edit['type'], 2);
00200   $edit['revision'] = in_array('revision', $node_type_default);
00201   $edit['format'] = FILTER_FORMAT_DEFAULT;
00202   $edit['status'] = $publish;
00203
00204   // check for bloggerAPI vs. metaWeblogAPI
00205   if (is_array($content)) {
00206     $edit['title'] = $content['title'];
00207     $edit['body'] = $content['description'];
00208     _blogapi_mt_extra($edit, $content);
00209   }
00210   else {
00211     $edit['title'] = blogapi_blogger_title($content);
00212     $edit['body'] = $content;
00213   }
00214
00215   if (!node_access('create', $edit['type'])) {
00216     return blogapi_error(t('You do not have permission to create this type of post.'));
00217   }
00218
00219   if (user_access('administer nodes') && !isset($edit['date'])) {
00220     $edit['date'] = format_date(time(), 'custom', 'Y-m-d H:i:s O');
00221   }
00222
00223   node_invoke_nodeapi($edit, 'blogapi new');
00224
00225   node_validate($edit);
00226   if ($errors = form_get_errors()) {
00227     return blogapi_error(implode("\n", $errors));
00228   }
00229
00230   $node = node_submit($edit);
00231   node_save($node);
00232   if ($node->nid) {
00233     watchdog('content', '@type: added %title using blog API.', array('@type' => $node->type, '%title' => $node->title), WATCHDOG_NOTICE, l(t('view'), "node/$node->nid"));
00234     // blogger.newPost returns a string so we cast the nid to a string by putting it in double quotes:
00235     return "$node->nid";
00236   }
00237
00238   return blogapi_error(t('Error storing post.'));
00239 }
00240
00244 function blogapi_blogger_edit_post($appkey, $postid, $username, $password, $content, $publish) {
00245
00246   $user = blogapi_validate_user($username, $password);
00247
00248   if (!$user->uid) {
00249     return blogapi_error($user);
00250   }
00251
00252   $node = node_load($postid);
00253   if (!$node) {
00254     return blogapi_error(t('n/a'));
00255   }
00256   // Let the teaser be re-generated.
00257   unset($node->teaser);
00258
00259   if (!node_access('update', $node)) {
00260     return blogapi_error(t('You do not have permission to update this post.'));
00261   }
00262
00263   $node->status = $publish;
00264
00265   // check for bloggerAPI vs. metaWeblogAPI
00266   if (is_array($content)) {
00267     $node->title = $content['title'];
00268     $node->body = $content['description'];
00269     _blogapi_mt_extra($node, $content);
00270   }
00271   else {
00272     $node->title = blogapi_blogger_title($content);
00273     $node->body = $content;
00274   }
00275
00276   node_invoke_nodeapi($node, 'blogapi edit');
00277
00278   node_validate($node);
00279   if ($errors = form_get_errors()) {
00280     return blogapi_error(implode("\n", $errors));
00281   }
00282
00283   if (user_access('administer nodes') && !isset($edit['date'])) {
00284     $node->date = format_date($node->created, 'custom', 'Y-m-d H:i:s O');
00285   }
00286   $node = node_submit($node);
00287   node_save($node);
00288   if ($node->nid) {
00289     watchdog('content', '@type: updated %title using Blog API.', array('@type' => $node->type, '%title' => $node->title), WATCHDOG_NOTICE, l(t('view'), "node/$node->nid"));
00290     return TRUE;
00291   }
00292
00293   return blogapi_error(t('Error storing post.'));
00294 }
00295
00299 function blogapi_blogger_get_post($appkey, $postid, $username, $password) {
00300   $user = blogapi_validate_user($username, $password);
00301   if (!$user->uid) {
00302     return blogapi_error($user);
00303   }
00304
00305   $node = node_load($postid);
00306
00307   return _blogapi_get_post($node, TRUE);
00308 }
00309
00313 function blogapi_blogger_delete_post($appkey, $postid, $username, $password, $publish) {
00314   $user = blogapi_validate_user($username, $password);
00315   if (!$user->uid) {
00316     return blogapi_error($user);
00317   }
00318
00319   node_delete($postid);
00320   return TRUE;
00321 }
00322
00328 function blogapi_blogger_get_recent_posts($appkey, $blogid, $username, $password, $number_of_posts, $bodies = TRUE) {
00329   // Remove unused appkey (from bloggerAPI).
00330   $user = blogapi_validate_user($username, $password);
00331   if (!$user->uid) {
00332     return blogapi_error($user);
00333   }
00334
00335   if (($error = _blogapi_validate_blogid($blogid)) !== TRUE) {
00336     // Return an error if not configured type.
00337     return $error;
00338   }
00339
00340   if ($bodies) {
00341     $result = db_query_range("SELECT n.nid, n.title, r.body, r.format, n.comment, n.created, u.name FROM {node} n, {node_revisions} r, {users} u WHERE n.uid = u.uid AND n.vid = r.vid AND n.type = '%s' AND n.uid = %d ORDER BY n.created DESC",  $blogid, $user->uid, 0, $number_of_posts);
00342   }
00343   else {
00344     $result = db_query_range("SELECT n.nid, n.title, n.created, u.name FROM {node} n, {users} u WHERE n.uid = u.uid AND n.type = '%s' AND n.uid = %d ORDER BY n.created DESC", $blogid, $user->uid, 0, $number_of_posts);
00345   }
00346   $blogs = array();
00347   while ($blog = db_fetch_object($result)) {
00348     $blogs[] = _blogapi_get_post($blog, $bodies);
00349   }
00350   return $blogs;
00351 }
00352
00353 function blogapi_metaweblog_new_post($blogid, $username, $password, $content, $publish) {
00354   return blogapi_blogger_new_post('0123456789ABCDEF', $blogid, $username, $password, $content, $publish);
00355 }
00356
00357 function blogapi_metaweblog_edit_post($postid, $username, $password, $content, $publish) {
00358   return blogapi_blogger_edit_post('0123456789ABCDEF', $postid, $username, $password, $content, $publish);
00359 }
00360
00361 function blogapi_metaweblog_get_post($postid, $username, $password) {
00362   return blogapi_blogger_get_post('01234567890ABCDEF', $postid, $username, $password);
00363 }
00364
00368 function blogapi_metaweblog_new_media_object($blogid, $username, $password, $file) {
00369   $user = blogapi_validate_user($username, $password);
00370   if (!$user->uid) {
00371     return blogapi_error($user);
00372   }
00373
00374   $name = basename($file['name']);
00375   $data = $file['bits'];
00376
00377   if (!$data) {
00378     return blogapi_error(t('No file sent.'));
00379   }
00380
00381   if (!$file = file_save_data($data, $name)) {
00382     return blogapi_error(t('Error storing file.'));
00383   }
00384
00385   // Return the successful result.
00386   return array('url' => file_create_url($file), 'struct');
00387 }
00392 function blogapi_metaweblog_get_category_list($blogid, $username, $password) {
00393   if (($error = _blogapi_validate_blogid($blogid)) !== TRUE) {
00394     // Return an error if not configured type.
00395     return $error;
00396   }
00397
00398   $vocabularies = module_invoke('taxonomy', 'get_vocabularies', $blogid, 'vid');
00399   $categories = array();
00400   if ($vocabularies) {
00401     foreach ($vocabularies as $vocabulary) {
00402       $terms = module_invoke('taxonomy', 'get_tree', $vocabulary->vid, 0, -1);
00403       foreach ($terms as $term) {
00404         $term_name = $term->name;
00405         foreach (module_invoke('taxonomy', 'get_parents', $term->tid, 'tid') as $parent) {
00406           $term_name = $parent->name .'/'. $term_name;
00407         }
00408         $categories[] = array('categoryName' => $term_name, 'categoryId' => $term->tid);
00409       }
00410     }
00411   }
00412   return $categories;
00413 }
00414
00415 function blogapi_metaweblog_get_recent_posts($blogid, $username, $password, $number_of_posts) {
00416   return blogapi_blogger_get_recent_posts('0123456789ABCDEF', $blogid, $username, $password, $number_of_posts, TRUE);
00417 }
00418
00419 function blogapi_mt_get_recent_post_titles($blogid, $username, $password, $number_of_posts) {
00420   return blogapi_blogger_get_recent_posts('0123456789ABCDEF', $blogid, $username, $password, $number_of_posts, FALSE);
00421 }
00422
00423 function blogapi_mt_get_category_list($blogid, $username, $password) {
00424   return blogapi_metaweblog_get_category_list($blogid, $username, $password);
00425 }
00426
00431 function blogapi_mt_get_post_categories($postid, $username, $password) {
00432   $user = blogapi_validate_user($username, $password);
00433   if (!$user->uid) {
00434     return blogapi_error($user);
00435   }
00436
00437   $node = node_load($postid);
00438   $terms = module_invoke('taxonomy', 'node_get_terms', $node, 'tid');
00439   $categories = array();
00440   foreach ($terms as $term) {
00441     $term_name = $term->name;
00442     foreach (module_invoke('taxonomy', 'get_parents', $term->tid, 'tid') as $parent) {
00443       $term_name = $parent->name .'/'. $term_name;
00444     }
00445     $categories[] = array('categoryName' => $term_name, 'categoryId' => $term->tid, 'isPrimary' => TRUE);
00446   }
00447
00448   return $categories;
00449 }
00450
00454 function blogapi_mt_set_post_categories($postid, $username, $password, $categories) {
00455   $user = blogapi_validate_user($username, $password);
00456   if (!$user->uid) {
00457     return blogapi_error($user);
00458   }
00459
00460   $node = node_load($postid);
00461   $node->taxonomy = array();
00462   foreach ($categories as $category) {
00463     $node->taxonomy[] = $category['categoryId'];
00464   }
00465   node_save($node);
00466   return TRUE;
00467 }
00468
00472 function blogapi_mt_supported_text_filters() {
00473   // NOTE: we're only using anonymous' formats because the MT spec
00474   // does not allow for per-user formats.
00475   $formats = filter_formats();
00476
00477   $filters = array();
00478   foreach ($formats as $format) {
00479     $filter['key'] = $format->format;
00480     $filter['label'] = $format->name;
00481     $filters[] = $filter;
00482   }
00483
00484   return $filters;
00485 }
00486
00490 function blogap_mti_publish_post($postid, $username, $password) {
00491   $user = blogapi_validate_user($username, $password);
00492   if (!$user->uid) {
00493     return blogapi_error($user);
00494   }
00495   $node = node_load($postid);
00496   if (!$node) {
00497     return blogapi_error(t('Invalid post.'));
00498   }
00499
00500   $node->status = 1;
00501   if (!node_access('update', $node)) {
00502     return blogapi_error(t('You do not have permission to update this post.'));
00503   }
00504
00505   node_save($node);
00506
00507   return TRUE;
00508 }
00509
00513 function blogapi_error($message) {
00514   static $xmlrpcusererr;
00515   if (!is_array($message)) {
00516     $message = array($message);
00517   }
00518
00519   $message = implode(' ', $message);
00520
00521   return xmlrpc_error($xmlrpcusererr + 1, strip_tags($message));
00522 }
00523
00527 function blogapi_validate_user($username, $password) {
00528   global $user;
00529
00530   $user = user_authenticate(array('name' => $username, 'pass' => $password));
00531
00532   if ($user->uid) {
00533     if (user_access('administer content with blog api', $user)) {
00534       return $user;
00535     }
00536     else {
00537       return t('You do not have permission to edit this blog.');
00538     }
00539   }
00540   else {
00541     return t('Wrong username or password.');
00542   }
00543 }
00544
00548 function blogapi_blogger_title(&$contents) {
00549   if (eregi('<title>([^<]*)</title>', $contents, $title)) {
00550     $title = strip_tags($title[0]);
00551     $contents = ereg_replace('<title>[^<]*</title>', '', $contents);
00552   }
00553   else {
00554     list($title, $contents) = explode("\n", $contents, 2);
00555   }
00556   return $title;
00557 }
00558
00559 function blogapi_admin_settings() {
00560   $node_types = array_map('check_plain', node_get_types('names'));
00561   $defaults = isset($node_types['blog']) ? array('blog' => 1) : array();
00562   $form['blogapi_node_types'] = array(
00563     '#type' => 'checkboxes',
00564     '#title' => t('Enable for external blogging clients'),
00565     '#required' => TRUE,
00566     '#default_value' => variable_get('blogapi_node_types', $defaults),
00567     '#options' => $node_types,
00568     '#description' => t('Select the content types available to external blogging clients via Blog API. If supported, each enabled content type will be displayed as a separate "blog" by the external client.')
00569   );
00570
00571   return system_settings_form($form);
00572 }
00573
00574 function blogapi_menu() {
00575   $items['blogapi/rsd'] = array(
00576     'title' => 'RSD',
00577     'page callback' => 'blogapi_rsd',
00578     'access arguments' => array('access content'),
00579     'type' => MENU_CALLBACK,
00580   );
00581   $items['admin/settings/blogapi'] = array(
00582     'title' => 'Blog API',
00583     'description' => 'Configure the content types available to external blogging clients.',
00584     'page callback' => 'drupal_get_form',
00585     'page arguments' => array('blogapi_admin_settings'),
00586     'access arguments' => array('administer site configuration'),
00587     'type' => MENU_NORMAL_ITEM,
00588   );
00589
00590   return $items;
00591 }
00592
00593 function blogapi_init() {
00594   if (drupal_is_front_page()) {
00595     drupal_add_link(array('rel' => 'EditURI',
00596                           'type' => 'application/rsd+xml',
00597                           'title' => t('RSD'),
00598                           'href' => url('blogapi/rsd', array('absolute' => TRUE))));
00599   }
00600 }
00601
00602 function blogapi_rsd() {
00603   global $base_url;
00604
00605   $xmlrpc = $base_url .'/xmlrpc.php';
00606   $base = url('', array('absolute' => TRUE));
00607   $blogid = 1; # until we figure out how to handle multiple bloggers
00608
00609   drupal_set_header('Content-Type: application/rsd+xml; charset=utf-8');
00610   print <<<__RSD__
00611 <?xml version="1.0"?>
00612 <rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd">
00613   <service>
00614     <engineName>Drupal</engineName>
00615     <engineLink>http://drupal.org/</engineLink>
00616     <homePageLink>$base</homePageLink>
00617     <apis>
00618       <api name="MetaWeblog" preferred="false" apiLink="$xmlrpc" blogID="$blogid" />
00619       <api name="Blogger" preferred="false" apiLink="$xmlrpc" blogID="$blogid" />
00620       <api name="MovableType" preferred="true" apiLink="$xmlrpc" blogID="$blogid" />
00621     </apis>
00622   </service>
00623 </rsd>
00624 __RSD__;
00625 }
00626
00630 function _blogapi_mt_extra(&$node, $struct) {
00631   if (is_array($node)) {
00632     $was_array = TRUE;
00633     $node = (object)$node;
00634   }
00635
00636   // mt_allow_comments
00637   if (array_key_exists('mt_allow_comments', $struct)) {
00638     switch ($struct['mt_allow_comments']) {
00639       case 0:
00640         $node->comment = COMMENT_NODE_DISABLED;
00641         break;
00642       case 1:
00643         $node->comment = COMMENT_NODE_READ_WRITE;
00644         break;
00645       case 2:
00646         $node->comment = COMMENT_NODE_READ_ONLY;
00647         break;
00648     }
00649   }
00650
00651   // merge the 3 body sections (description, mt_excerpt, mt_text_more) into
00652   // one body
00653   if ($struct['mt_excerpt']) {
00654     $node->body = $struct['mt_excerpt'] .'<!--break-->'. $node->body;
00655   }
00656   if ($struct['mt_text_more']) {
00657     $node->body = $node->body .'<!--extended-->'. $struct['mt_text_more'];
00658   }
00659
00660   // mt_convert_breaks
00661   if ($struct['mt_convert_breaks']) {
00662     $node->format = $struct['mt_convert_breaks'];
00663   }
00664
00665   // dateCreated
00666   if ($struct['dateCreated']) {
00667     $node->date = format_date(mktime($struct['dateCreated']->hour, $struct['dateCreated']->minute, $struct['dateCreated']->second, $struct['dateCreated']->month, $struct['dateCreated']->day, $struct['dateCreated']->year), 'custom', 'Y-m-d H:i:s O');
00668   }
00669
00670   if ($was_array) {
00671     $node = (array)$node;
00672   }
00673 }
00674
00675 function _blogapi_get_post($node, $bodies = TRUE) {
00676   $xmlrpcval = array(
00677     'userid' => $node->name,
00678     'dateCreated' => xmlrpc_date($node->created),
00679     'title' => $node->title,
00680     'postid' => $node->nid,
00681     'link' => url('node/'. $node->nid, array('absolute' => TRUE)),
00682     'permaLink' => url('node/'. $node->nid, array('absolute' => TRUE)),
00683   );
00684   if ($bodies) {
00685     if ($node->comment == 1) {
00686       $comment = 2;
00687     }
00688     else if ($node->comment == 2) {
00689       $comment = 1;
00690     }
00691     $xmlrpcval['content'] = "<title>$node->title</title>$node->body";
00692     $xmlrpcval['description'] = $node->body;
00693     // Add MT specific fields
00694     $xmlrpcval['mt_allow_comments'] = (int) $comment;
00695     $xmlrpcval['mt_convert_breaks'] = $node->format;
00696   }
00697
00698   return $xmlrpcval;
00699 }
00700
00710 function _blogapi_validate_blogid($blogid) {
00711   $types = _blogapi_get_node_types();
00712   if (in_array($blogid, $types, TRUE)) {
00713     return TRUE;
00714   }
00715   return blogapi_error(t("Blog API module is not configured to support the %type content type, or you don't have sufficient permissions to post this type of content.", array('%type' => $blogid)));
00716 }
00717
00718 function _blogapi_get_node_types() {
00719   $available_types = array_keys(array_filter(variable_get('blogapi_node_types', array('blog' => 1))));
00720   $types = array();
00721   foreach (node_get_types() as $type => $name) {
00722     if (node_access('create', $type) && in_array($type, $available_types)) {
00723       $types[] = $type;
00724     }
00725   }
00726
00727   return $types;
00728 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/book/book-all-books-block.tpl.php Source File

modules » book

book-all-books-block.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: book-all-books-block.tpl.php,v 1.1 2007/11/04 14:29:09 goba Exp $
00003
00017 ?>
00018 <?php foreach ($book_menus as $book_id => $menu) : ?>
00019 <div id="book-block-menu-<?php print $book_id; ?>" class="book-block-menu">
00020   <?php print $menu; ?>
00021 </div>
00022 <?php endforeach; ?>
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/book/book-export-html.tpl.php Source File

modules » book

book-export-html.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: book-export-html.tpl.php,v 1.1 2007/11/04 14:29:09 goba Exp $
00003
00019 ?>
00020 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
00021 <html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language->language; ?>" xml:lang="<?php print $language->language; ?>">
00022   <head>
00023     <title><?php print $title; ?></title>
00024     <?php print $head; ?>
00025     <base href="<?php print $base_url; ?>" />
00026     <link type="text/css" rel="stylesheet" href="misc/print.css" />
00027     <?php if ($language_rtl): ?>
00028       <link type="text/css" rel="stylesheet" href="misc/print-rtl.css" />
00029     <?php endif; ?>
00030   </head>
00031   <body>
00032     <?php
00042     $div_close = '';
00043     ?>
00044     <?php for ($i = 1; $i < $depth; $i++) : ?>
00045       <div class="section-<?php print $i; ?>">
00046       <?php $div_close .= '</div>'; ?>
00047     <?php endfor; ?>
00048
00049     <?php print $contents; ?>
00050     <?php print $div_close; ?>
00051
00052   </body>
00053 </html>
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/book/book-navigation.tpl.php Source File

modules » book

book-navigation.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: book-navigation.tpl.php,v 1.1 2007/11/04 14:29:09 goba Exp $
00003
00032 ?>
00033 <?php if ($tree || $has_links): ?>
00034   <div id="book-navigation-<?php print $book_id; ?>" class="book-navigation">
00035     <?php print $tree; ?>
00036
00037     <?php if ($has_links): ?>
00038     <div class="page-links clear-block">
00039       <?php if ($prev_url) : ?>
00040         <a href="<?php print $prev_url; ?>" class="page-previous" title="<?php print t('Go to previous page'); ?>"><?php print t('‹ ') . $prev_title; ?></a>
00041       <?php endif; ?>
00042       <?php if ($parent_url) : ?>
00043         <a href="<?php print $parent_url; ?>" class="page-up" title="<?php print t('Go to parent page'); ?>"><?php print t('up'); ?></a>
00044       <?php endif; ?>
00045       <?php if ($next_url) : ?>
00046         <a href="<?php print $next_url; ?>" class="page-next" title="<?php print t('Go to next page'); ?>"><?php print $next_title . t(' ›'); ?></a>
00047       <?php endif; ?>
00048     </div>
00049     <?php endif; ?>
00050
00051   </div>
00052 <?php endif; ?>
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/book/book-node-export-html.tpl.php Source File

modules » book

book-node-export-html.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: book-node-export-html.tpl.php,v 1.1 2007/11/04 14:29:09 goba Exp $
00003
00020 ?>
00021 <div id="node-<?php print $node->nid; ?>" class="section-<?php print $depth; ?>">
00022   <h1 class="book-heading"><?php print $title; ?></h1>
00023   <?php print $content; ?>
00024   <?php print $children; ?>
00025 </div>
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/book/book.admin.inc Source File

modules » book

book.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: book.admin.inc,v 1.8 2008/01/08 10:35:41 goba Exp $
00003
00012 function book_admin_overview() {
00013   $rows = array();
00014   foreach (book_get_books() as $book) {
00015     $rows[] = array(l($book['title'], $book['href'], $book['options']), l(t('edit order and titles'), "admin/content/book/". $book['nid']));
00016   }
00017   $headers = array(t('Book'), t('Operations'));
00018
00019   return theme('table', $headers, $rows);
00020 }
00021
00029 function book_admin_settings() {
00030   $types = node_get_types('names');
00031   $form['book_allowed_types'] = array(
00032     '#type' => 'checkboxes',
00033     '#title' => t('Allowed book outline types'),
00034     '#default_value' => variable_get('book_allowed_types', array('book')),
00035     '#options' => $types,
00036     '#description' => t('Select content types which users with the %add-perm permission will be allowed to add to the book hierarchy. Users with the %outline-perm permission can add all content types.', array('%add-perm' => t('add content to books'),  '%outline-perm' => t('administer book outlines'))),
00037     '#required' => TRUE,
00038   );
00039   $form['book_child_type'] = array(
00040     '#type' => 'radios',
00041     '#title' => t('Default child page type'),
00042     '#default_value' => variable_get('book_child_type', 'book'),
00043     '#options' => $types,
00044     '#description' => t('The content type for the %add-child link must be one of those selected as an allowed book outline type.', array('%add-child' => t('Add child page'))),
00045     '#required' => TRUE,
00046   );
00047   $form['array_filter'] = array('#type' => 'value', '#value' => TRUE);
00048   $form['#validate'][] = 'book_admin_settings_validate';
00049   return system_settings_form($form);
00050 }
00051
00057 function book_admin_settings_validate($form, &$form_state) {
00058   $child_type = $form_state['values']['book_child_type'];
00059   if (empty($form_state['values']['book_allowed_types'][$child_type])) {
00060     form_set_error('book_child_type', t('The content type for the %add-child link must be one of those selected as an allowed book outline type.', array('%add-child' => t('Add child page'))));
00061   }
00062 }
00063
00071 function book_admin_edit($form_state, $node) {
00072   drupal_set_title(check_plain($node->title));
00073   $form = array();
00074   $form['#node'] = $node;
00075   $form['table'] = _book_admin_table($node);
00076   $form['save'] = array(
00077     '#type' => 'submit',
00078     '#value' => t('Save book pages'),
00079   );
00080   return $form;
00081 }
00082
00092 function book_admin_edit_submit($form, &$form_state) {
00093   // Save elements in the same order as defined in post rather than the form.
00094   // This ensures parents are updated before their children, preventing orphans.
00095   $order = array_flip(array_keys($form['#post']['table']));
00096   $form['table'] = array_merge($order, $form['table']);
00097
00098   foreach (element_children($form['table']) as $key) {
00099     if ($form['table'][$key]['#item']) {
00100       $row = $form['table'][$key];
00101       $values = $form_state['values']['table'][$key];
00102
00103       // Update menu item if moved.
00104       if ($row['plid']['#default_value'] != $values['plid'] || $row['weight']['#default_value'] != $values['weight']) {
00105         $row['#item']['plid'] = $values['plid'];
00106         $row['#item']['weight'] = $values['weight'];
00107         menu_link_save($row['#item']);
00108       }
00109
00110       // Update the title if changed.
00111       if ($row['title']['#default_value'] != $values['title']) {
00112         $node = node_load($values['nid'], FALSE);
00113         $node->title = $values['title'];
00114         $node->book['link_title'] = $values['title'];
00115         $node->revision = 1;
00116         $node->log = t('Title changed from %original to %current.', array('%original' => $node->title, '%current' => $values['title']));
00117         node_save($node);
00118         watchdog('content', 'book: updated %title.', array('%title' => $node->title), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid));
00119       }
00120     }
00121   }
00122
00123   drupal_set_message(t('Updated book %title.', array('%title' => $form['#node']->title)));
00124 }
00125
00131 function _book_admin_table($node) {
00132   $form = array(
00133     '#theme' => 'book_admin_table',
00134     '#tree' => TRUE,
00135   );
00136
00137   $tree = book_menu_subtree_data($node->book);
00138   $tree = array_shift($tree); // Do not include the book item itself.
00139   if ($tree['below']) {
00140     _book_admin_table_tree($tree['below'], $form);
00141   }
00142   return $form;
00143 }
00144
00150 function _book_admin_table_tree($tree, &$form) {
00151   foreach ($tree as $key => $data) {
00152     $form[$key] = array(
00153       '#item' => $data['link'],
00154       'nid' => array('#type' => 'value', '#value' => $data['link']['nid']),
00155       'depth' => array('#type' => 'value', '#value' => $data['link']['depth']),
00156       'href' => array('#type' => 'value', '#value' => $data['link']['href']),
00157       'title' => array(
00158         '#type' => 'textfield',
00159         '#default_value' => $data['link']['link_title'],
00160         '#maxlength' => 255,
00161         '#size' => 40,
00162       ),
00163       'weight' => array(
00164         '#type' => 'weight',
00165         '#default_value' => $data['link']['weight'],
00166         '#delta' => 15,
00167       ),
00168       'plid' => array(
00169         '#type' => 'textfield',
00170         '#default_value' => $data['link']['plid'],
00171         '#size' => 6,
00172       ),
00173       'mlid' => array(
00174         '#type' => 'hidden',
00175         '#default_value' => $data['link']['mlid'],
00176       ),
00177     );
00178     if ($data['below']) {
00179       _book_admin_table_tree($data['below'], $form);
00180     }
00181   }
00182
00183   return $form;
00184 }
00185
00192 function theme_book_admin_table($form) {
00193   drupal_add_tabledrag('book-outline', 'match', 'parent', 'book-plid', 'book-plid', 'book-mlid', TRUE, MENU_MAX_DEPTH - 2);
00194   drupal_add_tabledrag('book-outline', 'order', 'sibling', 'book-weight');
00195
00196   $header = array(t('Title'), t('Weight'), t('Parent'), array('data' => t('Operations'), 'colspan' => '3'));
00197
00198   $rows = array();
00199   $destination = drupal_get_destination();
00200   $access = user_access('administer nodes');
00201   foreach (element_children($form) as $key) {
00202     $nid = $form[$key]['nid']['#value'];
00203     $href = $form[$key]['href']['#value'];
00204
00205     // Add special classes to be used with tabledrag.js.
00206     $form[$key]['plid']['#attributes']['class'] = 'book-plid';
00207     $form[$key]['mlid']['#attributes']['class'] = 'book-mlid';
00208     $form[$key]['weight']['#attributes']['class'] = 'book-weight';
00209
00210     $data = array(
00211       theme('indentation', $form[$key]['depth']['#value'] - 2) . drupal_render($form[$key]['title']),
00212       drupal_render($form[$key]['weight']),
00213       drupal_render($form[$key]['plid']) . drupal_render($form[$key]['mlid']),
00214       l(t('view'), $href),
00215       $access ? l(t('edit'), 'node/'. $nid .'/edit', array('query' => $destination)) : '&nbsp',
00216       $access ? l(t('delete'), 'node/'. $nid .'/delete', array('query' => $destination) )  : '&nbsp',
00217     );
00218     $row = array('data' => $data);
00219     if (isset($form[$key]['#attributes'])) {
00220       $row = array_merge($row, $form[$key]['#attributes']);
00221     }
00222     $row['class'] = empty($row['class']) ? 'draggable' : $row['class'] .' draggable';
00223     $rows[] = $row;
00224   }
00225
00226   return theme('table', $header, $rows, array('id' => 'book-outline'));
00227 }
00228
00232 function _book_admin_sort_tree(&$tree) {
00233   uasort($tree, '_book_admin_compare');
00234   foreach ($tree as $key => $subtree) {
00235     if (!empty($tree[$key]['below'])) {
00236       _book_admin_sort_tree($tree[$key]['below']);
00237     }
00238   }
00239 }
00240
00244 function _book_admin_compare($a, $b) {
00245   $weight = $a['link']['weight'] - $b['link']['weight'];
00246   if ($weight) {
00247     return $weight;
00248   }
00249   return strncmp($a['link']['title'], $b['link']['title']);
00250 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/book/book.install Source File

modules » book

book.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: book.install,v 1.20 2008/01/10 18:13:42 goba Exp $
00003
00007 function book_install() {
00008   // Create tables.
00009   drupal_install_schema('book');
00010   // Add the node type.
00011   _book_install_type_create();
00012 }
00013
00017 function book_uninstall() {
00018   // Delete menu links.
00019   db_query("DELETE FROM {menu_links} WHERE module = 'book'");
00020   menu_cache_clear_all();
00021   // Remove tables.
00022   drupal_uninstall_schema('book');
00023 }
00024
00025 function _book_install_type_create() {
00026   // Create an additional node type
00027   $book_node_type = array(
00028     'type' => 'book',
00029     'name' => t('Book page'),
00030     'module' => 'node',
00031     'description' => t('A <em>book page</em> is a page of content, organized into a collection of related entries collectively known as a <em>book</em>. A <em>book page</em> automatically displays links to adjacent pages, providing a simple navigation system for organizing and reviewing structured content.'),
00032     'custom' => TRUE,
00033     'modified' => TRUE,
00034     'locked' => FALSE,
00035   );
00036
00037   $book_node_type = (object)_node_type_set_defaults($book_node_type);
00038   node_type_save($book_node_type);
00039   // Default to not promoted.
00040   variable_set('node_options_book', array('status'));
00041   // Use this default type for adding content to books.
00042   variable_set('book_allowed_types', array('book'));
00043   variable_set('book_child_type', 'book');
00044 }
00045
00059 function book_update_6000() {
00060   $ret = array();
00061
00062   // Set up for a multi-part update.
00063   if (!isset($_SESSION['book_update_6000'])) {
00064
00065     $schema['book'] = array(
00066       'fields' => array(
00067         'mlid'    => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
00068         'nid'     => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
00069         'bid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
00070       ),
00071       'primary key' => array('mlid'),
00072       'unique keys' => array(
00073         'nid' => array('nid'),
00074       ),
00075       'indexes' => array(
00076         'bid' => array('bid'),
00077       ),
00078     );
00079     // Add the node type.
00080     _book_install_type_create();
00081
00082     // Fix role permissions to account for the changed names
00083     // Setup the array holding strings to match and the corresponding
00084     // strings to replace them with.
00085     $replace = array(
00086       'outline posts in books' => 'administer book outlines',
00087       'create book pages' => 'create book content',
00088       'edit book pages' => 'edit any book content',
00089       'edit own book pages' => 'edit own book content',
00090       'see printer-friendly version' => 'access printer-friendly version',
00091     );
00092
00093     // Loop over all the roles, and do the necessary transformations.
00094     $query = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
00095     while ($role = db_fetch_object($query)) {
00096       // Replace all the old permissions with the corresponding new permissions.
00097       $fixed_perm = strtr($role->perm, $replace);
00098       // If the user could previously create book pages, they should get the new
00099       // 'add content to books' permission.
00100       if (strpos($role->perm, 'create book pages') !== FALSE) {
00101         $fixed_perm .= ', add content to books';
00102       }
00103       // Only save if the permissions have changed.
00104       if ($fixed_perm != $role->perm) {
00105         $ret[] = update_sql("UPDATE {permission} SET perm = '$fixed_perm' WHERE rid = $role->rid");
00106       }
00107     }
00108
00109     // Determine whether there are any existing nodes in the book hierarchy.
00110     if (db_result(db_query("SELECT COUNT(*) FROM {book}"))) {
00111       // Temporary table for the old book hierarchy; we'll discard revision info.
00112       $schema['book_temp'] = array(
00113         'fields' => array(
00114           'nid'    => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
00115           'parent' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
00116           'weight' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')
00117         ),
00118         'indexes' => array(
00119           'parent' => array('parent')
00120         ),
00121         'primary key' => array('nid'),
00122       );
00123
00124       db_create_table($ret, 'book_temp', $schema['book_temp']);
00125
00126       // Insert each node in the old table into the temporary table.
00127       $ret[] = update_sql("INSERT INTO {book_temp} (nid, parent, weight) SELECT b.nid, b.parent, b.weight FROM {book} b INNER JOIN {node} n on b.vid = n.vid");
00128       $ret[] = update_sql("DROP TABLE {book}");
00129
00130       db_create_table($ret, 'book', $schema['book']);
00131
00132       $_SESSION['book_update_6000_orphans']['from'] = 0;
00133       $_SESSION['book_update_6000'] = array();
00134       $result = db_query("SELECT * from {book_temp} WHERE parent = 0");
00135
00136       // Collect all books - top-level nodes.
00137       while ($a = db_fetch_array($result)) {
00138         $_SESSION['book_update_6000'][] = $a;
00139       }
00140       $ret['#finished'] = FALSE;
00141       return $ret;
00142     }
00143     else {
00144       // No exising nodes in the hierarchy, so drop the table and re-create it.
00145       $ret[] = update_sql("DROP TABLE {book}");
00146       db_create_table($ret, 'book', $schema['book']);
00147       return $ret;
00148     }
00149   }
00150   elseif ($_SESSION['book_update_6000_orphans']) {
00151     // Do the first batched part of the update - collect orphans.
00152     $update_count = 400; // Update this many at a time
00153
00154     $result = db_query_range("SELECT * FROM {book_temp}", $_SESSION['book_update_6000_orphans']['from'], $update_count);
00155     $has_rows = FALSE;
00156     // Go through the next $update_count book pages and locate the orphans.
00157     while ($book = db_fetch_array($result)) {
00158       $has_rows = TRUE;
00159       // Orphans are defined as nodes whose parent does not exist in the table.
00160       if ($book['parent'] && !db_result(db_query("SELECT COUNT(*) FROM {book_temp} WHERE nid = %d", $book['parent']))) {
00161         if (empty($_SESSION['book_update_6000_orphans']['book'])) {
00162           // The first orphan becomes the parent for all other orphans.
00163           $book['parent'] = 0;
00164           $_SESSION['book_update_6000_orphans']['book'] = $book;
00165           $ret[] = array('success' => TRUE, 'query' => 'Relocated orphan book pages.');
00166         }
00167         else {
00168           // Re-assign the parent value of the book, and add it to the stack.
00169           $book['parent'] = $_SESSION['book_update_6000_orphans']['book']['nid'];
00170           $_SESSION['book_update_6000'][] = $book;
00171         }
00172       }
00173     }
00174     if ($has_rows) {
00175       $_SESSION['book_update_6000_orphans']['from'] += $update_count;
00176     }
00177     else {
00178       // Done with this part
00179       if (!empty($_SESSION['book_update_6000_orphans']['book'])) {
00180         // The orphans' parent is added last, so it will be processed first.
00181         $_SESSION['book_update_6000'][] = $_SESSION['book_update_6000_orphans']['book'];
00182       }
00183       $_SESSION['book_update_6000_orphans'] = FALSE;
00184     }
00185     $ret['#finished'] = FALSE;
00186     return $ret;
00187   }
00188   else {
00189     // Do the next batched part of the update
00190     $update_count = 100; // Update this many at a time
00191
00192     while ($update_count && $_SESSION['book_update_6000']) {
00193       // Get the last node off the stack.
00194       $book = array_pop($_SESSION['book_update_6000']);
00195
00196       // Add all of this node's children to the stack
00197       $result = db_query("SELECT * FROM {book_temp} WHERE parent = %d", $book['nid']);
00198       while ($a = db_fetch_array($result)) {
00199         $_SESSION['book_update_6000'][] = $a;
00200       }
00201
00202       if ($book['parent']) {
00203         // If its not a top level page, get its parent's mlid.
00204         $parent = db_fetch_array(db_query("SELECT b.mlid AS plid, b.bid FROM {book} b WHERE b.nid = %d", $book['parent']));
00205         $book = array_merge($book, $parent);
00206       }
00207       else {
00208         // There is not a parent - this is a new book.
00209         $book['plid'] = 0;
00210         $book['bid'] = $book['nid'];
00211       }
00212
00213       $book += array(
00214         'module' => 'book',
00215         'link_path' => 'node/'. $book['nid'],
00216         'router_path' => 'node/%',
00217         'menu_name' => 'book-toc-'. $book['bid'],
00218       );
00219       $book = array_merge($book, db_fetch_array(db_query("SELECT title AS link_title FROM {node} WHERE nid = %d", $book['nid'])));
00220
00221       // Items with depth > MENU_MAX_DEPTH cannot be saved.
00222       if (menu_link_save($book)) {
00223         db_query("INSERT INTO {book} (mlid, nid, bid) VALUES (%d, %d, %d)", $book['mlid'], $book['nid'], $book['bid']);
00224       }
00225       else {
00226         // The depth was greater then MENU_MAX_DEPTH, so attach it to the
00227         // closest valid parent.
00228         $book['plid'] = db_result(db_query("SELECT plid FROM {menu_links} WHERE mlid = %d", $book['plid']));
00229         if (menu_link_save($book)) {
00230           db_query("INSERT INTO {book} (mlid, nid, bid) VALUES (%d, %d, %d)", $book['mlid'], $book['nid'], $book['bid']);
00231         }
00232       }
00233       $update_count--;
00234     }
00235     $ret['#finished'] = FALSE;
00236   }
00237
00238   if (empty($_SESSION['book_update_6000'])) {
00239     $ret['#finished'] = TRUE;
00240     $ret[] = array('success' => TRUE, 'query' => 'Relocated existing book pages.');
00241     $ret[] = update_sql("DROP TABLE {book_temp}");
00242     unset($_SESSION['book_update_6000']);
00243     unset($_SESSION['book_update_6000_orphans']);
00244   }
00245
00246   return $ret;
00247 }
00248
00252 function book_schema() {
00253   $schema['book'] = array(
00254   'description' => t('Stores book outline information. Uniquely connects each node in the outline to a link in {menu_links}'),
00255     'fields' => array(
00256       'mlid' => array(
00257         'type' => 'int',
00258         'unsigned' => TRUE,
00259         'not null' => TRUE,
00260         'default' => 0,
00261         'description' => t("The book page's {menu_links}.mlid."),
00262       ),
00263       'nid' => array(
00264         'type' => 'int',
00265         'unsigned' => TRUE,
00266         'not null' => TRUE,
00267         'default' => 0,
00268         'description' => t("The book page's {node}.nid."),
00269       ),
00270       'bid' => array(
00271         'type' => 'int',
00272         'unsigned' => TRUE,
00273         'not null' => TRUE,
00274         'default' => 0,
00275         'description' => t("The book ID is the {book}.nid of the top-level page."),
00276       ),
00277     ),
00278     'primary key' => array('mlid'),
00279     'unique keys' => array(
00280       'nid' => array('nid'),
00281     ),
00282     'indexes' => array(
00283       'bid' => array('bid'),
00284     ),
00285   );
00286
00287   return $schema;
00288 }
00289
00290
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/book/book.module Source File

modules » book

book.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: book.module,v 1.454.2.1 2008/02/05 10:01:12 goba Exp $
00003
00012 function book_theme() {
00013   return array(
00014     'book_navigation' => array(
00015       'arguments' => array('book_link' => NULL),
00016       'template' => 'book-navigation',
00017     ),
00018     'book_export_html' => array(
00019       'arguments' => array('title' => NULL, 'contents' => NULL, 'depth' => NULL),
00020       'template' => 'book-export-html',
00021     ),
00022     'book_admin_table' => array(
00023       'arguments' => array('form' => NULL),
00024     ),
00025     'book_title_link' => array(
00026       'arguments' => array('link' => NULL),
00027     ),
00028     'book_all_books_block' => array(
00029       'arguments' => array('book_menus' => array()),
00030       'template' => 'book-all-books-block',
00031     ),
00032     'book_node_export_html' => array(
00033       'arguments' => array('node' => NULL, 'children' => NULL),
00034       'template' => 'book-node-export-html',
00035     ),
00036   );
00037 }
00038
00042 function book_perm() {
00043   return array('add content to books', 'administer book outlines', 'create new books', 'access printer-friendly version');
00044 }
00045
00049 function book_link($type, $node = NULL, $teaser = FALSE) {
00050   $links = array();
00051
00052   if ($type == 'node' && isset($node->book)) {
00053     if (!$teaser) {
00054       $child_type = variable_get('book_child_type', 'book');
00055       if ((user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->status == 1 && $node->book['depth'] < MENU_MAX_DEPTH) {
00056         $links['book_add_child'] = array(
00057           'title' => t('Add child page'),
00058           'href' => "node/add/". str_replace('_', '-', $child_type),
00059           'query' => "parent=". $node->book['mlid'],
00060         );
00061       }
00062       if (user_access('access printer-friendly version')) {
00063         $links['book_printer'] = array(
00064           'title' => t('Printer-friendly version'),
00065           'href' => 'book/export/html/'. $node->nid,
00066           'attributes' => array('title' => t('Show a printer-friendly version of this book page and its sub-pages.'))
00067         );
00068       }
00069     }
00070   }
00071   return $links;
00072 }
00073
00077 function book_menu() {
00078   $items['admin/content/book'] = array(
00079     'title' => 'Books',
00080     'description' => "Manage your site's book outlines.",
00081     'page callback' => 'book_admin_overview',
00082     'access arguments' => array('administer book outlines'),
00083     'file' => 'book.admin.inc',
00084   );
00085   $items['admin/content/book/list'] = array(
00086     'title' => 'List',
00087     'type' => MENU_DEFAULT_LOCAL_TASK,
00088   );
00089   $items['admin/content/book/settings'] = array(
00090     'title' => 'Settings',
00091     'page callback' => 'drupal_get_form',
00092     'page arguments' => array('book_admin_settings'),
00093     'access arguments' => array('administer site configuration'),
00094     'type' => MENU_LOCAL_TASK,
00095     'weight' => 8,
00096     'file' => 'book.admin.inc',
00097   );
00098   $items['admin/content/book/%node'] = array(
00099     'title' => 'Re-order book pages and change titles',
00100     'page callback' => 'drupal_get_form',
00101     'page arguments' => array('book_admin_edit', 3),
00102     'access callback' => '_book_outline_access',
00103     'access arguments' => array(3),
00104     'type' => MENU_CALLBACK,
00105     'file' => 'book.admin.inc',
00106   );
00107   $items['book'] = array(
00108     'title' => 'Books',
00109     'page callback' => 'book_render',
00110     'access arguments' => array('access content'),
00111     'type' => MENU_SUGGESTED_ITEM,
00112     'file' => 'book.pages.inc',
00113   );
00114   $items['book/export/%/%'] = array(
00115     'page callback' => 'book_export',
00116     'page arguments' => array(2, 3),
00117     'access arguments' => array('access printer-friendly version'),
00118     'type' => MENU_CALLBACK,
00119     'file' => 'book.pages.inc',
00120   );
00121   $items['node/%node/outline'] = array(
00122     'title' => 'Outline',
00123     'page callback' => 'book_outline',
00124     'page arguments' => array(1),
00125     'access callback' => '_book_outline_access',
00126     'access arguments' => array(1),
00127     'type' => MENU_LOCAL_TASK,
00128     'weight' => 2,
00129     'file' => 'book.pages.inc',
00130   );
00131   $items['node/%node/outline/remove'] = array(
00132     'title' => 'Remove from outline',
00133     'page callback' => 'drupal_get_form',
00134     'page arguments' => array('book_remove_form', 1),
00135     'access callback' => '_book_outline_remove_access',
00136     'access arguments' => array(1),
00137     'type' => MENU_CALLBACK,
00138     'file' => 'book.pages.inc',
00139   );
00140   $items['book/js/form'] = array(
00141     'page callback' => 'book_form_update',
00142     'access arguments' => array('access content'),
00143     'type' => MENU_CALLBACK,
00144     'file' => 'book.pages.inc',
00145   );
00146   return $items;
00147 }
00148
00152 function _book_outline_access($node) {
00153   return user_access('administer book outlines') && node_access('view', $node);
00154 }
00155
00159 function _book_outline_remove_access($node) {
00160   return isset($node->book) && ($node->book['bid'] != $node->nid) && _book_outline_access($node);
00161 }
00162
00166 function book_init() {
00167   drupal_add_css(drupal_get_path('module', 'book') .'/book.css');
00168 }
00169
00176 function book_block($op = 'list', $delta = 0, $edit = array()) {
00177   $block = array();
00178   switch ($op) {
00179     case 'list':
00180       $block[0]['info'] = t('Book navigation');
00181       $block[0]['cache'] = BLOCK_CACHE_PER_PAGE | BLOCK_CACHE_PER_ROLE;
00182       return $block;
00183     case 'view':
00184       $current_bid = 0;
00185       if ($node = menu_get_object()) {
00186         $current_bid = empty($node->book['bid']) ? 0 : $node->book['bid'];
00187       }
00188       if (variable_get('book_block_mode', 'all pages') == 'all pages') {
00189         $block['subject'] = t('Book navigation');
00190         $book_menus = array();
00191         $pseudo_tree = array(0 => array('below' => FALSE));
00192         foreach (book_get_books() as $book_id => $book) {
00193           if ($book['bid'] == $current_bid) {
00194             // If the current page is a node associated with a book, the menu
00195             // needs to be retrieved.
00196             $book_menus[$book_id] = menu_tree_output(menu_tree_all_data($node->book['menu_name'], $node->book));
00197           }
00198           else {
00199             // Since we know we will only display a link to the top node, there
00200             // is no reason to run an additional menu tree query for each book.
00201             $book['in_active_trail'] = FALSE;
00202             $pseudo_tree[0]['link'] = $book;
00203             $book_menus[$book_id] = menu_tree_output($pseudo_tree);
00204           }
00205         }
00206         $block['content'] = theme('book_all_books_block', $book_menus);
00207       }
00208       elseif ($current_bid) {
00209         // Only display this block when the user is browsing a book.
00210         $title = db_result(db_query(db_rewrite_sql('SELECT n.title FROM {node} n WHERE n.nid = %d'), $node->book['bid']));
00211         // Only show the block if the user has view access for the top-level node.
00212         if ($title) {
00213           $tree = menu_tree_all_data($node->book['menu_name'], $node->book);
00214           // There should only be one element at the top level.
00215           $data = array_shift($tree);
00216           $block['subject'] = theme('book_title_link', $data['link']);
00217           $block['content'] = ($data['below']) ? menu_tree_output($data['below']) : '';
00218         }
00219       }
00220       return $block;
00221     case 'configure':
00222       $options = array(
00223         'all pages' => t('Show block on all pages'),
00224         'book pages' => t('Show block only on book pages'),
00225       );
00226       $form['book_block_mode'] = array(
00227         '#type' => 'radios',
00228         '#title' => t('Book navigation block display'),
00229         '#options' => $options,
00230         '#default_value' => variable_get('book_block_mode', 'all pages'),
00231         '#description' => t("If <em>Show block on all pages</em> is selected, the block will contain the automatically generated menus for all of the site's books. If <em>Show block only on book pages</em> is selected, the block will contain only the one menu corresponding to the current page's book. In this case, if the current page is not in a book, no block will be displayed. The <em>Page specific visibility settings</em> or other visibility settings can be used in addition to selectively display this block."),
00232         );
00233       return $form;
00234     case 'save':
00235       variable_set('book_block_mode', $edit['book_block_mode']);
00236       break;
00237   }
00238 }
00239
00245 function theme_book_title_link($link) {
00246   $link['options']['attributes']['class'] =  'book-title';
00247   return l($link['title'], $link['href'], $link['options']);
00248 }
00249
00256 function book_get_books() {
00257   static $all_books;
00258
00259   if (!isset($all_books)) {
00260     $all_books = array();
00261     $result = db_query("SELECT DISTINCT(bid) FROM {book}");
00262     $nids = array();
00263     while ($book = db_fetch_array($result)) {
00264       $nids[] = $book['bid'];
00265     }
00266     if ($nids) {
00267       $result2 = db_query(db_rewrite_sql("SELECT n.type, n.title, b.*, ml.* FROM {book} b INNER JOIN {node} n on b.nid = n.nid INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE n.nid IN (". implode(',', $nids) .") AND n.status = 1 ORDER BY ml.weight, ml.link_title"));
00268       while ($link = db_fetch_array($result2)) {
00269         $link['href'] = $link['link_path'];
00270         $link['options'] = unserialize($link['options']);
00271         $all_books[$link['bid']] = $link;
00272       }
00273     }
00274   }
00275   return $all_books;
00276 }
00277
00284 function book_form_alter(&$form, $form_state, $form_id) {
00285
00286   if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
00287     // Add elements to the node form
00288     $node = $form['#node'];
00289
00290     $access = user_access('administer book outlines');
00291     if (!$access) {
00292       if (user_access('add content to books') && ((!empty($node->book['mlid']) && !empty($node->nid)) || book_type_is_allowed($node->type))) {
00293         // Already in the book hierarchy or this node type is allowed
00294         $access = TRUE;
00295       }
00296     }
00297
00298     if ($access) {
00299       _book_add_form_elements($form, $node);
00300       $form['book']['pick-book'] = array(
00301         '#type' => 'submit',
00302         '#value' => t('Change book (update list of parents)'),
00303          // Submit the node form so the parent select options get updated.
00304          // This is typically only used when JS is disabled.  Since the parent options
00305          // won't be changed via AJAX, a button is provided in the node form to submit
00306          // the form and generate options in the parent select corresponding to the
00307          // selected book.  This is similar to what happens during a node preview.
00308         '#submit' => array('node_form_submit_build_node'),
00309         '#weight' => 20,
00310       );
00311     }
00312   }
00313 }
00314
00322 function _book_parent_select($book_link) {
00323   if (variable_get('menu_override_parent_selector', FALSE)) {
00324     return array();
00325   }
00326   // Offer a message or a drop-down to choose a different parent page.
00327   $form = array(
00328     '#type' => 'hidden',
00329     '#value' => -1,
00330     '#prefix' => '<div id="edit-book-plid-wrapper">',
00331     '#suffix' => '</div>',
00332   );
00333
00334   if ($book_link['nid'] === $book_link['bid']) {
00335     // This is a book - at the top level.
00336     if ($book_link['original_bid'] === $book_link['bid']) {
00337       $form['#prefix'] .= '<em>'. t('This is the top-level page in this book.') .'</em>';
00338     }
00339     else {
00340       $form['#prefix'] .= '<em>'. t('This will be the top-level page in this book.') .'</em>';
00341     }
00342   }
00343   elseif (!$book_link['bid']) {
00344     $form['#prefix'] .= '<em>'. t('No book selected.') .'</em>';
00345   }
00346   else {
00347     $form = array(
00348       '#type' => 'select',
00349       '#title' => t('Parent item'),
00350       '#default_value' => $book_link['plid'],
00351       '#description' => t('The parent page in the book. The maximum depth for a book and all child pages is !maxdepth. Some pages in the selected book may not be available as parents if selecting them would exceed this limit.', array('!maxdepth' => MENU_MAX_DEPTH)),
00352       '#options' => book_toc($book_link['bid'], array($book_link['mlid']), $book_link['parent_depth_limit']),
00353       '#attributes' => array('class' => 'book-title-select'),
00354     );
00355   }
00356   return $form;
00357 }
00358
00362 function _book_add_form_elements(&$form, $node) {
00363   // Need this for AJAX.
00364   $form['#cache'] = TRUE;
00365   drupal_add_js("if (Drupal.jsEnabled) { $(document).ready(function() { $('#edit-book-pick-book').css('display', 'none'); }); }", 'inline');
00366
00367   $form['book'] = array(
00368     '#type' => 'fieldset',
00369     '#title' => t('Book outline'),
00370     '#weight' => 10,
00371     '#collapsible' => TRUE,
00372     '#collapsed' => TRUE,
00373     '#tree' => TRUE,
00374     '#attributes' => array('class' => 'book-outline-form'),
00375   );
00376   foreach (array('menu_name', 'mlid', 'nid', 'router_path', 'has_children', 'options', 'module', 'original_bid', 'parent_depth_limit') as $key) {
00377     $form['book'][$key] = array(
00378       '#type' => 'value',
00379       '#value' => $node->book[$key],
00380     );
00381   }
00382
00383   $form['book']['plid'] = _book_parent_select($node->book);
00384
00385   $form['book']['weight'] = array(
00386     '#type' => 'weight',
00387     '#title' => t('Weight'),
00388     '#default_value' => $node->book['weight'],
00389     '#delta' => 15,
00390     '#weight' => 5,
00391     '#description' => t('Pages at a given level are ordered first by weight and then by title.'),
00392   );
00393   $options = array();
00394   $nid = isset($node->nid) ? $node->nid : 'new';
00395
00396   if (isset($node->nid) && ($nid == $node->book['original_bid']) && ($node->book['parent_depth_limit'] == 0)) {
00397     // This is the top level node in a maximum depth book and thus cannot be moved.
00398     $options[$node->nid] = $node->title;
00399   }
00400   else {
00401     foreach (book_get_books() as $book) {
00402       $options[$book['nid']] = $book['title'];
00403     }
00404   }
00405
00406   if (user_access('create new books') && ($nid == 'new' || ($nid != $node->book['original_bid']))) {
00407     // The node can become a new book, if it is not one already.
00408     $options = array($nid => '<'. t('create a new book') .'>') + $options;
00409   }
00410   if (!$node->book['mlid']) {
00411     // The node is not currently in a the hierarchy.
00412     $options = array(0 => '<'. t('none') .'>') + $options;
00413   }
00414
00415   // Add a drop-down to select the destination book.
00416   $form['book']['bid'] = array(
00417     '#type' => 'select',
00418     '#title' => t('Book'),
00419     '#default_value' => $node->book['bid'],
00420     '#options' => $options,
00421     '#access' => (bool)$options,
00422     '#description' => t('Your page will be a part of the selected book.'),
00423     '#weight' => -5,
00424     '#attributes' => array('class' => 'book-title-select'),
00425     '#ahah' => array(
00426       'path' => 'book/js/form',
00427       'wrapper' => 'edit-book-plid-wrapper',
00428       'effect' => 'slide',
00429     ),
00430   );
00431 }
00432
00439 function _book_update_outline(&$node) {
00440   if (empty($node->book['bid'])) {
00441     return FALSE;
00442   }
00443   $new = empty($node->book['mlid']);
00444
00445   $node->book['link_path'] = 'node/'. $node->nid;
00446   $node->book['link_title'] = $node->title;
00447   $node->book['parent_mismatch'] = FALSE; // The normal case.
00448
00449   if ($node->book['bid'] == $node->nid) {
00450     $node->book['plid'] = 0;
00451     $node->book['menu_name'] = book_menu_name($node->nid);
00452   }
00453   else {
00454     // Check in case the parent is not is this book; the book takes precedence.
00455     if (!empty($node->book['plid'])) {
00456       $parent = db_fetch_array(db_query("SELECT * FROM {book} WHERE mlid = %d", $node->book['plid']));
00457     }
00458     if (empty($node->book['plid']) || !$parent || $parent['bid'] != $node->book['bid']) {
00459       $node->book['plid'] = db_result(db_query("SELECT mlid FROM {book} WHERE nid = %d", $node->book['bid']));
00460       $node->book['parent_mismatch'] = TRUE; // Likely when JS is disabled.
00461     }
00462   }
00463   if (menu_link_save($node->book)) {
00464     if ($new) {
00465       // Insert new.
00466       db_query("INSERT INTO {book} (nid, mlid, bid) VALUES (%d, %d, %d)", $node->nid, $node->book['mlid'], $node->book['bid']);
00467     }
00468     else {
00469       if ($node->book['bid'] != db_result(db_query("SELECT bid FROM {book} WHERE nid = %d", $node->nid))) {
00470         // Update the bid for this page and all children.
00471         book_update_bid($node->book);
00472       }
00473     }
00474     return TRUE;
00475   }
00476   // Failed to save the menu link
00477   return FALSE;
00478 }
00479
00486 function book_update_bid($book_link) {
00487
00488   for ($i = 1; $i <= MENU_MAX_DEPTH && $book_link["p$i"]; $i++) {
00489     $match[] = "p$i = %d";
00490     $args[] = $book_link["p$i"];
00491   }
00492   $result = db_query("SELECT mlid FROM {menu_links} WHERE ". implode(' AND ', $match), $args);
00493
00494   $mlids = array();
00495   while ($a = db_fetch_array($result)) {
00496     $mlids[] = $a['mlid'];
00497   }
00498   if ($mlids) {
00499     db_query("UPDATE {book} SET bid = %d WHERE mlid IN (". implode(',', $mlids) .")", $book_link['bid']);
00500   }
00501 }
00502
00514 function book_get_flat_menu($book_link) {
00515   static $flat = array();
00516
00517   if (!isset($flat[$book_link['mlid']])) {
00518     // Call menu_tree_full_data() to take advantage of the menu system's caching.
00519     $tree = menu_tree_all_data($book_link['menu_name'], $book_link);
00520     $flat[$book_link['mlid']] = array();
00521     _book_flatten_menu($tree, $flat[$book_link['mlid']]);
00522   }
00523   return $flat[$book_link['mlid']];
00524 }
00525
00529 function _book_flatten_menu($tree, &$flat) {
00530   foreach ($tree as $data) {
00531     if (!$data['link']['hidden']) {
00532       $flat[$data['link']['mlid']] = $data['link'];
00533       if ($data['below']) {
00534         _book_flatten_menu($data['below'], $flat);
00535       }
00536     }
00537   }
00538 }
00539
00543 function book_prev($book_link) {
00544   // If the parent is zero, we are at the start of a book.
00545   if ($book_link['plid'] == 0) {
00546     return NULL;
00547   }
00548   $flat = book_get_flat_menu($book_link);
00549   // Assigning the array to $flat resets the array pointer for use with each().
00550   $curr = NULL;
00551   do {
00552     $prev = $curr;
00553     list($key, $curr) = each($flat);
00554   } while ($key && $key != $book_link['mlid']);
00555
00556   if ($key == $book_link['mlid']) {
00557     // The previous page in the book may be a child of the previous visible link.
00558     if ($prev['depth'] == $book_link['depth'] && $prev['has_children']) {
00559       // The subtree will have only one link at the top level - get its data.
00560       $data = array_shift(book_menu_subtree_data($prev));
00561       // The link of interest is the last child - iterate to find the deepest one.
00562       while ($data['below']) {
00563         $data = end($data['below']);
00564       }
00565       return $data['link'];
00566     }
00567     else {
00568       return $prev;
00569     }
00570   }
00571 }
00572
00576 function book_next($book_link) {
00577   $flat = book_get_flat_menu($book_link);
00578   // Assigning the array to $flat resets the array pointer for use with each().
00579   do {
00580     list($key, $curr) = each($flat);
00581   } while ($key && $key != $book_link['mlid']);
00582   if ($key == $book_link['mlid']) {
00583     return current($flat);
00584   }
00585 }
00586
00590 function book_children($book_link) {
00591   $flat = book_get_flat_menu($book_link);
00592
00593   $children = array();
00594
00595   if ($book_link['has_children']) {
00596     // Walk through the array until we find the current page.
00597     do {
00598       $link = array_shift($flat);
00599     } while ($link && ($link['mlid'] != $book_link['mlid']));
00600     // Continue though the array and collect the links whose parent is this page.
00601     while (($link = array_shift($flat)) && $link['plid'] == $book_link['mlid']) {
00602       $data['link'] = $link;
00603       $data['below'] = '';
00604       $children[] = $data;
00605     }
00606   }
00607   return $children ? menu_tree_output($children) : '';
00608 }
00609
00613 function book_menu_name($bid) {
00614   return 'book-toc-'. $bid;
00615 }
00616
00620 function book_build_active_trail($book_link) {
00621   static $trail;
00622
00623   if (!isset($trail)) {
00624     $trail = array();
00625     $trail[] = array('title' => t('Home'), 'href' => '<front>', 'localized_options' => array());
00626
00627     $tree = menu_tree_all_data($book_link['menu_name'], $book_link);
00628     $curr = array_shift($tree);
00629
00630     while ($curr) {
00631       if ($curr['link']['href'] == $book_link['href']) {
00632         $trail[] = $curr['link'];
00633         $curr = FALSE;
00634       }
00635       else {
00636         if ($curr['below'] && $curr['link']['in_active_trail']) {
00637           $trail[] = $curr['link'];
00638           $tree = $curr['below'];
00639         }
00640         $curr = array_shift($tree);
00641       }
00642     }
00643   }
00644   return $trail;
00645 }
00646
00653 function book_nodeapi(&$node, $op, $teaser, $page) {
00654   switch ($op) {
00655     case 'load':
00656       // Note - we cannot use book_link_load() because it will call node_load()
00657       $info['book'] = db_fetch_array(db_query('SELECT * FROM {book} b INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE b.nid = %d', $node->nid));
00658       if ($info['book']) {
00659         $info['book']['href'] = $info['book']['link_path'];
00660         $info['book']['title'] = $info['book']['link_title'];
00661         $info['book']['options'] = unserialize($info['book']['options']);
00662         return $info;
00663       }
00664       break;
00665     case 'view':
00666     if (!$teaser) {
00667         if (!empty($node->book['bid']) && $node->build_mode == NODE_BUILD_NORMAL) {
00668
00669           $node->content['book_navigation'] = array(
00670             '#value' => theme('book_navigation', $node->book),
00671             '#weight' => 100,
00672           );
00673
00674           if ($page) {
00675             menu_set_active_trail(book_build_active_trail($node->book));
00676             menu_set_active_menu_name($node->book['menu_name']);
00677           }
00678         }
00679       }
00680       break;
00681     case 'presave':
00682       // Always save a revision for non-administrators.
00683       if (!empty($node->book['bid']) && !user_access('administer nodes')) {
00684         $node->revision = 1;
00685       }
00686       break;
00687     case 'insert':
00688     case 'update':
00689       if (!empty($node->book['bid'])) {
00690         if ($node->book['bid'] == 'new') {
00691           // New nodes that are their own book.
00692           $node->book['bid'] = $node->nid;
00693         }
00694         $node->book['nid'] = $node->nid;
00695         $node->book['menu_name'] = book_menu_name($node->book['bid']);
00696         _book_update_outline($node);
00697       }
00698       break;
00699     case 'delete':
00700       if (!empty($node->book['bid'])) {
00701         if ($node->nid == $node->book['bid']) {
00702           // Handle deletion of a top-level post.
00703           $result = db_query("SELECT b.nid FROM {menu_links} ml INNER JOIN {book} b on b.mlid = ml.mlid WHERE ml.plid = %d", $node->book['mlid']);
00704           while ($child = db_fetch_array($result)) {
00705             $child_node = node_load($child['nid']);
00706             $child_node->book['bid'] = $child_node->nid;
00707             _book_update_outline($child_node);
00708           }
00709         }
00710         menu_link_delete($node->book['mlid']);
00711         db_query('DELETE FROM {book} WHERE mlid = %d', $node->book['mlid']);
00712       }
00713       break;
00714     case 'prepare':
00715       // Prepare defaults for the add/edit form.
00716       if (empty($node->book) && (user_access('add content to books') || user_access('administer book outlines'))) {
00717         $node->book = array();
00718         if (empty($node->nid) && isset($_GET['parent']) && is_numeric($_GET['parent'])) {
00719           // Handle "Add child page" links:
00720           $parent = book_link_load($_GET['parent']);
00721           if ($parent && $parent['access']) {
00722             $node->book['bid'] = $parent['bid'];
00723             $node->book['plid'] = $parent['mlid'];
00724             $node->book['menu_name'] = $parent['menu_name'];
00725           }
00726         }
00727         // Set defaults.
00728         $node->book += _book_link_defaults(!empty($node->nid) ? $node->nid : 'new');
00729       }
00730       else {
00731         if (isset($node->book['bid']) && !isset($node->book['original_bid'])) {
00732           $node->book['original_bid'] = $node->book['bid'];
00733         }
00734       }
00735       // Find the depth limit for the parent select.
00736       if (isset($node->book['bid']) && !isset($node->book['parent_depth_limit'])) {
00737         $node->book['parent_depth_limit'] = _book_parent_depth_limit($node->book);
00738       }
00739       break;
00740   }
00741 }
00742
00746 function _book_parent_depth_limit($book_link) {
00747   return MENU_MAX_DEPTH - 1 - (($book_link['mlid'] && $book_link['has_children']) ? menu_link_children_relative_depth($book_link) : 0);
00748 }
00749
00753 function book_form_node_delete_confirm_alter(&$form, $form_state) {
00754
00755   $node = node_load($form['nid']['#value']);
00756
00757   if (isset($node->book) && $node->book['has_children']) {
00758     $form['book_warning'] = array(
00759       '#value' => '<p>'. t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', array('%title' => $node->title)) .'</p>',
00760       '#weight' => -10,
00761     );
00762   }
00763 }
00764
00768 function _book_link_defaults($nid) {
00769   return array('original_bid' => 0, 'menu_name' => '', 'nid' => $nid, 'bid' => 0, 'router_path' => 'node/%', 'plid' => 0, 'mlid' => 0, 'has_children' => 0, 'weight' => 0, 'module' => 'book', 'options' => array());
00770 }
00771
00780 function template_preprocess_book_navigation(&$variables) {
00781   $book_link = $variables['book_link'];
00782
00783   // Provide extra variables for themers. Not needed by default.
00784   $variables['book_id'] = $book_link['bid'];
00785   $variables['book_title'] = check_plain($book_link['link_title']);
00786   $variables['book_url'] = 'node/'. $book_link['bid'];
00787   $variables['current_depth'] = $book_link['depth'];
00788
00789   $variables['tree'] = '';
00790   if ($book_link['mlid']) {
00791     $variables['tree'] = book_children($book_link);
00792
00793     if ($prev = book_prev($book_link)) {
00794       $prev_href = url($prev['href']);
00795       drupal_add_link(array('rel' => 'prev', 'href' => $prev_href));
00796       $variables['prev_url'] = $prev_href;
00797       $variables['prev_title'] = check_plain($prev['title']);
00798     }
00799     if ($book_link['plid'] && $parent = book_link_load($book_link['plid'])) {
00800       $parent_href = url($parent['href']);
00801       drupal_add_link(array('rel' => 'up', 'href' => $parent_href));
00802       $variables['parent_url'] = $parent_href;
00803       $variables['parent_title'] = check_plain($parent['title']);
00804     }
00805     if ($next = book_next($book_link)) {
00806       $next_href = url($next['href']);
00807       drupal_add_link(array('rel' => 'next', 'href' => $next_href));
00808       $variables['next_url'] = $next_href;
00809       $variables['next_title'] = check_plain($next['title']);
00810     }
00811   }
00812
00813   $variables['has_links'] = FALSE;
00814   // Link variables to filter for values and set state of the flag variable.
00815   $links = array('prev_url', 'prev_title', 'parent_url', 'parent_title', 'next_url', 'next_title');
00816   foreach ($links as $link) {
00817     if (isset($variables[$link])) {
00818       // Flag when there is a value.
00819       $variables['has_links'] = TRUE;
00820     }
00821     else {
00822       // Set empty to prevent notices.
00823       $variables[$link] = '';
00824     }
00825   }
00826 }
00827
00831 function _book_toc_recurse($tree, $indent, &$toc, $exclude, $depth_limit) {
00832   foreach ($tree as $data) {
00833     if ($data['link']['depth'] > $depth_limit) {
00834       // Don't iterate through any links on this level.
00835       break;
00836     }
00837     if (!in_array($data['link']['mlid'], $exclude)) {
00838       $toc[$data['link']['mlid']] = $indent .' '. truncate_utf8($data['link']['title'], 30, TRUE, TRUE);
00839       if ($data['below']) {
00840         _book_toc_recurse($data['below'], $indent .'--', $toc, $exclude, $depth_limit);
00841       }
00842     }
00843   }
00844 }
00845
00859 function book_toc($bid, $exclude = array(), $depth_limit) {
00860
00861   $tree = menu_tree_all_data(book_menu_name($bid));
00862   $toc = array();
00863   _book_toc_recurse($tree, '', $toc, $exclude, $depth_limit);
00864
00865   return $toc;
00866 }
00867
00878 function template_preprocess_book_export_html(&$variables) {
00879   global $base_url, $language;
00880
00881   $variables['title'] = check_plain($variables['title']);
00882   $variables['base_url'] = $base_url;
00883   $variables['language'] = $language;
00884   $variables['language_rtl'] = (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) ? TRUE : FALSE;
00885   $variables['head'] = drupal_get_html_head();
00886 }
00887
00902 function book_export_traverse($tree, $visit_func) {
00903   $output = '';
00904
00905   foreach ($tree as $data) {
00906     // Note- access checking is already performed when building the tree.
00907     if ($node = node_load($data['link']['nid'], FALSE)) {
00908       $children = '';
00909       if ($data['below']) {
00910         $children = book_export_traverse($data['below'], $visit_func);
00911       }
00912
00913       if (function_exists($visit_func)) {
00914         $output .= call_user_func($visit_func, $node, $children);
00915       }
00916       else {
00917         // Use the default function.
00918         $output .= book_node_export($node, $children);
00919       }
00920     }
00921   }
00922   return $output;
00923 }
00924
00937 function book_node_export($node, $children = '') {
00938
00939   $node->build_mode = NODE_BUILD_PRINT;
00940   $node = node_build_content($node, FALSE, FALSE);
00941   $node->body = drupal_render($node->content);
00942
00943   return theme('book_node_export_html', $node, $children);
00944 }
00945
00955 function template_preprocess_book_node_export_html(&$variables) {
00956   $variables['depth'] = $variables['node']->book['depth'];
00957   $variables['title'] = check_plain($variables['node']->title);
00958   $variables['content'] = $variables['node']->body;
00959 }
00960
00964 function book_type_is_allowed($type) {
00965   return in_array($type, variable_get('book_allowed_types', array('book')));
00966 }
00967
00974 function book_node_type($op, $type) {
00975
00976   switch ($op) {
00977     case 'update':
00978       if (!empty($type->old_type) && $type->old_type != $type->type) {
00979         // Update the list of node types that are allowed to be added to books.
00980         $allowed_types = variable_get('book_allowed_types', array('book'));
00981         $key = array_search($type->old_type, $allowed_types);
00982         if ($key !== FALSE) {
00983           $allowed_types[$type->type] = $allowed_types[$key] ? $type->type : 0;
00984           unset($allowed_types[$key]);
00985           variable_set('book_allowed_types', $allowed_types);
00986         }
00987         // Update the setting for the "Add child page" link.
00988         if (variable_get('book_child_type', 'book') == $type->old_type) {
00989           variable_set('book_child_type', $type->type);
00990         }
00991       }
00992       break;
00993   }
00994 }
00995
00999 function book_help($path, $arg) {
01000   switch ($path) {
01001     case 'admin/help#book':
01002       $output = '<p>'. t('The book module is suited for creating structured, multi-page hypertexts such as site resource guides, manuals, and Frequently Asked Questions (FAQs). It permits a document to have chapters, sections, subsections, etc. Authors with suitable permissions can add pages to a collaborative book, placing them into the existing document by adding them to a table of contents menu.') .'</p>';
01003       $output .= '<p>'. t('Pages in the book hierarchy have navigation elements at the bottom of the page for moving through the text. These links lead to the previous and next pages in the book, and to the level above the current page in the book\'s structure. More comprehensive navigation may be provided by enabling the <em>book navigation block</em> on the <a href="@admin-block">blocks administration page</a>.', array('@admin-block' => url('admin/build/block'))) .'</p>';
01004       $output .= '<p>'. t('Users can select the <em>printer-friendly version</em> link visible at the bottom of a book page to generate a printer-friendly display of the page and all of its subsections. ') .'</p>';
01005       $output .= '<p>'. t("Users with the <em>administer book outlines</em> permission can add a post of any content type to a book, by selecting the appropriate book while editing the post or by using the interface available on the post's <em>outline</em> tab.") .'</p>';
01006       $output .= '<p>'. t('Administrators can view a list of all books on the <a href="@admin-node-book">book administration page</a>. The <em>Outline</em> page for each book allows section titles to be edited or rearranged.', array('@admin-node-book' => url('admin/content/book'))) .'</p>';
01007       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@book">Book module</a>.', array('@book' => 'http://drupal.org/handbook/modules/book/')) .'</p>';
01008       return $output;
01009     case 'admin/content/book':
01010       return '<p>'. t('The book module offers a means to organize a collection of related posts, collectively known as a book. When viewed, these posts automatically display links to adjacent book pages, providing a simple navigation system for creating and reviewing structured content.') .'</p>';
01011     case 'node/%/outline':
01012       return '<p>'. t('The outline feature allows you to include posts in the <a href="@book">book hierarchy</a>, as well as move them within the hierarchy or to <a href="@book-admin">reorder an entire book</a>.', array('@book' => url('book'), '@book-admin' => url('admin/content/book'))) .'</p>';
01013   }
01014 }
01015
01021 function book_link_load($mlid) {
01022   if ($item = db_fetch_array(db_query("SELECT * FROM {menu_links} ml INNER JOIN {book} b ON b.mlid = ml.mlid LEFT JOIN {menu_router} m ON m.path = ml.router_path WHERE ml.mlid = %d", $mlid))) {
01023     _menu_link_translate($item);
01024     return $item;
01025   }
01026   return FALSE;
01027 }
01028
01040 function book_menu_subtree_data($item) {
01041   static $tree = array();
01042
01043   $cid = 'links:'. $item['menu_name'] .':subtree:'. $item['mlid'];
01044
01045   if (!isset($tree[$cid])) {
01046     $cache = cache_get($cid, 'cache_menu');
01047     if ($cache && isset($cache->data)) {
01048       $data = $cache->data;
01049     }
01050     else {
01051       $match = array("menu_name = '%s'");
01052       $args = array($item['menu_name']);
01053       $i = 1;
01054       while ($i <= MENU_MAX_DEPTH && $item["p$i"]) {
01055         $match[] = "p$i = %d";
01056         $args[] = $item["p$i"];
01057         $i++;
01058       }
01059       $sql = "
01060         SELECT b.*, m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, ml.*
01061         FROM {menu_links} ml INNER JOIN {menu_router} m ON m.path = ml.router_path
01062         INNER JOIN {book} b ON ml.mlid = b.mlid
01063         WHERE ". implode(' AND ', $match) ."
01064         ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC";
01065
01066       $data['tree'] = menu_tree_data(db_query($sql, $args), array(), $item['depth']);
01067       $data['node_links'] = array();
01068       menu_tree_collect_node_links($data['tree'], $data['node_links']);
01069       // Cache the data.
01070       cache_set($cid, $data, 'cache_menu');
01071     }
01072     // Check access for the current user to each item in the tree.
01073     menu_tree_check_access($data['tree'], $data['node_links']);
01074     $tree[$cid] = $data['tree'];
01075   }
01076
01077   return $tree[$cid];
01078 }
01079
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/book/book.pages.inc Source File

modules » book

book.pages.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: book.pages.inc,v 1.5 2007/12/22 23:24:24 goba Exp $
00003
00012 function book_render() {
00013   $book_list = array();
00014   foreach (book_get_books() as $book) {
00015     $book_list[] = l($book['title'], $book['href'], $book['options']);
00016   }
00017
00018   return theme('item_list', $book_list);
00019 }
00020
00042 function book_export($type, $nid) {
00043
00044   $type = drupal_strtolower($type);
00045
00046   $export_function = 'book_export_'. $type;
00047
00048   if (function_exists($export_function)) {
00049     print call_user_func($export_function, $nid);
00050   }
00051   else {
00052     drupal_set_message(t('Unknown export format.'));
00053     drupal_not_found();
00054   }
00055 }
00056
00074 function book_export_html($nid) {
00075   if (user_access('access printer-friendly version')) {
00076     $export_data = array();
00077     $node = node_load($nid);
00078     if (isset($node->book)) {
00079       $tree = book_menu_subtree_data($node->book);
00080       $contents = book_export_traverse($tree, 'book_node_export');
00081     }
00082     return theme('book_export_html', $node->title, $contents, $node->book['depth']);
00083   }
00084   else {
00085     drupal_access_denied();
00086   }
00087 }
00088
00092 function book_outline($node) {
00093   drupal_set_title(check_plain($node->title));
00094   return drupal_get_form('book_outline_form', $node);
00095 }
00096
00105 function book_outline_form(&$form_state, $node) {
00106
00107   if (!isset($node->book)) {
00108     // The node is not part of any book yet - set default options.
00109     $node->book = _book_link_defaults($node->nid);
00110   }
00111   else {
00112     $node->book['original_bid'] = $node->book['bid'];
00113   }
00114   // Find the depth limit for the parent select.
00115   if (!isset($node->book['parent_depth_limit'])) {
00116     $node->book['parent_depth_limit'] = _book_parent_depth_limit($node->book);
00117   }
00118   $form['#node'] = $node;
00119   $form['#id'] = 'book-outline';
00120   _book_add_form_elements($form, $node);
00121
00122   $form['book']['#collapsible'] = FALSE;
00123
00124   $form['update'] = array(
00125     '#type' => 'submit',
00126     '#value' => $node->book['original_bid'] ? t('Update book outline') : t('Add to book outline'),
00127     '#weight' => 15,
00128   );
00129
00130   $form['remove'] = array(
00131     '#type' => 'submit',
00132     '#value' => t('Remove from book outline'),
00133     '#access' => $node->nid != $node->book['bid'] && $node->book['bid'],
00134     '#weight' => 20,
00135     '#submit' => array('book_remove_button_submit'),
00136   );
00137
00138   return $form;
00139 }
00140
00146 function book_remove_button_submit($form, &$form_state) {
00147   $form_state['redirect'] = 'node/'. $form['#node']->nid .'/outline/remove';
00148 }
00149
00155 function book_outline_form_submit($form, &$form_state) {
00156   $node = $form['#node'];
00157   $form_state['redirect'] = "node/". $node->nid;
00158   $book_link = $form_state['values']['book'];
00159   if (!$book_link['bid']) {
00160     drupal_set_message(t('No changes were made'));
00161     return;
00162   }
00163
00164   $book_link['menu_name'] = book_menu_name($book_link['bid']);
00165   $node->book = $book_link;
00166   if (_book_update_outline($node)) {
00167     if ($node->book['parent_mismatch']) {
00168       // This will usually only happen when JS is disabled.
00169       drupal_set_message(t('The post has been added to the selected book. You may now position it relative to other pages.'));
00170       $form_state['redirect'] = "node/". $node->nid ."/outline";
00171     }
00172     else {
00173       drupal_set_message(t('The book outline has been updated.'));
00174     }
00175   }
00176   else {
00177     drupal_set_message(t('There was an error adding the post to the book.'), 'error');
00178   }
00179 }
00180
00188 function book_remove_form(&$form_state, $node) {
00189   $form['#node'] = $node;
00190   $title = array('%title' => $node->title);
00191
00192   if ($node->book['has_children']) {
00193     $description = t('%title has associated child pages, which will be relocated automatically to maintain their connection to the book. To recreate the hierarchy (as it was before removing this page), %title may be added again using the Outline tab, and each of its former child pages will need to be relocated manually.', $title);
00194   }
00195   else {
00196     $description = t('%title may be added to hierarchy again using the Outline tab.', $title);
00197   }
00198
00199   return confirm_form($form, t('Are you sure you want to remove %title from the book hierarchy?', $title), 'node/'. $node->nid, $description, t('Remove'));
00200 }
00201
00207 function book_remove_form_submit($form, &$form_state) {
00208   $node = $form['#node'];
00209   if ($node->nid != $node->book['bid']) {
00210     // Only allowed when this is not a book (top-level page).
00211     menu_link_delete($node->book['mlid']);
00212     db_query('DELETE FROM {book} WHERE nid = %d', $node->nid);
00213     drupal_set_message(t('The post has been removed from the book.'));
00214   }
00215   $form_state['redirect'] = 'node/'. $node->nid;
00216 }
00217
00233 function book_form_update() {
00234   $cid = 'form_'. $_POST['form_build_id'];
00235   $bid = $_POST['book']['bid'];
00236   $cache = cache_get($cid, 'cache_form');
00237   if ($cache) {
00238     $form = $cache->data;
00239
00240     // Validate the bid.
00241     if (isset($form['book']['bid']['#options'][$bid])) {
00242       $book_link = $form['#node']->book;
00243       $book_link['bid'] = $bid;
00244       // Get the new options and update the cache.
00245       $form['book']['plid'] = _book_parent_select($book_link);
00246       cache_set($cid, $form, 'cache_form', $cache->expire);
00247
00248       // Build and render the new select element, then return it in JSON format.
00249       $form_state = array();
00250       $form['#post'] = array();
00251       $form = form_builder($form['form_id']['#value'] , $form, $form_state);
00252       $output = drupal_render($form['book']['plid']);
00253       drupal_json(array('status' => TRUE, 'data' => $output));
00254     }
00255     else {
00256       drupal_json(array('status' => FALSE, 'data' => ''));
00257     }
00258   }
00259   else {
00260     drupal_json(array('status' => FALSE, 'data' => ''));
00261   }
00262   exit();
00263 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/bootstrap.inc Source File

includes

bootstrap.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: bootstrap.inc,v 1.206.2.2 2008/02/11 14:36:21 goba Exp $
00003
00013 define('CACHE_PERMANENT', 0);
00014
00018 define('CACHE_TEMPORARY', -1);
00019
00023 define('CACHE_DISABLED', 0);
00024
00028 define('CACHE_NORMAL', 1);
00029
00035 define('CACHE_AGGRESSIVE', 2);
00036
00043 define('WATCHDOG_EMERG',    0); // Emergency: system is unusable
00044 define('WATCHDOG_ALERT',    1); // Alert: action must be taken immediately
00045 define('WATCHDOG_CRITICAL', 2); // Critical: critical conditions
00046 define('WATCHDOG_ERROR',    3); // Error: error conditions
00047 define('WATCHDOG_WARNING',  4); // Warning: warning conditions
00048 define('WATCHDOG_NOTICE',   5); // Notice: normal but significant condition
00049 define('WATCHDOG_INFO',     6); // Informational: informational messages
00050 define('WATCHDOG_DEBUG',    7); // Debug: debug-level messages
00051
00055 define('DRUPAL_BOOTSTRAP_CONFIGURATION', 0);
00056
00061 define('DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE', 1);
00062
00066 define('DRUPAL_BOOTSTRAP_DATABASE', 2);
00067
00071 define('DRUPAL_BOOTSTRAP_ACCESS', 3);
00072
00076 define('DRUPAL_BOOTSTRAP_SESSION', 4);
00077
00082 define('DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE', 5);
00083
00087 define('DRUPAL_BOOTSTRAP_LANGUAGE', 6);
00088
00092 define('DRUPAL_BOOTSTRAP_PATH', 7);
00093
00098 define('DRUPAL_BOOTSTRAP_FULL', 8);
00099
00103 define('DRUPAL_ANONYMOUS_RID', 1);
00104
00108 define('DRUPAL_AUTHENTICATED_RID', 2);
00109
00113 define('LANGUAGE_NEGOTIATION_NONE', 0);
00114
00119 define('LANGUAGE_NEGOTIATION_PATH_DEFAULT', 1);
00120
00126 define('LANGUAGE_NEGOTIATION_PATH', 2);
00127
00132 define('LANGUAGE_NEGOTIATION_DOMAIN', 3);
00133
00142 function timer_start($name) {
00143   global $timers;
00144
00145   list($usec, $sec) = explode(' ', microtime());
00146   $timers[$name]['start'] = (float)$usec + (float)$sec;
00147   $timers[$name]['count'] = isset($timers[$name]['count']) ? ++$timers[$name]['count'] : 1;
00148 }
00149
00158 function timer_read($name) {
00159   global $timers;
00160
00161   if (isset($timers[$name]['start'])) {
00162     list($usec, $sec) = explode(' ', microtime());
00163     $stop = (float)$usec + (float)$sec;
00164     $diff = round(($stop - $timers[$name]['start']) * 1000, 2);
00165
00166     if (isset($timers[$name]['time'])) {
00167       $diff += $timers[$name]['time'];
00168     }
00169     return $diff;
00170   }
00171 }
00172
00183 function timer_stop($name) {
00184   global $timers;
00185
00186   $timers[$name]['time'] = timer_read($name);
00187   unset($timers[$name]['start']);
00188
00189   return $timers[$name];
00190 }
00191
00232 function conf_path($require_settings = TRUE, $reset = FALSE) {
00233   static $conf = '';
00234
00235   if ($conf && !$reset) {
00236     return $conf;
00237   }
00238
00239   $confdir = 'sites';
00240   $uri = explode('/', $_SERVER['SCRIPT_NAME'] ? $_SERVER['SCRIPT_NAME'] : $_SERVER['SCRIPT_FILENAME']);
00241   $server = explode('.', implode('.', array_reverse(explode(':', rtrim($_SERVER['HTTP_HOST'], '.')))));
00242   for ($i = count($uri) - 1; $i > 0; $i--) {
00243     for ($j = count($server); $j > 0; $j--) {
00244       $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i));
00245       if (file_exists("$confdir/$dir/settings.php") || (!$require_settings && file_exists("$confdir/$dir"))) {
00246         $conf = "$confdir/$dir";
00247         return $conf;
00248       }
00249     }
00250   }
00251   $conf = "$confdir/default";
00252   return $conf;
00253 }
00254
00258 function drupal_unset_globals() {
00259   if (ini_get('register_globals')) {
00260     $allowed = array('_ENV' => 1, '_GET' => 1, '_POST' => 1, '_COOKIE' => 1, '_FILES' => 1, '_SERVER' => 1, '_REQUEST' => 1, 'GLOBALS' => 1);
00261     foreach ($GLOBALS as $key => $value) {
00262       if (!isset($allowed[$key])) {
00263         unset($GLOBALS[$key]);
00264       }
00265     }
00266   }
00267 }
00268
00273 function conf_init() {
00274   global $base_url, $base_path, $base_root;
00275
00276   // Export the following settings.php variables to the global namespace
00277   global $db_url, $db_prefix, $cookie_domain, $conf, $installed_profile, $update_free_access;
00278   $conf = array();
00279
00280   if (file_exists('./'. conf_path() .'/settings.php')) {
00281     include_once './'. conf_path() .'/settings.php';
00282   }
00283
00284   if (isset($base_url)) {
00285     // Parse fixed base URL from settings.php.
00286     $parts = parse_url($base_url);
00287     if (!isset($parts['path'])) {
00288       $parts['path'] = '';
00289     }
00290     $base_path = $parts['path'] .'/';
00291     // Build $base_root (everything until first slash after "scheme://").
00292     $base_root = substr($base_url, 0, strlen($base_url) - strlen($parts['path']));
00293   }
00294   else {
00295     // Create base URL
00296     $base_root = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
00297
00298     // As $_SERVER['HTTP_HOST'] is user input, ensure it only contains
00299     // characters allowed in hostnames.
00300     $base_url = $base_root .= '://'. preg_replace('/[^a-z0-9-:._]/i', '', $_SERVER['HTTP_HOST']);
00301
00302     // $_SERVER['SCRIPT_NAME'] can, in contrast to $_SERVER['PHP_SELF'], not
00303     // be modified by a visitor.
00304     if ($dir = trim(dirname($_SERVER['SCRIPT_NAME']), '\,/')) {
00305       $base_path = "/$dir";
00306       $base_url .= $base_path;
00307       $base_path .= '/';
00308     }
00309     else {
00310       $base_path = '/';
00311     }
00312   }
00313
00314   if ($cookie_domain) {
00315     // If the user specifies the cookie domain, also use it for session name.
00316     $session_name = $cookie_domain;
00317   }
00318   else {
00319     // Otherwise use $base_url as session name, without the protocol
00320     // to use the same session identifiers across http and https.
00321     list( , $session_name) = explode('://', $base_url, 2);
00322     // We escape the hostname because it can be modified by a visitor.
00323     if (!empty($_SERVER['HTTP_HOST'])) {
00324       $cookie_domain = check_plain($_SERVER['HTTP_HOST']);
00325     }
00326   }
00327   // Strip leading periods, www., and port numbers from cookie domain.
00328   $cookie_domain = ltrim($cookie_domain, '.');
00329   if (strpos($cookie_domain, 'www.') === 0) {
00330     $cookie_domain = substr($cookie_domain, 4);
00331   }
00332   $cookie_domain = explode(':', $cookie_domain);
00333   $cookie_domain = '.'. $cookie_domain[0];
00334   // Per RFC 2109, cookie domains must contain at least one dot other than the
00335   // first. For hosts such as 'localhost' or IP Addresses we don't set a cookie domain.
00336   if (count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) {
00337     ini_set('session.cookie_domain', $cookie_domain);
00338   }
00339   session_name('SESS'. md5($session_name));
00340 }
00341
00370 function drupal_get_filename($type, $name, $filename = NULL) {
00371   static $files = array();
00372
00373   if (!isset($files[$type])) {
00374     $files[$type] = array();
00375   }
00376
00377   if (!empty($filename) && file_exists($filename)) {
00378     $files[$type][$name] = $filename;
00379   }
00380   elseif (isset($files[$type][$name])) {
00381     // nothing
00382   }
00383   // Verify that we have an active database connection, before querying
00384   // the database.  This is required because this function is called both
00385   // before we have a database connection (i.e. during installation) and
00386   // when a database connection fails.
00387   elseif (db_is_active() && (($file = db_result(db_query("SELECT filename FROM {system} WHERE name = '%s' AND type = '%s'", $name, $type))) && file_exists($file))) {
00388     $files[$type][$name] = $file;
00389   }
00390   else {
00391     // Fallback to searching the filesystem if the database connection is
00392     // not established or the requested file is not found.
00393     $config = conf_path();
00394     $dir = (($type == 'theme_engine') ? 'themes/engines' : "${type}s");
00395     $file = (($type == 'theme_engine') ? "$name.engine" : "$name.$type");
00396
00397     foreach (array("$config/$dir/$file", "$config/$dir/$name/$file", "$dir/$file", "$dir/$name/$file") as $file) {
00398       if (file_exists($file)) {
00399         $files[$type][$name] = $file;
00400         break;
00401       }
00402     }
00403   }
00404
00405   if (isset($files[$type][$name])) {
00406     return $files[$type][$name];
00407   }
00408 }
00409
00417 function variable_init($conf = array()) {
00418   // NOTE: caching the variables improves performance by 20% when serving cached pages.
00419   if ($cached = cache_get('variables', 'cache')) {
00420     $variables = $cached->data;
00421   }
00422   else {
00423     $result = db_query('SELECT * FROM {variable}');
00424     while ($variable = db_fetch_object($result)) {
00425       $variables[$variable->name] = unserialize($variable->value);
00426     }
00427     cache_set('variables', $variables);
00428   }
00429
00430   foreach ($conf as $name => $value) {
00431     $variables[$name] = $value;
00432   }
00433
00434   return $variables;
00435 }
00436
00447 function variable_get($name, $default) {
00448   global $conf;
00449
00450   return isset($conf[$name]) ? $conf[$name] : $default;
00451 }
00452
00462 function variable_set($name, $value) {
00463   global $conf;
00464
00465   $serialized_value = serialize($value);
00466   db_query("UPDATE {variable} SET value = '%s' WHERE name = '%s'", $serialized_value, $name);
00467   if (!db_affected_rows()) {
00468     @db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, $serialized_value);
00469   }
00470
00471   cache_clear_all('variables', 'cache');
00472
00473   $conf[$name] = $value;
00474 }
00475
00482 function variable_del($name) {
00483   global $conf;
00484
00485   db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
00486   cache_clear_all('variables', 'cache');
00487
00488   unset($conf[$name]);
00489 }
00490
00491
00502 function page_get_cache($status_only = FALSE) {
00503   static $status = FALSE;
00504   global $user, $base_root;
00505
00506   if ($status_only) {
00507     return $status;
00508   }
00509   $cache = NULL;
00510
00511   if (!$user->uid && $_SERVER['REQUEST_METHOD'] == 'GET' && count(drupal_set_message()) == 0) {
00512     $cache = cache_get($base_root . request_uri(), 'cache_page');
00513
00514     if (empty($cache)) {
00515       ob_start();
00516       $status = TRUE;
00517     }
00518   }
00519
00520   return $cache;
00521 }
00522
00529 function bootstrap_invoke_all($hook) {
00530   foreach (module_list(TRUE, TRUE) as $module) {
00531     drupal_load('module', $module);
00532     module_invoke($module, $hook);
00533   }
00534 }
00535
00548 function drupal_load($type, $name) {
00549   static $files = array();
00550
00551   if (isset($files[$type][$name])) {
00552     return TRUE;
00553   }
00554
00555   $filename = drupal_get_filename($type, $name);
00556
00557   if ($filename) {
00558     include_once "./$filename";
00559     $files[$type][$name] = TRUE;
00560
00561     return TRUE;
00562   }
00563
00564   return FALSE;
00565 }
00566
00576 function drupal_page_header() {
00577   header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
00578   header("Last-Modified: ". gmdate("D, d M Y H:i:s") ." GMT");
00579   header("Cache-Control: store, no-cache, must-revalidate");
00580   header("Cache-Control: post-check=0, pre-check=0", FALSE);
00581 }
00582
00592 function drupal_page_cache_header($cache) {
00593   // Set default values:
00594   $last_modified = gmdate('D, d M Y H:i:s', $cache->created) .' GMT';
00595   $etag = '"'. md5($last_modified) .'"';
00596
00597   // See if the client has provided the required HTTP headers:
00598   $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE;
00599   $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : FALSE;
00600
00601   if ($if_modified_since && $if_none_match
00602       && $if_none_match == $etag // etag must match
00603       && $if_modified_since == $last_modified) {  // if-modified-since must match
00604     header('HTTP/1.1 304 Not Modified');
00605     // All 304 responses must send an etag if the 200 response for the same object contained an etag
00606     header("Etag: $etag");
00607     exit();
00608   }
00609
00610   // Send appropriate response:
00611   header("Last-Modified: $last_modified");
00612   header("ETag: $etag");
00613
00614   // The following headers force validation of cache:
00615   header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
00616   header("Cache-Control: must-revalidate");
00617
00618   if (variable_get('page_compression', TRUE)) {
00619     // Determine if the browser accepts gzipped data.
00620     if (@strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === FALSE && function_exists('gzencode')) {
00621       // Strip the gzip header and run uncompress.
00622       $cache->data = gzinflate(substr(substr($cache->data, 10), 0, -8));
00623     }
00624     elseif (function_exists('gzencode')) {
00625       header('Content-Encoding: gzip');
00626     }
00627   }
00628
00629   // Send the original request's headers. We send them one after
00630   // another so PHP's header() function can deal with duplicate
00631   // headers.
00632   $headers = explode("\n", $cache->headers);
00633   foreach ($headers as $header) {
00634     header($header);
00635   }
00636
00637   print $cache->data;
00638 }
00639
00643 function bootstrap_hooks() {
00644   return array('boot', 'exit');
00645 }
00646
00655 function drupal_unpack($obj, $field = 'data') {
00656   if ($obj->$field && $data = unserialize($obj->$field)) {
00657     foreach ($data as $key => $value) {
00658       if (!isset($obj->$key)) {
00659         $obj->$key = $value;
00660       }
00661     }
00662   }
00663   return $obj;
00664 }
00665
00669 function referer_uri() {
00670   if (isset($_SERVER['HTTP_REFERER'])) {
00671     return $_SERVER['HTTP_REFERER'];
00672   }
00673 }
00674
00681 function check_plain($text) {
00682   return drupal_validate_utf8($text) ? htmlspecialchars($text, ENT_QUOTES) : '';
00683 }
00684
00714 function drupal_validate_utf8($text) {
00715   if (strlen($text) == 0) {
00716     return TRUE;
00717   }
00718   return (preg_match('/^./us', $text) == 1);
00719 }
00720
00725 function request_uri() {
00726
00727   if (isset($_SERVER['REQUEST_URI'])) {
00728     $uri = $_SERVER['REQUEST_URI'];
00729   }
00730   else {
00731     if (isset($_SERVER['argv'])) {
00732       $uri = $_SERVER['SCRIPT_NAME'] .'?'. $_SERVER['argv'][0];
00733     }
00734     elseif (isset($_SERVER['QUERY_STRING'])) {
00735       $uri = $_SERVER['SCRIPT_NAME'] .'?'. $_SERVER['QUERY_STRING'];
00736     }
00737     else {
00738       $uri = $_SERVER['SCRIPT_NAME'];
00739     }
00740   }
00741
00742   return $uri;
00743 }
00744
00765 function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL) {
00766   global $user, $base_root;
00767
00768   // Prepare the fields to be logged
00769   $log_message = array(
00770     'type'        => $type,
00771     'message'     => $message,
00772     'variables'   => $variables,
00773     'severity'    => $severity,
00774     'link'        => $link,
00775     'user'        => $user,
00776     'request_uri' => $base_root . request_uri(),
00777     'referer'     => referer_uri(),
00778     'ip'          => ip_address(),
00779     'timestamp'   => time(),
00780     );
00781
00782   // Call the logging hooks to log/process the message
00783   foreach (module_implements('watchdog', TRUE) as $module) {
00784     module_invoke($module, 'watchdog', $log_message);
00785   }
00786 }
00787
00806 function drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE) {
00807   if ($message) {
00808     if (!isset($_SESSION['messages'])) {
00809       $_SESSION['messages'] = array();
00810     }
00811
00812     if (!isset($_SESSION['messages'][$type])) {
00813       $_SESSION['messages'][$type] = array();
00814     }
00815
00816     if ($repeat || !in_array($message, $_SESSION['messages'][$type])) {
00817       $_SESSION['messages'][$type][] = $message;
00818     }
00819   }
00820
00821   // messages not set when DB connection fails
00822   return isset($_SESSION['messages']) ? $_SESSION['messages'] : NULL;
00823 }
00824
00838 function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
00839   if ($messages = drupal_set_message()) {
00840     if ($type) {
00841       if ($clear_queue) {
00842         unset($_SESSION['messages'][$type]);
00843       }
00844       if (isset($messages[$type])) {
00845         return array($type => $messages[$type]);
00846       }
00847     }
00848     else {
00849       if ($clear_queue) {
00850         unset($_SESSION['messages']);
00851       }
00852       return $messages;
00853     }
00854   }
00855   return array();
00856 }
00857
00876 function drupal_is_denied($type, $mask) {
00877   // Because this function is called for every page request, both cached
00878   // and non-cached pages, we tried to optimize it as much as possible.
00879   // We deny access if the only matching records in the {access} table have
00880   // status 0 (deny). If any have status 1 (allow), or if there are no
00881   // matching records, we allow access.
00882   $sql = "SELECT 1 FROM {access} WHERE type = '%s' AND LOWER('%s') LIKE LOWER(mask) AND status = %d";
00883   return db_result(db_query_range($sql, $type, $mask, 0, 0, 1)) && !db_result(db_query_range($sql, $type, $mask, 1, 0, 1));
00884 }
00885
00891 function drupal_anonymous_user($session = '') {
00892   $user = new stdClass();
00893   $user->uid = 0;
00894   $user->hostname = ip_address();
00895   $user->roles = array();
00896   $user->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user';
00897   $user->session = $session;
00898   $user->cache = 0;
00899   return $user;
00900 }
00901
00922 function drupal_bootstrap($phase) {
00923   static $phases = array(DRUPAL_BOOTSTRAP_CONFIGURATION, DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE, DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_ACCESS, DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE, DRUPAL_BOOTSTRAP_LANGUAGE, DRUPAL_BOOTSTRAP_PATH, DRUPAL_BOOTSTRAP_FULL), $phase_index = 0;
00924
00925   while ($phase >= $phase_index && isset($phases[$phase_index])) {
00926     $current_phase = $phases[$phase_index];
00927     unset($phases[$phase_index++]);
00928     _drupal_bootstrap($current_phase);
00929   }
00930 }
00931
00932 function _drupal_bootstrap($phase) {
00933   global $conf;
00934
00935   switch ($phase) {
00936
00937     case DRUPAL_BOOTSTRAP_CONFIGURATION:
00938       drupal_unset_globals();
00939       // Start a page timer:
00940       timer_start('page');
00941       // Initialize the configuration
00942       conf_init();
00943       break;
00944
00945     case DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE:
00946       // Allow specifying special cache handlers in settings.php, like
00947       // using memcached or files for storing cache information.
00948       require_once variable_get('cache_inc', './includes/cache.inc');
00949       // If the page_cache_fastpath is set to TRUE in settings.php and
00950       // page_cache_fastpath (implemented in the special implementation of
00951       // cache.inc) printed the page and indicated this with a returned TRUE
00952       // then we are done.
00953       if (variable_get('page_cache_fastpath', FALSE) && page_cache_fastpath()) {
00954         exit;
00955       }
00956       break;
00957
00958     case DRUPAL_BOOTSTRAP_DATABASE:
00959       // Initialize the default database.
00960       require_once './includes/database.inc';
00961       db_set_active();
00962       break;
00963
00964     case DRUPAL_BOOTSTRAP_ACCESS:
00965       // Deny access to hosts which were banned - t() is not yet available.
00966       if (drupal_is_denied('host', ip_address())) {
00967         header('HTTP/1.1 403 Forbidden');
00968         print 'Sorry, '. check_plain(ip_address()) .' has been banned.';
00969         exit();
00970       }
00971       break;
00972
00973     case DRUPAL_BOOTSTRAP_SESSION:
00974       require_once variable_get('session_inc', './includes/session.inc');
00975       session_set_save_handler('sess_open', 'sess_close', 'sess_read', 'sess_write', 'sess_destroy_sid', 'sess_gc');
00976       session_start();
00977       break;
00978
00979     case DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE:
00980       // Initialize configuration variables, using values from settings.php if available.
00981       $conf = variable_init(isset($conf) ? $conf : array());
00982       // Load module handling.
00983       require_once './includes/module.inc';
00984       $cache_mode = variable_get('cache', CACHE_DISABLED);
00985       // Get the page from the cache.
00986       $cache = $cache_mode == CACHE_DISABLED ? '' : page_get_cache();
00987       // If the skipping of the bootstrap hooks is not enforced, call hook_boot.
00988       if ($cache_mode != CACHE_AGGRESSIVE) {
00989         bootstrap_invoke_all('boot');
00990       }
00991       // If there is a cached page, display it.
00992       if ($cache) {
00993         drupal_page_cache_header($cache);
00994         // If the skipping of the bootstrap hooks is not enforced, call hook_exit.
00995         if ($cache_mode != CACHE_AGGRESSIVE) {
00996           bootstrap_invoke_all('exit');
00997         }
00998         // We are done.
00999         exit;
01000       }
01001       // Prepare for non-cached page workflow.
01002       drupal_page_header();
01003       break;
01004
01005     case DRUPAL_BOOTSTRAP_LANGUAGE:
01006       drupal_init_language();
01007       break;
01008
01009     case DRUPAL_BOOTSTRAP_PATH:
01010       require_once './includes/path.inc';
01011       // Initialize $_GET['q'] prior to loading modules and invoking hook_init().
01012       drupal_init_path();
01013       break;
01014
01015     case DRUPAL_BOOTSTRAP_FULL:
01016       require_once './includes/common.inc';
01017       _drupal_bootstrap_full();
01018       break;
01019   }
01020 }
01021
01030 function drupal_maintenance_theme() {
01031   require_once './includes/theme.maintenance.inc';
01032   _drupal_maintenance_theme();
01033 }
01034
01039 function get_t() {
01040   static $t;
01041   if (is_null($t)) {
01042     $t = function_exists('install_main') ? 'st' : 't';
01043   }
01044   return $t;
01045 }
01046
01050 function drupal_init_language() {
01051   global $language, $user;
01052
01053   // Ensure the language is correctly returned, even without multilanguage support.
01054   // Useful for eg. XML/HTML 'lang' attributes.
01055   if (variable_get('language_count', 1) == 1) {
01056     $language = language_default();
01057   }
01058   else {
01059     include_once './includes/language.inc';
01060     $language = language_initialize();
01061   }
01062 }
01063
01070 function language_list($field = 'language', $reset = FALSE) {
01071   static $languages = NULL;
01072
01073   // Reset language list
01074   if ($reset) {
01075     $languages = NULL;
01076   }
01077
01078   // Init language list
01079   if (!isset($languages)) {
01080     if (variable_get('language_count', 1) > 1 || module_exists('locale')) {
01081       $result = db_query('SELECT * FROM {languages} ORDER BY weight ASC, name ASC');
01082       while ($row = db_fetch_object($result)) {
01083         $languages['language'][$row->language] = $row;
01084       }
01085     }
01086     else {
01087       // No locale module, so use the default language only.
01088       $default = language_default();
01089       $languages['language'][$default->language] = $default;
01090     }
01091   }
01092
01093   // Return the array indexed by the right field
01094   if (!isset($languages[$field])) {
01095     $languages[$field] = array();
01096     foreach ($languages['language'] as $lang) {
01097       // Some values should be collected into an array
01098       if (in_array($field, array('enabled', 'weight'))) {
01099         $languages[$field][$lang->$field][$lang->language] = $lang;
01100       }
01101       else {
01102         $languages[$field][$lang->$field] = $lang;
01103       }
01104     }
01105   }
01106   return $languages[$field];
01107 }
01108
01115 function language_default($property = NULL) {
01116   $language = variable_get('language_default', (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0, 'javascript' => ''));
01117   return $property ? $language->$property : $language;
01118 }
01119
01128 function ip_address() {
01129   static $ip_address = NULL;
01130
01131   if (!isset($ip_address)) {
01132     $ip_address = $_SERVER['REMOTE_ADDR'];
01133     if (variable_get('reverse_proxy', 0) && array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
01134       // If an array of known reverse proxy IPs is provided, then trust
01135       // the XFF header if request really comes from one of them.
01136       $reverse_proxy_addresses = variable_get('reverse_proxy_addresses', array());
01137       if (!empty($reverse_proxy_addresses) && in_array($ip_address, $reverse_proxy_addresses, TRUE)) {
01138         // If there are several arguments, we need to check the most
01139         // recently added one, i.e. the last one.
01140         $ip_address = array_pop(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']));
01141       }
01142     }
01143   }
01144
01145   return $ip_address;
01146 }
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/cache-install.inc Source File

includes

cache-install.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: cache-install.inc,v 1.2 2007/08/07 08:39:35 goba Exp $
00003
00014 function cache_get($key, $table = 'cache') {
00015   return FALSE;
00016 }
00017
00018 function cache_set($cid, $data, $table = 'cache', $expire = CACHE_PERMANENT, $headers = NULL) {
00019   return;
00020 }
00021
00022 function cache_clear_all($cid = NULL, $table = NULL, $wildcard = FALSE) {
00023   return;
00024 }
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/cache.inc Source File

includes

cache.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: cache.inc,v 1.17 2008/01/29 11:36:06 goba Exp $
00003
00014 function cache_get($cid, $table = 'cache') {
00015   global $user;
00016
00017   // Garbage collection necessary when enforcing a minimum cache lifetime
00018   $cache_flush = variable_get('cache_flush', 0);
00019   if ($cache_flush && ($cache_flush + variable_get('cache_lifetime', 0) <= time())) {
00020     // Reset the variable immediately to prevent a meltdown in heavy load situations.
00021     variable_set('cache_flush', 0);
00022     // Time to flush old cache data
00023     db_query("DELETE FROM {". $table ."} WHERE expire != %d AND expire <= %d", CACHE_PERMANENT, $cache_flush);
00024   }
00025
00026   $cache = db_fetch_object(db_query("SELECT data, created, headers, expire, serialized FROM {". $table ."} WHERE cid = '%s'", $cid));
00027   if (isset($cache->data)) {
00028     // If the data is permanent or we're not enforcing a minimum cache lifetime
00029     // always return the cached data.
00030     if ($cache->expire == CACHE_PERMANENT || !variable_get('cache_lifetime', 0)) {
00031       $cache->data = db_decode_blob($cache->data);
00032       if ($cache->serialized) {
00033         $cache->data = unserialize($cache->data);
00034       }
00035     }
00036     // If enforcing a minimum cache lifetime, validate that the data is
00037     // currently valid for this user before we return it by making sure the
00038     // cache entry was created before the timestamp in the current session's
00039     // cache timer. The cache variable is loaded into the $user object by
00040     // sess_read() in session.inc.
00041     else {
00042       if ($user->cache > $cache->created) {
00043         // This cache data is too old and thus not valid for us, ignore it.
00044         return 0;
00045       }
00046       else {
00047         $cache->data = db_decode_blob($cache->data);
00048         if ($cache->serialized) {
00049           $cache->data = unserialize($cache->data);
00050         }
00051       }
00052     }
00053     return $cache;
00054   }
00055   return 0;
00056 }
00057
00102 function cache_set($cid, $data, $table = 'cache', $expire = CACHE_PERMANENT, $headers = NULL) {
00103   $serialized = 0;
00104   if (is_object($data) || is_array($data)) {
00105     $data = serialize($data);
00106     $serialized = 1;
00107   }
00108   $created = time();
00109   db_query("UPDATE {". $table ."} SET data = %b, created = %d, expire = %d, headers = '%s', serialized = %d WHERE cid = '%s'", $data, $created, $expire, $headers, $serialized, $cid);
00110   if (!db_affected_rows()) {
00111     @db_query("INSERT INTO {". $table ."} (cid, data, created, expire, headers, serialized) VALUES ('%s', %b, %d, %d, '%s', %d)", $cid, $data, $created, $expire, $headers, $serialized);
00112   }
00113 }
00114
00133 function cache_clear_all($cid = NULL, $table = NULL, $wildcard = FALSE) {
00134   global $user;
00135
00136   if (!isset($cid) && !isset($table)) {
00137     // Clear the block cache first, so stale data will
00138     // not end up in the page cache.
00139     cache_clear_all(NULL, 'cache_block');
00140     cache_clear_all(NULL, 'cache_page');
00141     return;
00142   }
00143
00144   if (empty($cid)) {
00145     if (variable_get('cache_lifetime', 0)) {
00146       // We store the time in the current user's $user->cache variable which
00147       // will be saved into the sessions table by sess_write(). We then
00148       // simulate that the cache was flushed for this user by not returning
00149       // cached data that was cached before the timestamp.
00150       $user->cache = time();
00151
00152       $cache_flush = variable_get('cache_flush', 0);
00153       if ($cache_flush == 0) {
00154         // This is the first request to clear the cache, start a timer.
00155         variable_set('cache_flush', time());
00156       }
00157       else if (time() > ($cache_flush + variable_get('cache_lifetime', 0))) {
00158         // Clear the cache for everyone, cache_flush_delay seconds have
00159         // passed since the first request to clear the cache.
00160         db_query("DELETE FROM {". $table ."} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, time());
00161         variable_set('cache_flush', 0);
00162       }
00163     }
00164     else {
00165       // No minimum cache lifetime, flush all temporary cache entries now.
00166       db_query("DELETE FROM {". $table ."} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, time());
00167     }
00168   }
00169   else {
00170     if ($wildcard) {
00171       if ($cid == '*') {
00172         db_query("DELETE FROM {". $table ."}");
00173       }
00174       else {
00175         db_query("DELETE FROM {". $table ."} WHERE cid LIKE '%s%%'", $cid);
00176       }
00177     }
00178     else {
00179       db_query("DELETE FROM {". $table ."} WHERE cid = '%s'", $cid);
00180     }
00181   }
00182 }
00183
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/chameleon/chameleon.theme Source File

themes » chameleon

chameleon.theme

Go to the documentation of this file.
00001 <?php
00002 // $Id: chameleon.theme,v 1.76 2008/01/24 09:42:53 goba Exp $
00003
00012 function chameleon_theme($existing, $type, $theme, $path) {
00013   return drupal_find_theme_functions($existing, array($theme));
00014 }
00015
00016 function chameleon_page($content, $show_blocks = TRUE, $show_messages = TRUE) {
00017   $language = $GLOBALS['language']->language;
00018   $direction = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
00019
00020   if (theme_get_setting('toggle_favicon')) {
00021     drupal_set_html_head('<link rel="shortcut icon" href="'. check_url(theme_get_setting('favicon')) .'" type="image/x-icon" />');
00022   }
00023
00024   $title = drupal_get_title();
00025
00026   // Get blocks before so that they can alter the header (JavaScript, Stylesheets etc.)
00027   $blocks_left = theme_blocks('left');
00028   $blocks_right = theme_blocks('right');
00029
00030   $output  = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
00031   $output .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"$language\" xml:lang=\"$language\" dir=\"$direction\">\n";
00032   $output .= "<head>\n";
00033   $output .= " <title>". ($title ? strip_tags($title) ." | ". variable_get("site_name", "Drupal") : variable_get("site_name", "Drupal") ." | ". variable_get("site_slogan", "")) ."</title>\n";
00034   $output .= drupal_get_html_head();
00035   $output .= drupal_get_css();
00036   $output .= drupal_get_js();
00037   $output .= "</head>";
00038   $output .= "<body>\n";
00039   $output .= " <div id=\"header\">";
00040
00041   if ($logo = theme_get_setting('logo')) {
00042     $output .= "  <a href=\"". url() ."\" title=\"". t('Home') ."\"><img src=\"$logo\" alt=\"". t('Home') ."\" /></a>";
00043   }
00044   if (theme_get_setting('toggle_name')) {
00045     $output .= "  <h1 class=\"site-name title\">". l(variable_get('site_name', 'drupal'), "") ."</h1>";
00046   }
00047   if (theme_get_setting('toggle_slogan')) {
00048     $output .= "  <div class=\"site-slogan\">". variable_get('site_slogan', '') ."</div>";
00049   }
00050
00051   $output .= "</div>\n";
00052
00053   $primary_links = theme('links', menu_primary_links(), array('class' => 'links', 'id' => 'navlist'));
00054   $secondary_links = theme('links', menu_secondary_links(), array('class' => 'links', 'id' => 'subnavlist'));
00055   if (isset($primary_links) || isset($secondary_links)) {
00056     $output .= ' <div class="navlinks">';
00057     if (isset($primary_links)) {
00058       $output .= $primary_links;
00059     }
00060     if (isset($secondary_links)) {
00061       $output .= $secondary_links;
00062     }
00063     $output .= " </div>\n";
00064   }
00065
00066   $output .= " <table id=\"content\">\n";
00067   $output .= "  <tr>\n";
00068
00069   if ($show_blocks && !empty($blocks_left)) {
00070     $output .= "   <td id=\"sidebar-left\">$blocks_left</td>\n";
00071   }
00072
00073   $output .= "   <td id=\"main\">\n";
00074
00075   if ($title) {
00076     $output .= theme("breadcrumb", drupal_get_breadcrumb());
00077     $output .= "<h2>$title</h2>";
00078   }
00079
00080   if ($tabs = theme('menu_local_tasks')) {
00081     $output .= $tabs;
00082   }
00083
00084   if ($show_messages) {
00085     $output .= theme('status_messages');
00086   }
00087
00088   $output .= theme('help');
00089
00090   $output .= "\n<!-- begin content -->\n";
00091   $output .= $content;
00092   $output .= drupal_get_feeds();
00093   $output .= "\n<!-- end content -->\n";
00094
00095   if ($footer = variable_get('site_footer', '')) {
00096     $output .= " <div id=\"footer\">$footer</div>\n";
00097   }
00098
00099   $output .= "   </td>\n";
00100
00101   if ($show_blocks && !empty($blocks_right)) {
00102     $output .= "   <td id=\"sidebar-right\">$blocks_right</td>\n";
00103   }
00104
00105   $output .= "  </tr>\n";
00106   $output .= " </table>\n";
00107
00108   $output .=  theme_closure();
00109   $output .= " </body>\n";
00110   $output .= "</html>\n";
00111
00112   return $output;
00113 }
00114
00115 function chameleon_node($node, $teaser = 0, $page = 0) {
00116
00117   $output  = "<div class=\"node". ((!$node->status) ? ' node-unpublished' : '') . (($node->sticky) ? ' sticky' : '') ."\">\n";
00118
00119   if (!$page) {
00120     $output .= " <h2 class=\"title\">". ($teaser ? l($node->title, "node/$node->nid") : check_plain($node->title)) ."</h2>\n";
00121   }
00122
00123   $output .= " <div class=\"content\">\n";
00124
00125   if ($teaser && $node->teaser) {
00126     $output .= $node->teaser;
00127   }
00128   elseif (isset($node->body)) {
00129     $output .= $node->body;
00130   }
00131
00132   $output .= " </div>\n";
00133
00134   $submitted['node_submitted'] = theme_get_setting("toggle_node_info_$node->type") ? array(
00135     'title' => t("By !author at @date", array('!author' => theme('username', $node), '@date' => format_date($node->created, 'small'))),
00136     'html' => TRUE) : array();
00137
00138   $terms = array();
00139   if (module_exists('taxonomy')) {
00140     $terms = taxonomy_link("taxonomy terms", $node);
00141   }
00142
00143   $links = array_merge($submitted, $terms);
00144   if (isset($node->links)) {
00145     $links = array_merge($links, $node->links);
00146   }
00147   if (count($links)) {
00148     $output .= '<div class="links">'. theme('links', $links, array('class' => 'links inline')) ."</div>\n";
00149   }
00150
00151   $output .= "</div>\n";
00152
00153   return $output;
00154 }
00155
00156 function chameleon_comment($comment, $node, $links = array()) {
00157   $submitted['comment_submitted'] = array(
00158     'title' => t('By !author at @date', array('!author' => theme('username', $comment), '@date' => format_date($comment->timestamp, 'small'))),
00159     'html' => TRUE);
00160
00161   $output  = "<div class=\"comment". ' '. $status ."\">\n";
00162   $output .= " <h3 class=\"title\">". l($comment->subject, $_GET['q'], array('fragment' => "comment-$comment->cid")) ."</h3>\n";
00163   $output .= " <div class=\"content\">". $comment->comment;
00164   if (!empty($signature)) {
00165     $output .= "  <div class=\"clear-block\">";
00166     $output .= "<div>—</div>\n";
00167     $output .= $signature ."\n";
00168     $output .= "  </div>\n";
00169   }
00170   $output .= " </div>\n";
00171   $output .= " <div class=\"links\">". theme('links', array_merge($submitted, $links)) ."</div>\n";
00172   $output .= "</div>\n";
00173
00174   return $output;
00175 }
00176
00177 function chameleon_help() {
00178   if ($help = menu_get_active_help()) {
00179     return '<div class="help">'. $help .'</div><hr />';
00180   }
00181 }
00182
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Alphabetical List

  • Alphabetical List
  • Class List
  • Class Members

Class Index

U

U
update_xml_parser

U

Generated on Tue Feb 12 15:30:51 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Member List

  • Alphabetical List
  • Class List
  • Class Members

update_xml_parser Member List

This is the complete list of members for update_xml_parser, including all inherited members.

$current_object | update_xml_parser
$current_project | update_xml_parser
$current_release | update_xml_parser
$current_tag | update_xml_parser
$current_term | update_xml_parser
$projects | update_xml_parser
data($parser, $data) | update_xml_parser
end($parser, $name) | update_xml_parser
parse($data) | update_xml_parser
start($parser, $name, $attr) | update_xml_parser

Generated on Tue Feb 12 15:30:51 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/color/color.inc Source File

themes » garland » color

color.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: color.inc,v 1.4 2007/12/14 17:00:14 goba Exp $
00003
00004 $info = array(
00005
00006   // Pre-defined color schemes.
00007   'schemes' => array(
00008     '#0072b9,#027ac6,#2385c2,#5ab5ee,#494949' => t('Blue Lagoon (Default)'),
00009     '#464849,#2f416f,#2a2b2d,#5d6779,#494949' => t('Ash'),
00010     '#55c0e2,#000000,#085360,#007e94,#696969' => t('Aquamarine'),
00011     '#d5b048,#6c420e,#331900,#971702,#494949' => t('Belgian Chocolate'),
00012     '#3f3f3f,#336699,#6598cb,#6598cb,#000000' => t('Bluemarine'),
00013     '#d0cb9a,#917803,#efde01,#e6fb2d,#494949' => t('Citrus Blast'),
00014     '#0f005c,#434f8c,#4d91ff,#1a1575,#000000' => t('Cold Day'),
00015     '#c9c497,#0c7a00,#03961e,#7be000,#494949' => t('Greenbeam'),
00016     '#ffe23d,#a9290a,#fc6d1d,#a30f42,#494949' => t('Mediterrano'),
00017     '#788597,#3f728d,#a9adbc,#d4d4d4,#707070' => t('Mercury'),
00018     '#5b5fa9,#5b5faa,#0a2352,#9fa8d5,#494949' => t('Nocturnal'),
00019     '#7db323,#6a9915,#b5d52a,#7db323,#191a19' => t('Olivia'),
00020     '#12020b,#1b1a13,#f391c6,#f41063,#898080' => t('Pink Plastic'),
00021     '#b7a0ba,#c70000,#a1443a,#f21107,#515d52' => t('Shiny Tomato'),
00022     '#18583d,#1b5f42,#34775a,#52bf90,#2d2d2d' => t('Teal Top'),
00023   ),
00024
00025   // Images to copy over.
00026   'copy' => array(
00027     'images/menu-collapsed.gif',
00028     'images/menu-collapsed-rtl.gif',
00029     'images/menu-expanded.gif',
00030     'images/menu-leaf.gif',
00031   ),
00032
00033   // CSS files (excluding @import) to rewrite with new color scheme.
00034   'css' => array(
00035     'style.css',
00036   ),
00037
00038   // Coordinates of gradient (x, y, width, height).
00039   'gradient' => array(0, 37, 760, 121),
00040
00041   // Color areas to fill (x, y, width, height).
00042   'fill' => array(
00043     'base' => array(0, 0, 760, 568),
00044     'link' => array(107, 533, 41, 23),
00045   ),
00046
00047   // Coordinates of all the theme slices (x, y, width, height)
00048   // with their filename as used in the stylesheet.
00049   'slices' => array(
00050     'images/body.png'                      => array(0, 37, 1, 280),
00051     'images/bg-bar.png'                    => array(202, 530, 76, 14),
00052     'images/bg-bar-white.png'              => array(202, 506, 76, 14),
00053     'images/bg-tab.png'                    => array(107, 533, 41, 23),
00054     'images/bg-navigation.png'             => array(0, 0, 7, 37),
00055     'images/bg-content-left.png'           => array(40, 117, 50, 352),
00056     'images/bg-content-right.png'          => array(510, 117, 50, 352),
00057     'images/bg-content.png'                => array(299, 117, 7, 200),
00058     'images/bg-navigation-item.png'        => array(32, 37, 17, 12),
00059     'images/bg-navigation-item-hover.png'  => array(54, 37, 17, 12),
00060     'images/gradient-inner.png'            => array(646, 307, 112, 42),
00061
00062     'logo.png'                             => array(622, 51, 64, 73),
00063     'screenshot.png'                       => array(0, 37, 400, 240),
00064   ),
00065
00066   // Reference color used for blending. Matches the base.png's colors.
00067   'blend_target' => '#ffffff',
00068
00069   // Preview files.
00070   'preview_image' => 'color/preview.png',
00071   'preview_css' => 'color/preview.css',
00072
00073   // Base file for image generation.
00074   'base_image' => 'color/base.png',
00075 );
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/color/color.install Source File

modules » color

color.install

Go to the documentation of this file.
00001 <?php
00002 /* $Id: color.install,v 1.2 2006/12/05 05:49:50 dries Exp $ */
00003
00004 function color_requirements($phase) {
00005   $requirements = array();
00006
00007   if ($phase == 'runtime') {
00008     // Check GD library
00009     if (function_exists('imagegd2')) {
00010       $info = gd_info();
00011       $requirements['gd'] = array(
00012         'value' => $info['GD Version'],
00013       );
00014
00015       // Check PNG support
00016       if (function_exists('imagecreatefrompng')) {
00017         $requirements['gd']['severity'] = REQUIREMENT_OK;
00018       }
00019       else {
00020         $requirements['gd']['severity'] = REQUIREMENT_ERROR;
00021         $requirements['gd']['description'] = t('The GD library for PHP is enabled, but was compiled without PNG support. Please check the <a href="@url">PHP image documentation</a> for information on how to correct this.', array('@url' => 'http://www.php.net/manual/en/ref.image.php'));
00022       }
00023     }
00024     else {
00025       $requirements['gd'] = array(
00026         'value' => t('Not installed'),
00027         'severity' => REQUIREMENT_ERROR,
00028         'description' => t('The GD library for PHP is missing or outdated. Please check the <a href="@url">PHP image documentation</a> for information on how to correct this.', array('@url' => 'http://www.php.net/manual/en/ref.image.php')),
00029       );
00030     }
00031     $requirements['gd']['title'] = t('GD library');
00032   }
00033
00034   return $requirements;
00035 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/color/color.module Source File

modules » color

color.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: color.module,v 1.39 2008/01/23 09:43:25 goba Exp $
00003
00007 function color_help($path, $arg) {
00008   switch ($path) {
00009     case 'admin/help#color':
00010       $output = '<p>'. t('The color module allows a site administrator to quickly and easily change the color scheme of certain themes. Although not all themes support color module, both Garland (the default theme) and Minnelli were designed to take advantage of its features. By using color module with a compatible theme, you can easily change the color of links, backgrounds, text, and other theme elements. Color module requires that your <a href="@url">file download method</a> be set to public.', array('@url' => url('admin/settings/file-system'))) .'</p>';
00011       $output .= '<p>'. t("It is important to remember that color module saves a modified copy of the theme's specified stylesheets in the files directory. This means that if you make any manual changes to your theme's stylesheet, you must save your color settings again, even if they haven't changed. This causes the color module generated version of the stylesheets in the files directory to be recreated using the new version of the original file.") .'</p>';
00012       $output .= '<p>'. t('To change the color settings for a compatible theme, select the "configure" link for the theme on the <a href="@themes">themes administration page</a>.', array('@themes' => url('admin/build/themes'))) .'</p>';
00013       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@color">Color module</a>.', array('@color' => 'http://drupal.org/handbook/modules/color/')) .'</p>';
00014       return $output;
00015   }
00016 }
00017
00021 function color_theme() {
00022   return array(
00023     'color_scheme_form' => array(
00024       'arguments' => array('form' => NULL),
00025     ),
00026   );
00027 }
00028
00032 function color_form_alter(&$form, $form_state, $form_id) {
00033   // Insert the color changer into the theme settings page.
00034   if ($form_id == 'system_theme_settings' && color_get_info(arg(4)) && function_exists('gd_info')) {
00035     if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) != FILE_DOWNLOADS_PUBLIC) {
00036       // Disables the color changer when the private download method is used.
00037       // TODO: This should be solved in a different way. See issue #181003.
00038       drupal_set_message(t('The color picker only works if the <a href="@url">download method</a> is set to public.', array('@url' => url('admin/settings/file-system'))), 'warning');
00039     }
00040     else {
00041       $form['color'] = array(
00042         '#type' => 'fieldset',
00043         '#title' => t('Color scheme'),
00044         '#weight' => -1,
00045         '#attributes' => array('id' => 'color_scheme_form'),
00046         '#theme' => 'color_scheme_form',
00047       );
00048       $form['color'] += color_scheme_form($form_state, arg(4));
00049       $form['#submit'][] = 'color_scheme_form_submit';
00050     }
00051   }
00052
00053   // Use the generated screenshot in the theme list.
00054   if ($form_id == 'system_theme_select_form' || $form_id == 'system_themes') {
00055     $themes = list_themes();
00056     foreach (element_children($form) as $theme) {
00057       if ($screenshot = variable_get('color_'. $theme .'_screenshot', NULL)) {
00058         if (isset($form[$theme]['screenshot'])) {
00059           $form[$theme]['screenshot']['#value'] = theme('image', $screenshot, '', '', array('class' => 'screenshot'), FALSE);
00060         }
00061       }
00062     }
00063   }
00064 }
00065
00069 function _color_page_alter(&$vars) {
00070   global $language, $theme_key;
00071
00072   // Override stylesheets.
00073   $color_paths = variable_get('color_'. $theme_key .'_stylesheets', array());
00074   if (!empty($color_paths)) {
00075     // Loop over theme CSS files and try to rebuild CSS array with rewritten
00076     // stylesheets. Keep the orginal order intact for CSS cascading.
00077     $new_theme_css = array();
00078
00079     foreach ($vars['css']['all']['theme'] as $old_path => $old_preprocess) {
00080       // Add the non-colored stylesheet first as we might not find a
00081       // re-colored stylesheet for replacement later.
00082       $new_theme_css[$old_path] = $old_preprocess;
00083
00084       // Loop over the path array with recolored CSS files to find matching
00085       // paths which could replace the non-recolored paths.
00086       foreach ($color_paths as $color_path) {
00087         // Color module currently requires unique file names to be used,
00088         // which allows us to compare different file paths.
00089         if (basename($old_path) == basename($color_path)) {
00090           // Pull out the non-colored and add rewritten stylesheet.
00091           unset($new_theme_css[$old_path]);
00092           $new_theme_css[$color_path] = $old_preprocess;
00093
00094           // If the current language is RTL and the CSS file had an RTL variant,
00095           // pull out the non-colored and add rewritten RTL stylesheet.
00096           if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) {
00097             $rtl_old_path = str_replace('.css', '-rtl.css', $old_path);
00098             $rtl_color_path = str_replace('.css', '-rtl.css', $color_path);
00099             if (file_exists($rtl_color_path)) {
00100               unset($new_theme_css[$rtl_old_path]);
00101               $new_theme_css[$rtl_color_path] = $old_preprocess;
00102             }
00103           }
00104           break;
00105         }
00106       }
00107     }
00108     $vars['css']['all']['theme'] = $new_theme_css;
00109     $vars['styles'] = drupal_get_css($vars['css']);
00110   }
00111
00112   // Override logo.
00113   $logo = variable_get('color_'. $theme_key .'_logo', NULL);
00114   if ($logo && $vars['logo'] && preg_match('!'. $theme_key .'/logo.png$!', $vars['logo'])) {
00115     $vars['logo'] = base_path() . $logo;
00116   }
00117 }
00118
00122 function color_get_info($theme) {
00123   $path = drupal_get_path('theme', $theme);
00124   $file = $path .'/color/color.inc';
00125   if ($path && file_exists($file)) {
00126     include $file;
00127     return $info;
00128   }
00129 }
00130
00134 function color_get_palette($theme, $default = false) {
00135   // Fetch and expand default palette
00136   $fields = array('base', 'link', 'top', 'bottom', 'text');
00137   $info = color_get_info($theme);
00138   $keys = array_keys($info['schemes']);
00139   foreach (explode(',', array_shift($keys)) as $k => $scheme) {
00140     $palette[$fields[$k]] = $scheme;
00141   }
00142
00143   // Load variable
00144   return $default ? $palette : variable_get('color_'. $theme .'_palette', $palette);
00145 }
00146
00150 function color_scheme_form(&$form_state, $theme) {
00151   $base = drupal_get_path('module', 'color');
00152   $info = color_get_info($theme);
00153
00154   // Add Farbtastic color picker
00155   drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE);
00156   drupal_add_js('misc/farbtastic/farbtastic.js');
00157
00158   // Add custom CSS/JS
00159   drupal_add_css($base .'/color.css', 'module', 'all', FALSE);
00160   drupal_add_js($base .'/color.js');
00161   drupal_add_js(array('color' => array(
00162     'reference' => color_get_palette($theme, true)
00163   )), 'setting');
00164
00165   // See if we're using a predefined scheme
00166   $current = implode(',', variable_get('color_'. $theme .'_palette', array()));
00167   // Note: we use the original theme when the default scheme is chosen.
00168   $current = isset($info['schemes'][$current]) ? $current : ($current == '' ? reset($info['schemes']) : '');
00169
00170   // Add scheme selector
00171   $info['schemes'][''] = t('Custom');
00172   $form['scheme'] = array(
00173     '#type' => 'select',
00174     '#title' => t('Color set'),
00175     '#options' => $info['schemes'],
00176     '#default_value' => $current,
00177   );
00178
00179   // Add palette fields
00180   $palette = color_get_palette($theme);
00181   $names = array(
00182     'base' => t('Base color'),
00183     'link' => t('Link color'),
00184     'top' => t('Header top'),
00185     'bottom' => t('Header bottom'),
00186     'text' => t('Text color')
00187   );
00188   $form['palette']['#tree'] = true;
00189   foreach ($palette as $name => $value) {
00190     $form['palette'][$name] = array(
00191       '#type' => 'textfield',
00192       '#title' => $names[$name],
00193       '#default_value' => $value,
00194       '#size' => 8,
00195     );
00196   }
00197   $form['theme'] = array('#type' => 'value', '#value' => arg(4));
00198   $form['info'] = array('#type' => 'value', '#value' => $info);
00199
00200   return $form;
00201 }
00202
00208 function theme_color_scheme_form($form) {
00209   // Include stylesheet
00210   $theme = $form['theme']['#value'];
00211   $info = $form['info']['#value'];
00212   $path = drupal_get_path('theme', $theme) .'/';
00213   drupal_add_css($path . $info['preview_css']);
00214   $output = '';
00215   // Wrapper
00216   $output .= '<div class="color-form clear-block">';
00217
00218   // Color schemes
00219   $output .= drupal_render($form['scheme']);
00220
00221   // Palette
00222   $output .= '<div id="palette" class="clear-block">';
00223   foreach (element_children($form['palette']) as $name) {
00224     $output .= drupal_render($form['palette'][$name]);
00225   }
00226   $output .= '</div>';
00227
00228   // Preview
00229   $output .= drupal_render($form);
00230   $output .= '<h2>'. t('Preview') .'</h2>';
00231   $output .= '<div id="preview"><div id="text"><h2>Lorem ipsum dolor</h2><p>Sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud <a href="#">exercitation ullamco</a> laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p></div><div id="img" style="background-image: url('. base_path() . $path . $info['preview_image'] .')"></div></div>';
00232
00233   // Close wrapper
00234   $output .= '</div>';
00235
00236   return $output;
00237 }
00238
00242 function color_scheme_form_submit($form, &$form_state) {
00243   // Get theme coloring info
00244   if (!isset($form_state['values']['info'])) {
00245     return;
00246   }
00247   $theme = $form_state['values']['theme'];
00248   $info = $form_state['values']['info'];
00249
00250   // Resolve palette
00251   $palette = $form_state['values']['palette'];
00252   if ($form_state['values']['scheme'] != '') {
00253     $scheme = explode(',', $form_state['values']['scheme']);
00254     foreach ($palette as $k => $color) {
00255       $palette[$k] = array_shift($scheme);
00256     }
00257   }
00258
00259   // Make sure enough memory is available, if PHP's memory limit is compiled in.
00260   if (function_exists('memory_get_usage')) {
00261     // Fetch source image dimensions.
00262     $source = drupal_get_path('theme', $theme) .'/'. $info['base_image'];
00263     list($width, $height) = getimagesize($source);
00264
00265     // We need at least a copy of the source and a target buffer of the same
00266     // size (both at 32bpp).
00267     $required = $width * $height * 8;
00268     $usage = memory_get_usage();
00269     $limit = parse_size(ini_get('memory_limit'));
00270     if ($usage + $required > $limit) {
00271       drupal_set_message(t('There is not enough memory available to PHP to change this theme\'s color scheme. You need at least %size more. Check the <a href="@url">PHP documentation</a> for more information.', array('%size' => format_size($usage + $required - $limit), '@url' => 'http://www.php.net/manual/en/ini.core.php#ini.sect.resource-limits')), 'error');
00272       return;
00273     }
00274   }
00275
00276   // Delete old files
00277   foreach (variable_get('color_'. $theme .'_files', array()) as $file) {
00278     @unlink($file);
00279   }
00280   if (isset($file) && $file = dirname($file)) {
00281     @rmdir($file);
00282   }
00283
00284   // Don't render the default colorscheme, use the standard theme instead.
00285   if (implode(',', color_get_palette($theme, true)) == implode(',', $palette)
00286     || $form_state['values']['op'] == t('Reset to defaults')) {
00287     variable_del('color_'. $theme .'_palette');
00288     variable_del('color_'. $theme .'_stylesheets');
00289     variable_del('color_'. $theme .'_logo');
00290     variable_del('color_'. $theme .'_files');
00291     variable_del('color_'. $theme .'_screenshot');
00292     return;
00293   }
00294
00295   // Prepare target locations for generated files.
00296   $id = $theme .'-'. substr(md5(serialize($palette) . microtime()), 0, 8);
00297   $paths['color'] = file_directory_path() .'/color';
00298   $paths['target'] = $paths['color'] .'/'. $id;
00299   foreach ($paths as $path) {
00300     file_check_directory($path, FILE_CREATE_DIRECTORY);
00301   }
00302   $paths['target'] = $paths['target'] .'/';
00303   $paths['id'] = $id;
00304   $paths['source'] = drupal_get_path('theme', $theme) .'/';
00305   $paths['files'] = $paths['map'] = array();
00306
00307   // Save palette and logo location.
00308   variable_set('color_'. $theme .'_palette', $palette);
00309   variable_set('color_'. $theme .'_logo', $paths['target'] .'logo.png');
00310
00311   // Copy over neutral images.
00312   foreach ($info['copy'] as $file) {
00313     $base = basename($file);
00314     $source = $paths['source'] . $file;
00315     file_copy($source, $paths['target'] . $base);
00316     $paths['map'][$file] = $base;
00317     $paths['files'][] = $paths['target'] . $base;
00318   }
00319
00320   // Render new images, if image provided.
00321   if ($info['base_image']) {
00322     _color_render_images($theme, $info, $paths, $palette);
00323   }
00324
00325   // Rewrite theme stylesheets.
00326   $css = array();
00327   foreach ($info['css'] as $stylesheet) {
00328     // Build a temporary array with LTR and RTL files.
00329     $files = array();
00330     if (file_exists($paths['source'] . $stylesheet)) {
00331       $files[] = $stylesheet;
00332
00333       $rtl_file = str_replace('.css', '-rtl.css', $stylesheet);
00334       if (file_exists($paths['source'] . $rtl_file)) {
00335         $files[] = $rtl_file;
00336       }
00337     }
00338
00339     foreach ($files as $file) {
00340       // Aggregate @imports recursively for each configured top level CSS file
00341       // without optimization. Aggregation and optimization will be
00342       // handled by drupal_build_css_cache() only.
00343       $style = drupal_load_stylesheet($paths['source'] . $file, FALSE);
00344
00345       // Return the path to where this CSS file originated from, stripping
00346       // off the name of the file at the end of the path.
00347       $base = base_path() . dirname($paths['source'] . $file) .'/';
00348       _drupal_build_css_path(NULL, $base);
00349
00350       // Prefix all paths within this CSS file, ignoring absolute paths.
00351       $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', '_drupal_build_css_path', $style);
00352
00353       // Rewrite stylesheet with new colors.
00354       $style = _color_rewrite_stylesheet($theme, $info, $paths, $palette, $style);
00355       $base_file = basename($file);
00356       $css[] = $paths['target'] . $base_file;
00357       _color_save_stylesheet($paths['target'] . $base_file, $style, $paths);
00358     }
00359   }
00360
00361   // Maintain list of files.
00362   variable_set('color_'. $theme .'_stylesheets', $css);
00363   variable_set('color_'. $theme .'_files', $paths['files']);
00364 }
00365
00369 function _color_rewrite_stylesheet($theme, &$info, &$paths, $palette, $style) {
00370   $themes = list_themes();
00371
00372   // Prepare color conversion table
00373   $conversion = $palette;
00374   unset($conversion['base']);
00375   foreach ($conversion as $k => $v) {
00376     $conversion[$k] = drupal_strtolower($v);
00377   }
00378   $default = color_get_palette($theme, true);
00379
00380   // Split off the "Don't touch" section of the stylesheet.
00381   $split = "Color Module: Don't touch";
00382   if (strpos($style, $split) !== FALSE) {
00383     list($style, $fixed) = explode($split, $style);
00384   }
00385
00386   // Find all colors in the stylesheet and the chunks in between.
00387   $style = preg_split('/(#[0-9a-f]{6}|#[0-9a-f]{3})/i', $style, -1, PREG_SPLIT_DELIM_CAPTURE);
00388   $is_color = false;
00389   $output = '';
00390   $base = 'base';
00391
00392   // Iterate over all parts.
00393   foreach ($style as $chunk) {
00394     if ($is_color) {
00395       $chunk = drupal_strtolower($chunk);
00396       // Check if this is one of the colors in the default palette.
00397       if ($key = array_search($chunk, $default)) {
00398         $chunk = $conversion[$key];
00399       }
00400       // Not a pre-set color. Extrapolate from the base.
00401       else {
00402         $chunk = _color_shift($palette[$base], $default[$base], $chunk, $info['blend_target']);
00403       }
00404     }
00405     else {
00406       // Determine the most suitable base color for the next color.
00407
00408       // 'a' declarations. Use link.
00409       if (preg_match('@[^a-z0-9_-](a)[^a-z0-9_-][^/{]*{[^{]+$@i', $chunk)) {
00410         $base = 'link';
00411       }
00412       // 'color:' styles. Use text.
00413       else if (preg_match('/(?<!-)color[^{:]*:[^{#]*$/i', $chunk)) {
00414         $base = 'text';
00415       }
00416       // Reset back to base.
00417       else {
00418         $base = 'base';
00419       }
00420     }
00421     $output .= $chunk;
00422     $is_color = !$is_color;
00423   }
00424   // Append fixed colors segment.
00425   if (isset($fixed)) {
00426     $output .= $fixed;
00427   }
00428
00429   // Replace paths to images.
00430   foreach ($paths['map'] as $before => $after) {
00431     $before = base_path() . $paths['source'] . $before;
00432     $before = preg_replace('`(^|/)(?!../)([^/]+)/../`', '$1', $before);
00433     $output = str_replace($before, $after, $output);
00434   }
00435
00436   return $output;
00437 }
00438
00442 function _color_save_stylesheet($file, $style, &$paths) {
00443
00444   // Write new stylesheet.
00445   file_save_data($style, $file, FILE_EXISTS_REPLACE);
00446   $paths['files'][] = $file;
00447
00448   // Set standard file permissions for webserver-generated files.
00449   @chmod($file, 0664);
00450 }
00451
00455 function _color_render_images($theme, &$info, &$paths, $palette) {
00456
00457   // Prepare template image.
00458   $source = $paths['source'] .'/'. $info['base_image'];
00459   $source = imagecreatefrompng($source);
00460   $width = imagesx($source);
00461   $height = imagesy($source);
00462
00463   // Prepare target buffer.
00464   $target = imagecreatetruecolor($width, $height);
00465   imagealphablending($target, true);
00466
00467   // Fill regions of solid color.
00468   foreach ($info['fill'] as $color => $fill) {
00469     imagefilledrectangle($target, $fill[0], $fill[1], $fill[0] + $fill[2], $fill[1] + $fill[3], _color_gd($target, $palette[$color]));
00470   }
00471
00472   // Render gradient.
00473   for ($y = 0; $y < $info['gradient'][3]; ++$y) {
00474     $color = _color_blend($target, $palette['top'], $palette['bottom'], $y / ($info['gradient'][3] - 1));
00475     imagefilledrectangle($target, $info['gradient'][0], $info['gradient'][1] + $y, $info['gradient'][0] + $info['gradient'][2], $info['gradient'][1] + $y + 1, $color);
00476   }
00477
00478   // Blend over template.
00479   imagecopy($target, $source, 0, 0, 0, 0, $width, $height);
00480
00481   // Clean up template image.
00482   imagedestroy($source);
00483
00484   // Cut out slices.
00485   foreach ($info['slices'] as $file => $coord) {
00486     list($x, $y, $width, $height) = $coord;
00487     $base = basename($file);
00488     $image = $paths['target'] . $base;
00489
00490     // Cut out slice.
00491     if ($file == 'screenshot.png') {
00492       $slice = imagecreatetruecolor(150, 90);
00493       imagecopyresampled($slice, $target, 0, 0, $x, $y, 150, 90, $width, $height);
00494       variable_set('color_'. $theme .'_screenshot', $image);
00495     }
00496     else {
00497       $slice = imagecreatetruecolor($width, $height);
00498       imagecopy($slice, $target, 0, 0, $x, $y, $width, $height);
00499     }
00500
00501     // Save image.
00502     imagepng($slice, $image);
00503     imagedestroy($slice);
00504     $paths['files'][] = $image;
00505
00506     // Set standard file permissions for webserver-generated files
00507     @chmod(realpath($image), 0664);
00508
00509     // Build before/after map of image paths.
00510     $paths['map'][$file] = $base;
00511   }
00512
00513   // Clean up target buffer.
00514   imagedestroy($target);
00515 }
00516
00529 function _color_shift($given, $ref1, $ref2, $target) {
00530
00531   // We assume that ref2 is a blend of ref1 and target and find
00532   // delta based on the length of the difference vectors:
00533
00534   // delta = 1 - |ref2 - ref1| / |white - ref1|
00535   $target = _color_unpack($target, true);
00536   $ref1 = _color_unpack($ref1, true);
00537   $ref2 = _color_unpack($ref2, true);
00538   $numerator = 0;
00539   $denominator = 0;
00540   for ($i = 0; $i < 3; ++$i) {
00541     $numerator += ($ref2[$i] - $ref1[$i]) * ($ref2[$i] - $ref1[$i]);
00542     $denominator += ($target[$i] - $ref1[$i]) * ($target[$i] - $ref1[$i]);
00543   }
00544   $delta = ($denominator > 0) ? (1 - sqrt($numerator / $denominator)) : 0;
00545
00546   // Calculate the color that ref2 would be if the assumption was true.
00547   for ($i = 0; $i < 3; ++$i) {
00548     $ref3[$i] = $target[$i] + ($ref1[$i] - $target[$i]) * $delta;
00549   }
00550
00551   // If the assumption is not true, there is a difference between ref2 and ref3.
00552   // We measure this in HSL space. Notation: x' = hsl(x).
00553   $ref2 = _color_rgb2hsl($ref2);
00554   $ref3 = _color_rgb2hsl($ref3);
00555   for ($i = 0; $i < 3; ++$i) {
00556     $shift[$i] = $ref2[$i] - $ref3[$i];
00557   }
00558
00559   // Take the given color, and blend it towards the target.
00560   $given = _color_unpack($given, true);
00561   for ($i = 0; $i < 3; ++$i) {
00562     $result[$i] = $target[$i] + ($given[$i] - $target[$i]) * $delta;
00563   }
00564
00565   // Finally, we apply the extra shift in HSL space.
00566   // Note: if ref2 is a pure blend of ref1 and target, then |shift| = 0.
00567   $result = _color_rgb2hsl($result);
00568   for ($i = 0; $i < 3; ++$i) {
00569     $result[$i] = min(1, max(0, $result[$i] + $shift[$i]));
00570   }
00571   $result = _color_hsl2rgb($result);
00572
00573   // Return hex color.
00574   return _color_pack($result, true);
00575 }
00576
00580 function _color_gd($img, $hex) {
00581   $c = array_merge(array($img), _color_unpack($hex));
00582   return call_user_func_array('imagecolorallocate', $c);
00583 }
00584
00588 function _color_blend($img, $hex1, $hex2, $alpha) {
00589   $in1 = _color_unpack($hex1);
00590   $in2 = _color_unpack($hex2);
00591   $out = array($img);
00592   for ($i = 0; $i < 3; ++$i) {
00593     $out[] = $in1[$i] + ($in2[$i] - $in1[$i]) * $alpha;
00594   }
00595   return call_user_func_array('imagecolorallocate', $out);
00596 }
00597
00601 function _color_unpack($hex, $normalize = false) {
00602   if (strlen($hex) == 4) {
00603     $hex = $hex[1] . $hex[1] . $hex[2] . $hex[2] . $hex[3] . $hex[3];
00604   }
00605   $c = hexdec($hex);
00606   for ($i = 16; $i >= 0; $i -= 8) {
00607     $out[] = (($c >> $i) & 0xFF) / ($normalize ? 255 : 1);
00608   }
00609   return $out;
00610 }
00611
00615 function _color_pack($rgb, $normalize = false) {
00616   $out = 0;
00617   foreach ($rgb as $k => $v) {
00618     $out |= (($v * ($normalize ? 255 : 1)) << (16 - $k * 8));
00619   }
00620   return '#'. str_pad(dechex($out), 6, 0, STR_PAD_LEFT);
00621 }
00622
00626 function _color_hsl2rgb($hsl) {
00627   $h = $hsl[0];
00628   $s = $hsl[1];
00629   $l = $hsl[2];
00630   $m2 = ($l <= 0.5) ? $l * ($s + 1) : $l + $s - $l*$s;
00631   $m1 = $l * 2 - $m2;
00632   return array(
00633     _color_hue2rgb($m1, $m2, $h + 0.33333),
00634     _color_hue2rgb($m1, $m2, $h),
00635     _color_hue2rgb($m1, $m2, $h - 0.33333),
00636   );
00637 }
00638
00642 function _color_hue2rgb($m1, $m2, $h) {
00643   $h = ($h < 0) ? $h + 1 : (($h > 1) ? $h - 1 : $h);
00644   if ($h * 6 < 1) return $m1 + ($m2 - $m1) * $h * 6;
00645   if ($h * 2 < 1) return $m2;
00646   if ($h * 3 < 2) return $m1 + ($m2 - $m1) * (0.66666 - $h) * 6;
00647   return $m1;
00648 }
00649
00653 function _color_rgb2hsl($rgb) {
00654   $r = $rgb[0];
00655   $g = $rgb[1];
00656   $b = $rgb[2];
00657   $min = min($r, min($g, $b));
00658   $max = max($r, max($g, $b));
00659   $delta = $max - $min;
00660   $l = ($min + $max) / 2;
00661   $s = 0;
00662   if ($l > 0 && $l < 1) {
00663     $s = $delta / ($l < 0.5 ? (2 * $l) : (2 - 2 * $l));
00664   }
00665   $h = 0;
00666   if ($delta > 0) {
00667     if ($max == $r && $max != $g) $h += ($g - $b) / $delta;
00668     if ($max == $g && $max != $b) $h += (2 + ($b - $r) / $delta);
00669     if ($max == $b && $max != $r) $h += (4 + ($r - $g) / $delta);
00670     $h /= 6;
00671   }
00672   return array($h, $s, $l);
00673 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/comment/comment-folded.tpl.php Source File

modules » comment

comment-folded.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: comment-folded.tpl.php,v 1.2 2007/08/07 08:39:35 goba Exp $
00003
00018 ?>
00019 <div class="comment-folded">
00020   <span class="subject"><?php print $title .' '. $new; ?></span><span class="credit"><?php print t('by') .' '. $author; ?></span>
00021 </div>
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/comment/comment-wrapper.tpl.php Source File

modules » comment

comment-wrapper.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: comment-wrapper.tpl.php,v 1.2 2007/08/07 08:39:35 goba Exp $
00003
00033 ?>
00034 <div id="comments">
00035   <?php print $content; ?>
00036 </div>
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/comment/comment.admin.inc Source File

modules » comment

comment.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: comment.admin.inc,v 1.4 2008/01/08 10:35:41 goba Exp $
00003
00012 function comment_admin($type = 'new') {
00013   $edit = $_POST;
00014
00015   if (isset($edit['operation']) && ($edit['operation'] == 'delete') && isset($edit['comments']) && $edit['comments']) {
00016     return drupal_get_form('comment_multiple_delete_confirm');
00017   }
00018   else {
00019     return drupal_get_form('comment_admin_overview', $type, arg(4));
00020   }
00021 }
00022
00037 function comment_admin_overview($type = 'new', $arg) {
00038   // build an 'Update options' form
00039   $form['options'] = array(
00040     '#type' => 'fieldset', '#title' => t('Update options'),
00041     '#prefix' => '<div class="container-inline">', '#suffix' => '</div>'
00042   );
00043   $options = array();
00044   foreach (comment_operations($arg == 'approval' ? 'publish' : 'unpublish') as $key => $value) {
00045     $options[$key] = $value[0];
00046   }
00047   $form['options']['operation'] = array('#type' => 'select', '#options' => $options, '#default_value' => 'publish');
00048   $form['options']['submit'] = array('#type' => 'submit', '#value' => t('Update'));
00049
00050   // load the comments that we want to display
00051   $status = ($arg == 'approval') ? COMMENT_NOT_PUBLISHED : COMMENT_PUBLISHED;
00052   $form['header'] = array('#type' => 'value', '#value' => array(
00053     theme('table_select_header_cell'),
00054     array('data' => t('Subject'), 'field' => 'subject'),
00055     array('data' => t('Author'), 'field' => 'name'),
00056     array('data' => t('Posted in'), 'field' => 'node_title'),
00057     array('data' => t('Time'), 'field' => 'timestamp', 'sort' => 'desc'),
00058     array('data' => t('Operations'))
00059   ));
00060   $result = pager_query('SELECT c.subject, c.nid, c.cid, c.comment, c.timestamp, c.status, c.name, c.homepage, u.name AS registered_name, u.uid, n.title as node_title FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid INNER JOIN {node} n ON n.nid = c.nid WHERE c.status = %d'. tablesort_sql($form['header']['#value']), 50, 0, NULL, $status);
00061
00062   // build a table listing the appropriate comments
00063   $destination = drupal_get_destination();
00064   while ($comment = db_fetch_object($result)) {
00065     $comments[$comment->cid] = '';
00066     $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
00067     $form['subject'][$comment->cid] = array('#value' => l($comment->subject, 'node/'. $comment->nid, array('title' => truncate_utf8($comment->comment, 128), 'fragment' => 'comment-'. $comment->cid)));
00068     $form['username'][$comment->cid] = array('#value' => theme('username', $comment));
00069     $form['node_title'][$comment->cid] = array('#value' => l($comment->node_title, 'node/'. $comment->nid));
00070     $form['timestamp'][$comment->cid] = array('#value' => format_date($comment->timestamp, 'small'));
00071     $form['operations'][$comment->cid] = array('#value' => l(t('edit'), 'comment/edit/'. $comment->cid, array('query' => $destination)));
00072   }
00073   $form['comments'] = array('#type' => 'checkboxes', '#options' => isset($comments) ? $comments: array());
00074   $form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
00075   return $form;
00076 }
00077
00083 function comment_admin_overview_validate($form, &$form_state) {
00084   $form_state['values']['comments'] = array_diff($form_state['values']['comments'], array(0));
00085   if (count($form_state['values']['comments']) == 0) {
00086     form_set_error('', t('Please select one or more comments to perform the update on.'));
00087     drupal_goto('admin/content/comment');
00088   }
00089 }
00090
00097 function comment_admin_overview_submit($form, &$form_state) {
00098   $operations = comment_operations();
00099   if ($operations[$form_state['values']['operation']][1]) {
00100     // extract the appropriate database query operation
00101     $query = $operations[$form_state['values']['operation']][1];
00102     foreach ($form_state['values']['comments'] as $cid => $value) {
00103       if ($value) {
00104         // perform the update action, then refresh node statistics
00105         db_query($query, $cid);
00106         $comment = _comment_load($cid);
00107         _comment_update_node_statistics($comment->nid);
00108         // Allow modules to respond to the updating of a comment.
00109         comment_invoke_comment($comment, $form_state['values']['operation']);
00110         // Add an entry to the watchdog log.
00111         watchdog('content', 'Comment: updated %subject.', array('%subject' => $comment->subject), WATCHDOG_NOTICE, l(t('view'), 'node/'. $comment->nid, array('fragment' => 'comment-'. $comment->cid)));
00112       }
00113     }
00114     cache_clear_all();
00115     drupal_set_message(t('The update has been performed.'));
00116     $form_state['redirect'] = 'admin/content/comment';
00117   }
00118 }
00119
00127 function theme_comment_admin_overview($form) {
00128   $output = drupal_render($form['options']);
00129   if (isset($form['subject']) && is_array($form['subject'])) {
00130     foreach (element_children($form['subject']) as $key) {
00131       $row = array();
00132       $row[] = drupal_render($form['comments'][$key]);
00133       $row[] = drupal_render($form['subject'][$key]);
00134       $row[] = drupal_render($form['username'][$key]);
00135       $row[] = drupal_render($form['node_title'][$key]);
00136       $row[] = drupal_render($form['timestamp'][$key]);
00137       $row[] = drupal_render($form['operations'][$key]);
00138       $rows[] = $row;
00139     }
00140   }
00141   else {
00142     $rows[] = array(array('data' => t('No comments available.'), 'colspan' => '6'));
00143   }
00144
00145   $output .= theme('table', $form['header']['#value'], $rows);
00146   if ($form['pager']['#value']) {
00147     $output .= drupal_render($form['pager']);
00148   }
00149
00150   $output .= drupal_render($form);
00151
00152   return $output;
00153 }
00154
00166 function comment_multiple_delete_confirm(&$form_state) {
00167   $edit = $form_state['post'];
00168
00169   $form['comments'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
00170   // array_filter() returns only elements with actual values
00171   $comment_counter = 0;
00172   foreach (array_filter($edit['comments']) as $cid => $value) {
00173     $comment = _comment_load($cid);
00174     if (is_object($comment) && is_numeric($comment->cid)) {
00175       $subject = db_result(db_query('SELECT subject FROM {comments} WHERE cid = %d', $cid));
00176       $form['comments'][$cid] = array('#type' => 'hidden', '#value' => $cid, '#prefix' => '<li>', '#suffix' => check_plain($subject) .'</li>');
00177       $comment_counter++;
00178     }
00179   }
00180   $form['operation'] = array('#type' => 'hidden', '#value' => 'delete');
00181
00182   if (!$comment_counter) {
00183     drupal_set_message(t('There do not appear to be any comments to delete or your selected comment was deleted by another administrator.'));
00184     drupal_goto('admin/content/comment');
00185   }
00186   else {
00187     return confirm_form($form,
00188                         t('Are you sure you want to delete these comments and all their children?'),
00189                         'admin/content/comment', t('This action cannot be undone.'),
00190                         t('Delete comments'), t('Cancel'));
00191   }
00192 }
00193
00199 function comment_multiple_delete_confirm_submit($form, &$form_state) {
00200   if ($form_state['values']['confirm']) {
00201     foreach ($form_state['values']['comments'] as $cid => $value) {
00202       $comment = _comment_load($cid);
00203       _comment_delete_thread($comment);
00204       _comment_update_node_statistics($comment->nid);
00205     }
00206     cache_clear_all();
00207     drupal_set_message(t('The comments have been deleted.'));
00208   }
00209   $form_state['redirect'] = 'admin/content/comment';
00210 }
00211
00218 function comment_delete($cid = NULL) {
00219   $comment = db_fetch_object(db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.cid = %d', $cid));
00220   $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
00221
00222   $output = '';
00223
00224   if (is_object($comment) && is_numeric($comment->cid)) {
00225     $output = drupal_get_form('comment_confirm_delete', $comment);
00226   }
00227   else {
00228     drupal_set_message(t('The comment no longer exists.'));
00229   }
00230
00231   return $output;
00232 }
00233
00240 function comment_confirm_delete(&$form_state, $comment) {
00241   $form = array();
00242   $form['#comment'] = $comment;
00243   return confirm_form(
00244     $form,
00245     t('Are you sure you want to delete the comment %title?', array('%title' => $comment->subject)),
00246     'node/'. $comment->nid,
00247     t('Any replies to this comment will be lost. This action cannot be undone.'),
00248     t('Delete'),
00249     t('Cancel'),
00250     'comment_confirm_delete');
00251 }
00252
00256 function comment_confirm_delete_submit($form, &$form_state) {
00257   drupal_set_message(t('The comment and all its replies have been deleted.'));
00258
00259   $comment = $form['#comment'];
00260
00261   // Delete comment and its replies.
00262   _comment_delete_thread($comment);
00263
00264   _comment_update_node_statistics($comment->nid);
00265
00266   // Clear the cache so an anonymous user sees that his comment was deleted.
00267   cache_clear_all();
00268
00269   $form_state['redirect'] = "node/$comment->nid";
00270 }
00271
00278 function _comment_delete_thread($comment) {
00279   if (!is_object($comment) || !is_numeric($comment->cid)) {
00280     watchdog('content', 'Cannot delete non-existent comment.', WATCHDOG_WARNING);
00281     return;
00282   }
00283
00284   // Delete the comment:
00285   db_query('DELETE FROM {comments} WHERE cid = %d', $comment->cid);
00286   watchdog('content', 'Comment: deleted %subject.', array('%subject' => $comment->subject));
00287
00288   comment_invoke_comment($comment, 'delete');
00289
00290   // Delete the comment's replies
00291   $result = db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE pid = %d', $comment->cid);
00292   while ($comment = db_fetch_object($result)) {
00293     $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
00294     _comment_delete_thread($comment);
00295   }
00296 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/comment/comment.install Source File

modules » comment

comment.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: comment.install,v 1.19 2008/01/16 21:45:30 goba Exp $
00003
00007 function comment_enable() {
00008   // Insert records into the node_comment_statistics for nodes that are missing.
00009   db_query("INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) SELECT n.nid, n.changed, NULL, n.uid, 0 FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE c.comment_count IS NULL");
00010 }
00011
00015 function comment_update_1() {
00016   // Change any future last comment timestamps to now.
00017   db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE last_comment_timestamp > %d', time(), time());
00018
00019   // Unstuck node indexing timestamp if needed.
00020   if (($last = variable_get('node_cron_last', FALSE)) !== FALSE) {
00021     variable_set('node_cron_last', min(time(), $last));
00022   }
00023   return array();
00024 }
00025
00026 function comment_update_6001() {
00027   $ret[] = update_sql("ALTER TABLE {comments} DROP score");
00028   $ret[] = update_sql("ALTER TABLE {comments} DROP users");
00029   return $ret;
00030 }
00031
00036 function comment_update_6002() {
00037   // Comment module might not be enabled when this is run, but we need the
00038   // constants defined by the module for this update.
00039   drupal_load('module', 'comment');
00040   $settings = array(
00041     'comment_default_mode' => COMMENT_MODE_THREADED_EXPANDED,
00042     'comment_default_order' => COMMENT_ORDER_NEWEST_FIRST,
00043     'comment_default_per_page' => 50,
00044     'comment_controls' => COMMENT_CONTROLS_HIDDEN,
00045     'comment_anonymous' => COMMENT_ANONYMOUS_MAYNOT_CONTACT,
00046     'comment_subject_field' => 1,
00047     'comment_preview' => COMMENT_PREVIEW_REQUIRED,
00048     'comment_form_location' => COMMENT_FORM_SEPARATE_PAGE,
00049   );
00050   $types = node_get_types();
00051   foreach ($settings as $setting => $default) {
00052     $value = variable_get($setting, $default);
00053     foreach ($types as $type => $object) {
00054       variable_set($setting .'_'. $type, $value);
00055     }
00056     variable_del($setting);
00057   }
00058   return array(array('success' => TRUE, 'query' => 'Global comment settings copied to all node types.'));
00059 }
00060
00064 function comment_update_6003() {
00065   $ret = array();
00066   db_add_index($ret, 'comments', 'pid', array('pid'));
00067   return $ret;
00068 }
00069
00070
00074 function comment_schema() {
00075   $schema['comments'] = array(
00076     'description' => t('Stores comments and associated data.'),
00077     'fields' => array(
00078       'cid' => array(
00079         'type' => 'serial',
00080         'not null' => TRUE,
00081         'description' => t('Primary Key: Unique comment ID.'),
00082       ),
00083       'pid' => array(
00084         'type' => 'int',
00085         'not null' => TRUE,
00086         'default' => 0,
00087         'description' => t('The {comments}.cid to which this comment is a reply. If set to 0, this comment is not a reply to an existing comment.'),
00088       ),
00089       'nid' => array(
00090         'type' => 'int',
00091         'not null' => TRUE,
00092         'default' => 0,
00093         'description' => t('The {node}.nid to which this comment is a reply.'),
00094       ),
00095       'uid' => array(
00096         'type' => 'int',
00097         'not null' => TRUE,
00098         'default' => 0,
00099         'description' => t('The {users}.uid who authored the comment. If set to 0, this comment was created by an anonymous user.'),
00100       ),
00101       'subject' => array(
00102         'type' => 'varchar',
00103         'length' => 64,
00104         'not null' => TRUE,
00105         'default' => '',
00106         'description' => t('The comment title.'),
00107       ),
00108       'comment' => array(
00109         'type' => 'text',
00110         'not null' => TRUE,
00111         'size' => 'big',
00112         'description' => t('The comment body.'),
00113       ),
00114       'hostname' => array(
00115         'type' => 'varchar',
00116         'length' => 128,
00117         'not null' => TRUE,
00118         'default' => '',
00119         'description' => t("The author's host name."),
00120       ),
00121       'timestamp' => array(
00122         'type' => 'int',
00123         'not null' => TRUE,
00124         'default' => 0,
00125         'description' => t('The time that the comment was created, or last edited by its author, as a Unix timestamp.'),
00126       ),
00127       'status' => array(
00128         'type' => 'int',
00129         'unsigned' => TRUE,
00130         'not null' => TRUE,
00131         'default' => 0,
00132         'size' => 'tiny',
00133         'description' => t('The published status of a comment. (0 = Published, 1 = Not Published)'),
00134       ),
00135       'format' => array(
00136         'type' => 'int',
00137         'size' => 'small',
00138         'not null' => TRUE,
00139         'default' => 0,
00140         'description' => t('The {filter_formats}.format of the comment body.'),
00141       ),
00142       'thread' => array(
00143         'type' => 'varchar',
00144         'length' => 255,
00145         'not null' => TRUE,
00146         'description' => t("The vancode representation of the comment's place in a thread."),
00147       ),
00148       'name' => array(
00149         'type' => 'varchar',
00150         'length' => 60,
00151         'not null' => FALSE,
00152         'description' => t("The comment author's name. Uses {users}.name if the user is logged in, otherwise uses the value typed into the comment form."),
00153       ),
00154       'mail' => array(
00155         'type' => 'varchar',
00156         'length' => 64,
00157         'not null' => FALSE,
00158         'description' => t("The comment author's e-mail address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."),
00159       ),
00160       'homepage' => array(
00161         'type' => 'varchar',
00162         'length' => 255,
00163         'not null' => FALSE,
00164         'description' => t("The comment author's home page address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."),
00165       )
00166     ),
00167     'indexes' => array(
00168       'pid'    => array('pid'),
00169       'nid'    => array('nid'),
00170       'status' => array('status'), // This index is probably unused
00171     ),
00172     'primary key' => array('cid'),
00173   );
00174
00175   $schema['node_comment_statistics'] = array(
00176     'description' => t('Maintains statistics of node and comments posts to show "new" and "updated" flags.'),
00177     'fields' => array(
00178       'nid' => array(
00179         'type' => 'int',
00180         'unsigned' => TRUE,
00181         'not null' => TRUE,
00182         'default' => 0,
00183         'description' => t('The {node}.nid for which the statistics are compiled.'),
00184       ),
00185       'last_comment_timestamp' => array(
00186         'type' => 'int',
00187         'not null' => TRUE,
00188         'default' => 0,
00189         'description' => t('The Unix timestamp of the last comment that was posted within this node, from {comments}.timestamp.'),
00190       ),
00191       'last_comment_name' => array(
00192         'type' => 'varchar',
00193         'length' => 60,
00194         'not null' => FALSE,
00195         'description' => t('The name of the latest author to post a comment on this node, from {comments}.name.'),
00196       ),
00197       'last_comment_uid' => array(
00198         'type' => 'int',
00199         'not null' => TRUE,
00200         'default' => 0,
00201         'description' => t('The user ID of the latest author to post a comment on this node, from {comments}.uid.'),
00202       ),
00203       'comment_count' => array(
00204         'type' => 'int',
00205         'unsigned' => TRUE,
00206         'not null' => TRUE,
00207         'default' => 0,
00208         'description' => t('The total number of comments on this node.'),
00209       ),
00210     ),
00211     'primary key' => array('nid'),
00212     'indexes' => array(
00213       'node_comment_timestamp' => array('last_comment_timestamp')
00214     ),
00215   );
00216
00217   return $schema;
00218 }
00219
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/comment/comment.module Source File

modules » comment

comment.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: comment.module,v 1.617 2008/01/25 16:19:12 goba Exp $
00003
00016 define('COMMENT_PUBLISHED', 0);
00017
00021 define('COMMENT_NOT_PUBLISHED', 1);
00022
00026 define('COMMENT_MODE_FLAT_COLLAPSED', 1);
00027
00031 define('COMMENT_MODE_FLAT_EXPANDED', 2);
00032
00036 define('COMMENT_MODE_THREADED_COLLAPSED', 3);
00037
00041 define('COMMENT_MODE_THREADED_EXPANDED', 4);
00042
00046 define('COMMENT_ORDER_NEWEST_FIRST', 1);
00047
00051 define('COMMENT_ORDER_OLDEST_FIRST', 2);
00052
00056 define('COMMENT_CONTROLS_ABOVE', 0);
00057
00061 define('COMMENT_CONTROLS_BELOW', 1);
00062
00066 define('COMMENT_CONTROLS_ABOVE_BELOW', 2);
00067
00071 define('COMMENT_CONTROLS_HIDDEN', 3);
00072
00076 define('COMMENT_ANONYMOUS_MAYNOT_CONTACT', 0);
00077
00081 define('COMMENT_ANONYMOUS_MAY_CONTACT', 1);
00082
00086 define('COMMENT_ANONYMOUS_MUST_CONTACT', 2);
00087
00091 define('COMMENT_FORM_SEPARATE_PAGE', 0);
00092
00096 define('COMMENT_FORM_BELOW', 1);
00097
00101 define('COMMENT_NODE_DISABLED', 0);
00102
00106 define('COMMENT_NODE_READ_ONLY', 1);
00107
00111 define('COMMENT_NODE_READ_WRITE', 2);
00112
00116 define('COMMENT_PREVIEW_OPTIONAL', 0);
00117
00121 define('COMMENT_PREVIEW_REQUIRED', 1);
00122
00126 function comment_help($path, $arg) {
00127   switch ($path) {
00128     case 'admin/help#comment':
00129       $output = '<p>'. t('The comment module allows visitors to comment on your posts, creating ad hoc discussion boards. Any <a href="@content-type">content type</a> may have its <em>Default comment setting</em> set to <em>Read/Write</em> to allow comments, or <em>Disabled</em>, to prevent comments. Comment display settings and other controls may also be customized for each content type (some display settings are customizable by individual users).', array('@content-type' => url('admin/content/types'))) .'</p>';
00130       $output .= '<p>'. t('Comment permissions are assigned to user roles, and are used to determine whether anonymous users (or other roles) are allowed to comment on posts. If anonymous users are allowed to comment, their individual contact information may be retained in cookies stored on their local computer for use in later comment submissions. When a comment has no replies, it may be (optionally) edited by its author. The comment module uses the same input formats and HTML tags available when creating other forms of content.') .'</p>';
00131       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@comment">Comment module</a>.', array('@comment' => 'http://drupal.org/handbook/modules/comment/')) .'</p>';
00132       return $output;
00133     case 'admin/content/comment':
00134       return '<p>'. t("Below is a list of the latest comments posted to your site. Click on a subject to see the comment, the author's name to edit the author's user information, 'edit' to modify the text, and 'delete' to remove their submission.") .'</p>';
00135     case 'admin/content/comment/approval':
00136       return '<p>'. t("Below is a list of the comments posted to your site that need approval. To approve a comment, click on 'edit' and then change its 'moderation status' to Approved. Click on a subject to see the comment, the author's name to edit the author's user information, 'edit' to modify the text, and 'delete' to remove their submission.") .'</p>';
00137   }
00138 }
00139
00143 function comment_theme() {
00144   return array(
00145     'comment_block' => array(
00146       'arguments' => array(),
00147     ),
00148     'comment_admin_overview' => array(
00149       'arguments' => array('form' => NULL),
00150     ),
00151     'comment_preview' => array(
00152       'arguments' => array('comment' => NULL, 'node' => NULL, 'links' => array(), 'visible' => 1),
00153     ),
00154     'comment_view' => array(
00155       'arguments' => array('comment' => NULL, 'node' => NULL, 'links' => array(), 'visible' => 1),
00156     ),
00157     'comment_controls' => array(
00158       'arguments' => array('form' => NULL),
00159     ),
00160     'comment' => array(
00161       'template' => 'comment',
00162       'arguments' => array('comment' => NULL, 'node' => NULL, 'links' => array()),
00163     ),
00164     'comment_folded' => array(
00165       'template' => 'comment-folded',
00166       'arguments' => array('comment' => NULL),
00167     ),
00168     'comment_flat_collapsed' => array(
00169       'arguments' => array('comment' => NULL, 'node' => NULL),
00170     ),
00171     'comment_flat_expanded' => array(
00172       'arguments' => array('comment' => NULL, 'node' => NULL),
00173     ),
00174     'comment_thread_collapsed' => array(
00175       'arguments' => array('comment' => NULL, 'node' => NULL),
00176     ),
00177     'comment_thread_expanded' => array(
00178       'arguments' => array('comment' => NULL, 'node' => NULL),
00179     ),
00180     'comment_post_forbidden' => array(
00181       'arguments' => array('nid' => NULL),
00182     ),
00183     'comment_wrapper' => array(
00184       'template' => 'comment-wrapper',
00185       'arguments' => array('content' => NULL, 'node' => NULL),
00186     ),
00187     'comment_submitted' => array(
00188       'arguments' => array('comment' => NULL),
00189     ),
00190   );
00191 }
00192
00196 function comment_menu() {
00197   $items['admin/content/comment'] = array(
00198     'title' => 'Comments',
00199     'description' => 'List and edit site comments and the comment moderation queue.',
00200     'page callback' => 'comment_admin',
00201     'access arguments' => array('administer comments'),
00202     'file' => 'comment.admin.inc',
00203   );
00204
00205   // Tabs:
00206   $items['admin/content/comment/new'] = array(
00207     'title' => 'Published comments',
00208     'type' => MENU_DEFAULT_LOCAL_TASK,
00209     'weight' => -10,
00210   );
00211   $items['admin/content/comment/approval'] = array(
00212     'title' => 'Approval queue',
00213     'page arguments' => array('approval'),
00214     'type' => MENU_LOCAL_TASK,
00215     'file' => 'comment.admin.inc',
00216   );
00217
00218   $items['comment/delete'] = array(
00219     'title' => 'Delete comment',
00220     'page callback' => 'comment_delete',
00221     'access arguments' => array('administer comments'),
00222     'type' => MENU_CALLBACK,
00223     'file' => 'comment.admin.inc',
00224   );
00225
00226   $items['comment/edit'] = array(
00227     'title' => 'Edit comment',
00228     'page callback' => 'comment_edit',
00229     'access arguments' => array('post comments'),
00230     'type' => MENU_CALLBACK,
00231     'file' => 'comment.pages.inc',
00232   );
00233   $items['comment/reply/%node'] = array(
00234     'title' => 'Reply to comment',
00235     'page callback' => 'comment_reply',
00236     'page arguments' => array(2),
00237     'access callback' => 'node_access',
00238     'access arguments' => array('view', 2),
00239     'type' => MENU_CALLBACK,
00240     'file' => 'comment.pages.inc',
00241   );
00242
00243   return $items;
00244 }
00245
00249 function comment_node_type($op, $info) {
00250   $settings = array(
00251     'comment',
00252     'comment_default_mode',
00253     'comment_default_order',
00254     'comment_default_per_page',
00255     'comment_controls',
00256     'comment_anonymous',
00257     'comment_subject_field',
00258     'comment_preview',
00259     'comment_form_location',
00260   );
00261   switch ($op) {
00262     case 'delete':
00263       foreach ($settings as $setting) {
00264         variable_del($setting .'_'. $info->type);
00265       }
00266       break;
00267   }
00268 }
00269
00273 function comment_perm() {
00274   return array('access comments', 'post comments', 'administer comments', 'post comments without approval');
00275 }
00276
00282 function comment_block($op = 'list', $delta = 0) {
00283   if ($op == 'list') {
00284     $blocks[0]['info'] = t('Recent comments');
00285     return $blocks;
00286   }
00287   else if ($op == 'view' && user_access('access comments')) {
00288     $block['subject'] = t('Recent comments');
00289     $block['content'] = theme('comment_block');
00290     return $block;
00291   }
00292 }
00293
00309 function comment_get_recent($number = 10) {
00310   // Select the $number nodes (visible to the current user) with the most
00311   // recent comments. This is efficient due to the index on
00312   // last_comment_timestamp.
00313   $result = db_query_range(db_rewrite_sql("SELECT nc.nid FROM {node_comment_statistics} nc WHERE nc.comment_count > 0 ORDER BY nc.last_comment_timestamp DESC", 'nc'), 0, $number);
00314
00315   $nids = array();
00316   while ($row = db_fetch_object($result)) {
00317     $nids[] = $row->nid;
00318   }
00319
00320   $comments = array();
00321   if (!empty($nids)) {
00322     // From among the comments on the nodes selected in the first query,
00323     // find the $number most recent comments.
00324     $result = db_query_range('SELECT c.nid, c.subject, c.cid, c.timestamp FROM {comments} c INNER JOIN {node} n ON n.nid = c.nid WHERE c.nid IN ('. implode(',', $nids) .') AND n.status = 1 AND c.status = %d ORDER BY c.cid DESC', COMMENT_PUBLISHED, 0, $number);
00325     while ($comment = db_fetch_object($result)) {
00326       $comments[] = $comment;
00327     }
00328   }
00329
00330   return $comments;
00331 }
00332
00345 function comment_new_page_count($num_comments, $new_replies, $node) {
00346   $comments_per_page = _comment_get_display_setting('comments_per_page', $node);
00347   $mode = _comment_get_display_setting('mode', $node);
00348   $order = _comment_get_display_setting('sort', $node);
00349   $pagenum = NULL;
00350   $flat = in_array($mode, array(COMMENT_MODE_FLAT_COLLAPSED, COMMENT_MODE_FLAT_EXPANDED));
00351   if ($num_comments <= $comments_per_page || ($flat && $order == COMMENT_ORDER_NEWEST_FIRST)) {
00352     // Only one page of comments or flat forum and newest first.
00353     // First new comment will always be on first page.
00354     $pageno = 0;
00355   }
00356   else {
00357     if ($flat) {
00358       // Flat comments and oldest first.
00359       $count = $num_comments - $new_replies;
00360     }
00361     else {
00362       // Threaded comments. See the documentation for comment_render().
00363       if ($order == COMMENT_ORDER_NEWEST_FIRST) {
00364         // Newest first: find the last thread with new comment
00365         $result = db_query('(SELECT thread FROM {comments} WHERE nid = %d  AND status = 0 ORDER BY timestamp DESC LIMIT %d) ORDER BY thread DESC LIMIT 1', $node->nid, $new_replies);
00366         $thread = db_result($result);
00367         $result_count = db_query("SELECT COUNT(*) FROM {comments} WHERE nid = %d AND status = 0 AND thread > '". $thread ."'", $node->nid);
00368       }
00369       else {
00370         // Oldest first: find the first thread with new comment
00371         $result = db_query('(SELECT thread FROM {comments} WHERE nid = %d  AND status = 0 ORDER BY timestamp DESC LIMIT %d) ORDER BY SUBSTRING(thread, 1, (LENGTH(thread) - 1)) LIMIT 1', $node->nid, $new_replies);
00372         $thread = substr(db_result($result), 0, -1);
00373         $result_count = db_query("SELECT COUNT(*) FROM {comments} WHERE nid = %d AND status = 0 AND SUBSTRING(thread, 1, (LENGTH(thread) - 1)) < '". $thread ."'", $node->nid);
00374       }
00375       $count = db_result($result_count);
00376     }
00377     $pageno =  $count / $comments_per_page;
00378   }
00379   if ($pageno >= 1) {
00380     $pagenum = "page=". intval($pageno);
00381   }
00382   return $pagenum;
00383 }
00384
00392 function theme_comment_block() {
00393   $items = array();
00394   foreach (comment_get_recent() as $comment) {
00395     $items[] = l($comment->subject, 'node/'. $comment->nid, array('fragment' => 'comment-'. $comment->cid)) .'<br />'. t('@time ago', array('@time' => format_interval(time() - $comment->timestamp)));
00396   }
00397   if ($items) {
00398     return theme('item_list', $items);
00399   }
00400 }
00401
00405 function comment_link($type, $node = NULL, $teaser = FALSE) {
00406   $links = array();
00407
00408   if ($type == 'node' && $node->comment) {
00409
00410     if ($teaser) {
00411       // Main page: display the number of comments that have been posted.
00412
00413       if (user_access('access comments')) {
00414         $all = comment_num_all($node->nid);
00415
00416         if ($all) {
00417           $links['comment_comments'] = array(
00418             'title' => format_plural($all, '1 comment', '@count comments'),
00419             'href' => "node/$node->nid",
00420             'attributes' => array('title' => t('Jump to the first comment of this posting.')),
00421             'fragment' => 'comments'
00422           );
00423
00424           $new = comment_num_new($node->nid);
00425
00426           if ($new) {
00427             $links['comment_new_comments'] = array(
00428               'title' => format_plural($new, '1 new comment', '@count new comments'),
00429               'href' => "node/$node->nid",
00430               'query' => comment_new_page_count($all, $new, $node),
00431               'attributes' => array('title' => t('Jump to the first new comment of this posting.')),
00432               'fragment' => 'new'
00433             );
00434           }
00435         }
00436         else {
00437           if ($node->comment == COMMENT_NODE_READ_WRITE) {
00438             if (user_access('post comments')) {
00439               $links['comment_add'] = array(
00440                 'title' => t('Add new comment'),
00441                 'href' => "comment/reply/$node->nid",
00442                 'attributes' => array('title' => t('Add a new comment to this page.')),
00443                 'fragment' => 'comment-form'
00444               );
00445             }
00446             else {
00447               $links['comment_forbidden']['title'] = theme('comment_post_forbidden', $node);
00448             }
00449           }
00450         }
00451       }
00452     }
00453     else {
00454       // Node page: add a "post comment" link if the user is allowed to
00455       // post comments, if this node is not read-only, and if the comment form isn't already shown
00456
00457       if ($node->comment == COMMENT_NODE_READ_WRITE) {
00458         if (user_access('post comments')) {
00459           if (variable_get('comment_form_location_'. $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
00460             $links['comment_add'] = array(
00461               'title' => t('Add new comment'),
00462               'href' => "comment/reply/$node->nid",
00463               'attributes' => array('title' => t('Share your thoughts and opinions related to this posting.')),
00464               'fragment' => 'comment-form'
00465             );
00466           }
00467         }
00468         else {
00469           $links['comment_forbidden']['title'] = theme('comment_post_forbidden', $node);
00470         }
00471       }
00472     }
00473   }
00474
00475   if ($type == 'comment') {
00476     $links = comment_links($node, $teaser);
00477   }
00478   if (isset($links['comment_forbidden'])) {
00479     $links['comment_forbidden']['html'] = TRUE;
00480   }
00481
00482   return $links;
00483 }
00484
00488 function comment_form_alter(&$form, $form_state, $form_id) {
00489   if ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
00490     $form['comment'] = array(
00491       '#type' => 'fieldset',
00492       '#title' => t('Comment settings'),
00493       '#collapsible' => TRUE,
00494       '#collapsed' => TRUE,
00495     );
00496     $form['comment']['comment'] = array(
00497       '#type' => 'radios',
00498       '#title' => t('Default comment setting'),
00499       '#default_value' => variable_get('comment_'. $form['#node_type']->type, COMMENT_NODE_READ_WRITE),
00500       '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')),
00501       '#description' => t('Users with the <em>administer comments</em> permission will be able to override this setting.'),
00502     );
00503     $form['comment']['comment_default_mode'] = array(
00504       '#type' => 'radios',
00505       '#title' => t('Default display mode'),
00506       '#default_value' => variable_get('comment_default_mode_'. $form['#node_type']->type, COMMENT_MODE_THREADED_EXPANDED),
00507       '#options' => _comment_get_modes(),
00508       '#description' => t('The default view for comments. Expanded views display the body of the comment. Threaded views keep replies together.'),
00509     );
00510     $form['comment']['comment_default_order'] = array(
00511       '#type' => 'radios',
00512       '#title' => t('Default display order'),
00513       '#default_value' => variable_get('comment_default_order_'. $form['#node_type']->type, COMMENT_ORDER_NEWEST_FIRST),
00514       '#options' => _comment_get_orders(),
00515       '#description' => t('The default sorting for new users and anonymous users while viewing comments. These users may change their view using the comment control panel. For registered users, this change is remembered as a persistent user preference.'),
00516     );
00517     $form['comment']['comment_default_per_page'] = array(
00518       '#type' => 'select',
00519       '#title' => t('Default comments per page'),
00520       '#default_value' => variable_get('comment_default_per_page_'. $form['#node_type']->type, 50),
00521       '#options' => _comment_per_page(),
00522       '#description' => t('Default number of comments for each page: more comments are distributed in several pages.'),
00523     );
00524     $form['comment']['comment_controls'] = array(
00525       '#type' => 'radios',
00526       '#title' => t('Comment controls'),
00527       '#default_value' => variable_get('comment_controls_'. $form['#node_type']->type, COMMENT_CONTROLS_HIDDEN),
00528       '#options' => array(
00529         t('Display above the comments'),
00530         t('Display below the comments'),
00531         t('Display above and below the comments'),
00532         t('Do not display')),
00533       '#description' => t('Position of the comment controls box. The comment controls let the user change the default display mode and display order of comments.'),
00534     );
00535     $form['comment']['comment_anonymous'] = array(
00536       '#type' => 'radios',
00537       '#title' => t('Anonymous commenting'),
00538       '#default_value' => variable_get('comment_anonymous_'. $form['#node_type']->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT),
00539       '#options' => array(
00540         COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'),
00541         COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
00542         COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information')),
00543       '#description' => t('This option is enabled when anonymous users have permission to post comments on the <a href="@url">permissions page</a>.', array('@url' => url('admin/user/permissions', array('fragment' => 'module-comment')))),
00544     );
00545     if (!user_access('post comments', drupal_anonymous_user())) {
00546       $form['comment']['comment_anonymous']['#disabled'] = TRUE;
00547     }
00548     $form['comment']['comment_subject_field'] = array(
00549       '#type' => 'radios',
00550       '#title' => t('Comment subject field'),
00551       '#default_value' => variable_get('comment_subject_field_'. $form['#node_type']->type, 1),
00552       '#options' => array(t('Disabled'), t('Enabled')),
00553       '#description' => t('Can users provide a unique subject for their comments?'),
00554     );
00555     $form['comment']['comment_preview'] = array(
00556       '#type' => 'radios',
00557       '#title' => t('Preview comment'),
00558       '#default_value' => variable_get('comment_preview_'. $form['#node_type']->type, COMMENT_PREVIEW_REQUIRED),
00559       '#options' => array(t('Optional'), t('Required')),
00560       '#description' => t("Forces a user to look at their comment by clicking on a 'Preview' button before they can actually add the comment"),
00561     );
00562     $form['comment']['comment_form_location'] = array(
00563       '#type' => 'radios',
00564       '#title' => t('Location of comment submission form'),
00565       '#default_value' => variable_get('comment_form_location_'. $form['#node_type']->type, COMMENT_FORM_SEPARATE_PAGE),
00566       '#options' => array(t('Display on separate page'), t('Display below post or comments')),
00567     );
00568   }
00569   elseif (isset($form['type']) && isset($form['#node'])) {
00570     if ($form['type']['#value'] .'_node_form' == $form_id) {
00571       $node = $form['#node'];
00572       $form['comment_settings'] = array(
00573         '#type' => 'fieldset',
00574         '#access' => user_access('administer comments'),
00575         '#title' => t('Comment settings'),
00576         '#collapsible' => TRUE,
00577         '#collapsed' => TRUE,
00578         '#weight' => 30,
00579       );
00580       $form['comment_settings']['comment'] = array(
00581         '#type' => 'radios',
00582         '#parents' => array('comment'),
00583         '#default_value' => $node->comment,
00584         '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')),
00585       );
00586     }
00587   }
00588 }
00589
00593 function comment_nodeapi(&$node, $op, $arg = 0) {
00594   switch ($op) {
00595     case 'load':
00596       return db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid = %d", $node->nid));
00597       break;
00598
00599     case 'prepare':
00600       if (!isset($node->comment)) {
00601         $node->comment = variable_get("comment_$node->type", COMMENT_NODE_READ_WRITE);
00602       }
00603       break;
00604
00605     case 'insert':
00606       db_query('INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (%d, %d, NULL, %d, 0)', $node->nid, $node->changed, $node->uid);
00607       break;
00608
00609     case 'delete':
00610       db_query('DELETE FROM {comments} WHERE nid = %d', $node->nid);
00611       db_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $node->nid);
00612       break;
00613
00614     case 'update index':
00615       $text = '';
00616       $comments = db_query('SELECT subject, comment, format FROM {comments} WHERE nid = %d AND status = %d', $node->nid, COMMENT_PUBLISHED);
00617       while ($comment = db_fetch_object($comments)) {
00618         $text .= '<h2>'. check_plain($comment->subject) .'</h2>'. check_markup($comment->comment, $comment->format, FALSE);
00619       }
00620       return $text;
00621
00622     case 'search result':
00623       $comments = db_result(db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = %d', $node->nid));
00624       return format_plural($comments, '1 comment', '@count comments');
00625
00626     case 'rss item':
00627       if ($node->comment != COMMENT_NODE_DISABLED) {
00628         return array(array('key' => 'comments', 'value' => url('node/'. $node->nid, array('fragment' => 'comments', 'absolute' => TRUE))));
00629       }
00630       else {
00631         return array();
00632       }
00633   }
00634 }
00635
00639 function comment_user($type, $edit, &$user, $category = NULL) {
00640   if ($type == 'delete') {
00641     db_query('UPDATE {comments} SET uid = 0 WHERE uid = %d', $user->uid);
00642     db_query('UPDATE {node_comment_statistics} SET last_comment_uid = 0 WHERE last_comment_uid = %d', $user->uid);
00643   }
00644 }
00645
00661 function comment_access($op, $comment) {
00662   global $user;
00663
00664   if ($op == 'edit') {
00665     return ($user->uid && $user->uid == $comment->uid && comment_num_replies($comment->cid) == 0) || user_access('administer comments');
00666   }
00667 }
00668
00675 function comment_node_url() {
00676   return arg(0) .'/'. arg(1);
00677 }
00678
00689 function comment_save($edit) {
00690   global $user;
00691   if (user_access('post comments') && (user_access('administer comments') || node_comment_mode($edit['nid']) == COMMENT_NODE_READ_WRITE)) {
00692     if (!form_get_errors()) {
00693       $edit += array(
00694         'mail' => '',
00695         'homepage' => '',
00696         'name' => '',
00697         'status' => user_access('post comments without approval') ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED,
00698       );
00699       if ($edit['cid']) {
00700         // Update the comment in the database.
00701         db_query("UPDATE {comments} SET status = %d, timestamp = %d, subject = '%s', comment = '%s', format = %d, uid = %d, name = '%s', mail = '%s', homepage = '%s' WHERE cid = %d", $edit['status'], $edit['timestamp'], $edit['subject'], $edit['comment'], $edit['format'], $edit['uid'], $edit['name'], $edit['mail'], $edit['homepage'], $edit['cid']);
00702
00703         // Allow modules to respond to the updating of a comment.
00704         comment_invoke_comment($edit, 'update');
00705
00706         // Add an entry to the watchdog log.
00707         watchdog('content', 'Comment: updated %subject.', array('%subject' => $edit['subject']), WATCHDOG_NOTICE, l(t('view'), 'node/'. $edit['nid'], array('fragment' => 'comment-'. $edit['cid'])));
00708       }
00709       else {
00710         // Add the comment to database.
00711         // Here we are building the thread field. See the documentation for
00712         // comment_render().
00713         if ($edit['pid'] == 0) {
00714           // This is a comment with no parent comment (depth 0): we start
00715           // by retrieving the maximum thread level.
00716           $max = db_result(db_query('SELECT MAX(thread) FROM {comments} WHERE nid = %d', $edit['nid']));
00717
00718           // Strip the "/" from the end of the thread.
00719           $max = rtrim($max, '/');
00720
00721           // Finally, build the thread field for this new comment.
00722           $thread = int2vancode(vancode2int($max) + 1) .'/';
00723         }
00724         else {
00725           // This is comment with a parent comment: we increase
00726           // the part of the thread value at the proper depth.
00727
00728           // Get the parent comment:
00729           $parent = _comment_load($edit['pid']);
00730
00731           // Strip the "/" from the end of the parent thread.
00732           $parent->thread = (string) rtrim((string) $parent->thread, '/');
00733
00734           // Get the max value in _this_ thread.
00735           $max = db_result(db_query("SELECT MAX(thread) FROM {comments} WHERE thread LIKE '%s.%%' AND nid = %d", $parent->thread, $edit['nid']));
00736
00737           if ($max == '') {
00738             // First child of this parent.
00739             $thread = $parent->thread .'.'. int2vancode(0) .'/';
00740           }
00741           else {
00742             // Strip the "/" at the end of the thread.
00743             $max = rtrim($max, '/');
00744
00745             // We need to get the value at the correct depth.
00746             $parts = explode('.', $max);
00747             $parent_depth = count(explode('.', $parent->thread));
00748             $last = $parts[$parent_depth];
00749
00750             // Finally, build the thread field for this new comment.
00751             $thread = $parent->thread .'.'. int2vancode(vancode2int($last) + 1) .'/';
00752           }
00753         }
00754
00755         $edit['timestamp'] = time();
00756
00757         if ($edit['uid'] === $user->uid) { // '===' because we want to modify anonymous users too
00758           $edit['name'] = $user->name;
00759         }
00760
00761         db_query("INSERT INTO {comments} (nid, pid, uid, subject, comment, format, hostname, timestamp, status, thread, name, mail, homepage) VALUES (%d, %d, %d, '%s', '%s', %d, '%s', %d, %d, '%s', '%s', '%s', '%s')", $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], $edit['comment'], $edit['format'], ip_address(), $edit['timestamp'], $edit['status'], $thread, $edit['name'], $edit['mail'], $edit['homepage']);
00762         $edit['cid'] = db_last_insert_id('comments', 'cid');
00763
00764         // Tell the other modules a new comment has been submitted.
00765         comment_invoke_comment($edit, 'insert');
00766
00767         // Add an entry to the watchdog log.
00768         watchdog('content', 'Comment: added %subject.', array('%subject' => $edit['subject']), WATCHDOG_NOTICE, l(t('view'), 'node/'. $edit['nid'], array('fragment' => 'comment-'. $edit['cid'])));
00769       }
00770       _comment_update_node_statistics($edit['nid']);
00771
00772       // Clear the cache so an anonymous user can see his comment being added.
00773       cache_clear_all();
00774
00775       // Explain the approval queue if necessary, and then
00776       // redirect the user to the node he's commenting on.
00777       if ($edit['status'] == COMMENT_NOT_PUBLISHED) {
00778         drupal_set_message(t('Your comment has been queued for moderation by site administrators and will be published after approval.'));
00779       }
00780       else {
00781         comment_invoke_comment($edit, 'publish');
00782       }
00783       return $edit['cid'];
00784     }
00785     else {
00786       return FALSE;
00787     }
00788   }
00789   else {
00790     watchdog('content', 'Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $edit['subject']), WATCHDOG_WARNING);
00791     drupal_set_message(t('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $edit['subject'])), 'error');
00792     return FALSE;
00793   }
00794 }
00795
00806 function comment_links($comment, $return = 1) {
00807   global $user;
00808
00809   $links = array();
00810
00811   // If we are viewing just this comment, we link back to the node.
00812   if ($return) {
00813     $links['comment_parent'] = array(
00814       'title' => t('parent'),
00815       'href' => comment_node_url(),
00816       'fragment' => "comment-$comment->cid"
00817     );
00818   }
00819
00820   if (node_comment_mode($comment->nid) == COMMENT_NODE_READ_WRITE) {
00821     if (user_access('administer comments') && user_access('post comments')) {
00822       $links['comment_delete'] = array(
00823         'title' => t('delete'),
00824         'href' => "comment/delete/$comment->cid"
00825       );
00826       $links['comment_edit'] = array(
00827         'title' => t('edit'),
00828         'href' => "comment/edit/$comment->cid"
00829       );
00830       $links['comment_reply'] = array(
00831         'title' => t('reply'),
00832         'href' => "comment/reply/$comment->nid/$comment->cid"
00833       );
00834     }
00835     else if (user_access('post comments')) {
00836       if (comment_access('edit', $comment)) {
00837         $links['comment_edit'] = array(
00838           'title' => t('edit'),
00839           'href' => "comment/edit/$comment->cid"
00840         );
00841       }
00842       $links['comment_reply'] = array(
00843         'title' => t('reply'),
00844         'href' => "comment/reply/$comment->nid/$comment->cid"
00845       );
00846     }
00847     else {
00848       $node = node_load($comment->nid);
00849       $links['comment_forbidden']['title'] = theme('comment_post_forbidden', $node);
00850     }
00851   }
00852
00853   return $links;
00854 }
00855
00918 function comment_render($node, $cid = 0) {
00919   global $user;
00920
00921   $output = '';
00922
00923   if (user_access('access comments')) {
00924     // Pre-process variables.
00925     $nid = $node->nid;
00926     if (empty($nid)) {
00927       $nid = 0;
00928     }
00929
00930     $mode = _comment_get_display_setting('mode', $node);
00931     $order = _comment_get_display_setting('sort', $node);
00932     $comments_per_page = _comment_get_display_setting('comments_per_page', $node);
00933
00934     if ($cid && is_numeric($cid)) {
00935       // Single comment view.
00936       $query = 'SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d';
00937       $query_args = array($cid);
00938       if (!user_access('administer comments')) {
00939         $query .= ' AND c.status = %d';
00940         $query_args[] = COMMENT_PUBLISHED;
00941       }
00942
00943       $query = db_rewrite_sql($query, 'c', 'cid');
00944       $result = db_query($query, $query_args);
00945
00946       if ($comment = db_fetch_object($result)) {
00947         $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
00948         $links = module_invoke_all('link', 'comment', $comment, 1);
00949         drupal_alter('link', $links, $node);
00950
00951         $output .= theme('comment_view', $comment, $node, $links);
00952       }
00953     }
00954     else {
00955       // Multiple comment view
00956       $query_count = 'SELECT COUNT(*) FROM {comments} WHERE nid = %d';
00957       $query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d';
00958
00959       $query_args = array($nid);
00960       if (!user_access('administer comments')) {
00961         $query .= ' AND c.status = %d';
00962         $query_count .= ' AND status = %d';
00963         $query_args[] = COMMENT_PUBLISHED;
00964       }
00965
00966       if ($order == COMMENT_ORDER_NEWEST_FIRST) {
00967         if ($mode == COMMENT_MODE_FLAT_COLLAPSED || $mode == COMMENT_MODE_FLAT_EXPANDED) {
00968           $query .= ' ORDER BY c.cid DESC';
00969         }
00970         else {
00971           $query .= ' ORDER BY c.thread DESC';
00972         }
00973       }
00974       else if ($order == COMMENT_ORDER_OLDEST_FIRST) {
00975         if ($mode == COMMENT_MODE_FLAT_COLLAPSED || $mode == COMMENT_MODE_FLAT_EXPANDED) {
00976           $query .= ' ORDER BY c.cid';
00977         }
00978         else {
00979           // See comment above. Analysis reveals that this doesn't cost too
00980           // much. It scales much much better than having the whole comment
00981           // structure.
00982           $query .= ' ORDER BY SUBSTRING(c.thread, 1, (LENGTH(c.thread) - 1))';
00983         }
00984       }
00985       $query = db_rewrite_sql($query, 'c', 'cid');
00986       $query_count = db_rewrite_sql($query_count, 'c', 'cid');
00987
00988       // Start a form, for use with comment control.
00989       $result = pager_query($query, $comments_per_page, 0, $query_count, $query_args);
00990
00991       $divs = 0;
00992       $num_rows = FALSE;
00993       $comments = '';
00994       drupal_add_css(drupal_get_path('module', 'comment') .'/comment.css');
00995       while ($comment = db_fetch_object($result)) {
00996         $comment = drupal_unpack($comment);
00997         $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
00998         $comment->depth = count(explode('.', $comment->thread)) - 1;
00999
01000         if ($mode == COMMENT_MODE_THREADED_COLLAPSED || $mode == COMMENT_MODE_THREADED_EXPANDED) {
01001           if ($comment->depth > $divs) {
01002             $divs++;
01003             $comments .= '<div class="indented">';
01004           }
01005           else {
01006             while ($comment->depth < $divs) {
01007               $divs--;
01008               $comments .= '</div>';
01009             }
01010           }
01011         }
01012
01013         if ($mode == COMMENT_MODE_FLAT_COLLAPSED) {
01014           $comments .= theme('comment_flat_collapsed', $comment, $node);
01015         }
01016         else if ($mode == COMMENT_MODE_FLAT_EXPANDED) {
01017           $comments .= theme('comment_flat_expanded', $comment, $node);
01018         }
01019         else if ($mode == COMMENT_MODE_THREADED_COLLAPSED) {
01020           $comments .= theme('comment_thread_collapsed', $comment, $node);
01021         }
01022         else if ($mode == COMMENT_MODE_THREADED_EXPANDED) {
01023           $comments .= theme('comment_thread_expanded', $comment, $node);
01024         }
01025
01026         $num_rows = TRUE;
01027       }
01028       while ($divs-- > 0) {
01029         $comments .= '</div>';
01030       }
01031
01032       $comment_controls = variable_get('comment_controls_'. $node->type, COMMENT_CONTROLS_HIDDEN);
01033       if ($num_rows && ($comment_controls == COMMENT_CONTROLS_ABOVE || $comment_controls == COMMENT_CONTROLS_ABOVE_BELOW)) {
01034         $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
01035       }
01036
01037       $output .= $comments;
01038       $output .= theme('pager', NULL, $comments_per_page, 0);
01039
01040       if ($num_rows && ($comment_controls == COMMENT_CONTROLS_BELOW || $comment_controls == COMMENT_CONTROLS_ABOVE_BELOW)) {
01041         $output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
01042       }
01043     }
01044
01045     // If enabled, show new comment form if it's not already being displayed.
01046     $reply = arg(0) == 'comment' && arg(1) == 'reply';
01047     if (user_access('post comments') && node_comment_mode($nid) == COMMENT_NODE_READ_WRITE && (variable_get('comment_form_location_'. $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_BELOW) && !$reply) {
01048       $output .= comment_form_box(array('nid' => $nid), t('Post new comment'));
01049     }
01050
01051     $output = theme('comment_wrapper', $output, $node);
01052   }
01053
01054   return $output;
01055 }
01056
01066 function comment_operations($action = NULL) {
01067   if ($action == 'publish') {
01068     $operations = array(
01069       'publish' => array(t('Publish the selected comments'), 'UPDATE {comments} SET status = '. COMMENT_PUBLISHED .' WHERE cid = %d'),
01070       'delete' => array(t('Delete the selected comments'), '')
01071     );
01072   }
01073   else if ($action == 'unpublish') {
01074     $operations = array(
01075       'unpublish' => array(t('Unpublish the selected comments'), 'UPDATE {comments} SET status = '. COMMENT_NOT_PUBLISHED .' WHERE cid = %d'),
01076       'delete' => array(t('Delete the selected comments'), '')
01077     );
01078   }
01079   else {
01080     $operations = array(
01081       'publish' => array(t('Publish the selected comments'), 'UPDATE {comments} SET status = '. COMMENT_PUBLISHED .' WHERE cid = %d'),
01082       'unpublish' => array(t('Unpublish the selected comments'), 'UPDATE {comments} SET status = '. COMMENT_NOT_PUBLISHED .' WHERE cid = %d'),
01083       'delete' => array(t('Delete the selected comments'), '')
01084     );
01085   }
01086   return $operations;
01087 }
01088
01101 function _comment_load($cid) {
01102   return db_fetch_object(db_query('SELECT * FROM {comments} WHERE cid = %d', $cid));
01103 }
01104
01113 function comment_num_all($nid) {
01114   static $cache;
01115
01116   if (!isset($cache[$nid])) {
01117     $cache[$nid] = db_result(db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = %d', $nid));
01118   }
01119   return $cache[$nid];
01120 }
01121
01130 function comment_num_replies($pid) {
01131   static $cache;
01132
01133   if (!isset($cache[$pid])) {
01134     $cache[$pid] = db_result(db_query('SELECT COUNT(cid) FROM {comments} WHERE pid = %d AND status = %d', $pid, COMMENT_PUBLISHED));
01135   }
01136
01137   return $cache[$pid];
01138 }
01139
01149 function comment_num_new($nid, $timestamp = 0) {
01150   global $user;
01151
01152   if ($user->uid) {
01153     // Retrieve the timestamp at which the current user last viewed the
01154     // specified node.
01155     if (!$timestamp) {
01156       $timestamp = node_last_viewed($nid);
01157     }
01158     $timestamp = ($timestamp > NODE_NEW_LIMIT ? $timestamp : NODE_NEW_LIMIT);
01159
01160     // Use the timestamp to retrieve the number of new comments.
01161     $result = db_result(db_query('SELECT COUNT(c.cid) FROM {node} n INNER JOIN {comments} c ON n.nid = c.nid WHERE n.nid = %d AND timestamp > %d AND c.status = %d', $nid, $timestamp, COMMENT_PUBLISHED));
01162
01163     return $result;
01164   }
01165   else {
01166     return 0;
01167   }
01168
01169 }
01170
01179 function comment_validate($edit) {
01180   global $user;
01181
01182   // Invoke other validation handlers
01183   comment_invoke_comment($edit, 'validate');
01184
01185   if (isset($edit['date'])) {
01186     // As of PHP 5.1.0, strtotime returns FALSE upon failure instead of -1.
01187     if (strtotime($edit['date']) <= 0) {
01188       form_set_error('date', t('You have to specify a valid date.'));
01189     }
01190   }
01191   if (isset($edit['author']) && !$account = user_load(array('name' => $edit['author']))) {
01192     form_set_error('author', t('You have to specify a valid author.'));
01193   }
01194
01195   // Check validity of name, mail and homepage (if given)
01196   if (!$user->uid || isset($edit['is_anonymous'])) {
01197     $node = node_load($edit['nid']);
01198     if (variable_get('comment_anonymous_'. $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) > COMMENT_ANONYMOUS_MAYNOT_CONTACT) {
01199       if ($edit['name']) {
01200         $taken = db_result(db_query("SELECT COUNT(uid) FROM {users} WHERE LOWER(name) = '%s'", $edit['name']));
01201
01202         if ($taken != 0) {
01203           form_set_error('name', t('The name you used belongs to a registered user.'));
01204         }
01205
01206       }
01207       else if (variable_get('comment_anonymous_'. $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) == COMMENT_ANONYMOUS_MUST_CONTACT) {
01208         form_set_error('name', t('You have to leave your name.'));
01209       }
01210
01211       if ($edit['mail']) {
01212         if (!valid_email_address($edit['mail'])) {
01213           form_set_error('mail', t('The e-mail address you specified is not valid.'));
01214         }
01215       }
01216       else if (variable_get('comment_anonymous_'. $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) == COMMENT_ANONYMOUS_MUST_CONTACT) {
01217         form_set_error('mail', t('You have to leave an e-mail address.'));
01218       }
01219
01220       if ($edit['homepage']) {
01221         if (!valid_url($edit['homepage'], TRUE)) {
01222           form_set_error('homepage', t('The URL of your homepage is not valid. Remember that it must be fully qualified, i.e. of the form <code>http://example.com/directory</code>.'));
01223         }
01224       }
01225     }
01226   }
01227
01228   return $edit;
01229 }
01230
01240 function comment_form(&$form_state, $edit, $title = NULL) {
01241   global $user;
01242
01243   $op = isset($_POST['op']) ? $_POST['op'] : '';
01244   $node = node_load($edit['nid']);
01245
01246   if (!$user->uid && variable_get('comment_anonymous_'. $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) != COMMENT_ANONYMOUS_MAYNOT_CONTACT) {
01247     drupal_add_js(drupal_get_path('module', 'comment') .'/comment.js');
01248   }
01249   $edit += array('name' => '', 'mail' => '', 'homepage' => '');
01250   if ($user->uid) {
01251     if (!empty($edit['cid']) && user_access('administer comments')) {
01252       if (!empty($edit['author'])) {
01253         $author = $edit['author'];
01254       }
01255       elseif (!empty($edit['name'])) {
01256         $author = $edit['name'];
01257       }
01258       else {
01259         $author = $edit['registered_name'];
01260       }
01261
01262       if (!empty($edit['status'])) {
01263         $status = $edit['status'];
01264       }
01265       else {
01266         $status = 0;
01267       }
01268
01269       if (!empty($edit['date'])) {
01270         $date = $edit['date'];
01271       }
01272       else {
01273         $date = format_date($edit['timestamp'], 'custom', 'Y-m-d H:i O');
01274       }
01275
01276       $form['admin'] = array(
01277         '#type' => 'fieldset',
01278         '#title' => t('Administration'),
01279         '#collapsible' => TRUE,
01280         '#collapsed' => TRUE,
01281         '#weight' => -2,
01282       );
01283
01284       if ($edit['registered_name'] != '') {
01285         // The comment is by a registered user
01286         $form['admin']['author'] = array(
01287           '#type' => 'textfield',
01288           '#title' => t('Authored by'),
01289           '#size' => 30,
01290           '#maxlength' => 60,
01291           '#autocomplete_path' => 'user/autocomplete',
01292           '#default_value' => $author,
01293           '#weight' => -1,
01294         );
01295       }
01296       else {
01297         // The comment is by an anonymous user
01298         $form['is_anonymous'] = array(
01299           '#type' => 'value',
01300           '#value' => TRUE,
01301         );
01302         $form['admin']['name'] = array(
01303           '#type' => 'textfield',
01304           '#title' => t('Authored by'),
01305           '#size' => 30,
01306           '#maxlength' => 60,
01307           '#default_value' => $author,
01308           '#weight' => -1,
01309         );
01310         $form['admin']['mail'] = array(
01311           '#type' => 'textfield',
01312           '#title' => t('E-mail'),
01313           '#maxlength' => 64,
01314           '#size' => 30,
01315           '#default_value' => $edit['mail'],
01316           '#description' => t('The content of this field is kept private and will not be shown publicly.'),
01317         );
01318
01319         $form['admin']['homepage'] = array(
01320           '#type' => 'textfield',
01321           '#title' => t('Homepage'),
01322           '#maxlength' => 255,
01323           '#size' => 30,
01324           '#default_value' => $edit['homepage'],
01325         );
01326       }
01327
01328       $form['admin']['date'] = array('#type' => 'textfield', '#parents' => array('date'), '#title' => t('Authored on'), '#size' => 20, '#maxlength' => 25, '#default_value' => $date, '#weight' => -1);
01329
01330       $form['admin']['status'] = array('#type' => 'radios', '#parents' => array('status'), '#title' => t('Status'), '#default_value' =>  $status, '#options' => array(t('Published'), t('Not published')), '#weight' => -1);
01331
01332     }
01333     else {
01334       $form['_author'] = array('#type' => 'item', '#title' => t('Your name'), '#value' => theme('username', $user)
01335       );
01336       $form['author'] = array('#type' => 'value', '#value' => $user->name);
01337     }
01338   }
01339   else if (variable_get('comment_anonymous_'. $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) == COMMENT_ANONYMOUS_MAY_CONTACT) {
01340     $form['name'] = array('#type' => 'textfield', '#title' => t('Your name'), '#maxlength' => 60, '#size' => 30, '#default_value' => $edit['name'] ? $edit['name'] : variable_get('anonymous', t('Anonymous'))
01341     );
01342
01343     $form['mail'] = array('#type' => 'textfield', '#title' => t('E-mail'), '#maxlength' => 64, '#size' => 30, '#default_value' => $edit['mail'], '#description' => t('The content of this field is kept private and will not be shown publicly.')
01344     );
01345
01346     $form['homepage'] = array('#type' => 'textfield', '#title' => t('Homepage'), '#maxlength' => 255, '#size' => 30, '#default_value' => $edit['homepage']);
01347   }
01348   else if (variable_get('comment_anonymous_'. $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) == COMMENT_ANONYMOUS_MUST_CONTACT) {
01349     $form['name'] = array('#type' => 'textfield', '#title' => t('Your name'), '#maxlength' => 60, '#size' => 30, '#default_value' => $edit['name'] ? $edit['name'] : variable_get('anonymous', t('Anonymous')), '#required' => TRUE);
01350
01351     $form['mail'] = array('#type' => 'textfield', '#title' => t('E-mail'), '#maxlength' => 64, '#size' => 30, '#default_value' => $edit['mail'], '#description' => t('The content of this field is kept private and will not be shown publicly.'), '#required' => TRUE);
01352
01353     $form['homepage'] = array('#type' => 'textfield', '#title' => t('Homepage'), '#maxlength' => 255, '#size' => 30, '#default_value' => $edit['homepage']);
01354   }
01355
01356   if (variable_get('comment_subject_field_'. $node->type, 1) == 1) {
01357     $form['subject'] = array('#type' => 'textfield', '#title' => t('Subject'), '#maxlength' => 64, '#default_value' => !empty($edit['subject']) ? $edit['subject'] : '');
01358   }
01359
01360   if (!empty($edit['comment'])) {
01361     $default = $edit['comment'];
01362   }
01363   else {
01364     $default = '';
01365   }
01366
01367   $form['comment_filter']['comment'] = array(
01368     '#type' => 'textarea',
01369     '#title' => t('Comment'),
01370     '#rows' => 15,
01371     '#default_value' => $default,
01372     '#required' => TRUE,
01373   );
01374   if (!isset($edit['format'])) {
01375     $edit['format'] = FILTER_FORMAT_DEFAULT;
01376   }
01377   $form['comment_filter']['format'] = filter_form($edit['format']);
01378
01379   $form['cid'] = array('#type' => 'value', '#value' => !empty($edit['cid']) ? $edit['cid'] : NULL);
01380   $form['pid'] = array('#type' => 'value', '#value' => !empty($edit['pid']) ? $edit['pid'] : NULL);
01381   $form['nid'] = array('#type' => 'value', '#value' => $edit['nid']);
01382   $form['uid'] = array('#type' => 'value', '#value' => !empty($edit['uid']) ? $edit['uid'] : NULL);
01383
01384   // Only show save button if preview is optional or if we are in preview mode.
01385   // We show the save button in preview mode even if there are form errors so that
01386   // optional form elements (e.g., captcha) can be updated in preview mode.
01387   if (!form_get_errors() && ((variable_get('comment_preview_'. $node->type, COMMENT_PREVIEW_REQUIRED) == COMMENT_PREVIEW_OPTIONAL) || ($op == t('Preview')) || ($op == t('Save')))) {
01388     $form['submit'] = array('#type' => 'submit', '#value' => t('Save'), '#weight' => 19);
01389   }
01390
01391   $form['preview'] = array('#type' => 'button', '#value' => t('Preview'), '#weight' => 20);
01392   $form['#token'] = 'comment'. $edit['nid'] . (isset($edit['pid']) ? $edit['pid'] : '');
01393
01394   if ($op == t('Preview')) {
01395     $form['#after_build'] = array('comment_form_add_preview');
01396   }
01397
01398   if (empty($edit['cid']) && empty($edit['pid'])) {
01399     $form['#action'] = url('comment/reply/'. $edit['nid']);
01400   }
01401
01402   return $form;
01403 }
01404
01413 function comment_form_box($edit, $title = NULL) {
01414   return theme('box', $title, drupal_get_form('comment_form', $edit, $title));
01415 }
01416
01422 function comment_form_add_preview($form, &$form_state) {
01423   global $user;
01424   $edit = $form_state['values'];
01425   drupal_set_title(t('Preview comment'));
01426
01427   $output = '';
01428   $node = node_load($edit['nid']);
01429
01430   // Invoke full validation for the form, to protect against cross site
01431   // request forgeries (CSRF) and setting arbitrary values for fields such as
01432   // the input format. Preview the comment only when form validation does not
01433   // set any errors.
01434   drupal_validate_form($form['form_id']['#value'], $form, $form_state);
01435   if (!form_get_errors()) {
01436     _comment_form_submit($edit);
01437     $comment = (object)$edit;
01438
01439     // Attach the user and time information.
01440     if (!empty($edit['author'])) {
01441       $account = user_load(array('name' => $edit['author']));
01442     }
01443     elseif ($user->uid && !isset($edit['is_anonymous'])) {
01444       $account = $user;
01445     }
01446     if (!empty($account)) {
01447       $comment->uid = $account->uid;
01448       $comment->name = check_plain($account->name);
01449     }
01450     elseif (empty($comment->name)) {
01451       $comment->name = variable_get('anonymous', t('Anonymous'));
01452     }
01453     $comment->timestamp = !empty($edit['timestamp']) ? $edit['timestamp'] : time();
01454     $output .= theme('comment_view', $comment, $node);
01455   }
01456   $form['comment_preview'] = array(
01457     '#value' => $output,
01458     '#weight' => -100,
01459     '#prefix' => '<div class="preview">',
01460     '#suffix' => '</div>',
01461   );
01462
01463   $output = '';
01464
01465   if ($edit['pid']) {
01466     $comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d', $edit['pid'], COMMENT_PUBLISHED));
01467     $comment = drupal_unpack($comment);
01468     $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
01469     $output .= theme('comment_view', $comment, $node);
01470   }
01471   else {
01472     $suffix = empty($form['#suffix']) ? '' : $form['#suffix'];
01473     $form['#suffix'] = $suffix . node_view($node);
01474     $edit['pid'] = 0;
01475   }
01476
01477   $form['comment_preview_below'] = array('#value' => $output, '#weight' => 100);
01478
01479   return $form;
01480 }
01481
01485 function comment_form_validate($form, &$form_state) {
01486   global $user;
01487   if ($user->uid === 0) {
01488     foreach (array('name', 'homepage', 'mail') as $field) {
01489       // Set cookie for 365 days.
01490       if (isset($form_state['values'][$field])) {
01491         setcookie('comment_info_'. $field, $form_state['values'][$field], time() + 31536000, '/');
01492       }
01493     }
01494   }
01495   comment_validate($form_state['values']);
01496 }
01497
01504 function _comment_form_submit(&$comment_values) {
01505   $comment_values += array('subject' => '');
01506   if (!isset($comment_values['date'])) {
01507     $comment_values['date'] = 'now';
01508   }
01509   $comment_values['timestamp'] = strtotime($comment_values['date']);
01510   if (isset($comment_values['author'])) {
01511     $account = user_load(array('name' => $comment_values['author']));
01512     $comment_values['uid'] = $account->uid;
01513     $comment_values['name'] = $comment_values['author'];
01514   }
01515   // Validate the comment's subject. If not specified, extract
01516   // one from the comment's body.
01517   if (trim($comment_values['subject']) == '') {
01518     // The body may be in any format, so we:
01519     // 1) Filter it into HTML
01520     // 2) Strip out all HTML tags
01521     // 3) Convert entities back to plain-text.
01522     // Note: format is checked by check_markup().
01523     $comment_values['subject'] = trim(truncate_utf8(decode_entities(strip_tags(check_markup($comment_values['comment'], $comment_values['format']))), 29, TRUE));
01524     // Edge cases where the comment body is populated only by HTML tags will
01525     // require a default subject.
01526     if ($comment_values['subject'] == '') {
01527       $comment_values['subject'] = t('(No subject)');
01528     }
01529   }
01530 }
01531
01535 function comment_form_submit($form, &$form_state) {
01536   _comment_form_submit($form_state['values']);
01537   if ($cid = comment_save($form_state['values'])) {
01538     $node = node_load($form_state['values']['nid']);
01539     $page = comment_new_page_count($node->comment_count, 1, $node);
01540     $form_state['redirect'] = array('node/'. $node->nid, $page, "comment-$cid");
01541     return;
01542   }
01543 }
01544
01558 function theme_comment_view($comment, $node, $links = array(), $visible = TRUE) {
01559   static $first_new = TRUE;
01560
01561   $output = '';
01562   $comment->new = node_mark($comment->nid, $comment->timestamp);
01563   if ($first_new && $comment->new != MARK_READ) {
01564     // Assign the anchor only for the first new comment. This avoids duplicate
01565     // id attributes on a page.
01566     $first_new = FALSE;
01567     $output .= "<a id=\"new\"></a>\n";
01568   }
01569
01570   $output .= "<a id=\"comment-$comment->cid\"></a>\n";
01571
01572   // Switch to folded/unfolded view of the comment
01573   if ($visible) {
01574     $comment->comment = check_markup($comment->comment, $comment->format, FALSE);
01575
01576     // Comment API hook
01577     comment_invoke_comment($comment, 'view');
01578
01579     $output .= theme('comment', $comment, $node, $links);
01580   }
01581   else {
01582     $output .= theme('comment_folded', $comment);
01583   }
01584
01585   return $output;
01586 }
01587
01588
01600 function comment_controls($mode = COMMENT_MODE_THREADED_EXPANDED, $order = COMMENT_ORDER_NEWEST_FIRST, $comments_per_page = 50) {
01601   $form['mode'] = array('#type' => 'select',
01602     '#default_value' => $mode,
01603     '#options' => _comment_get_modes(),
01604     '#weight' => 1,
01605   );
01606   $form['order'] = array(
01607     '#type' => 'select',
01608     '#default_value' => $order,
01609     '#options' => _comment_get_orders(),
01610     '#weight' => 2,
01611   );
01612   foreach (_comment_per_page() as $i) {
01613     $options[$i] = t('!a comments per page', array('!a' => $i));
01614   }
01615   $form['comments_per_page'] = array('#type' => 'select',
01616     '#default_value' => $comments_per_page,
01617     '#options' => $options,
01618     '#weight' => 3,
01619   );
01620
01621   $form['submit'] = array('#type' => 'submit',
01622     '#value' => t('Save settings'),
01623     '#weight' => 20,
01624   );
01625
01626   return $form;
01627 }
01628
01636 function theme_comment_controls($form) {
01637   $output = '<div class="container-inline">';
01638   $output .=  drupal_render($form);
01639   $output .= '</div>';
01640   $output .= '<div class="description">'. t('Select your preferred way to display the comments and click "Save settings" to activate your changes.') .'</div>';
01641   return theme('box', t('Comment viewing options'), $output);
01642 }
01643
01647 function comment_controls_submit($form, &$form_state) {
01648   global $user;
01649
01650   $mode = $form_state['values']['mode'];
01651   $order = $form_state['values']['order'];
01652   $comments_per_page = $form_state['values']['comments_per_page'];
01653
01654   if ($user->uid) {
01655     $account = user_save($user, array('mode' => $mode, 'sort' => $order, 'comments_per_page' => $comments_per_page));
01656     // Terminate if an error occured during user_save().
01657     if (!$account) {
01658       drupal_set_message(t("Error saving user account."), 'error');
01659       return;
01660     }
01661     $user = $account;
01662   }
01663   else {
01664     $_SESSION['comment_mode'] = $mode;
01665     $_SESSION['comment_sort'] = $order;
01666     $_SESSION['comment_comments_per_page'] = $comments_per_page;
01667   }
01668 }
01669
01676 function template_preprocess_comment(&$variables) {
01677   $comment = $variables['comment'];
01678   $node = $variables['node'];
01679   $variables['author']    = theme('username', $comment);
01680   $variables['content']   = $comment->comment;
01681   $variables['date']      = format_date($comment->timestamp);
01682   $variables['links']     = isset($variables['links']) ? theme('links', $variables['links']) : '';
01683   $variables['new']       = $comment->new ? t('new') : '';
01684   $variables['picture']   = theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', $comment) : '';
01685   $variables['signature'] = $comment->signature;
01686   $variables['submitted'] = theme('comment_submitted', $comment);
01687   $variables['title']     = l($comment->subject, $_GET['q'], array('fragment' => "comment-$comment->cid"));
01688   $variables['template_files'][] = 'comment-'. $node->type;
01689   // set status to a string representation of comment->status.
01690   if (isset($comment->preview)) {
01691     $variables['status']  = 'comment-preview';
01692   }
01693   else {
01694     $variables['status']  = ($comment->status == COMMENT_NOT_PUBLISHED) ? 'comment-unpublished' : 'comment-published';
01695   }
01696 }
01697
01704 function template_preprocess_comment_folded(&$variables) {
01705   $comment = $variables['comment'];
01706   $variables['author'] = theme('username', $comment);
01707   $variables['date']   = format_date($comment->timestamp);
01708   $variables['new']    = $comment->new ? t('new') : '';
01709   $variables['title']  = l($comment->subject, comment_node_url() .'/'. $comment->cid, array('fragment' => "comment-$comment->cid"));
01710 }
01711
01721 function theme_comment_flat_collapsed($comment, $node) {
01722   return theme('comment_view', $comment, $node, '', 0);
01723 }
01724
01734 function theme_comment_flat_expanded($comment, $node) {
01735   return theme('comment_view', $comment, $node, module_invoke_all('link', 'comment', $comment, 0));
01736 }
01737
01747 function theme_comment_thread_collapsed($comment, $node) {
01748   return theme('comment_view', $comment, $node, '', 0);
01749 }
01750
01760 function theme_comment_thread_expanded($comment, $node) {
01761   return theme('comment_view', $comment, $node, module_invoke_all('link', 'comment', $comment, 0));
01762 }
01763
01771 function theme_comment_post_forbidden($node) {
01772   global $user;
01773   static $authenticated_post_comments;
01774
01775   if (!$user->uid) {
01776     if (!isset($authenticated_post_comments)) {
01777       // We only output any link if we are certain, that users get permission
01778       // to post comments by logging in. We also locally cache this information.
01779       $authenticated_post_comments = array_key_exists(DRUPAL_AUTHENTICATED_RID, user_roles(TRUE, 'post comments') + user_roles(TRUE, 'post comments without approval'));
01780     }
01781
01782     if ($authenticated_post_comments) {
01783       // We cannot use drupal_get_destination() because these links
01784       // sometimes appear on /node and taxonomy listing pages.
01785       if (variable_get('comment_form_location_'. $node->type, COMMENT_FORM_SEPARATE_PAGE) == COMMENT_FORM_SEPARATE_PAGE) {
01786         $destination = 'destination='. drupal_urlencode("comment/reply/$node->nid#comment-form");
01787       }
01788       else {
01789         $destination = 'destination='. drupal_urlencode("node/$node->nid#comment-form");
01790       }
01791
01792       if (variable_get('user_register', 1)) {
01793         // Users can register themselves.
01794         return t('<a href="@login">Login</a> or <a href="@register">register</a> to post comments', array('@login' => url('user/login', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination))));
01795       }
01796       else {
01797         // Only admins can add new users, no public registration.
01798         return t('<a href="@login">Login</a> to post comments', array('@login' => url('user/login', array('query' => $destination))));
01799       }
01800     }
01801   }
01802 }
01803
01810 function template_preprocess_comment_wrapper(&$variables) {
01811   // Provide contextual information.
01812   $variables['display_mode']  = _comment_get_display_setting('mode', $variables['node']);
01813   $variables['display_order'] = _comment_get_display_setting('sort', $variables['node']);
01814   $variables['comment_controls_state'] = variable_get('comment_controls_'. $variables['node']->type, COMMENT_CONTROLS_HIDDEN);
01815   $variables['template_files'][] = 'comment-wrapper-'. $variables['node']->type;
01816 }
01817
01825 function theme_comment_submitted($comment) {
01826   return t('Submitted by !username on @datetime.',
01827     array(
01828       '!username' => theme('username', $comment),
01829       '@datetime' => format_date($comment->timestamp)
01830     ));
01831 }
01832
01839 function _comment_get_modes() {
01840   return array(
01841     COMMENT_MODE_FLAT_COLLAPSED => t('Flat list - collapsed'),
01842     COMMENT_MODE_FLAT_EXPANDED => t('Flat list - expanded'),
01843     COMMENT_MODE_THREADED_COLLAPSED => t('Threaded list - collapsed'),
01844     COMMENT_MODE_THREADED_EXPANDED => t('Threaded list - expanded')
01845   );
01846 }
01847
01854 function _comment_get_orders() {
01855   return array(
01856     COMMENT_ORDER_NEWEST_FIRST => t('Date - newest first'),
01857     COMMENT_ORDER_OLDEST_FIRST => t('Date - oldest first')
01858   );
01859 }
01860
01865 function _comment_per_page() {
01866   return drupal_map_assoc(array(10, 30, 50, 70, 90, 150, 200, 250, 300));
01867 }
01868
01877 function _comment_get_display_setting($setting, $node) {
01878   global $user;
01879
01880   if (isset($_GET[$setting])) {
01881     $value = $_GET[$setting];
01882   }
01883   else {
01884     // get the setting's site default
01885     switch ($setting) {
01886       case 'mode':
01887         $default = variable_get('comment_default_mode_'. $node->type, COMMENT_MODE_THREADED_EXPANDED);
01888         break;
01889       case 'sort':
01890         $default = variable_get('comment_default_order_'. $node->type, COMMENT_ORDER_NEWEST_FIRST);
01891         break;
01892       case 'comments_per_page':
01893         $default = variable_get('comment_default_per_page_'. $node->type, 50);
01894     }
01895     if (variable_get('comment_controls_'. $node->type, COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_HIDDEN) {
01896       // if comment controls are disabled use site default
01897       $value = $default;
01898     }
01899     else {
01900       // otherwise use the user's setting if set
01901       if (isset($user->$setting) && $user->$setting) {
01902         $value = $user->$setting;
01903       }
01904       else if (isset($_SESSION['comment_'. $setting]) && $_SESSION['comment_'. $setting]) {
01905         $value = $_SESSION['comment_'. $setting];
01906       }
01907       else {
01908         $value = $default;
01909       }
01910     }
01911   }
01912   return $value;
01913 }
01914
01925 function _comment_update_node_statistics($nid) {
01926   $count = db_result(db_query('SELECT COUNT(cid) FROM {comments} WHERE nid = %d AND status = %d', $nid, COMMENT_PUBLISHED));
01927
01928   // comments exist
01929   if ($count > 0) {
01930     $last_reply = db_fetch_object(db_query_range('SELECT cid, name, timestamp, uid FROM {comments} WHERE nid = %d AND status = %d ORDER BY cid DESC', $nid, COMMENT_PUBLISHED, 0, 1));
01931     db_query("UPDATE {node_comment_statistics} SET comment_count = %d, last_comment_timestamp = %d, last_comment_name = '%s', last_comment_uid = %d WHERE nid = %d", $count, $last_reply->timestamp, $last_reply->uid ? '' : $last_reply->name, $last_reply->uid, $nid);
01932   }
01933
01934   // no comments
01935   else {
01936     $node = db_fetch_object(db_query("SELECT uid, created FROM {node} WHERE nid = %d", $nid));
01937     db_query("UPDATE {node_comment_statistics} SET comment_count = 0, last_comment_timestamp = %d, last_comment_name = '', last_comment_uid = %d WHERE nid = %d", $node->created, $node->uid, $nid);
01938   }
01939 }
01940
01951 function comment_invoke_comment(&$comment, $op) {
01952   $return = array();
01953   foreach (module_implements('comment') as $name) {
01954     $function = $name .'_comment';
01955     $result = $function($comment, $op);
01956     if (isset($result) && is_array($result)) {
01957       $return = array_merge($return, $result);
01958     }
01959     else if (isset($result)) {
01960       $return[] = $result;
01961     }
01962   }
01963   return $return;
01964 }
01965
01979 function int2vancode($i = 0) {
01980   $num = base_convert((int)$i, 10, 36);
01981   $length = strlen($num);
01982   return chr($length + ord('0') - 1) . $num;
01983 }
01984
01988 function vancode2int($c = '00') {
01989   return base_convert(substr($c, 1), 36, 10);
01990 }
01991
01995 function comment_hook_info() {
01996   return array(
01997     'comment' => array(
01998       'comment' => array(
01999         'insert' => array(
02000           'runs when' => t('After saving a new comment'),
02001         ),
02002         'update' => array(
02003           'runs when' => t('After saving an updated comment'),
02004         ),
02005         'delete' => array(
02006           'runs when' => t('After deleting a comment')
02007         ),
02008         'view' => array(
02009           'runs when' => t('When a comment is being viewed by an authenticated user')
02010         ),
02011       ),
02012     ),
02013   );
02014 }
02015
02019 function comment_action_info() {
02020   return array(
02021     'comment_unpublish_action' => array(
02022       'description' => t('Unpublish comment'),
02023       'type' => 'comment',
02024       'configurable' => FALSE,
02025       'hooks' => array(
02026         'comment' => array('insert', 'update'),
02027       )
02028     ),
02029     'comment_unpublish_by_keyword_action' => array(
02030       'description' => t('Unpublish comment containing keyword(s)'),
02031       'type' => 'comment',
02032       'configurable' => TRUE,
02033       'hooks' => array(
02034         'comment' => array('insert', 'update'),
02035       )
02036     )
02037   );
02038 }
02039
02048 function comment_unpublish_action($comment, $context = array()) {
02049   if (isset($comment->cid)) {
02050     $cid = $comment->cid;
02051     $subject = $comment->subject;
02052   }
02053   else {
02054     $cid = $context['cid'];
02055     $subject = db_result(db_query("SELECT subject FROM {comments} WHERE cid = %d", $cid));
02056   }
02057   db_query('UPDATE {comments} SET status = %d WHERE cid = %d', COMMENT_NOT_PUBLISHED, $cid);
02058   watchdog('action', 'Unpublished comment %subject.', array('%subject' => $subject));
02059 }
02060
02066 function comment_unpublish_by_keyword_action_form($context) {
02067   $form['keywords'] = array(
02068     '#title' => t('Keywords'),
02069     '#type' => 'textarea',
02070     '#description' => t('The comment will be unpublished if it contains any of the character sequences above. Use a comma-separated list of character sequences. Example: funny, bungee jumping, "Company, Inc.". Character sequences are case-sensitive.'),
02071     '#default_value' => isset($context['keywords']) ? drupal_implode_tags($context['keywords']) : '',
02072   );
02073   return $form;
02074 }
02075
02079 function comment_unpublish_by_keyword_action_submit($form, $form_state) {
02080   return array('keywords' => drupal_explode_tags($form_state['values']['keywords']));
02081 }
02082
02094 function comment_unpublish_by_keyword_action($comment, $context) {
02095   foreach ($context['keywords'] as $keyword) {
02096     if (strstr($comment->comment, $keyword) || strstr($comment->subject, $keyword)) {
02097       db_query('UPDATE {comments} SET status = %d WHERE cid = %d', COMMENT_NOT_PUBLISHED, $comment->cid);
02098       watchdog('action', 'Unpublished comment %subject.', array('%subject' => $comment->subject));
02099       break;
02100     }
02101   }
02102 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/comment/comment.pages.inc Source File

modules » comment

comment.pages.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: comment.pages.inc,v 1.2.2.1 2008/02/07 18:53:38 goba Exp $
00003
00016 function comment_edit($cid) {
00017   global $user;
00018
00019   $comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d', $cid));
00020   $comment = drupal_unpack($comment);
00021   $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
00022   if (comment_access('edit', $comment)) {
00023     return comment_form_box((array)$comment);
00024   }
00025   else {
00026     drupal_access_denied();
00027   }
00028 }
00029
00051 function comment_reply($node, $pid = NULL) {
00052   // Set the breadcrumb trail.
00053   drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->title, 'node/'. $node->nid)));
00054   $op = isset($_POST['op']) ? $_POST['op'] : '';
00055
00056   $output = '';
00057
00058   if (user_access('access comments')) {
00059     // The user is previewing a comment prior to submitting it.
00060     if ($op == t('Preview')) {
00061       if (user_access('post comments')) {
00062         $output .= comment_form_box(array('pid' => $pid, 'nid' => $node->nid), NULL);
00063       }
00064       else {
00065         drupal_set_message(t('You are not authorized to post comments.'), 'error');
00066         drupal_goto("node/$node->nid");
00067       }
00068     }
00069     else {
00070       // $pid indicates that this is a reply to a comment.
00071       if ($pid) {
00072         // load the comment whose cid = $pid
00073         if ($comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d', $pid, COMMENT_PUBLISHED))) {
00074           // If that comment exists, make sure that the current comment and the parent comment both
00075           // belong to the same parent node.
00076           if ($comment->nid != $node->nid) {
00077             // Attempting to reply to a comment not belonging to the current nid.
00078             drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
00079             drupal_goto("node/$node->nid");
00080           }
00081           // Display the parent comment
00082           $comment = drupal_unpack($comment);
00083           $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
00084           $output .= theme('comment_view', $comment, $node);
00085         }
00086         else {
00087           drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
00088           drupal_goto("node/$node->nid");
00089         }
00090       }
00091       // This is the case where the comment is in response to a node. Display the node.
00092       else if (user_access('access content')) {
00093         $output .= node_view($node);
00094       }
00095
00096       // Should we show the reply box?
00097       if (node_comment_mode($node->nid) != COMMENT_NODE_READ_WRITE) {
00098         drupal_set_message(t("This discussion is closed: you can't post new comments."), 'error');
00099         drupal_goto("node/$node->nid");
00100       }
00101       else if (user_access('post comments')) {
00102         $output .= comment_form_box(array('pid' => $pid, 'nid' => $node->nid), t('Reply'));
00103       }
00104       else {
00105         drupal_set_message(t('You are not authorized to post comments.'), 'error');
00106         drupal_goto("node/$node->nid");
00107       }
00108     }
00109   }
00110   else {
00111     drupal_set_message(t('You are not authorized to view comments.'), 'error');
00112     drupal_goto("node/$node->nid");
00113   }
00114
00115   return $output;
00116 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/common.inc Source File

includes

common.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: common.inc,v 1.756.2.3 2008/02/11 13:11:14 goba Exp $
00003
00015 define('SAVED_NEW', 1);
00016
00020 define('SAVED_UPDATED', 2);
00021
00025 define('SAVED_DELETED', 3);
00026
00035 function drupal_set_content($region = NULL, $data = NULL) {
00036   static $content = array();
00037
00038   if (!is_null($region) && !is_null($data)) {
00039     $content[$region][] = $data;
00040   }
00041   return $content;
00042 }
00043
00053 function drupal_get_content($region = NULL, $delimiter = ' ') {
00054   $content = drupal_set_content();
00055   if (isset($region)) {
00056     if (isset($content[$region]) && is_array($content[$region])) {
00057       return implode($delimiter, $content[$region]);
00058     }
00059   }
00060   else {
00061     foreach (array_keys($content) as $region) {
00062       if (is_array($content[$region])) {
00063         $content[$region] = implode($delimiter, $content[$region]);
00064       }
00065     }
00066     return $content;
00067   }
00068 }
00069
00077 function drupal_set_breadcrumb($breadcrumb = NULL) {
00078   static $stored_breadcrumb;
00079
00080   if (!is_null($breadcrumb)) {
00081     $stored_breadcrumb = $breadcrumb;
00082   }
00083   return $stored_breadcrumb;
00084 }
00085
00089 function drupal_get_breadcrumb() {
00090   $breadcrumb = drupal_set_breadcrumb();
00091
00092   if (is_null($breadcrumb)) {
00093     $breadcrumb = menu_get_active_breadcrumb();
00094   }
00095
00096   return $breadcrumb;
00097 }
00098
00104 function drupal_set_html_head($data = NULL) {
00105   static $stored_head = '';
00106
00107   if (!is_null($data)) {
00108     $stored_head .= $data ."\n";
00109   }
00110   return $stored_head;
00111 }
00112
00116 function drupal_get_html_head() {
00117   $output = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
00118   return $output . drupal_set_html_head();
00119 }
00120
00124 function drupal_clear_path_cache() {
00125   drupal_lookup_path('wipe');
00126 }
00127
00134 function drupal_set_header($header = NULL) {
00135   // We use an array to guarantee there are no leading or trailing delimiters.
00136   // Otherwise, header('') could get called when serving the page later, which
00137   // ends HTTP headers prematurely on some PHP versions.
00138   static $stored_headers = array();
00139
00140   if (strlen($header)) {
00141     header($header);
00142     $stored_headers[] = $header;
00143   }
00144   return implode("\n", $stored_headers);
00145 }
00146
00150 function drupal_get_headers() {
00151   return drupal_set_header();
00152 }
00153
00162 function drupal_add_feed($url = NULL, $title = '') {
00163   static $stored_feed_links = array();
00164
00165   if (!is_null($url) && !isset($stored_feed_links[$url])) {
00166     $stored_feed_links[$url] = theme('feed_icon', $url, $title);
00167
00168     drupal_add_link(array('rel' => 'alternate',
00169                           'type' => 'application/rss+xml',
00170                           'title' => $title,
00171                           'href' => $url));
00172   }
00173   return $stored_feed_links;
00174 }
00175
00182 function drupal_get_feeds($delimiter = "\n") {
00183   $feeds = drupal_add_feed();
00184   return implode($feeds, $delimiter);
00185 }
00186
00206 function drupal_query_string_encode($query, $exclude = array(), $parent = '') {
00207   $params = array();
00208
00209   foreach ($query as $key => $value) {
00210     $key = drupal_urlencode($key);
00211     if ($parent) {
00212       $key = $parent .'['. $key .']';
00213     }
00214
00215     if (in_array($key, $exclude)) {
00216       continue;
00217     }
00218
00219     if (is_array($value)) {
00220       $params[] = drupal_query_string_encode($value, $exclude, $key);
00221     }
00222     else {
00223       $params[] = $key .'='. drupal_urlencode($value);
00224     }
00225   }
00226
00227   return implode('&', $params);
00228 }
00229
00240 function drupal_get_destination() {
00241   if (isset($_REQUEST['destination'])) {
00242     return 'destination='. urlencode($_REQUEST['destination']);
00243   }
00244   else {
00245     // Use $_GET here to retrieve the original path in source form.
00246     $path = isset($_GET['q']) ? $_GET['q'] : '';
00247     $query = drupal_query_string_encode($_GET, array('q'));
00248     if ($query != '') {
00249       $path .= '?'. $query;
00250     }
00251     return 'destination='. urlencode($path);
00252   }
00253 }
00254
00296 function drupal_goto($path = '', $query = NULL, $fragment = NULL, $http_response_code = 302) {
00297
00298   if (isset($_REQUEST['destination'])) {
00299     extract(parse_url(urldecode($_REQUEST['destination'])));
00300   }
00301   else if (isset($_REQUEST['edit']['destination'])) {
00302     extract(parse_url(urldecode($_REQUEST['edit']['destination'])));
00303   }
00304
00305   $url = url($path, array('query' => $query, 'fragment' => $fragment, 'absolute' => TRUE));
00306   // Remove newlines from the URL to avoid header injection attacks.
00307   $url = str_replace(array("\n", "\r"), '', $url);
00308
00309   // Allow modules to react to the end of the page request before redirecting.
00310   // We do not want this while running update.php.
00311   if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') {
00312     module_invoke_all('exit', $url);
00313   }
00314
00315   // Even though session_write_close() is registered as a shutdown function, we
00316   // need all session data written to the database before redirecting.
00317   session_write_close();
00318
00319   header('Location: '. $url, TRUE, $http_response_code);
00320
00321   // The "Location" header sends a redirect status code to the HTTP daemon. In
00322   // some cases this can be wrong, so we make sure none of the code below the
00323   // drupal_goto() call gets executed upon redirection.
00324   exit();
00325 }
00326
00330 function drupal_site_offline() {
00331   drupal_maintenance_theme();
00332   drupal_set_header('HTTP/1.1 503 Service unavailable');
00333   drupal_set_title(t('Site off-line'));
00334   print theme('maintenance_page', filter_xss_admin(variable_get('site_offline_message',
00335     t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal'))))));
00336 }
00337
00341 function drupal_not_found() {
00342   drupal_set_header('HTTP/1.1 404 Not Found');
00343
00344   watchdog('page not found', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
00345
00346   // Keep old path for reference.
00347   if (!isset($_REQUEST['destination'])) {
00348     $_REQUEST['destination'] = $_GET['q'];
00349   }
00350
00351   $path = drupal_get_normal_path(variable_get('site_404', ''));
00352   if ($path && $path != $_GET['q']) {
00353     // Set the active item in case there are tabs to display, or other
00354     // dependencies on the path.
00355     menu_set_active_item($path);
00356     $return = menu_execute_active_handler($path);
00357   }
00358
00359   if (empty($return) || $return == MENU_NOT_FOUND || $return == MENU_ACCESS_DENIED) {
00360     drupal_set_title(t('Page not found'));
00361     $return = t('The requested page could not be found.');
00362   }
00363
00364   // To conserve CPU and bandwidth, omit the blocks.
00365   print theme('page', $return, FALSE);
00366 }
00367
00371 function drupal_access_denied() {
00372   drupal_set_header('HTTP/1.1 403 Forbidden');
00373   watchdog('access denied', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
00374
00375   // Keep old path for reference.
00376   if (!isset($_REQUEST['destination'])) {
00377     $_REQUEST['destination'] = $_GET['q'];
00378   }
00379
00380   $path = drupal_get_normal_path(variable_get('site_403', ''));
00381   if ($path && $path != $_GET['q']) {
00382     // Set the active item in case there are tabs to display or other
00383     // dependencies on the path.
00384     menu_set_active_item($path);
00385     $return = menu_execute_active_handler($path);
00386   }
00387
00388   if (empty($return) || $return == MENU_NOT_FOUND || $return == MENU_ACCESS_DENIED) {
00389     drupal_set_title(t('Access denied'));
00390     $return = t('You are not authorized to access this page.');
00391   }
00392   print theme('page', $return);
00393 }
00394
00416 function drupal_http_request($url, $headers = array(), $method = 'GET', $data = NULL, $retry = 3) {
00417   static $self_test = FALSE;
00418   $result = new stdClass();
00419   // Try to clear the drupal_http_request_fails variable if it's set. We
00420   // can't tie this call to any error because there is no surefire way to
00421   // tell whether a request has failed, so we add the check to places where
00422   // some parsing has failed.
00423   if (!$self_test && variable_get('drupal_http_request_fails', FALSE)) {
00424     $self_test = TRUE;
00425     $works = module_invoke('system', 'check_http_request');
00426     $self_test = FALSE;
00427     if (!$works) {
00428       // Do not bother with further operations if we already know that we
00429       // have no chance.
00430       $result->error = t("The server can't issue HTTP requests");
00431       return $result;
00432     }
00433   }
00434
00435   // Parse the URL and make sure we can handle the schema.
00436   $uri = parse_url($url);
00437
00438   switch ($uri['scheme']) {
00439     case 'http':
00440       $port = isset($uri['port']) ? $uri['port'] : 80;
00441       $host = $uri['host'] . ($port != 80 ? ':'. $port : '');
00442       $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
00443       break;
00444     case 'https':
00445       // Note: Only works for PHP 4.3 compiled with OpenSSL.
00446       $port = isset($uri['port']) ? $uri['port'] : 443;
00447       $host = $uri['host'] . ($port != 443 ? ':'. $port : '');
00448       $fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20);
00449       break;
00450     default:
00451       $result->error = 'invalid schema '. $uri['scheme'];
00452       return $result;
00453   }
00454
00455   // Make sure the socket opened properly.
00456   if (!$fp) {
00457     // When a network error occurs, we use a negative number so it does not
00458     // clash with the HTTP status codes.
00459     $result->code = -$errno;
00460     $result->error = trim($errstr);
00461     return $result;
00462   }
00463
00464   // Construct the path to act on.
00465   $path = isset($uri['path']) ? $uri['path'] : '/';
00466   if (isset($uri['query'])) {
00467     $path .= '?'. $uri['query'];
00468   }
00469
00470   // Create HTTP request.
00471   $defaults = array(
00472     // RFC 2616: "non-standard ports MUST, default ports MAY be included".
00473     // We don't add the port to prevent from breaking rewrite rules checking the
00474     // host that do not take into account the port number.
00475     'Host' => "Host: $host",
00476     'User-Agent' => 'User-Agent: Drupal (+http://drupal.org/)',
00477     'Content-Length' => 'Content-Length: '. strlen($data)
00478   );
00479
00480   // If the server url has a user then attempt to use basic authentication
00481   if (isset($uri['user'])) {
00482     $defaults['Authorization'] = 'Authorization: Basic '. base64_encode($uri['user'] . (!empty($uri['pass']) ? ":". $uri['pass'] : ''));
00483   }
00484
00485   foreach ($headers as $header => $value) {
00486     $defaults[$header] = $header .': '. $value;
00487   }
00488
00489   $request = $method .' '. $path ." HTTP/1.0\r\n";
00490   $request .= implode("\r\n", $defaults);
00491   $request .= "\r\n\r\n";
00492   if ($data) {
00493     $request .= $data ."\r\n";
00494   }
00495   $result->request = $request;
00496
00497   fwrite($fp, $request);
00498
00499   // Fetch response.
00500   $response = '';
00501   while (!feof($fp) && $chunk = fread($fp, 1024)) {
00502     $response .= $chunk;
00503   }
00504   fclose($fp);
00505
00506   // Parse response.
00507   list($split, $result->data) = explode("\r\n\r\n", $response, 2);
00508   $split = preg_split("/\r\n|\n|\r/", $split);
00509
00510   list($protocol, $code, $text) = explode(' ', trim(array_shift($split)), 3);
00511   $result->headers = array();
00512
00513   // Parse headers.
00514   while ($line = trim(array_shift($split))) {
00515     list($header, $value) = explode(':', $line, 2);
00516     if (isset($result->headers[$header]) && $header == 'Set-Cookie') {
00517       // RFC 2109: the Set-Cookie response header comprises the token Set-
00518       // Cookie:, followed by a comma-separated list of one or more cookies.
00519       $result->headers[$header] .= ','. trim($value);
00520     }
00521     else {
00522       $result->headers[$header] = trim($value);
00523     }
00524   }
00525
00526   $responses = array(
00527     100 => 'Continue', 101 => 'Switching Protocols',
00528     200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content',
00529     300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect',
00530     400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Large', 415 => 'Unsupported Media Type', 416 => 'Requested range not satisfiable', 417 => 'Expectation Failed',
00531     500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported'
00532   );
00533   // RFC 2616 states that all unknown HTTP codes must be treated the same as the
00534   // base code in their class.
00535   if (!isset($responses[$code])) {
00536     $code = floor($code / 100) * 100;
00537   }
00538
00539   switch ($code) {
00540     case 200: // OK
00541     case 304: // Not modified
00542       break;
00543     case 301: // Moved permanently
00544     case 302: // Moved temporarily
00545     case 307: // Moved temporarily
00546       $location = $result->headers['Location'];
00547
00548       if ($retry) {
00549         $result = drupal_http_request($result->headers['Location'], $headers, $method, $data, --$retry);
00550         $result->redirect_code = $result->code;
00551       }
00552       $result->redirect_url = $location;
00553
00554       break;
00555     default:
00556       $result->error = $text;
00557   }
00558
00559   $result->code = $code;
00560   return $result;
00561 }
00573 function drupal_error_handler($errno, $message, $filename, $line, $context) {
00574   // If the @ error suppression operator was used, error_reporting is
00575   // temporarily set to 0.
00576   if (error_reporting() == 0) {
00577     return;
00578   }
00579
00580   if ($errno & (E_ALL)) {
00581     $types = array(1 => 'error', 2 => 'warning', 4 => 'parse error', 8 => 'notice', 16 => 'core error', 32 => 'core warning', 64 => 'compile error', 128 => 'compile warning', 256 => 'user error', 512 => 'user warning', 1024 => 'user notice', 2048 => 'strict warning', 4096 => 'recoverable fatal error');
00582
00583     // For database errors, we want the line number/file name of the place that
00584     // the query was originally called, not _db_query().
00585     if (isset($context[DB_ERROR])) {
00586       $backtrace = array_reverse(debug_backtrace());
00587
00588       // List of functions where SQL queries can originate.
00589       $query_functions = array('db_query', 'pager_query', 'db_query_range', 'db_query_temporary', 'update_sql');
00590
00591       // Determine where query function was called, and adjust line/file
00592       // accordingly.
00593       foreach ($backtrace as $index => $function) {
00594         if (in_array($function['function'], $query_functions)) {
00595           $line = $backtrace[$index]['line'];
00596           $filename = $backtrace[$index]['file'];
00597           break;
00598         }
00599       }
00600     }
00601
00602     $entry = $types[$errno] .': '. $message .' in '. $filename .' on line '. $line .'.';
00603
00604     // Force display of error messages in update.php.
00605     if (variable_get('error_level', 1) == 1 || strstr($_SERVER['SCRIPT_NAME'], 'update.php')) {
00606       drupal_set_message($entry, 'error');
00607     }
00608
00609     watchdog('php', '%message in %file on line %line.', array('%error' => $types[$errno], '%message' => $message, '%file' => $filename, '%line' => $line), WATCHDOG_ERROR);
00610   }
00611 }
00612
00613 function _fix_gpc_magic(&$item) {
00614   if (is_array($item)) {
00615     array_walk($item, '_fix_gpc_magic');
00616   }
00617   else {
00618     $item = stripslashes($item);
00619   }
00620 }
00621
00629 function _fix_gpc_magic_files(&$item, $key) {
00630   if ($key != 'tmp_name') {
00631     if (is_array($item)) {
00632       array_walk($item, '_fix_gpc_magic_files');
00633     }
00634     else {
00635       $item = stripslashes($item);
00636     }
00637   }
00638 }
00639
00643 function fix_gpc_magic() {
00644   static $fixed = FALSE;
00645   if (!$fixed && ini_get('magic_quotes_gpc')) {
00646     array_walk($_GET, '_fix_gpc_magic');
00647     array_walk($_POST, '_fix_gpc_magic');
00648     array_walk($_COOKIE, '_fix_gpc_magic');
00649     array_walk($_REQUEST, '_fix_gpc_magic');
00650     array_walk($_FILES, '_fix_gpc_magic_files');
00651     $fixed = TRUE;
00652   }
00653 }
00654
00753 function t($string, $args = array(), $langcode = NULL) {
00754   global $language;
00755   static $custom_strings;
00756
00757   $langcode = isset($langcode) ? $langcode : $language->language;
00758
00759   // First, check for an array of customized strings. If present, use the array
00760   // *instead of* database lookups. This is a high performance way to provide a
00761   // handful of string replacements. See settings.php for examples.
00762   // Cache the $custom_strings variable to improve performance.
00763   if (!isset($custom_strings[$langcode])) {
00764     $custom_strings[$langcode] = variable_get('locale_custom_strings_'. $langcode, array());
00765   }
00766   // Custom strings work for English too, even if locale module is disabled.
00767   if (isset($custom_strings[$langcode][$string])) {
00768     $string = $custom_strings[$langcode][$string];
00769   }
00770   // Translate with locale module if enabled.
00771   elseif (function_exists('locale') && $langcode != 'en') {
00772     $string = locale($string, $langcode);
00773   }
00774   if (empty($args)) {
00775     return $string;
00776   }
00777   else {
00778     // Transform arguments before inserting them.
00779     foreach ($args as $key => $value) {
00780       switch ($key[0]) {
00781         case '@':
00782           // Escaped only.
00783           $args[$key] = check_plain($value);
00784           break;
00785
00786         case '%':
00787         default:
00788           // Escaped and placeholder.
00789           $args[$key] = theme('placeholder', $value);
00790           break;
00791
00792         case '!':
00793           // Pass-through.
00794       }
00795     }
00796     return strtr($string, $args);
00797   }
00798 }
00799
00816 function valid_email_address($mail) {
00817   $user = '[a-zA-Z0-9_\-\.\+\^!#\$%&*+\/\=\?\`\|\{\}~\']+';
00818   $domain = '(?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.?)+';
00819   $ipv4 = '[0-9]{1,3}(\.[0-9]{1,3}){3}';
00820   $ipv6 = '[0-9a-fA-F]{1,4}(\:[0-9a-fA-F]{1,4}){7}';
00821
00822   return preg_match("/^$user@($domain|(\[($ipv4|$ipv6)\]))$/", $mail);
00823 }
00824
00838 function valid_url($url, $absolute = FALSE) {
00839   $allowed_characters = '[a-z0-9\/:_\-_\.\?\$,;~=#&%\+]';
00840   if ($absolute) {
00841     return preg_match("/^(http|https|ftp):\/\/". $allowed_characters ."+$/i", $url);
00842   }
00843   else {
00844     return preg_match("/^". $allowed_characters ."+$/i", $url);
00845   }
00846 }
00847
00858 function flood_register_event($name) {
00859   db_query("INSERT INTO {flood} (event, hostname, timestamp) VALUES ('%s', '%s', %d)", $name, ip_address(), time());
00860 }
00861
00875 function flood_is_allowed($name, $threshold) {
00876   $number = db_result(db_query("SELECT COUNT(*) FROM {flood} WHERE event = '%s' AND hostname = '%s' AND timestamp > %d", $name, ip_address(), time() - 3600));
00877   return ($number < $threshold ? TRUE : FALSE);
00878 }
00879
00880 function check_file($filename) {
00881   return is_uploaded_file($filename);
00882 }
00883
00887 function check_url($uri) {
00888   return filter_xss_bad_protocol($uri, FALSE);
00889 }
00890
00902 function format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()) {
00903   global $language;
00904   $langcode = $langcode ? $langcode : $language->language;
00905
00906   $output = "<channel>\n";
00907   $output .= ' <title>'. check_plain($title) ."</title>\n";
00908   $output .= ' <link>'. check_url($link) ."</link>\n";
00909
00910   // The RSS 2.0 "spec" doesn't indicate HTML can be used in the description.
00911   // We strip all HTML tags, but need to prevent double encoding from properly
00912   // escaped source data (such as &amp becoming &amp;amp;).
00913   $output .= ' <description>'. check_plain(decode_entities(strip_tags($description))) ."</description>\n";
00914   $output .= ' <language>'. check_plain($langcode) ."</language>\n";
00915   $output .= format_xml_elements($args);
00916   $output .= $items;
00917   $output .= "</channel>\n";
00918
00919   return $output;
00920 }
00921
00927 function format_rss_item($title, $link, $description, $args = array()) {
00928   $output = "<item>\n";
00929   $output .= ' <title>'. check_plain($title) ."</title>\n";
00930   $output .= ' <link>'. check_url($link) ."</link>\n";
00931   $output .= ' <description>'. check_plain($description) ."</description>\n";
00932   $output .= format_xml_elements($args);
00933   $output .= "</item>\n";
00934
00935   return $output;
00936 }
00937
00952 function format_xml_elements($array) {
00953   $output = '';
00954   foreach ($array as $key => $value) {
00955     if (is_numeric($key)) {
00956       if ($value['key']) {
00957         $output .= ' <'. $value['key'];
00958         if (isset($value['attributes']) && is_array($value['attributes'])) {
00959           $output .= drupal_attributes($value['attributes']);
00960         }
00961
00962         if ($value['value'] != '') {
00963           $output .= '>'. (is_array($value['value']) ? format_xml_elements($value['value']) : check_plain($value['value'])) .'</'. $value['key'] .">\n";
00964         }
00965         else {
00966           $output .= " />\n";
00967         }
00968       }
00969     }
00970     else {
00971       $output .= ' <'. $key .'>'. (is_array($value) ? format_xml_elements($value) : check_plain($value)) ."</$key>\n";
00972     }
00973   }
00974   return $output;
00975 }
00976
01023 function format_plural($count, $singular, $plural, $args = array(), $langcode = NULL) {
01024   $args['@count'] = $count;
01025   if ($count == 1) {
01026     return t($singular, $args, $langcode);
01027   }
01028
01029   // Get the plural index through the gettext formula.
01030   $index = (function_exists('locale_get_plural')) ? locale_get_plural($count, $langcode) : -1;
01031   // Backwards compatibility.
01032   if ($index < 0) {
01033     return t($plural, $args, $langcode);
01034   }
01035   else {
01036     switch ($index) {
01037       case "0":
01038         return t($singular, $args, $langcode);
01039       case "1":
01040         return t($plural, $args, $langcode);
01041       default:
01042         unset($args['@count']);
01043         $args['@count['. $index .']'] = $count;
01044         return t(strtr($plural, array('@count' => '@count['. $index .']')), $args, $langcode);
01045     }
01046   }
01047 }
01048
01058 function parse_size($size) {
01059   $suffixes = array(
01060     '' => 1,
01061     'k' => 1024,
01062     'm' => 1048576, // 1024 * 1024
01063     'g' => 1073741824, // 1024 * 1024 * 1024
01064   );
01065   if (preg_match('/([0-9]+)\s*(k|m|g)?(b?(ytes?)?)/i', $size, $match)) {
01066     return $match[1] * $suffixes[drupal_strtolower($match[2])];
01067   }
01068 }
01069
01081 function format_size($size, $langcode = NULL) {
01082   if ($size < 1024) {
01083     return format_plural($size, '1 byte', '@count bytes', array(), $langcode);
01084   }
01085   else {
01086     $size = round($size / 1024, 2);
01087     $suffix = t('KB', array(), $langcode);
01088     if ($size >= 1024) {
01089       $size = round($size / 1024, 2);
01090       $suffix = t('MB', array(), $langcode);
01091     }
01092     return t('@size @suffix', array('@size' => $size, '@suffix' => $suffix), $langcode);
01093   }
01094 }
01095
01109 function format_interval($timestamp, $granularity = 2, $langcode = NULL) {
01110   $units = array('1 year|@count years' => 31536000, '1 week|@count weeks' => 604800, '1 day|@count days' => 86400, '1 hour|@count hours' => 3600, '1 min|@count min' => 60, '1 sec|@count sec' => 1);
01111   $output = '';
01112   foreach ($units as $key => $value) {
01113     $key = explode('|', $key);
01114     if ($timestamp >= $value) {
01115       $output .= ($output ? ' ' : '') . format_plural(floor($timestamp / $value), $key[0], $key[1], array(), $langcode);
01116       $timestamp %= $value;
01117       $granularity--;
01118     }
01119
01120     if ($granularity == 0) {
01121       break;
01122     }
01123   }
01124   return $output ? $output : t('0 sec', array(), $langcode);
01125 }
01126
01151 function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
01152   if (!isset($timezone)) {
01153     global $user;
01154     if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
01155       $timezone = $user->timezone;
01156     }
01157     else {
01158       $timezone = variable_get('date_default_timezone', 0);
01159     }
01160   }
01161
01162   $timestamp += $timezone;
01163
01164   switch ($type) {
01165     case 'small':
01166       $format = variable_get('date_format_short', 'm/d/Y - H:i');
01167       break;
01168     case 'large':
01169       $format = variable_get('date_format_long', 'l, F j, Y - H:i');
01170       break;
01171     case 'custom':
01172       // No change to format.
01173       break;
01174     case 'medium':
01175     default:
01176       $format = variable_get('date_format_medium', 'D, m/d/Y - H:i');
01177   }
01178
01179   $max = strlen($format);
01180   $date = '';
01181   for ($i = 0; $i < $max; $i++) {
01182     $c = $format[$i];
01183     if (strpos('AaDlM', $c) !== FALSE) {
01184       $date .= t(gmdate($c, $timestamp), array(), $langcode);
01185     }
01186     else if ($c == 'F') {
01187       // Special treatment for long month names: May is both an abbreviation
01188       // and a full month name in English, but other languages have
01189       // different abbreviations.
01190       $date .= trim(t('!long-month-name '. gmdate($c, $timestamp), array('!long-month-name' => ''), $langcode));
01191     }
01192     else if (strpos('BdgGhHiIjLmnsStTUwWYyz', $c) !== FALSE) {
01193       $date .= gmdate($c, $timestamp);
01194     }
01195     else if ($c == 'r') {
01196       $date .= format_date($timestamp - $timezone, 'custom', 'D, d M Y H:i:s O', $timezone, $langcode);
01197     }
01198     else if ($c == 'O') {
01199       $date .= sprintf('%s%02d%02d', ($timezone < 0 ? '-' : '+'), abs($timezone / 3600), abs($timezone % 3600) / 60);
01200     }
01201     else if ($c == 'Z') {
01202       $date .= $timezone;
01203     }
01204     else if ($c == '\\') {
01205       $date .= $format[++$i];
01206     }
01207     else {
01208       $date .= $c;
01209     }
01210   }
01211
01212   return $date;
01213 }
01214
01257 function url($path = NULL, $options = array()) {
01258   // Merge in defaults.
01259   $options += array(
01260     'fragment' => '',
01261     'query' => '',
01262     'absolute' => FALSE,
01263     'alias' => FALSE,
01264     'prefix' => ''
01265   );
01266   if (!isset($options['external'])) {
01267     // Return an external link if $path contains an allowed absolute URL.
01268     // Only call the slow filter_xss_bad_protocol if $path contains a ':' before
01269     // any / ? or #.
01270     $colonpos = strpos($path, ':');
01271     $options['external'] = ($colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && filter_xss_bad_protocol($path, FALSE) == check_plain($path));
01272   }
01273
01274   // May need language dependent rewriting if language.inc is present.
01275   if (function_exists('language_url_rewrite')) {
01276     language_url_rewrite($path, $options);
01277   }
01278   if ($options['fragment']) {
01279     $options['fragment'] = '#'. $options['fragment'];
01280   }
01281   if (is_array($options['query'])) {
01282     $options['query'] = drupal_query_string_encode($options['query']);
01283   }
01284
01285   if ($options['external']) {
01286     // Split off the fragment.
01287     if (strpos($path, '#') !== FALSE) {
01288       list($path, $old_fragment) = explode('#', $path, 2);
01289       if (isset($old_fragment) && !$options['fragment']) {
01290         $options['fragment'] = '#'. $old_fragment;
01291       }
01292     }
01293     // Append the query.
01294     if ($options['query']) {
01295       $path .= (strpos($path, '?') !== FALSE ? '&' : '?') . $options['query'];
01296     }
01297     // Reassemble.
01298     return $path . $options['fragment'];
01299   }
01300
01301   global $base_url;
01302   static $script;
01303   static $clean_url;
01304
01305   if (!isset($script)) {
01306     // On some web servers, such as IIS, we can't omit "index.php". So, we
01307     // generate "index.php?q=foo" instead of "?q=foo" on anything that is not
01308     // Apache.
01309     $script = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === FALSE) ? 'index.php' : '';
01310   }
01311
01312   // Cache the clean_url variable to improve performance.
01313   if (!isset($clean_url)) {
01314     $clean_url = (bool)variable_get('clean_url', '0');
01315   }
01316
01317   if (!isset($options['base_url'])) {
01318     // The base_url might be rewritten from the language rewrite in domain mode.
01319     $options['base_url'] = $base_url;
01320   }
01321
01322   // Preserve the original path before aliasing.
01323   $original_path = $path;
01324
01325   // The special path '<front>' links to the default front page.
01326   if ($path == '<front>') {
01327     $path = '';
01328   }
01329   elseif (!empty($path) && !$options['alias']) {
01330     $path = drupal_get_path_alias($path, isset($options['language']) ? $options['language']->language : '');
01331   }
01332
01333   if (function_exists('custom_url_rewrite_outbound')) {
01334     // Modules may alter outbound links by reference.
01335     custom_url_rewrite_outbound($path, $options, $original_path);
01336   }
01337
01338   $base = $options['absolute'] ? $options['base_url'] .'/' : base_path();
01339   $prefix = empty($path) ? rtrim($options['prefix'], '/') : $options['prefix'];
01340   $path = drupal_urlencode($prefix . $path);
01341
01342   if ($clean_url) {
01343     // With Clean URLs.
01344     if ($options['query']) {
01345       return $base . $path .'?'. $options['query'] . $options['fragment'];
01346     }
01347     else {
01348       return $base . $path . $options['fragment'];
01349     }
01350   }
01351   else {
01352     // Without Clean URLs.
01353     $variables = array();
01354     if (!empty($path)) {
01355       $variables[] = 'q='. $path;
01356     }
01357     if (!empty($options['query'])) {
01358       $variables[] = $options['query'];
01359     }
01360     if ($query = join('&', $variables)) {
01361       return $base . $script .'?'. $query . $options['fragment'];
01362     }
01363     else {
01364       return $base . $options['fragment'];
01365     }
01366   }
01367 }
01368
01377 function drupal_attributes($attributes = array()) {
01378   if (is_array($attributes)) {
01379     $t = '';
01380     foreach ($attributes as $key => $value) {
01381       $t .= " $key=".'"'. check_plain($value) .'"';
01382     }
01383     return $t;
01384   }
01385 }
01386
01430 function l($text, $path, $options = array()) {
01431   // Merge in defaults.
01432   $options += array(
01433       'attributes' => array(),
01434       'html' => FALSE,
01435     );
01436
01437   // Append active class.
01438   if ($path == $_GET['q'] || ($path == '<front>' && drupal_is_front_page())) {
01439     if (isset($options['attributes']['class'])) {
01440       $options['attributes']['class'] .= ' active';
01441     }
01442     else {
01443       $options['attributes']['class'] = 'active';
01444     }
01445   }
01446
01447   // Remove all HTML and PHP tags from a tooltip. For best performance, we act only
01448   // if a quick strpos() pre-check gave a suspicion (because strip_tags() is expensive).
01449   if (isset($options['attributes']['title']) && strpos($options['attributes']['title'], '<') !== FALSE) {
01450     $options['attributes']['title'] = strip_tags($options['attributes']['title']);
01451   }
01452
01453   return '<a href="'. check_url(url($path, $options)) .'"'. drupal_attributes($options['attributes']) .'>'. ($options['html'] ? $text : check_plain($text)) .'</a>';
01454 }
01455
01462 function drupal_page_footer() {
01463   if (variable_get('cache', CACHE_DISABLED) != CACHE_DISABLED) {
01464     page_set_cache();
01465   }
01466
01467   module_invoke_all('exit');
01468 }
01469
01486 function drupal_map_assoc($array, $function = NULL) {
01487   if (!isset($function)) {
01488     $result = array();
01489     foreach ($array as $value) {
01490       $result[$value] = $value;
01491     }
01492     return $result;
01493   }
01494   elseif (function_exists($function)) {
01495     $result = array();
01496     foreach ($array as $value) {
01497       $result[$value] = $function($value);
01498     }
01499     return $result;
01500   }
01501 }
01502
01520 function drupal_eval($code) {
01521   global $theme_path, $theme_info, $conf;
01522
01523   // Store current theme path.
01524   $old_theme_path = $theme_path;
01525
01526   // Restore theme_path to the theme, as long as drupal_eval() executes,
01527   // so code evaluted will not see the caller module as the current theme.
01528   // If theme info is not initialized get the path from theme_default.
01529   if (!isset($theme_info)) {
01530     $theme_path = drupal_get_path('theme', $conf['theme_default']);
01531   }
01532   else {
01533     $theme_path = dirname($theme_info->filename);
01534   }
01535
01536   ob_start();
01537   print eval('?>'. $code);
01538   $output = ob_get_contents();
01539   ob_end_clean();
01540
01541   // Recover original theme path.
01542   $theme_path = $old_theme_path;
01543
01544   return $output;
01545 }
01546
01558 function drupal_get_path($type, $name) {
01559   return dirname(drupal_get_filename($type, $name));
01560 }
01561
01566 function base_path() {
01567   return $GLOBALS['base_path'];
01568 }
01569
01573 function drupal_clone($object) {
01574   return version_compare(phpversion(), '5.0') < 0 ? $object : clone($object);
01575 }
01576
01580 function drupal_add_link($attributes) {
01581   drupal_set_html_head('<link'. drupal_attributes($attributes) ." />\n");
01582 }
01583
01643 function drupal_add_css($path = NULL, $type = 'module', $media = 'all', $preprocess = TRUE) {
01644   static $css = array();
01645   global $language;
01646
01647   // Create an array of CSS files for each media type first, since each type needs to be served
01648   // to the browser differently.
01649   if (isset($path)) {
01650     // This check is necessary to ensure proper cascading of styles and is faster than an asort().
01651     if (!isset($css[$media])) {
01652       $css[$media] = array('module' => array(), 'theme' => array());
01653     }
01654
01655     // If a theme is adding the current stylesheet, check for any existing CSS files
01656     // with the same name. If they exist, remove them and allow the theme's own CSS
01657     // file to replace it.
01658     if ($type == 'theme') {
01659       foreach ($css[$media]['module'] as $old_path => $old_preprocess) {
01660         // Match by style sheet name.
01661         if (basename($path) == basename($old_path)) {
01662           unset($css[$media]['module'][$old_path]);
01663
01664           // If the current language is RTL and the CSS file had an RTL variant,
01665           // pull out the original. The theme must provide its own RTL style.
01666           if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) {
01667             $rtl_old_path = str_replace('.css', '-rtl.css', $old_path);
01668             if (isset($css[$media]['module'][$rtl_old_path])) {
01669               unset($css[$media]['module'][$rtl_old_path]);
01670             }
01671           }
01672           // Set the preprocess state of the current module, then exit the search loop.
01673           $preprocess = $old_preprocess;
01674           break;
01675         }
01676       }
01677     }
01678     $css[$media][$type][$path] = $preprocess;
01679
01680     // If the current language is RTL, add the CSS file with RTL overrides.
01681     if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) {
01682       $rtl_path = str_replace('.css', '-rtl.css', $path);
01683       if (file_exists($rtl_path)) {
01684         $css[$media][$type][$rtl_path] = $preprocess;
01685       }
01686     }
01687   }
01688
01689   return $css;
01690 }
01691
01705 function drupal_get_css($css = NULL) {
01706   $output = '';
01707   if (!isset($css)) {
01708     $css = drupal_add_css();
01709   }
01710   $no_module_preprocess = '';
01711   $no_theme_preprocess = '';
01712
01713   $preprocess_css = (variable_get('preprocess_css', FALSE) && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update'));
01714   $directory = file_directory_path();
01715   $is_writable = is_dir($directory) && is_writable($directory) && (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC);
01716
01717   // A dummy query-string is added to filenames, to gain control over
01718   // browser-caching. The string changes on every update or full cache
01719   // flush, forcing browsers to load a new copy of the files, as the
01720   // URL changed.
01721   $query_string = '?'. substr(variable_get('css_js_query_string', '0'), 0, 1);
01722
01723   foreach ($css as $media => $types) {
01724     // If CSS preprocessing is off, we still need to output the styles.
01725     // Additionally, go through any remaining styles if CSS preprocessing is on and output the non-cached ones.
01726     foreach ($types as $type => $files) {
01727       foreach ($types[$type] as $file => $preprocess) {
01728         if (!$preprocess || !($is_writable && $preprocess_css)) {
01729           // If a CSS file is not to be preprocessed and it's a module CSS file, it needs to *always* appear at the *top*,
01730           // regardless of whether preprocessing is on or off.
01731           if (!$preprocess && $type == 'module') {
01732             $no_module_preprocess .= '<link type="text/css" rel="stylesheet" media="'. $media .'" href="'. base_path() . $file . $query_string .'" />'."\n";
01733           }
01734           // If a CSS file is not to be preprocessed and it's a theme CSS file, it needs to *always* appear at the *bottom*,
01735           // regardless of whether preprocessing is on or off.
01736           else if (!$preprocess && $type == 'theme') {
01737             $no_theme_preprocess .= '<link type="text/css" rel="stylesheet" media="'. $media .'" href="'. base_path() . $file . $query_string .'" />'."\n";
01738           }
01739           else {
01740             $output .= '<link type="text/css" rel="stylesheet" media="'. $media .'" href="'. base_path() . $file . $query_string .'" />'."\n";
01741           }
01742         }
01743       }
01744     }
01745
01746     if ($is_writable && $preprocess_css) {
01747       $filename = md5(serialize($types) . $query_string) .'.css';
01748       $preprocess_file = drupal_build_css_cache($types, $filename);
01749       $output .= '<link type="text/css" rel="stylesheet" media="'. $media .'" href="'. base_path() . $preprocess_file .'" />'."\n";
01750     }
01751   }
01752
01753   return $no_module_preprocess . $output . $no_theme_preprocess;
01754 }
01755
01767 function drupal_build_css_cache($types, $filename) {
01768   $data = '';
01769
01770   // Create the css/ within the files folder.
01771   $csspath = file_create_path('css');
01772   file_check_directory($csspath, FILE_CREATE_DIRECTORY);
01773
01774   if (!file_exists($csspath .'/'. $filename)) {
01775     // Build aggregate CSS file.
01776     foreach ($types as $type) {
01777       foreach ($type as $file => $cache) {
01778         if ($cache) {
01779           $contents = drupal_load_stylesheet($file, TRUE);
01780           // Return the path to where this CSS file originated from.
01781           $base = base_path() . dirname($file) .'/';
01782           _drupal_build_css_path(NULL, $base);
01783           // Prefix all paths within this CSS file, ignoring external and absolute paths.
01784           $data .= preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', '_drupal_build_css_path', $contents);
01785         }
01786       }
01787     }
01788
01789     // Per the W3C specification at http://www.w3.org/TR/REC-CSS2/cascade.html#at-import,
01790     // @import rules must proceed any other style, so we move those to the top.
01791     $regexp = '/@import[^;]+;/i';
01792     preg_match_all($regexp, $data, $matches);
01793     $data = preg_replace($regexp, '', $data);
01794     $data = implode('', $matches[0]) . $data;
01795
01796     // Create the CSS file.
01797     file_save_data($data, $csspath .'/'. $filename, FILE_EXISTS_REPLACE);
01798   }
01799   return $csspath .'/'. $filename;
01800 }
01801
01807 function _drupal_build_css_path($matches, $base = NULL) {
01808   static $_base;
01809   // Store base path for preg_replace_callback.
01810   if (isset($base)) {
01811     $_base = $base;
01812   }
01813
01814   // Prefix with base and remove '../' segments where possible.
01815   $path = $_base . $matches[1];
01816   $last = '';
01817   while ($path != $last) {
01818     $last = $path;
01819     $path = preg_replace('`(^|/)(?!../)([^/]+)/../`', '$1', $path);
01820   }
01821   return 'url('. $path .')';
01822 }
01823
01842 function drupal_load_stylesheet($file, $optimize = NULL) {
01843   static $_optimize;
01844   // Store optimization parameter for preg_replace_callback with nested @import loops.
01845   if (isset($optimize)) {
01846     $_optimize = $optimize;
01847   }
01848
01849   $contents = '';
01850   if (file_exists($file)) {
01851     // Load the local CSS stylesheet.
01852     $contents = file_get_contents($file);
01853
01854     // Change to the current stylesheet's directory.
01855     $cwd = getcwd();
01856     chdir(dirname($file));
01857
01858     // Replaces @import commands with the actual stylesheet content.
01859     // This happens recursively but omits external files.
01860     $contents = preg_replace_callback('/@import\s*(?:url\()?[\'"]?(?![a-z]+:)([^\'"\()]+)[\'"]?\)?;/', '_drupal_load_stylesheet', $contents);
01861     // Remove multiple charset declarations for standards compliance (and fixing Safari problems).
01862     $contents = preg_replace('/^@charset\s+[\'"](\S*)\b[\'"];/i', '', $contents);
01863
01864     if ($_optimize) {
01865       // Perform some safe CSS optimizations.
01866       $contents = preg_replace('<
01867         \s*([@{}:;,]|\)\s|\s\()\s* |  # Remove whitespace around separators, but keep space around parentheses.
01868         /\*([^*\\\\]|\*(?!/))+\*/ |   # Remove comments that are not CSS hacks.
01869         [\n\r]                        # Remove line breaks.
01870         >x', '\1', $contents);
01871     }
01872
01873     // Change back directory.
01874     chdir($cwd);
01875   }
01876
01877   return $contents;
01878 }
01879
01886 function _drupal_load_stylesheet($matches) {
01887   $filename = $matches[1];
01888   // Load the imported stylesheet and replace @import commands in there as well.
01889   $file = drupal_load_stylesheet($filename);
01890   // Alter all url() paths, but not external.
01891   return preg_replace('/url\(([\'"]?)(?![a-z]+:)([^\'")]+)[\'"]?\)?;/i', 'url(\1'. dirname($filename) .'/', $file);
01892 }
01893
01897 function drupal_clear_css_cache() {
01898   file_scan_directory(file_create_path('css'), '.*', array('.', '..', 'CVS'), 'file_delete', TRUE);
01899 }
01900
01957 function drupal_add_js($data = NULL, $type = 'module', $scope = 'header', $defer = FALSE, $cache = TRUE, $preprocess = TRUE) {
01958   static $javascript = array();
01959
01960   if (isset($data)) {
01961
01962     // Add jquery.js and drupal.js, as well as the basePath setting, the
01963     // first time a Javascript file is added.
01964     if (empty($javascript)) {
01965       $javascript['header'] = array(
01966         'core' => array(
01967           'misc/jquery.js' => array('cache' => TRUE, 'defer' => FALSE, 'preprocess' => TRUE),
01968           'misc/drupal.js' => array('cache' => TRUE, 'defer' => FALSE, 'preprocess' => TRUE),
01969         ),
01970         'module' => array(),
01971         'theme' => array(),
01972         'setting' => array(
01973           array('basePath' => base_path()),
01974         ),
01975         'inline' => array(),
01976       );
01977     }
01978
01979     if (isset($scope) && !isset($javascript[$scope])) {
01980       $javascript[$scope] = array('core' => array(), 'module' => array(), 'theme' => array(), 'setting' => array(), 'inline' => array());
01981     }
01982
01983     if (isset($type) && isset($scope) && !isset($javascript[$scope][$type])) {
01984       $javascript[$scope][$type] = array();
01985     }
01986
01987     switch ($type) {
01988       case 'setting':
01989         $javascript[$scope][$type][] = $data;
01990         break;
01991       case 'inline':
01992         $javascript[$scope][$type][] = array('code' => $data, 'defer' => $defer);
01993         break;
01994       default:
01995         // If cache is FALSE, don't preprocess the JS file.
01996         $javascript[$scope][$type][$data] = array('cache' => $cache, 'defer' => $defer, 'preprocess' => (!$cache ? FALSE : $preprocess));
01997     }
01998   }
01999
02000   if (isset($scope)) {
02001
02002     if (isset($javascript[$scope])) {
02003       return $javascript[$scope];
02004     }
02005     else {
02006       return array();
02007     }
02008   }
02009   else {
02010     return $javascript;
02011   }
02012 }
02013
02031 function drupal_get_js($scope = 'header', $javascript = NULL) {
02032   if ((!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') && function_exists('locale_update_js_files')) {
02033     locale_update_js_files();
02034   }
02035
02036   if (!isset($javascript)) {
02037     $javascript = drupal_add_js(NULL, NULL, $scope);
02038   }
02039
02040   if (empty($javascript)) {
02041     return '';
02042   }
02043
02044   $output = '';
02045   $preprocessed = '';
02046   $no_preprocess = array('core' => '', 'module' => '', 'theme' => '');
02047   $files = array();
02048   $preprocess_js = (variable_get('preprocess_js', FALSE) && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update'));
02049   $directory = file_directory_path();
02050   $is_writable = is_dir($directory) && is_writable($directory) && (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC);
02051
02052   // A dummy query-string is added to filenames, to gain control over
02053   // browser-caching. The string changes on every update or full cache
02054   // flush, forcing browsers to load a new copy of the files, as the
02055   // URL changed. Files that should not be cached (see drupal_add_js())
02056   // get time() as query-string instead, to enforce reload on every
02057   // page request.
02058   $query_string = '?'. substr(variable_get('css_js_query_string', '0'), 0, 1);
02059
02060   foreach ($javascript as $type => $data) {
02061
02062     if (!$data) continue;
02063
02064     switch ($type) {
02065       case 'setting':
02066         $output .= '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $data)) .");</script>\n";
02067         break;
02068       case 'inline':
02069         foreach ($data as $info) {
02070           $output .= '<script type="text/javascript"'. ($info['defer'] ? ' defer="defer"' : '') .'>'. $info['code'] ."</script>\n";
02071         }
02072         break;
02073       default:
02074         // If JS preprocessing is off, we still need to output the scripts.
02075         // Additionally, go through any remaining scripts if JS preprocessing is on and output the non-cached ones.
02076         foreach ($data as $path => $info) {
02077           if (!$info['preprocess'] || !$is_writable || !$preprocess_js) {
02078             $no_preprocess[$type] .= '<script type="text/javascript"'. ($info['defer'] ? ' defer="defer"' : '') .' src="'. base_path() . $path . ($info['cache'] ? $query_string : '?'. time()) ."\"></script>\n";
02079           }
02080           else {
02081             $files[$path] = $info;
02082           }
02083         }
02084     }
02085   }
02086
02087   // Aggregate any remaining JS files that haven't already been output.
02088   if ($is_writable && $preprocess_js && count($files) > 0) {
02089     $filename = md5(serialize($files) . $query_string) .'.js';
02090     $preprocess_file = drupal_build_js_cache($files, $filename);
02091     $preprocessed .= '<script type="text/javascript" src="'. base_path() . $preprocess_file .'"></script>'."\n";
02092   }
02093
02094   // Keep the order of JS files consistent as some are preprocessed and others are not.
02095   // Make sure any inline or JS setting variables appear last after libraries have loaded.
02096   $output = $preprocessed . implode('', $no_preprocess) . $output;
02097
02098   return $output;
02099 }
02100
02208 function drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgroup = NULL, $source = NULL, $hidden = TRUE, $limit = 0) {
02209   static $js_added = FALSE;
02210   if (!$js_added) {
02211     drupal_add_js('misc/tabledrag.js', 'core');
02212     $js_added = TRUE;
02213   }
02214
02215   // If a subgroup or source isn't set, assume it is the same as the group.
02216   $target = isset($subgroup) ? $subgroup : $group;
02217   $source = isset($source) ? $source : $target;
02218   $settings['tableDrag'][$table_id][$group][] = array(
02219     'target' => $target,
02220     'source' => $source,
02221     'relationship' => $relationship,
02222     'action' => $action,
02223     'hidden' => $hidden,
02224     'limit' => $limit,
02225   );
02226   drupal_add_js($settings, 'setting');
02227 }
02228
02239 function drupal_build_js_cache($files, $filename) {
02240   $contents = '';
02241
02242   // Create the js/ within the files folder.
02243   $jspath = file_create_path('js');
02244   file_check_directory($jspath, FILE_CREATE_DIRECTORY);
02245
02246   if (!file_exists($jspath .'/'. $filename)) {
02247     // Build aggregate JS file.
02248     foreach ($files as $path => $info) {
02249       if ($info['preprocess']) {
02250         // Append a ';' after each JS file to prevent them from running together.
02251         $contents .= file_get_contents($path) .';';
02252       }
02253     }
02254
02255     // Create the JS file.
02256     file_save_data($contents, $jspath .'/'. $filename, FILE_EXISTS_REPLACE);
02257   }
02258
02259   return $jspath .'/'. $filename;
02260 }
02261
02265 function drupal_clear_js_cache() {
02266   file_scan_directory(file_create_path('js'), '.*', array('.', '..', 'CVS'), 'file_delete', TRUE);
02267   variable_set('javascript_parsed', array());
02268 }
02269
02275 function drupal_to_js($var) {
02276   switch (gettype($var)) {
02277     case 'boolean':
02278       return $var ? 'true' : 'false'; // Lowercase necessary!
02279     case 'integer':
02280     case 'double':
02281       return $var;
02282     case 'resource':
02283     case 'string':
02284       return '"'. str_replace(array("\r", "\n", "<", ">", "&"),
02285                               array('\r', '\n', '\x3c', '\x3e', '\x26'),
02286                               addslashes($var)) .'"';
02287     case 'array':
02288       // Arrays in JSON can't be associative. If the array is empty or if it
02289       // has sequential whole number keys starting with 0, it's not associative
02290       // so we can go ahead and convert it as an array.
02291       if (empty ($var) || array_keys($var) === range(0, sizeof($var) - 1)) {
02292         $output = array();
02293         foreach ($var as $v) {
02294           $output[] = drupal_to_js($v);
02295         }
02296         return '[ '. implode(', ', $output) .' ]';
02297       }
02298       // Otherwise, fall through to convert the array as an object.
02299     case 'object':
02300       $output = array();
02301       foreach ($var as $k => $v) {
02302         $output[] = drupal_to_js(strval($k)) .': '. drupal_to_js($v);
02303       }
02304       return '{ '. implode(', ', $output) .' }';
02305     default:
02306       return 'null';
02307   }
02308 }
02309
02319 function drupal_json($var = NULL) {
02320   // We are returning JavaScript, so tell the browser.
02321   drupal_set_header('Content-Type: text/javascript; charset=utf-8');
02322
02323   if (isset($var)) {
02324     echo drupal_to_js($var);
02325   }
02326 }
02327
02347 function drupal_urlencode($text) {
02348   if (variable_get('clean_url', '0')) {
02349     return str_replace(array('%2F', '%26', '%23', '//'),
02350                        array('/', '%2526', '%2523', '/%252F'),
02351                        rawurlencode($text));
02352   }
02353   else {
02354     return str_replace('%2F', '/', rawurlencode($text));
02355   }
02356 }
02357
02364 function drupal_get_private_key() {
02365   if (!($key = variable_get('drupal_private_key', 0))) {
02366     $key = md5(uniqid(mt_rand(), true)) . md5(uniqid(mt_rand(), true));
02367     variable_set('drupal_private_key', $key);
02368   }
02369   return $key;
02370 }
02371
02378 function drupal_get_token($value = '') {
02379   $private_key = drupal_get_private_key();
02380   return md5(session_id() . $value . $private_key);
02381 }
02382
02396 function drupal_valid_token($token, $value = '', $skip_anonymous = FALSE) {
02397   global $user;
02398   return (($skip_anonymous && $user->uid == 0) || ($token == md5(session_id() . $value . variable_get('drupal_private_key', ''))));
02399 }
02400
02423 function xmlrpc($url) {
02424   require_once './includes/xmlrpc.inc';
02425   $args = func_get_args();
02426   return call_user_func_array('_xmlrpc', $args);
02427 }
02428
02429 function _drupal_bootstrap_full() {
02430   static $called;
02431
02432   if ($called) {
02433     return;
02434   }
02435   $called = 1;
02436   require_once './includes/theme.inc';
02437   require_once './includes/pager.inc';
02438   require_once './includes/menu.inc';
02439   require_once './includes/tablesort.inc';
02440   require_once './includes/file.inc';
02441   require_once './includes/unicode.inc';
02442   require_once './includes/image.inc';
02443   require_once './includes/form.inc';
02444   require_once './includes/mail.inc';
02445   require_once './includes/actions.inc';
02446   // Set the Drupal custom error handler.
02447   set_error_handler('drupal_error_handler');
02448   // Emit the correct charset HTTP header.
02449   drupal_set_header('Content-Type: text/html; charset=utf-8');
02450   // Detect string handling method
02451   unicode_check();
02452   // Undo magic quotes
02453   fix_gpc_magic();
02454   // Load all enabled modules
02455   module_load_all();
02456   // Let all modules take action before menu system handles the request
02457   // We do not want this while running update.php.
02458   if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update') {
02459     module_invoke_all('init');
02460   }
02461 }
02462
02476 function page_set_cache() {
02477   global $user, $base_root;
02478
02479   if (!$user->uid && $_SERVER['REQUEST_METHOD'] == 'GET' && page_get_cache(TRUE)) {
02480     // This will fail in some cases, see page_get_cache() for the explanation.
02481     if ($data = ob_get_contents()) {
02482       $cache = TRUE;
02483       if (variable_get('page_compression', TRUE) && function_exists('gzencode')) {
02484         // We do not store the data in case the zlib mode is deflate.
02485         // This should be rarely happening.
02486         if (zlib_get_coding_type() == 'deflate') {
02487           $cache = FALSE;
02488         }
02489         else if (zlib_get_coding_type() == FALSE) {
02490           $data = gzencode($data, 9, FORCE_GZIP);
02491         }
02492         // The remaining case is 'gzip' which means the data is
02493         // already compressed and nothing left to do but to store it.
02494       }
02495       ob_end_flush();
02496       if ($cache && $data) {
02497         cache_set($base_root . request_uri(), $data, 'cache_page', CACHE_TEMPORARY, drupal_get_headers());
02498       }
02499     }
02500   }
02501 }
02502
02508 function drupal_cron_run() {
02509   // If not in 'safe mode', increase the maximum execution time:
02510   if (!ini_get('safe_mode')) {
02511     set_time_limit(240);
02512   }
02513
02514   // Fetch the cron semaphore
02515   $semaphore = variable_get('cron_semaphore', FALSE);
02516
02517   if ($semaphore) {
02518     if (time() - $semaphore > 3600) {
02519       // Either cron has been running for more than an hour or the semaphore
02520       // was not reset due to a database error.
02521       watchdog('cron', 'Cron has been running for more than an hour and is most likely stuck.', array(), WATCHDOG_ERROR);
02522
02523       // Release cron semaphore
02524       variable_del('cron_semaphore');
02525     }
02526     else {
02527       // Cron is still running normally.
02528       watchdog('cron', 'Attempting to re-run cron while it is already running.', array(), WATCHDOG_WARNING);
02529     }
02530   }
02531   else {
02532     // Register shutdown callback
02533     register_shutdown_function('drupal_cron_cleanup');
02534
02535     // Lock cron semaphore
02536     variable_set('cron_semaphore', time());
02537
02538     // Iterate through the modules calling their cron handlers (if any):
02539     module_invoke_all('cron');
02540
02541     // Record cron time
02542     variable_set('cron_last', time());
02543     watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE);
02544
02545     // Release cron semaphore
02546     variable_del('cron_semaphore');
02547
02548     // Return TRUE so other functions can check if it did run successfully
02549     return TRUE;
02550   }
02551 }
02552
02556 function drupal_cron_cleanup() {
02557   // See if the semaphore is still locked.
02558   if (variable_get('cron_semaphore', FALSE)) {
02559     watchdog('cron', 'Cron run exceeded the time limit and was aborted.', array(), WATCHDOG_WARNING);
02560
02561     // Release cron semaphore
02562     variable_del('cron_semaphore');
02563   }
02564 }
02565
02593 function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) {
02594   global $profile;
02595   $config = conf_path();
02596
02597   // When this function is called during Drupal's initial installation process,
02598   // the name of the profile that's about to be installed is stored in the global
02599   // $profile variable. At all other times, the standard Drupal systems variable
02600   // table contains the name of the current profile, and we can call variable_get()
02601   // to determine what one is active.
02602   if (!isset($profile)) {
02603     $profile = variable_get('install_profile', 'default');
02604   }
02605   $searchdir = array($directory);
02606   $files = array();
02607
02608   // Always search sites/all/* as well as the global directories
02609   $searchdir[] = 'sites/all/'. $directory;
02610
02611   // The 'profiles' directory contains pristine collections of modules and
02612   // themes as organized by a distribution.  It is pristine in the same way
02613   // that /modules is pristine for core; users should avoid changing anything
02614   // there in favor of sites/all or sites/<domain> directories.
02615   if (file_exists("profiles/$profile/$directory")) {
02616     $searchdir[] = "profiles/$profile/$directory";
02617   }
02618
02619   if (file_exists("$config/$directory")) {
02620     $searchdir[] = "$config/$directory";
02621   }
02622
02623   // Get current list of items
02624   foreach ($searchdir as $dir) {
02625     $files = array_merge($files, file_scan_directory($dir, $mask, array('.', '..', 'CVS'), 0, TRUE, $key, $min_depth));
02626   }
02627
02628   return $files;
02629 }
02630
02631
02646 function drupal_alter($type, &$data) {
02647   // PHP's func_get_args() always returns copies of params, not references, so
02648   // drupal_alter() can only manipulate data that comes in via the required first
02649   // param. For the edge case functions that must pass in an arbitrary number of
02650   // alterable parameters (hook_form_alter() being the best example), an array of
02651   // those params can be placed in the __drupal_alter_by_ref key of the $data
02652   // array. This is somewhat ugly, but is an unavoidable consequence of a flexible
02653   // drupal_alter() function, and the limitations of func_get_args().
02654   // @todo: Remove this in Drupal 7.
02655   if (is_array($data) && isset($data['__drupal_alter_by_ref'])) {
02656     $by_ref_parameters = $data['__drupal_alter_by_ref'];
02657     unset($data['__drupal_alter_by_ref']);
02658   }
02659
02660   // Hang onto a reference to the data array so that it isn't blown away later.
02661   // Also, merge in any parameters that need to be passed by reference.
02662   $args = array(&$data);
02663   if (isset($by_ref_parameters)) {
02664     $args = array_merge($args, $by_ref_parameters);
02665   }
02666
02667   // Now, use func_get_args() to pull in any additional parameters passed into
02668   // the drupal_alter() call.
02669   $additional_args = func_get_args();
02670   array_shift($additional_args);
02671   array_shift($additional_args);
02672   $args = array_merge($args, $additional_args);
02673
02674   foreach (module_implements($type .'_alter') as $module) {
02675     $function = $module .'_'. $type .'_alter';
02676     call_user_func_array($function, $args);
02677   }
02678 }
02679
02680
02693 function drupal_render(&$elements) {
02694   if (!isset($elements) || (isset($elements['#access']) && !$elements['#access'])) {
02695     return NULL;
02696   }
02697
02698   // If the default values for this element haven't been loaded yet, populate
02699   // them.
02700   if (!isset($elements['#defaults_loaded']) || !$elements['#defaults_loaded']) {
02701     if ((!empty($elements['#type'])) && ($info = _element_info($elements['#type']))) {
02702       $elements += $info;
02703     }
02704   }
02705
02706   // Make any final changes to the element before it is rendered. This means
02707   // that the $element or the children can be altered or corrected before the
02708   // element is rendered into the final text.
02709   if (isset($elements['#pre_render'])) {
02710     foreach ($elements['#pre_render'] as $function) {
02711       if (function_exists($function)) {
02712         $elements = $function($elements);
02713       }
02714     }
02715   }
02716
02717   $content = '';
02718   // Either the elements did not go through form_builder or one of the children
02719   // has a #weight.
02720   if (!isset($elements['#sorted'])) {
02721     uasort($elements, "element_sort");
02722   }
02723   $elements += array('#title' => NULL, '#description' => NULL);
02724   if (!isset($elements['#children'])) {
02725     $children = element_children($elements);
02726     /* Render all the children that use a theme function */
02727     if (isset($elements['#theme']) && empty($elements['#theme_used'])) {
02728       $elements['#theme_used'] = TRUE;
02729
02730       $previous = array();
02731       foreach (array('#value', '#type', '#prefix', '#suffix') as $key) {
02732         $previous[$key] = isset($elements[$key]) ? $elements[$key] : NULL;
02733       }
02734       // If we rendered a single element, then we will skip the renderer.
02735       if (empty($children)) {
02736         $elements['#printed'] = TRUE;
02737       }
02738       else {
02739         $elements['#value'] = '';
02740       }
02741       $elements['#type'] = 'markup';
02742
02743       unset($elements['#prefix'], $elements['#suffix']);
02744       $content = theme($elements['#theme'], $elements);
02745
02746       foreach (array('#value', '#type', '#prefix', '#suffix') as $key) {
02747         $elements[$key] = isset($previous[$key]) ? $previous[$key] : NULL;
02748       }
02749     }
02750     /* render each of the children using drupal_render and concatenate them */
02751     if (!isset($content) || $content === '') {
02752       foreach ($children as $key) {
02753         $content .= drupal_render($elements[$key]);
02754       }
02755     }
02756   }
02757   if (isset($content) && $content !== '') {
02758     $elements['#children'] = $content;
02759   }
02760
02761   // Until now, we rendered the children, here we render the element itself
02762   if (!isset($elements['#printed'])) {
02763     $content = theme(!empty($elements['#type']) ? $elements['#type'] : 'markup', $elements);
02764     $elements['#printed'] = TRUE;
02765   }
02766
02767   if (isset($content) && $content !== '') {
02768     // Filter the outputted content and make any last changes before the
02769     // content is sent to the browser. The changes are made on $content
02770     // which allows the output'ed text to be filtered.
02771     if (isset($elements['#post_render'])) {
02772       foreach ($elements['#post_render'] as $function) {
02773         if (function_exists($function)) {
02774           $content = $function($content, $elements);
02775         }
02776       }
02777     }
02778     $prefix = isset($elements['#prefix']) ? $elements['#prefix'] : '';
02779     $suffix = isset($elements['#suffix']) ? $elements['#suffix'] : '';
02780     return $prefix . $content . $suffix;
02781   }
02782 }
02783
02787 function element_sort($a, $b) {
02788   $a_weight = (is_array($a) && isset($a['#weight'])) ? $a['#weight'] : 0;
02789   $b_weight = (is_array($b) && isset($b['#weight'])) ? $b['#weight'] : 0;
02790   if ($a_weight == $b_weight) {
02791     return 0;
02792   }
02793   return ($a_weight < $b_weight) ? -1 : 1;
02794 }
02795
02799 function element_property($key) {
02800   return $key[0] == '#';
02801 }
02802
02806 function element_properties($element) {
02807   return array_filter(array_keys((array) $element), 'element_property');
02808 }
02809
02813 function element_child($key) {
02814   return !isset($key[0]) || $key[0] != '#';
02815 }
02816
02820 function element_children($element) {
02821   return array_filter(array_keys((array) $element), 'element_child');
02822 }
02823
02827 function drupal_common_theme() {
02828   return array(
02829     // theme.inc
02830     'placeholder' => array(
02831       'arguments' => array('text' => NULL)
02832     ),
02833     'page' => array(
02834       'arguments' => array('content' => NULL, 'show_blocks' => TRUE, 'show_messages' => TRUE),
02835       'template' => 'page',
02836     ),
02837     'maintenance_page' => array(
02838       'arguments' => array('content' => NULL, 'show_blocks' => TRUE, 'show_messages' => TRUE),
02839       'template' => 'maintenance-page',
02840     ),
02841     'update_page' => array(
02842       'arguments' => array('content' => NULL, 'show_messages' => TRUE),
02843     ),
02844     'install_page' => array(
02845       'arguments' => array('content' => NULL),
02846     ),
02847     'task_list' => array(
02848       'arguments' => array('items' => NULL, 'active' => NULL),
02849     ),
02850     'status_messages' => array(
02851       'arguments' => array('display' => NULL),
02852     ),
02853     'links' => array(
02854       'arguments' => array('links' => NULL, 'attributes' => array('class' => 'links')),
02855     ),
02856     'image' => array(
02857       'arguments' => array('path' => NULL, 'alt' => '', 'title' => '', 'attributes' => NULL, 'getsize' => TRUE),
02858     ),
02859     'breadcrumb' => array(
02860       'arguments' => array('breadcrumb' => NULL),
02861     ),
02862     'help' => array(
02863       'arguments' => array(),
02864     ),
02865     'submenu' => array(
02866       'arguments' => array('links' => NULL),
02867     ),
02868     'table' => array(
02869       'arguments' => array('header' => NULL, 'rows' => NULL, 'attributes' => array(), 'caption' => NULL),
02870     ),
02871     'table_select_header_cell' => array(
02872       'arguments' => array(),
02873     ),
02874     'tablesort_indicator' => array(
02875       'arguments' => array('style' => NULL),
02876     ),
02877     'box' => array(
02878       'arguments' => array('title' => NULL, 'content' => NULL, 'region' => 'main'),
02879       'template' => 'box',
02880     ),
02881     'block' => array(
02882       'arguments' => array('block' => NULL),
02883       'template' => 'block',
02884     ),
02885     'mark' => array(
02886       'arguments' => array('type' => MARK_NEW),
02887     ),
02888     'item_list' => array(
02889       'arguments' => array('items' => array(), 'title' => NULL, 'type' => 'ul', 'attributes' => NULL),
02890     ),
02891     'more_help_link' => array(
02892       'arguments' => array('url' => NULL),
02893     ),
02894     'xml_icon' => array(
02895       'arguments' => array('url' => NULL),
02896     ),
02897     'feed_icon' => array(
02898       'arguments' => array('url' => NULL, 'title' => NULL),
02899     ),
02900     'more_link' => array(
02901       'arguments' => array('url' => NULL, 'title' => NULL)
02902     ),
02903     'closure' => array(
02904       'arguments' => array('main' => 0),
02905     ),
02906     'blocks' => array(
02907       'arguments' => array('region' => NULL),
02908     ),
02909     'username' => array(
02910       'arguments' => array('object' => NULL),
02911     ),
02912     'progress_bar' => array(
02913       'arguments' => array('percent' => NULL, 'message' => NULL),
02914     ),
02915     'indentation' => array(
02916       'arguments' => array('size' => 1),
02917     ),
02918     // from pager.inc
02919     'pager' => array(
02920       'arguments' => array('tags' => array(), 'limit' => 10, 'element' => 0, 'parameters' => array()),
02921     ),
02922     'pager_first' => array(
02923       'arguments' => array('text' => NULL, 'limit' => NULL, 'element' => 0, 'parameters' => array()),
02924     ),
02925     'pager_previous' => array(
02926       'arguments' => array('text' => NULL, 'limit' => NULL, 'element' => 0, 'interval' => 1, 'parameters' => array()),
02927     ),
02928     'pager_next' => array(
02929       'arguments' => array('text' => NULL, 'limit' => NULL, 'element' => 0, 'interval' => 1, 'parameters' => array()),
02930     ),
02931     'pager_last' => array(
02932       'arguments' => array('text' => NULL, 'limit' => NULL, 'element' => 0, 'parameters' => array()),
02933     ),
02934     'pager_link' => array(
02935       'arguments' => array('text' => NULL, 'page_new' => NULL, 'element' => NULL, 'parameters' => array(), 'attributes' => array()),
02936     ),
02937     // from locale.inc
02938     'locale_admin_manage_screen' => array(
02939       'arguments' => array('form' => NULL),
02940     ),
02941     // from menu.inc
02942     'menu_item_link' => array(
02943       'arguments' => array('item' => NULL),
02944     ),
02945     'menu_tree' => array(
02946       'arguments' => array('tree' => NULL),
02947     ),
02948     'menu_item' => array(
02949       'arguments' => array('link' => NULL, 'has_children' => NULL, 'menu' => ''),
02950     ),
02951     'menu_local_task' => array(
02952       'arguments' => array('link' => NULL, 'active' => FALSE),
02953     ),
02954     'menu_local_tasks' => array(
02955       'arguments' => array(),
02956     ),
02957     // from form.inc
02958     'select' => array(
02959       'arguments' => array('element' => NULL),
02960     ),
02961     'fieldset' => array(
02962       'arguments' => array('element' => NULL),
02963     ),
02964     'radio' => array(
02965       'arguments' => array('element' => NULL),
02966     ),
02967     'radios' => array(
02968       'arguments' => array('element' => NULL),
02969     ),
02970     'password_confirm' => array(
02971       'arguments' => array('element' => NULL),
02972     ),
02973     'date' => array(
02974       'arguments' => array('element' => NULL),
02975     ),
02976     'item' => array(
02977       'arguments' => array('element' => NULL),
02978     ),
02979     'checkbox' => array(
02980       'arguments' => array('element' => NULL),
02981     ),
02982     'checkboxes' => array(
02983       'arguments' => array('element' => NULL),
02984     ),
02985     'submit' => array(
02986       'arguments' => array('element' => NULL),
02987     ),
02988     'button' => array(
02989       'arguments' => array('element' => NULL),
02990     ),
02991     'image_button' => array(
02992       'arguments' => array('element' => NULL),
02993     ),
02994     'hidden' => array(
02995       'arguments' => array('element' => NULL),
02996     ),
02997     'token' => array(
02998       'arguments' => array('element' => NULL),
02999     ),
03000     'textfield' => array(
03001       'arguments' => array('element' => NULL),
03002     ),
03003     'form' => array(
03004       'arguments' => array('element' => NULL),
03005     ),
03006     'textarea' => array(
03007       'arguments' => array('element' => NULL),
03008     ),
03009     'markup' => array(
03010       'arguments' => array('element' => NULL),
03011     ),
03012     'password' => array(
03013       'arguments' => array('element' => NULL),
03014     ),
03015     'file' => array(
03016       'arguments' => array('element' => NULL),
03017     ),
03018     'form_element' => array(
03019       'arguments' => array('element' => NULL, 'value' => NULL),
03020     ),
03021   );
03022 }
03023
03040 function drupal_get_schema($table = NULL, $rebuild = FALSE) {
03041   static $schema = array();
03042
03043   if (empty($schema) || $rebuild) {
03044     // Try to load the schema from cache.
03045     if (!$rebuild && $cached = cache_get('schema')) {
03046       $schema = $cached->data;
03047     }
03048     // Otherwise, rebuild the schema cache.
03049     else {
03050       $schema = array();
03051       // Load the .install files to get hook_schema.
03052       module_load_all_includes('install');
03053
03054       // Invoke hook_schema for all modules.
03055       foreach (module_implements('schema') as $module) {
03056         $current = module_invoke($module, 'schema');
03057         _drupal_initialize_schema($module, $current);
03058         $schema = array_merge($schema, $current);
03059       }
03060
03061       drupal_alter('schema', $schema);
03062       cache_set('schema', $schema);
03063     }
03064   }
03065
03066   if (!isset($table)) {
03067     return $schema;
03068   }
03069   elseif (isset($schema[$table])) {
03070     return $schema[$table];
03071   }
03072   else {
03073     return FALSE;
03074   }
03075 }
03076
03091 function drupal_install_schema($module) {
03092   $schema = drupal_get_schema_unprocessed($module);
03093   _drupal_initialize_schema($module, $schema);
03094
03095   $ret = array();
03096   foreach ($schema as $name => $table) {
03097     db_create_table($ret, $name, $table);
03098   }
03099   return $ret;
03100 }
03101
03116 function drupal_uninstall_schema($module) {
03117   $schema = drupal_get_schema_unprocessed($module);
03118   _drupal_initialize_schema($module, $schema);
03119
03120   $ret = array();
03121   foreach ($schema as $table) {
03122     db_drop_table($ret, $table['name']);
03123   }
03124   return $ret;
03125 }
03126
03151 function drupal_get_schema_unprocessed($module, $table = NULL) {
03152   // Load the .install file to get hook_schema.
03153   module_load_include('install', $module);
03154   $schema = module_invoke($module, 'schema');
03155
03156   if (!is_null($table) && isset($schema[$table])) {
03157     return $schema[$table];
03158   }
03159   else {
03160     return $schema;
03161   }
03162 }
03163
03173 function _drupal_initialize_schema($module, &$schema) {
03174   // Set the name and module key for all tables.
03175   foreach ($schema as $name => $table) {
03176     if (empty($table['module'])) {
03177       $schema[$name]['module'] = $module;
03178     }
03179     if (!isset($table['name'])) {
03180       $schema[$name]['name'] = $name;
03181     }
03182   }
03183 }
03184
03195 function drupal_schema_fields_sql($table, $prefix = NULL) {
03196   $schema = drupal_get_schema($table);
03197   $fields = array_keys($schema['fields']);
03198   if ($prefix) {
03199     $columns = array();
03200     foreach ($fields as $field) {
03201       $columns[] = "$prefix.$field";
03202     }
03203     return $columns;
03204   }
03205   else {
03206     return $fields;
03207   }
03208 }
03209
03233 function drupal_write_record($table, &$object, $update = array()) {
03234   // Standardize $update to an array.
03235   if (is_string($update)) {
03236     $update = array($update);
03237   }
03238
03239   // Convert to an object if needed.
03240   if (is_array($object)) {
03241     $object = (object) $object;
03242     $array = TRUE;
03243   }
03244   else {
03245     $array = FALSE;
03246   }
03247
03248   $schema = drupal_get_schema($table);
03249   if (empty($schema)) {
03250     return FALSE;
03251   }
03252
03253   $fields = $defs = $values = $serials = $placeholders = array();
03254
03255   // Go through our schema, build SQL, and when inserting, fill in defaults for
03256   // fields that are not set.
03257   foreach ($schema['fields'] as $field => $info) {
03258     // Special case -- skip serial types if we are updating.
03259     if ($info['type'] == 'serial' && count($update)) {
03260       continue;
03261     }
03262
03263     // For inserts, populate defaults from Schema if not already provided
03264     if (!isset($object->$field) && !count($update) && isset($info['default'])) {
03265       $object->$field = $info['default'];
03266     }
03267
03268     // Track serial fields so we can helpfully populate them after the query.
03269     if ($info['type'] == 'serial') {
03270       $serials[] = $field;
03271       // Ignore values for serials when inserting data. Unsupported.
03272       unset($object->$field);
03273     }
03274
03275     // Build arrays for the fields, placeholders, and values in our query.
03276     if (isset($object->$field)) {
03277       $fields[] = $field;
03278       $placeholders[] = db_type_placeholder($info['type']);
03279
03280       if (empty($info['serialize'])) {
03281         $values[] = $object->$field;
03282       }
03283       else {
03284         $values[] = serialize($object->$field);
03285       }
03286     }
03287   }
03288
03289   // Build the SQL.
03290   $query = '';
03291   if (!count($update)) {
03292     $query = "INSERT INTO {". $table ."} (". implode(', ', $fields) .') VALUES ('. implode(', ', $placeholders) .')';
03293     $return = SAVED_NEW;
03294   }
03295   else {
03296     $query = '';
03297     foreach ($fields as $id => $field) {
03298       if ($query) {
03299         $query .= ', ';
03300       }
03301       $query .= $field .' = '. $placeholders[$id];
03302     }
03303
03304     foreach ($update as $key){
03305       $conditions[] = "$key = ". db_type_placeholder($schema['fields'][$key]['type']);
03306       $values[] = $object->$key;
03307     }
03308
03309     $query = "UPDATE {". $table ."} SET $query WHERE ". implode(' AND ', $conditions);
03310     $return = SAVED_UPDATED;
03311   }
03312
03313   // Execute the SQL.
03314   if (db_query($query, $values)) {
03315     if ($serials) {
03316       // Get last insert ids and fill them in.
03317       foreach ($serials as $field) {
03318         $object->$field = db_last_insert_id($table, $field);
03319       }
03320     }
03321
03322     // If we began with an array, convert back so we don't surprise the caller.
03323     if ($array) {
03324       $object = (array) $object;
03325     }
03326
03327     return $return;
03328   }
03329
03330   return FALSE;
03331 }
03332
03396 function drupal_parse_info_file($filename) {
03397   $info = array();
03398
03399   if (!file_exists($filename)) {
03400     return $info;
03401   }
03402
03403   $data = file_get_contents($filename);
03404   if (preg_match_all('
03405     @^\s*                           # Start at the beginning of a line, ignoring leading whitespace
03406     ((?:
03407       [^=;\[\]]|                    # Key names cannot contain equal signs, semi-colons or square brackets,
03408       \[[^\[\]]*\]                  # unless they are balanced and not nested
03409     )+?)
03410     \s*=\s*                         # Key/value pairs are separated by equal signs (ignoring white-space)
03411     (?:
03412       ("(?:[^"]|(?<=\\\\)")*")|     # Double-quoted string, which may contain slash-escaped quotes/slashes
03413       (\'(?:[^\']|(?<=\\\\)\')*\')| # Single-quoted string, which may contain slash-escaped quotes/slashes
03414       ([^\r\n]*?)                   # Non-quoted string
03415     )\s*$                           # Stop at the next end of a line, ignoring trailing whitespace
03416     @msx', $data, $matches, PREG_SET_ORDER)) {
03417     foreach ($matches as $match) {
03418       // Fetch the key and value string
03419       $i = 0;
03420       foreach (array('key', 'value1', 'value2', 'value3') as $var) {
03421         $$var = isset($match[++$i]) ? $match[$i] : '';
03422       }
03423       $value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3;
03424
03425       // Parse array syntax
03426       $keys = preg_split('/\]?\[/', rtrim($key, ']'));
03427       $last = array_pop($keys);
03428       $parent = &$info;
03429
03430       // Create nested arrays
03431       foreach ($keys as $key) {
03432         if ($key == '') {
03433           $key = count($parent);
03434         }
03435         if (!isset($parent[$key]) || !is_array($parent[$key])) {
03436           $parent[$key] = array();
03437         }
03438         $parent = &$parent[$key];
03439       }
03440
03441       // Handle PHP constants
03442       if (defined($value)) {
03443         $value = constant($value);
03444       }
03445
03446       // Insert actual value
03447       if ($last == '') {
03448         $last = count($parent);
03449       }
03450       $parent[$last] = $value;
03451     }
03452   }
03453
03454   return $info;
03455 }
03456
03463 function watchdog_severity_levels() {
03464   return array(
03465     WATCHDOG_EMERG    => t('emergency'),
03466     WATCHDOG_ALERT    => t('alert'),
03467     WATCHDOG_CRITICAL => t('critical'),
03468     WATCHDOG_ERROR    => t('error'),
03469     WATCHDOG_WARNING  => t('warning'),
03470     WATCHDOG_NOTICE   => t('notice'),
03471     WATCHDOG_INFO     => t('info'),
03472     WATCHDOG_DEBUG    => t('debug'),
03473   );
03474 }
03475
03476
03480 function drupal_explode_tags($tags) {
03481   // This regexp allows the following types of user input:
03482   // this, "somecompany, llc", "and ""this"" w,o.rks", foo bar
03483   $regexp = '%(?:^|,\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x';
03484   preg_match_all($regexp, $tags, $matches);
03485   $typed_tags = array_unique($matches[1]);
03486
03487   $tags = array();
03488   foreach ($typed_tags as $tag) {
03489     // If a user has escaped a term (to demonstrate that it is a group,
03490     // or includes a comma or quote character), we remove the escape
03491     // formatting so to save the term into the database as the user intends.
03492     $tag = trim(str_replace('""', '"', preg_replace('/^"(.*)"$/', '\1', $tag)));
03493     if ($tag != "") {
03494       $tags[] = $tag;
03495     }
03496   }
03497
03498   return $tags;
03499 }
03500
03504 function drupal_implode_tags($tags) {
03505   $encoded_tags = array();
03506   foreach ($tags as $tag) {
03507     // Commas and quotes in tag names are special cases, so encode them.
03508     if (strpos($tag, ',') !== FALSE || strpos($tag, '"') !== FALSE) {
03509       $tag = '"'. str_replace('"', '""', $tag) .'"';
03510     }
03511
03512     $encoded_tags[] = $tag;
03513   }
03514   return implode(', ', $encoded_tags);
03515 }
03516
03523 function drupal_flush_all_caches() {
03524   // Change query-strings on css/js files to enforce reload for all users.
03525   _drupal_flush_css_js();
03526
03527   drupal_clear_css_cache();
03528   drupal_clear_js_cache();
03529   drupal_rebuild_theme_registry();
03530   menu_rebuild();
03531   node_types_rebuild();
03532   // Don't clear cache_form - in-progress form submissions may break.
03533   // Ordered so clearing the page cache will always be the last action.
03534   $core = array('cache', 'cache_block', 'cache_filter', 'cache_page');
03535   $cache_tables = array_merge(module_invoke_all('flush_caches'), $core);
03536   foreach ($cache_tables as $table) {
03537     cache_clear_all('*', $table, TRUE);
03538   }
03539 }
03540
03550 function _drupal_flush_css_js() {
03551   $string_history = variable_get('css_js_query_string', '00000000000000000000');
03552   $new_character = $string_history[0];
03553   $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
03554   while (strpos($string_history, $new_character) !== FALSE) {
03555     $new_character = $characters[mt_rand(0, strlen($characters) - 1)];
03556   }
03557   variable_set('css_js_query_string', $new_character . substr($string_history, 0, 19));
03558 }
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/contact/contact.admin.inc Source File

modules » contact

contact.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: contact.admin.inc,v 1.3 2007/11/09 07:55:13 dries Exp $
00003
00012 function contact_admin_categories() {
00013   $result = db_query('SELECT cid, category, recipients, selected FROM {contact} ORDER BY weight, category');
00014   $rows = array();
00015   while ($category = db_fetch_object($result)) {
00016     $rows[] = array($category->category, $category->recipients, ($category->selected ? t('Yes') : t('No')), l(t('edit'), 'admin/build/contact/edit/'. $category->cid), l(t('delete'), 'admin/build/contact/delete/'. $category->cid));
00017   }
00018   $header = array(t('Category'), t('Recipients'), t('Selected'), array('data' => t('Operations'), 'colspan' => 2));
00019
00020   return theme('table', $header, $rows);
00021 }
00022
00026 function contact_admin_edit($form_state = array(), $op, $contact = NULL) {
00027
00028   if (empty($contact) || $op == 'add') {
00029     $contact = array(
00030       'category' => '',
00031       'recipients' => '',
00032       'reply' => '',
00033       'weight' => 0,
00034       'selected' => 0,
00035       'cid' => NULL,
00036     );
00037   }
00038   $form['contact_op'] = array('#type' => 'value', '#value' => $op);
00039   $form['category'] = array('#type' => 'textfield',
00040     '#title' => t('Category'),
00041     '#maxlength' => 255,
00042     '#default_value' => $contact['category'],
00043     '#description' => t("Example: 'website feedback' or 'product information'."),
00044     '#required' => TRUE,
00045   );
00046   $form['recipients'] = array('#type' => 'textarea',
00047     '#title' => t('Recipients'),
00048     '#default_value' => $contact['recipients'],
00049     '#description' => t("Example: 'webmaster@example.com' or 'sales@example.com,support@example.com'. To specify multiple recipients, separate each e-mail address with a comma."),
00050     '#required' => TRUE,
00051   );
00052   $form['reply'] = array('#type' => 'textarea',
00053     '#title' => t('Auto-reply'),
00054     '#default_value' => $contact['reply'],
00055     '#description' => t('Optional auto-reply. Leave empty if you do not want to send the user an auto-reply message.'),
00056   );
00057   $form['weight'] = array('#type' => 'weight',
00058     '#title' => t('Weight'),
00059     '#default_value' => $contact['weight'],
00060     '#description' => t('When listing categories, those with lighter (smaller) weights get listed before categories with heavier (larger) weights. Categories with equal weights are sorted alphabetically.'),
00061   );
00062   $form['selected'] = array('#type' => 'select',
00063     '#title' => t('Selected'),
00064     '#options' => array('0' => t('No'), '1' => t('Yes')),
00065     '#default_value' => $contact['selected'],
00066     '#description' => t('Set this to <em>Yes</em> if you would like this category to be selected by default.'),
00067   );
00068   $form['cid'] = array('#type' => 'value',
00069     '#value' => $contact['cid'],
00070   );
00071   $form['submit'] = array('#type' => 'submit',
00072     '#value' => t('Save'),
00073   );
00074
00075   return $form;
00076 }
00077
00081 function contact_admin_edit_validate($form, &$form_state) {
00082   if (empty($form_state['values']['category'])) {
00083     form_set_error('category', t('You must enter a category.'));
00084   }
00085   if (empty($form_state['values']['recipients'])) {
00086     form_set_error('recipients', t('You must enter one or more recipients.'));
00087   }
00088   else {
00089     $recipients = explode(',', $form_state['values']['recipients']);
00090     foreach ($recipients as $recipient) {
00091       if (!valid_email_address(trim($recipient))) {
00092         form_set_error('recipients', t('%recipient is an invalid e-mail address.', array('%recipient' => $recipient)));
00093       }
00094     }
00095   }
00096 }
00097
00101 function contact_admin_edit_submit($form, &$form_state) {
00102   if ($form_state['values']['selected']) {
00103     // Unselect all other contact categories.
00104     db_query('UPDATE {contact} SET selected = 0');
00105   }
00106   $recipients = explode(',', $form_state['values']['recipients']);
00107   foreach ($recipients as $key => $recipient) {
00108     // E-mail address validation has already been done in _validate.
00109     $recipients[$key] = trim($recipient);
00110   }
00111   $form_state['values']['recipients'] = implode(',', $recipients);
00112   if (empty($form_state['values']['cid']) || $form_state['values']['contact_op'] == 'add') {
00113     drupal_write_record('contact', $form_state['values']);
00114     drupal_set_message(t('Category %category has been added.', array('%category' => $form_state['values']['category'])));
00115     watchdog('mail', 'Contact form: category %category added.', array('%category' => $form_state['values']['category']), WATCHDOG_NOTICE, l(t('view'), 'admin/build/contact'));
00116
00117   }
00118   else {
00119     drupal_write_record('contact', $form_state['values'], 'cid');
00120     drupal_set_message(t('Category %category has been updated.', array('%category' => $form_state['values']['category'])));
00121     watchdog('mail', 'Contact form: category %category updated.', array('%category' => $form_state['values']['category']), WATCHDOG_NOTICE, l(t('view'), 'admin/build/contact'));
00122   }
00123
00124   $form_state['redirect'] = 'admin/build/contact';
00125   return;
00126 }
00127
00131 function contact_admin_delete(&$form_state, $contact) {
00132
00133   $form['contact'] = array(
00134     '#type' => 'value',
00135     '#value' => $contact,
00136   );
00137
00138   return confirm_form($form, t('Are you sure you want to delete %category?', array('%category' => $contact['category'])), 'admin/build/contact', t('This action cannot be undone.'), t('Delete'), t('Cancel'));
00139 }
00140
00144 function contact_admin_delete_submit($form, &$form_state) {
00145   $contact = $form_state['values']['contact'];
00146   db_query("DELETE FROM {contact} WHERE cid = %d", $contact['cid']);
00147   drupal_set_message(t('Category %category has been deleted.', array('%category' => $contact['category'])));
00148   watchdog('mail', 'Contact form: category %category deleted.', array('%category' => $contact['category']), WATCHDOG_NOTICE);
00149
00150   $form_state['redirect'] = 'admin/build/contact';
00151   return;
00152 }
00153
00154 function contact_admin_settings() {
00155   $form['contact_form_information'] = array('#type' => 'textarea',
00156     '#title' => t('Additional information'),
00157     '#default_value' => variable_get('contact_form_information', t('You can leave a message using the contact form below.')),
00158     '#description' => t('Information to show on the <a href="@form">contact page</a>. Can be anything from submission guidelines to your postal address or telephone number.', array('@form' => url('contact'))),
00159   );
00160   $form['contact_hourly_threshold'] = array('#type' => 'select',
00161     '#title' => t('Hourly threshold'),
00162     '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50)),
00163     '#default_value' => variable_get('contact_hourly_threshold', 3),
00164     '#description' => t('The maximum number of contact form submissions a user can perform per hour.'),
00165   );
00166   $form['contact_default_status'] = array(
00167     '#type' => 'checkbox',
00168     '#title' => t('Enable personal contact form by default'),
00169     '#default_value' => variable_get('contact_default_status', 1),
00170     '#description' => t('Default status of the personal contact form for new users.'),
00171   );
00172   return system_settings_form($form);
00173 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/contact/contact.install Source File

modules » contact

contact.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: contact.install,v 1.10 2007/12/18 12:59:21 dries Exp $
00003
00007 function contact_install() {
00008   // Create tables.
00009   drupal_install_schema('contact');
00010 }
00011
00015 function contact_uninstall() {
00016   // Remove tables.
00017   drupal_uninstall_schema('contact');
00018
00019   variable_del('contact_default_status');
00020   variable_del('contact_form_information');
00021   variable_del('contact_hourly_threshold');
00022 }
00023
00027 function contact_schema() {
00028   $schema['contact'] = array(
00029     'description' => t('Contact form category settings.'),
00030     'fields' => array(
00031       'cid' => array(
00032         'type' => 'serial',
00033         'unsigned' => TRUE,
00034         'not null' => TRUE,
00035         'description' => t('Primary Key: Unique category ID.'),
00036       ),
00037       'category' => array(
00038         'type' => 'varchar',
00039         'length' => 255,
00040         'not null' => TRUE,
00041         'default' => '',
00042         'description' => t('Category name.'),
00043       ),
00044       'recipients' => array(
00045         'type' => 'text',
00046         'not null' => TRUE,
00047         'size' => 'big',
00048         'description' => t('Comma-separated list of recipient e-mail addresses.'),
00049       ),
00050       'reply' => array(
00051         'type' => 'text',
00052         'not null' => TRUE,
00053         'size' => 'big',
00054         'description' => t('Text of the auto-reply message.'),
00055       ),
00056       'weight' => array(
00057         'type' => 'int',
00058         'not null' => TRUE,
00059         'default' => 0,
00060         'size' => 'tiny',
00061         'description' => t("The category's weight."),
00062       ),
00063       'selected' => array(
00064         'type' => 'int',
00065         'not null' => TRUE,
00066         'default' => 0,
00067         'size' => 'tiny',
00068         'description' => t('Flag to indicate whether or not category is selected by default. (1 = Yes, 0 = No)'),
00069       ),
00070     ),
00071     'primary key' => array('cid'),
00072     'unique keys' => array(
00073       'category' => array('category'),
00074     ),
00075     'indexes' => array(
00076       'list' => array('weight', 'category'),
00077     ),
00078   );
00079
00080   return $schema;
00081 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/contact/contact.module Source File

modules » contact

contact.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: contact.module,v 1.103 2008/01/16 12:46:52 goba Exp $
00003
00012 function contact_help($path, $arg) {
00013   switch ($path) {
00014     case 'admin/help#contact':
00015       $output = '<p>'. t('The contact module facilitates communication via e-mail, by allowing your site\'s visitors to contact one another (personal contact forms), and by providing a simple way to direct messages to a set of administrator-defined recipients (the <a href="@contact">contact page</a>). With either form, users specify a subject, write their message, and (optionally) have a copy of their message sent to their own e-mail address.', array('@contact' => url('contact'))) .'</p>';
00016       $output .= '<p>'. t("Personal contact forms allow users to be contacted via e-mail, while keeping recipient e-mail addresses private. Users may enable or disable their personal contact forms by editing their <em>My account</em> page. If enabled, a <em>Contact</em> tab leading to their personal contact form is available on their user profile. Site administrators have access to all personal contact forms (even if they have been disabled). The <em>Contact</em> tab is only visible when viewing another user's profile (users do not see their own <em>Contact</em> tab).") .'</p>';
00017       $output .= '<p>'. t('The <a href="@contact">contact page</a> provides a simple form for visitors to leave comments, feedback, or other requests. Messages are routed by selecting a category from a list of administrator-defined options; each category has its own set of e-mail recipients. Common categories for a business site include, for example, "Website feedback" (messages are forwarded to web site administrators) and "Product information" (messages are forwarded to members of the sales department). The actual e-mail addresses defined within a category are not displayed. Only users in roles with the <em>access site-wide contact form</em> permission may access the <a href="@contact">contact page</a>.', array('@contact' => url('contact'))) .'</p>';
00018       $output .= '<p>'. t('A link to your site\'s <a href="@contact">contact page</a> from the main <em>Navigation</em> menu is created, but is disabled by default. Create a similar link on another menu by adding a menu item pointing to the path "contact"', array('@contact' => url('contact'))) .'</p>';
00019       $output .= '<p>'. t('Customize the <a href="@contact">contact page</a> with additional information (like physical location, mailing address, and telephone number) using the <a href="@contact-settings">contact form settings page</a>. The <a href="@contact-settings">settings page</a> also provides configuration options for the maximum number of contact form submissions a user may perform per hour, and the default status of users\' personal contact forms.', array('@contact-settings' => url('admin/build/contact/settings'), '@contact' => url('contact'))) .'</p>';
00020       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@contact">Contact module</a>.', array('@contact' => url('http://drupal.org/handbook/modules/contact/', array('absolute' => TRUE)))) .'</p>';
00021       return $output;
00022     case 'admin/build/contact':
00023       $output = '<p>'. t('This page lets you set up <a href="@form">your site-wide contact form</a>. To do so, add one or more categories. You can associate different recipients with each category to route e-mails to different people. For example, you can route website feedback to the webmaster and direct product information requests to the sales department. On the <a href="@settings">settings page</a>, you can customize the information shown above the contact form. This can be useful to provide additional contact information such as your postal address and telephone number.', array('@settings' => url('admin/build/contact/settings'), '@form' => url('contact'))) .'</p>';
00024       if (!module_exists('menu')) {
00025         $menu_note = t('The menu item can be customized and configured only once the menu module has been <a href="@modules-page">enabled</a>.', array('@modules-page' => url('admin/settings/modules')));
00026       }
00027       else {
00028         $menu_note = '';
00029       }
00030       $output .= '<p>'. t('The contact module also adds a <a href="@menu-settings">menu item</a> (disabled by default) to the navigation block.', array('@menu-settings' => url('admin/build/menu'))) .' '. $menu_note .'</p>';
00031       return $output;
00032   }
00033 }
00034
00038 function contact_perm() {
00039   return array('access site-wide contact form', 'administer site-wide contact form');
00040 }
00044 function contact_menu() {
00045   $items['admin/build/contact'] = array(
00046     'title' => 'Contact form',
00047     'description' => 'Create a system contact form and set up categories for the form to use.',
00048     'page callback' => 'contact_admin_categories',
00049     'access arguments' => array('administer site-wide contact form'),
00050     'file' => 'contact.admin.inc',
00051   );
00052   $items['admin/build/contact/list'] = array(
00053     'title' => 'List',
00054     'page callback' => 'contact_admin_categories',
00055     'type' => MENU_DEFAULT_LOCAL_TASK,
00056     'file' => 'contact.admin.inc',
00057   );
00058   $items['admin/build/contact/add'] = array(
00059     'title' => 'Add category',
00060     'page callback' => 'drupal_get_form',
00061     'page arguments' => array('contact_admin_edit', 3),
00062     'type' => MENU_LOCAL_TASK,
00063     'weight' => 1,
00064     'file' => 'contact.admin.inc',
00065   );
00066   $items['admin/build/contact/edit/%contact'] = array(
00067     'title' => 'Edit contact category',
00068     'page callback' => 'drupal_get_form',
00069     'page arguments' => array('contact_admin_edit', 3, 4),
00070     'type' => MENU_CALLBACK,
00071     'file' => 'contact.admin.inc',
00072   );
00073   $items['admin/build/contact/delete/%contact'] = array(
00074     'title' => 'Delete contact',
00075     'page callback' => 'drupal_get_form',
00076     'page arguments' => array('contact_admin_delete', 4),
00077     'type' => MENU_CALLBACK,
00078     'file' => 'contact.admin.inc',
00079   );
00080   $items['admin/build/contact/settings'] = array(
00081     'title' => 'Settings',
00082     'page callback' => 'drupal_get_form',
00083     'page arguments' => array('contact_admin_settings'),
00084     'type' => MENU_LOCAL_TASK,
00085     'weight' => 2,
00086     'file' => 'contact.admin.inc',
00087   );
00088   $items['contact'] = array(
00089     'title' => 'Contact',
00090     'page callback' => 'contact_site_page',
00091     'access arguments' => array('access site-wide contact form'),
00092     'type' => MENU_SUGGESTED_ITEM,
00093     'file' => 'contact.pages.inc',
00094   );
00095   $items['user/%user/contact'] = array(
00096     'title' => 'Contact',
00097     'page callback' => 'contact_user_page',
00098     'page arguments' => array(1),
00099     'type' => MENU_LOCAL_TASK,
00100     'access callback' => '_contact_user_tab_access',
00101     'access arguments' => array(1),
00102     'weight' => 2,
00103     'file' => 'contact.pages.inc',
00104   );
00105   return $items;
00106 }
00107
00111 function _contact_user_tab_access($account) {
00112   global $user;
00113   if (!isset($account->contact)) {
00114     $account->contact = FALSE;
00115   }
00116   return
00117     $account && $user->uid &&
00118     (
00119       ($user->uid != $account->uid && $account->contact) ||
00120       user_access('administer users')
00121     );
00122 }
00123
00127 function contact_load($cid) {
00128   $contact = db_fetch_array(db_query("SELECT * FROM {contact} WHERE cid = %d", $cid));
00129   return empty($contact) ? FALSE : $contact;
00130 }
00131
00137 function contact_user($type, &$edit, &$user, $category = NULL) {
00138   if ($type == 'form' && $category == 'account') {
00139     $form['contact'] = array('#type' => 'fieldset',
00140       '#title' => t('Contact settings'),
00141       '#weight' => 5,
00142       '#collapsible' => TRUE,
00143     );
00144     $form['contact']['contact'] = array('#type' => 'checkbox',
00145       '#title' => t('Personal contact form'),
00146       '#default_value' => !empty($edit['contact']) ? $edit['contact'] : FALSE,
00147       '#description' => t('Allow other users to contact you by e-mail via <a href="@url">your personal contact form</a>. Note that while your e-mail address is not made public to other members of the community, privileged users such as site administrators are able to contact you even if you choose not to enable this feature.', array('@url' => url("user/$user->uid/contact"))),
00148     );
00149     return $form;
00150   }
00151   elseif ($type == 'validate') {
00152     return array('contact' => isset($edit['contact']) ? $edit['contact'] : FALSE);
00153   }
00154   elseif ($type == 'insert') {
00155     $edit['contact'] = variable_get('contact_default_status', 1);
00156   }
00157 }
00158
00162 function contact_mail($key, &$message, $params) {
00163   $language = $message['language'];
00164   switch ($key) {
00165     case 'page_mail':
00166     case 'page_copy':
00167       $contact = $params['contact'];
00168       $message['subject'] .= t('[!category] !subject', array('!category' => $contact['category'], '!subject' => $params['subject']), $language->language);
00169       $message['body'][] = t("!name sent a message using the contact form at !form.", array('!name' => $params['name'], '!form' => url($_GET['q'], array('absolute' => TRUE, 'language' => $language))), $language->language);
00170       $message['body'][] = $params['message'];
00171       break;
00172     case 'page_autoreply':
00173       $contact = $params['contact'];
00174       $message['subject'] .= t('[!category] !subject', array('!category' => $contact['category'], '!subject' => $params['subject']), $language->language);
00175       $message['body'][] = $contact['reply'];
00176       break;
00177     case 'user_mail':
00178     case 'user_copy':
00179       $user = $params['user'];
00180       $account = $params['account'];
00181       $message['subject'] .= '['. variable_get('site_name', 'Drupal') .'] '. $params['subject'];
00182       $message['body'][] = "$account->name,";
00183       $message['body'][] = t("!name (!name-url) has sent you a message via your contact form (!form-url) at !site.", array('!name' => $user->name, '!name-url' => url("user/$user->uid", array('absolute' => TRUE, 'language' => $language)), '!form-url' => url($_GET['q'], array('absolute' => TRUE, 'language' => $language)), '!site' => variable_get('site_name', 'Drupal')), $language->language);
00184       $message['body'][] = t("If you don't want to receive such e-mails, you can change your settings at !url.", array('!url' => url("user/$account->uid", array('absolute' => TRUE, 'language' => $language))), $language->language);
00185       $message['body'][] = t('Message:', NULL, $language->language);
00186       $message['body'][] = $params['message'];
00187       break;
00188   }
00189 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/contact/contact.pages.inc Source File

modules » contact

contact.pages.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: contact.pages.inc,v 1.6 2008/01/16 22:56:21 goba Exp $
00003
00013 function contact_site_page() {
00014   global $user;
00015
00016   if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) {
00017     $output = t("You cannot send more than %number messages per hour. Please try again later.", array('%number' => variable_get('contact_hourly_threshold', 3)));
00018   }
00019   else {
00020     $output = drupal_get_form('contact_mail_page');
00021   }
00022
00023   return $output;
00024 }
00025
00026 function contact_mail_page() {
00027   global $user;
00028
00029   $form = $categories = array();
00030
00031   $result = db_query('SELECT cid, category, selected FROM {contact} ORDER BY weight, category');
00032   while ($category = db_fetch_object($result)) {
00033     $categories[$category->cid] = $category->category;
00034     if ($category->selected) {
00035       $default_category = $category->cid;
00036     }
00037   }
00038
00039   if (count($categories) > 0) {
00040     $form['#token'] = $user->uid ? $user->name . $user->mail : '';
00041     $form['contact_information'] = array('#value' => filter_xss_admin(variable_get('contact_form_information', t('You can leave a message using the contact form below.'))));
00042     $form['name'] = array('#type' => 'textfield',
00043       '#title' => t('Your name'),
00044       '#maxlength' => 255,
00045       '#default_value' => $user->uid ? $user->name : '',
00046       '#required' => TRUE,
00047     );
00048     $form['mail'] = array('#type' => 'textfield',
00049       '#title' => t('Your e-mail address'),
00050       '#maxlength' => 255,
00051       '#default_value' => $user->uid ? $user->mail : '',
00052       '#required' => TRUE,
00053     );
00054     $form['subject'] = array('#type' => 'textfield',
00055       '#title' => t('Subject'),
00056       '#maxlength' => 255,
00057       '#required' => TRUE,
00058     );
00059     if (count($categories) > 1) {
00060       // If there is more than one category available and no default category has been selected,
00061       // prepend a default placeholder value.
00062       if (!isset($default_category)) {
00063         $default_category = t('- Please choose -');
00064         $categories = array($default_category) + $categories;
00065       }
00066       $form['cid'] = array('#type' => 'select',
00067         '#title' => t('Category'),
00068         '#default_value' => $default_category,
00069         '#options' => $categories,
00070         '#required' => TRUE,
00071       );
00072     }
00073     else {
00074       // If there is only one category, store its cid.
00075       $category_keys = array_keys($categories);
00076       $form['cid'] = array('#type' => 'value',
00077         '#value' => array_shift($category_keys),
00078       );
00079     }
00080     $form['message'] = array('#type' => 'textarea',
00081       '#title' => t('Message'),
00082       '#required' => TRUE,
00083     );
00084     // We do not allow anonymous users to send themselves a copy
00085     // because it can be abused to spam people.
00086     if ($user->uid) {
00087       $form['copy'] = array('#type' => 'checkbox',
00088         '#title' => t('Send yourself a copy.'),
00089       );
00090     }
00091     else {
00092       $form['copy'] = array('#type' => 'value', '#value' => FALSE);
00093     }
00094     $form['submit'] = array('#type' => 'submit',
00095       '#value' => t('Send e-mail'),
00096     );
00097   }
00098   else {
00099     drupal_set_message(t('The contact form has not been configured. <a href="@add">Add one or more categories</a> to the form.', array('@add' => url('admin/build/contact/add'))), 'error');
00100   }
00101   return $form;
00102 }
00103
00107 function contact_mail_page_validate($form, &$form_state) {
00108   if (!$form_state['values']['cid']) {
00109     form_set_error('category', t('You must select a valid category.'));
00110   }
00111   if (!valid_email_address($form_state['values']['mail'])) {
00112     form_set_error('mail', t('You must enter a valid e-mail address.'));
00113   }
00114 }
00115
00119 function contact_mail_page_submit($form, &$form_state) {
00120   global $language;
00121
00122   $values = $form_state['values'];
00123
00124   // E-mail address of the sender: as the form field is a text field,
00125   // all instances of \r and \n have been automatically stripped from it.
00126   $from = $values['mail'];
00127
00128   // Load category properties and save form values for email composition.
00129   $contact = contact_load($values['cid']);
00130   $values['contact'] = $contact;
00131
00132   // Send the e-mail to the recipients using the site default language.
00133   drupal_mail('contact', 'page_mail', $contact['recipients'], language_default(), $values, $from);
00134
00135   // If the user requests it, send a copy using the current language.
00136   if ($values['copy']) {
00137     drupal_mail('contact', 'page_copy', $from, $language, $values, $from);
00138   }
00139
00140   // Send an auto-reply if necessary using the current language.
00141   if ($contact['reply']) {
00142     drupal_mail('contact', 'page_autoreply', $from, $language, $values, $contact['recipients']);
00143   }
00144
00145   flood_register_event('contact');
00146   watchdog('mail', '%name-from sent an e-mail regarding %category.', array('%name-from' => $values['name'] ." [$from]", '%category' => $contact['category']));
00147   drupal_set_message(t('Your message has been sent.'));
00148
00149   // Jump to home page rather than back to contact page to avoid
00150   // contradictory messages if flood control has been activated.
00151   $form_state['redirect'] = '';
00152 }
00153
00157 function contact_user_page($account) {
00158   global $user;
00159
00160   if (!valid_email_address($user->mail)) {
00161     $output = t('You need to provide a valid e-mail address to contact other users. Please update your <a href="@url">user information</a> and try again.', array('@url' => url("user/$user->uid/edit")));
00162   }
00163   else if (!flood_is_allowed('contact', variable_get('contact_hourly_threshold', 3))) {
00164     $output = t('You cannot contact more than %number users per hour. Please try again later.', array('%number' => variable_get('contact_hourly_threshold', 3)));
00165   }
00166   else {
00167     drupal_set_title(check_plain($account->name));
00168     $output = drupal_get_form('contact_mail_user', $account);
00169   }
00170
00171   return $output;
00172 }
00173
00174 function contact_mail_user(&$form_state, $recipient) {
00175   global $user;
00176   $form['#token'] = $user->name . $user->mail;
00177   $form['recipient'] = array('#type' => 'value', '#value' => $recipient);
00178   $form['from'] = array('#type' => 'item',
00179     '#title' => t('From'),
00180     '#value' => check_plain($user->name) .' &lt;'. check_plain($user->mail) .'&gt;',
00181   );
00182   $form['to'] = array('#type' => 'item',
00183     '#title' => t('To'),
00184     '#value' => check_plain($recipient->name),
00185   );
00186   $form['subject'] = array('#type' => 'textfield',
00187     '#title' => t('Subject'),
00188     '#maxlength' => 50,
00189     '#required' => TRUE,
00190   );
00191   $form['message'] = array('#type' => 'textarea',
00192     '#title' => t('Message'),
00193     '#rows' => 15,
00194     '#required' => TRUE,
00195   );
00196   $form['copy'] = array('#type' => 'checkbox',
00197     '#title' => t('Send yourself a copy.'),
00198   );
00199   $form['submit'] = array('#type' => 'submit',
00200     '#value' => t('Send e-mail'),
00201   );
00202   return $form;
00203 }
00204
00208 function contact_mail_user_submit($form, &$form_state) {
00209   global $user, $language;
00210
00211   $account = $form_state['values']['recipient'];
00212
00213   // Send from the current user to the requested user.
00214   $to = $account->mail;
00215   $from = $user->mail;
00216
00217   // Save both users and all form values for email composition.
00218   $values = $form_state['values'];
00219   $values['account'] = $account;
00220   $values['user'] = $user;
00221
00222   // Send the e-mail in the requested user language.
00223   drupal_mail('contact', 'user_mail', $to, user_preferred_language($account), $values, $from);
00224
00225   // Send a copy if requested, using current page language.
00226   if ($form_state['values']['copy']) {
00227     drupal_mail('contact', 'user_copy', $from, $language, $values, $from);
00228   }
00229
00230   flood_register_event('contact');
00231   watchdog('mail', '%name-from sent %name-to an e-mail.', array('%name-from' => $user->name, '%name-to' => $account->name));
00232   drupal_set_message(t('The message has been sent.'));
00233
00234   // Back to the requested users profile page.
00235   $form_state['redirect'] = "user/$account->uid";
00236 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/node/content_types.inc Source File

modules » node

content_types.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: content_types.inc,v 1.50 2008/01/27 18:03:05 goba Exp $
00003
00012 function node_overview_types() {
00013   $types = node_get_types();
00014   $names = node_get_types('names');
00015   $header = array(t('Name'), t('Type'), t('Description'), array('data' => t('Operations'), 'colspan' => '2'));
00016   $rows = array();
00017
00018   foreach ($names as $key => $name) {
00019     $type = $types[$key];
00020     if (node_hook($type, 'form')) {
00021       $type_url_str = str_replace('_', '-', $type->type);
00022       $row = array(
00023         l($name, 'admin/content/node-type/'. $type_url_str),
00024         check_plain($type->type),
00025         filter_xss_admin($type->description),
00026       );
00027       // Set the edit column.
00028       $row[] = array('data' => l(t('edit'), 'admin/content/node-type/'. $type_url_str));
00029
00030       // Set the delete column.
00031       if ($type->custom) {
00032         $row[] = array('data' => l(t('delete'), 'admin/content/node-type/'. $type_url_str .'/delete'));
00033       }
00034       else {
00035         $row[] = array('data' => '');
00036       }
00037       $rows[] = $row;
00038     }
00039   }
00040
00041   if (empty($rows)) {
00042     $rows[] = array(array('data' => t('No content types available.'), 'colspan' => '5', 'class' => 'message'));
00043   }
00044
00045   return theme('table', $header, $rows);
00046 }
00047
00051 function node_type_form(&$form_state, $type = NULL) {
00052   if (!isset($type->type)) {
00053     $type = new stdClass();
00054     $type->type = $type->name = $type->module = $type->description = $type->help = '';
00055     $type->min_word_count = 0;
00056     $type->has_title = TRUE;
00057     $type->has_body = TRUE;
00058     $type->title_label = t('Title');
00059     $type->body_label = t('Body');
00060     $type->custom = TRUE;
00061     $type->modified = FALSE;
00062     $type->locked = FALSE;
00063   }
00064
00065   $form['#node_type'] = $type; // Make the type object available to implementations of hook_form_alter.
00066
00067   $form['identity'] = array(
00068     '#type' => 'fieldset',
00069     '#title' => t('Identification'),
00070   );
00071   $form['identity']['name'] = array(
00072     '#title' => t('Name'),
00073     '#type' => 'textfield',
00074     '#default_value' => $type->name,
00075     '#description' => t('The human-readable name of this content type. This text will be displayed as part of the list on the <em>create content</em> page. It is recommended that this name begin with a capital letter and contain only letters, numbers, and <strong>spaces</strong>. This name must be unique.'),
00076     '#required' => TRUE,
00077   );
00078
00079   if (!$type->locked) {
00080     $form['identity']['type'] = array(
00081       '#title' => t('Type'),
00082       '#type' => 'textfield',
00083       '#default_value' => $type->type,
00084       '#maxlength' => 32,
00085       '#required' => TRUE,
00086       '#description' => t('The machine-readable name of this content type. This text will be used for constructing the URL of the <em>create content</em> page for this content type. This name must contain only lowercase letters, numbers, and underscores. Underscores will be converted into hyphens when constructing the URL of the <em>create content</em> page. This name must be unique.'),
00087     );
00088   }
00089   else {
00090     $form['identity']['type'] = array(
00091       '#type' => 'value',
00092       '#value' => $type->type,
00093     );
00094     $form['identity']['type_display'] = array(
00095       '#title' => t('Type'),
00096       '#type' => 'item',
00097       '#value' => theme('placeholder', $type->type),
00098       '#description' => t('The machine-readable name of this content type. This field cannot be modified for system-defined content types.'),
00099     );
00100   }
00101
00102   $form['identity']['description'] = array(
00103     '#title' => t('Description'),
00104     '#type' => 'textarea',
00105     '#default_value' => $type->description,
00106     '#description' => t('A brief description of this content type. This text will be displayed as part of the list on the <em>create content</em> page.'),
00107     );
00108
00109   $form['submission'] = array(
00110     '#type' => 'fieldset',
00111     '#title' => t('Submission form settings'),
00112     '#collapsible' => TRUE,
00113     '#collapsed' => TRUE,
00114   );
00115   $form['submission']['title_label'] = array(
00116     '#title' => t('Title field label'),
00117     '#type' => 'textfield',
00118     '#default_value' => $type->title_label,
00119     '#required' => TRUE,
00120   );
00121   if (!$type->has_title) {
00122     // Avoid overwriting a content type that intentionally does not have a
00123     // title field.
00124     $form['submission']['title_label']['#attributes'] = array('disabled' => 'disabled');
00125     $form['submission']['title_label']['#description'] = t('This content type does not have a title field.');
00126     $form['submission']['title_label']['#required'] = FALSE;
00127   }
00128   $form['submission']['body_label'] = array(
00129     '#title' => t('Body field label'),
00130     '#type' => 'textfield',
00131     '#default_value' => isset($type->body_label) ? $type->body_label : '',
00132     '#description' => t('To omit the body field for this content type, remove any text and leave this field blank.'),
00133   );
00134   $form['submission']['min_word_count'] = array(
00135     '#type' => 'select',
00136     '#title' => t('Minimum number of words'),
00137     '#default_value' => $type->min_word_count,
00138     '#options' => drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)),
00139     '#description' => t('The minimum number of words for the body field to be considered valid for this content type. This can be useful to rule out submissions that do not meet the site\'s standards, such as short test posts.')
00140   );
00141   $form['submission']['help']  = array(
00142     '#type' => 'textarea',
00143     '#title' => t('Explanation or submission guidelines'),
00144     '#default_value' => $type->help,
00145     '#description' => t('This text will be displayed at the top of the submission form for this content type. It is useful for helping or instructing your users.')
00146   );
00147   $form['workflow'] = array(
00148     '#type' => 'fieldset',
00149     '#title' => t('Workflow settings'),
00150     '#collapsible' => TRUE,
00151     '#collapsed' => TRUE,
00152   );
00153   $form['workflow']['node_options'] = array('#type' => 'checkboxes',
00154     '#title' => t('Default options'),
00155     '#default_value' => variable_get('node_options_'. $type->type, array('status', 'promote')),
00156     '#options' => array(
00157       'status' => t('Published'),
00158       'promote' => t('Promoted to front page'),
00159       'sticky' => t('Sticky at top of lists'),
00160       'revision' => t('Create new revision'),
00161     ),
00162     '#description' => t('Users with the <em>administer nodes</em> permission will be able to override these options.'),
00163   );
00164
00165   $form['old_type'] = array(
00166     '#type' => 'value',
00167     '#value' => $type->type,
00168   );
00169   $form['orig_type'] = array(
00170     '#type' => 'value',
00171     '#value' => isset($type->orig_type) ? $type->orig_type : '',
00172   );
00173   $form['module'] = array(
00174     '#type' => 'value',
00175     '#value' => $type->module,
00176   );
00177   $form['custom'] = array(
00178     '#type' => 'value',
00179     '#value' => $type->custom,
00180   );
00181   $form['modified'] = array(
00182     '#type' => 'value',
00183     '#value' => $type->modified,
00184   );
00185   $form['locked'] = array(
00186     '#type' => 'value',
00187     '#value' => $type->locked,
00188   );
00189
00190   $form['submit'] = array(
00191     '#type' => 'submit',
00192     '#value' => t('Save content type'),
00193     '#weight' => 40,
00194   );
00195
00196   if ($type->custom) {
00197     if (!empty($type->type)) {
00198       $form['delete'] = array(
00199         '#type' => 'submit',
00200         '#value' => t('Delete content type'),
00201         '#weight' => 45,
00202       );
00203     }
00204   }
00205   else {
00206     $form['reset'] = array(
00207       '#type' => 'submit',
00208       '#value' => t('Reset to defaults'),
00209       '#weight' => 50,
00210     );
00211   }
00212
00213   return $form;
00214 }
00215
00219 function node_type_form_validate($form, &$form_state) {
00220   $type = new stdClass();
00221   $type->type = trim($form_state['values']['type']);
00222   $type->name = trim($form_state['values']['name']);
00223
00224   // Work out what the type was before the user submitted this form
00225   $old_type = trim($form_state['values']['old_type']);
00226
00227   $types = node_get_types('names');
00228
00229   if (!$form_state['values']['locked']) {
00230     if (isset($types[$type->type]) && $type->type != $old_type) {
00231       form_set_error('type', t('The machine-readable name %type is already taken.', array('%type' => $type->type)));
00232     }
00233     if (!preg_match('!^[a-z0-9_]+$!', $type->type)) {
00234       form_set_error('type', t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
00235     }
00236     // 'theme' conflicts with theme_node_form().
00237     // '0' is invalid, since elsewhere we check it using empty().
00238     if (in_array($type->type, array('0', 'theme'))) {
00239       form_set_error('type', t("Invalid machine-readable name. Please enter a name other than %invalid.", array('%invalid' => $type->type)));
00240     }
00241   }
00242
00243   $names = array_flip($types);
00244
00245   if (isset($names[$type->name]) && $names[$type->name] != $old_type) {
00246     form_set_error('name', t('The human-readable name %name is already taken.', array('%name' => $type->name)));
00247   }
00248 }
00249
00253 function node_type_form_submit($form, &$form_state) {
00254   $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
00255
00256   $type = new stdClass();
00257
00258   $type->type = trim($form_state['values']['type']);
00259   $type->name = trim($form_state['values']['name']);
00260   $type->orig_type = trim($form_state['values']['orig_type']);
00261   $type->old_type = isset($form_state['values']['old_type']) ? $form_state['values']['old_type'] : $type->type;
00262
00263   $type->description = $form_state['values']['description'];
00264   $type->help = $form_state['values']['help'];
00265   $type->min_word_count = $form_state['values']['min_word_count'];
00266   $type->title_label = $form_state['values']['title_label'];
00267   $type->body_label = $form_state['values']['body_label'];
00268
00269   // title_label is required in core; has_title will always be true, unless a
00270   // module alters the title field.
00271   $type->has_title = ($type->title_label != '');
00272   $type->has_body = ($type->body_label != '');
00273
00274   $type->module = !empty($form_state['values']['module']) ? $form_state['values']['module'] : 'node';
00275   $type->custom = $form_state['values']['custom'];
00276   $type->modified = TRUE;
00277   $type->locked = $form_state['values']['locked'];
00278
00279   if ($op == t('Reset to defaults')) {
00280     node_type_reset($type);
00281   }
00282   elseif ($op == t('Delete content type')) {
00283     $form_state['redirect'] = 'admin/content/node-type/'. str_replace('_', '-', $type->old_type) .'/delete';
00284     return;
00285   }
00286
00287   $status = node_type_save($type);
00288
00289   $variables = $form_state['values'];
00290
00291   // Remove everything that's been saved already - whatever's left is assumed
00292   // to be a persistent variable.
00293   foreach ($variables as $key => $value) {
00294     if (isset($type->$key)) {
00295       unset($variables[$key]);
00296     }
00297   }
00298
00299   unset($variables['form_token'], $variables['op'], $variables['submit'], $variables['delete'], $variables['reset'], $variables['form_id']);
00300
00301   // Save or reset persistent variable values.
00302   foreach ($variables as $key => $value) {
00303     $variable_new = $key .'_'. $type->type;
00304     $variable_old = $key .'_'. $type->old_type;
00305
00306     if ($op == t('Reset to defaults')) {
00307       variable_del($variable_old);
00308     }
00309     else {
00310       if (is_array($value)) {
00311         $value = array_keys(array_filter($value));
00312       }
00313       variable_set($variable_new, $value);
00314
00315       if ($variable_new != $variable_old) {
00316         variable_del($variable_old);
00317       }
00318     }
00319   }
00320
00321   node_types_rebuild();
00322   menu_rebuild();
00323   $t_args = array('%name' => $type->name);
00324
00325   if ($op == t('Reset to defaults')) {
00326     drupal_set_message(t('The content type %name has been reset to its default values.', $t_args));
00327     return;
00328   }
00329
00330   if ($status == SAVED_UPDATED) {
00331     drupal_set_message(t('The content type %name has been updated.', $t_args));
00332   }
00333   elseif ($status == SAVED_NEW) {
00334     drupal_set_message(t('The content type %name has been added.', $t_args));
00335     watchdog('node', 'Added content type %name.', $t_args, WATCHDOG_NOTICE, l(t('view'), 'admin/content/types'));
00336   }
00337
00338   $form_state['redirect'] = 'admin/content/types';
00339   return;
00340 }
00341
00345 function node_node_type($op, $info) {
00346   if ($op != 'delete' && !empty($info->old_type) && $info->old_type != $info->type) {
00347     $update_count = node_type_update_nodes($info->old_type, $info->type);
00348
00349     if ($update_count) {
00350       drupal_set_message(format_plural($update_count, 'Changed the content type of 1 post from %old-type to %type.', 'Changed the content type of @count posts from %old-type to %type.', array('%old-type' => $info->old_type, '%type' => $info->type)));
00351     }
00352   }
00353 }
00354
00364 function node_type_reset(&$type) {
00365   $info_array = module_invoke_all('node_info');
00366   if (isset($info_array[$type->orig_type])) {
00367     $info = _node_type_set_defaults($info_array[$type->orig_type]);
00368     $info['type'] = $type->orig_type;
00369
00370     foreach ($info as $field => $value) {
00371       $type->$field = $value;
00372     }
00373   }
00374 }
00375
00379 function node_type_delete_confirm(&$form_state, $type) {
00380   $form['type'] = array('#type' => 'value', '#value' => $type->type);
00381   $form['name'] = array('#type' => 'value', '#value' => $type->name);
00382
00383   $message = t('Are you sure you want to delete the content type %type?', array('%type' => $type->name));
00384   $caption = '';
00385
00386   $num_nodes = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE type = '%s'", $type->type));
00387   if ($num_nodes) {
00388     $caption .= '<p>'. format_plural($num_nodes, '<strong>Warning:</strong> there is currently 1 %type post on your site. It may not be able to be displayed or edited correctly, once you have removed this content type.', '<strong>Warning:</strong> there are currently @count %type posts on your site. They may not be able to be displayed or edited correctly, once you have removed this content type.', array('%type' => $type->name)) .'</p>';
00389   }
00390
00391   $caption .= '<p>'. t('This action cannot be undone.') .'</p>';
00392
00393   return confirm_form($form, $message, 'admin/content/types', $caption, t('Delete'));
00394 }
00395
00399 function node_type_delete_confirm_submit($form, &$form_state) {
00400   node_type_delete($form_state['values']['type']);
00401
00402   $t_args = array('%name' => $form_state['values']['name']);
00403   drupal_set_message(t('The content type %name has been deleted.', $t_args));
00404   watchdog('menu', 'Deleted content type %name.', $t_args, WATCHDOG_NOTICE);
00405
00406   node_types_rebuild();
00407   menu_rebuild();
00408
00409   $form_state['redirect'] = 'admin/content/types';
00410   return;
00411 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/hooks/core.php Source File

docs » hooks

core.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: core.php,v 1.167 2008/02/09 02:04:23 pwolanin Exp $
00003
00078 function hook_block($op = 'list', $delta = 0, $edit = array()) {
00079   if ($op == 'list') {
00080     $blocks[0] = array('info' => t('Mymodule block #1 shows ...'),
00081       'weight' => 0, 'status' => 1, 'region' => 'left');
00082       // BLOCK_CACHE_PER_ROLE will be assumed for block 0.
00083
00084     $blocks[1] = array('info' => t('Mymodule block #2 describes ...'),
00085       'cache' => BLOCK_CACHE_PER_ROLE | BLOCK_CACHE_PER_PAGE);
00086
00087     return $blocks;
00088   }
00089   else if ($op == 'configure' && $delta == 0) {
00090     $form['items'] = array(
00091       '#type' => 'select',
00092       '#title' => t('Number of items'),
00093       '#default_value' => variable_get('mymodule_block_items', 0),
00094       '#options' => array('1', '2', '3'),
00095     );
00096     return $form;
00097   }
00098   else if ($op == 'save' && $delta == 0) {
00099     variable_set('mymodule_block_items', $edit['items']);
00100   }
00101   else if ($op == 'view') {
00102     switch($delta) {
00103       case 0:
00104         $block = array('subject' => t('Title of block #1'),
00105           'content' => mymodule_display_block_1());
00106         break;
00107       case 1:
00108         $block = array('subject' => t('Title of block #2'),
00109           'content' => mymodule_display_block_2());
00110         break;
00111     }
00112     return $block;
00113   }
00114 }
00115
00143 function hook_comment($a1, $op) {
00144   if ($op == 'insert' || $op == 'update') {
00145     $nid = $a1['nid'];
00146   }
00147
00148   cache_clear_all_like(drupal_url(array('id' => $nid)));
00149 }
00150
00166 function hook_cron() {
00167   $result = db_query('SELECT * FROM {site} WHERE checked = 0 OR checked
00168     + refresh < %d', time());
00169
00170   while ($site = db_fetch_array($result)) {
00171     cloud_update($site);
00172   }
00173 }
00174
00188 function hook_menu_alter(&$callbacks) {
00189   // Example - disable the page at node/add
00190   $callbacks['node/add']['access callback'] = FALSE;
00191 }
00192
00203 function hook_menu_link_alter(&$item, $menu) {
00204   // Example 1 - make all new admin links hidden (a.k.a disabled).
00205   if (strpos($item['link_path'], 'admin') === 0 && empty($item['mlid'])) {
00206     $item['hidden'] = 1;
00207   }
00208   // Example 2  - flag a link to be altered by hook_translated_menu_link_alter()
00209   if ($item['link_path'] == 'devel/cache/clear') {
00210     $item['options']['alter'] = TRUE;
00211   }
00212 }
00213
00229 function hook_translated_menu_link_alter(&$item, $map) {
00230   if ($item['href'] == 'devel/cache/clear') {
00231     $item['localized_options']['query'] = drupal_get_destination();
00232   }
00233 }
00234
00262 function hook_db_rewrite_sql($query, $primary_table, $primary_field, $args) {
00263   switch ($primary_field) {
00264     case 'nid':
00265       // this query deals with node objects
00266       $return = array();
00267       if ($primary_table != 'n') {
00268         $return['join'] = "LEFT JOIN {node} n ON $primary_table.nid = n.nid";
00269       }
00270       $return['where'] = 'created >' . mktime(0, 0, 0, 1, 1, 2005);
00271       return $return;
00272       break;
00273     case 'tid':
00274       // this query deals with taxonomy objects
00275       break;
00276     case 'vid':
00277       // this query deals with vocabulary objects
00278       break;
00279   }
00280 }
00281
00289 function hook_elements() {
00290   $type['filter_format'] = array('#input' => TRUE);
00291   return $type;
00292 }
00293
00316 function hook_exit($destination = NULL) {
00317   db_query('UPDATE {counter} SET hits = hits + 1 WHERE type = 1');
00318 }
00319
00329 function hook_file_download($file) {
00330   if (user_access('access content')) {
00331     if ($filemime = db_result(db_query("SELECT filemime FROM {fileupload} WHERE filepath = '%s'", file_create_path($file)))) {
00332       return array('Content-type:' . $filemime);
00333     }
00334   }
00335   else {
00336     return -1;
00337   }
00338 }
00339
00428 function hook_filter($op, $delta = 0, $format = -1, $text = '') {
00429   switch ($op) {
00430     case 'list':
00431       return array(0 => t('Code filter'));
00432
00433     case 'description':
00434       return t('Allows users to post code verbatim using &lt;code&gt; and &lt;?php ?&gt; tags.');
00435
00436     case 'prepare':
00437       // Note: we use the bytes 0xFE and 0xFF to replace < > during the
00438       // filtering process. These bytes are not valid in UTF-8 data and thus
00439       // least likely to cause problems.
00440       $text = preg_replace('@<code>(.+?)</code>@se', "'\xFEcode\xFF'. codefilter_escape('\\1') .'\xFE/code\xFF'", $text);
00441       $text = preg_replace('@<(\?(php)?|%)(.+?)(\?|%)>@se', "'\xFEphp\xFF'. codefilter_escape('\\3') .'\xFE/php\xFF'", $text);
00442       return $text;
00443
00444     case "process":
00445       $text = preg_replace('@\xFEcode\xFF(.+?)\xFE/code\xFF@se', "codefilter_process_code('$1')", $text);
00446       $text = preg_replace('@\xFEphp\xFF(.+?)\xFE/php\xFF@se', "codefilter_process_php('$1')", $text);
00447       return $text;
00448
00449     default:
00450       return $text;
00451   }
00452 }
00453
00472 function hook_filter_tips($delta, $format, $long = false) {
00473   if ($long) {
00474     return t('To post pieces of code, surround them with &lt;code&gt;...&lt;/code&gt; tags. For PHP code, you can use &lt;?php ... ?&gt;, which will also colour it based on syntax.');
00475   }
00476   else {
00477     return t('You may post code using &lt;code&gt;...&lt;/code&gt; (generic) or &lt;?php ... ?&gt; (highlighted PHP) tags.');
00478   }
00479 }
00480
00493 function hook_footer($main = 0) {
00494   if (variable_get('dev_query', 0)) {
00495     return '<div style="clear:both;">'. devel_query_table() .'</div>';
00496   }
00497 }
00498
00515 function hook_form_alter(&$form, $form_state, $form_id) {
00516   if (isset($form['type']) && $form['type']['#value'] .'_node_settings' == $form_id) {
00517     $form['workflow']['upload_'. $form['type']['#value']] = array(
00518       '#type' => 'radios',
00519       '#title' => t('Attachments'),
00520       '#default_value' => variable_get('upload_'. $form['type']['#value'], 1),
00521       '#options' => array(t('Disabled'), t('Enabled')),
00522     );
00523   }
00524 }
00525
00543 function hook_forms() {
00544   $forms['mymodule_first_form'] = array(
00545     'callback' => 'mymodule_form_builder',
00546     'callback arguments' => array('some parameter'),
00547   );
00548   $forms['mymodule_second_form'] = array(
00549     'callback' => 'mymodule_form_builder',
00550   );
00551   return $forms;
00552 }
00553
00593 function hook_help($path, $arg) {
00594   switch ($path) {
00595     case 'admin/help#block':
00596       return '<p>'. t('Blocks are boxes of content that may be rendered into certain regions of your web pages, for example, into sidebars. Blocks are usually generated automatically by modules (e.g., Recent Forum Topics), but administrators can also define custom blocks.') .'</p>';
00597
00598     case 'admin/build/block':
00599       return t('<p>Blocks are boxes of content that may be rendered into certain regions of your web pages, for example, into sidebars. They are usually generated automatically by modules, but administrators can create blocks manually.</p>
00600 <p>If you want certain blocks to disable themselves temporarily during high server loads, check the "Throttle" box. You can configure the auto-throttle on the <a href="@throttle">throttle configuration page</a> after having enabled the throttle module.</p>
00601 <p>You can configure the behaviour of each block (for example, specifying on which pages and for what users it will appear) by clicking the "configure" link for each block.</p>', array('@throttle' => url('admin/settings/throttle')));
00602   }
00603 }
00604
00618 function hook_boot() {
00619   // we need user_access() in the shutdown function. make sure it gets loaded
00620   drupal_load('module', 'user');
00621   register_shutdown_function('devel_shutdown');
00622 }
00623
00638 function hook_init() {
00639   drupal_add_css(drupal_get_path('module', 'book') .'/book.css');
00640 }
00641
00678 function hook_link($type, $object, $teaser = FALSE) {
00679   $links = array();
00680
00681   if ($type == 'node' && isset($object->parent)) {
00682     if (!$teaser) {
00683       if (book_access('create', $object)) {
00684         $links['book_add_child'] = array(
00685           'title' => t('add child page'),
00686           'href' => "node/add/book/parent/$object->nid",
00687         );
00688       }
00689       if (user_access('see printer-friendly version')) {
00690         $links['book_printer'] = array(
00691           'title' => t('printer-friendly version'),
00692           'href' => 'book/export/html/'. $object->nid,
00693           'attributes' => array('title' => t('Show a printer-friendly version of this book page and its sub-pages.'))
00694         );
00695       }
00696     }
00697   }
00698
00699   $links['sample_link'] = array(
00700     'title' => t('go somewhere'),
00701     'href' => 'node/add',
00702     'query' => 'foo=bar',
00703     'fragment' => 'anchorname',
00704     'attributes' => array('title' => t('go to another page')),
00705   );
00706
00707   // Example of a link that's not an anchor
00708   if ($type == 'video') {
00709     if (variable_get('video_playcounter', 1) && user_access('view play counter')) {
00710       $links['play_counter'] = array(
00711         'title' => format_plural($object->play_counter, '1 play', '@count plays'),
00712       );
00713     }
00714   }
00715
00716   return $links;
00717 }
00718
00730 function hook_link_alter(&$links, $node) {
00731   foreach ($links AS $module => $link) {
00732     if (strstr($module, 'taxonomy_term')) {
00733       // Link back to the forum and not the taxonomy term page
00734       $links[$module]['#href'] = str_replace('taxonomy/term', 'forum', $link['#href']);
00735     }
00736   }
00737 }
00738
00749 function hook_profile_alter(&$fields, $account) {
00750   foreach ($fields AS $key => $field) {
00751     // do something
00752   }
00753 }
00754
00785 function hook_mail_alter(&$message) {
00786   if ($message['mail_id'] == 'my_message') {
00787     $message['body'] .= "\n\n--\nMail sent out from " . variable_get('sitename', t('Drupal'));
00788   }
00789 }
00790
00842 function hook_menu() {
00843   $items = array();
00844
00845   $items['blog'] = array(
00846     'title' => 'blogs',
00847     'page callback' => 'blog_page',
00848     'access arguments' => array('access content'),
00849     'type' => MENU_SUGGESTED_ITEM,
00850   );
00851   $items['blog/feed'] = array(
00852     'title' => t('RSS feed'),
00853     'page callback' => 'blog_feed',
00854     'access arguments' => array('access content'),
00855     'type' => MENU_CALLBACK,
00856   );
00857
00858   return $items;
00859 }
00860
00861
00890 function hook_node_grants($account, $op) {
00891   if (user_access('access private content', $account)) {
00892     $grants['example'] = array(1);
00893   }
00894   $grants['example_owner'] = array($user->uid);
00895   return $grants;
00896 }
00897
00927 function hook_node_access_records($node) {
00928   if (node_access_example_disabling()) {
00929     return;
00930   }
00931
00932   // We only care about the node if it's been marked private. If not, it is
00933   // treated just like any other node and we completely ignore it.
00934   if ($node->private) {
00935     $grants = array();
00936     $grants[] = array(
00937       'realm' => 'example',
00938       'gid' => TRUE,
00939       'grant_view' => TRUE,
00940       'grant_update' => FALSE,
00941       'grant_delete' => FALSE,
00942       'priority' => 0,
00943     );
00944
00945     // For the example_author array, the GID is equivalent to a UID, which
00946     // means there are many many groups of just 1 user.
00947     $grants[] = array(
00948       'realm' => 'example_author',
00949       'gid' => $node->uid,
00950       'grant_view' => TRUE,
00951       'grant_update' => TRUE,
00952       'grant_delete' => TRUE,
00953       'priority' => 0,
00954     );
00955     return $grants;
00956   }
00957 }
00958
00976 function hook_node_operations() {
00977   $operations = array(
00978     'approve' => array(
00979       'label' => t('Approve the selected posts'),
00980       'callback' => 'node_operations_approve',
00981     ),
00982     'promote' => array(
00983       'label' => t('Promote the selected posts'),
00984       'callback' => 'node_operations_promote',
00985     ),
00986     'sticky' => array(
00987       'label' => t('Make the selected posts sticky'),
00988       'callback' => 'node_operations_sticky',
00989     ),
00990     'demote' => array(
00991       'label' => t('Demote the selected posts'),
00992       'callback' => 'node_operations_demote',
00993     ),
00994     'unpublish' => array(
00995       'label' => t('Unpublish the selected posts'),
00996       'callback' => 'node_operations_unpublish',
00997     ),
00998     'delete' => array(
00999       'label' => t('Delete the selected posts'),
01000     ),
01001   );
01002   return $operations;
01003 }
01004
01064 function hook_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
01065   switch ($op) {
01066     case 'submit':
01067       if ($node->nid && $node->moderate) {
01068         // Reset votes when node is updated:
01069         $node->score = 0;
01070         $node->users = '';
01071         $node->votes = 0;
01072       }
01073       break;
01074     case 'insert':
01075     case 'update':
01076       if ($node->moderate && user_access('access submission queue')) {
01077         drupal_set_message(t('The post is queued for approval'));
01078       }
01079       elseif ($node->moderate) {
01080         drupal_set_message(t('The post is queued for approval. The editors will decide whether it should be published.'));
01081       }
01082       break;
01083     case 'view':
01084       $node->content['my_additional_field'] = array(
01085         '#value' => theme('mymodule_my_additional_field', $additional_field),
01086         '#weight' => 10,
01087       );
01088       break;
01089   }
01090 }
01091
01109 function hook_perm() {
01110   return array('administer my module');
01111 }
01112
01126 function hook_ping($name = '', $url = '') {
01127   $feed = url('node/feed');
01128
01129   $client = new xmlrpc_client('/RPC2', 'rpc.weblogs.com', 80);
01130
01131   $message = new xmlrpcmsg('weblogUpdates.ping',
01132     array(new xmlrpcval($name), new xmlrpcval($url)));
01133
01134   $result = $client->send($message);
01135
01136   if (!$result || $result->faultCode()) {
01137     watchdog('error', 'failed to notify "weblogs.com" (site)');
01138   }
01139
01140   unset($client);
01141 }
01142
01199 function hook_search($op = 'search', $keys = null) {
01200   switch ($op) {
01201     case 'name':
01202       return t('content');
01203     case 'reset':
01204       variable_del('node_cron_last');
01205       return;
01206     case 'search':
01207       $find = do_search($keys, 'node', 'INNER JOIN {node} n ON n.nid = i.sid '. node_access_join_sql() .' INNER JOIN {users} u ON n.uid = u.uid', 'n.status = 1 AND '. node_access_where_sql());
01208       $results = array();
01209       foreach ($find as $item) {
01210         $node = node_load(array('nid' => $item));
01211         $extra = node_invoke_nodeapi($node, 'search result');
01212         $results[] = array('link' => url('node/'. $item),
01213                            'type' => node_invoke($node, 'node_name'),
01214                            'title' => $node->title,
01215                            'user' => theme('username', $node),
01216                            'date' => $node->changed,
01217                            'extra' => $extra,
01218                            'snippet' => search_excerpt($keys, check_output($node->body, $node->format)));
01219       }
01220       return $results;
01221   }
01222 }
01223
01241 function hook_search_preprocess($text) {
01242   // Do processing on $text
01243   return $text;
01244 }
01245
01274 function hook_taxonomy($op, $type, $array = NULL) {
01275   if ($type == 'vocabulary' && ($op == 'insert' || $op == 'update')) {
01276     if (variable_get('forum_nav_vocabulary', '') == ''
01277         && in_array('forum', $array['nodes'])) {
01278       // since none is already set, silently set this vocabulary as the
01279       // navigation vocabulary
01280       variable_set('forum_nav_vocabulary', $array['vid']);
01281     }
01282   }
01283 }
01284
01361 function hook_theme() {
01362   return array(
01363     'forum_display' => array(
01364       'arguments' => array('forums' => NULL, 'topics' => NULL, 'parents' => NULL, 'tid' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL),
01365     ),
01366     'forum_list' => array(
01367       'arguments' => array('forums' => NULL, 'parents' => NULL, 'tid' => NULL),
01368     ),
01369     'forum_topic_list' => array(
01370       'arguments' => array('tid' => NULL, 'topics' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL),
01371     ),
01372     'forum_icon' => array(
01373       'arguments' => array('new_posts' => NULL, 'num_posts' => 0, 'comment_mode' => 0, 'sticky' => 0),
01374     ),
01375     'forum_topic_navigation' => array(
01376       'arguments' => array('node' => NULL),
01377     ),
01378   );
01379 }
01380
01405 function hook_update_index() {
01406   $last = variable_get('node_cron_last', 0);
01407   $limit = (int)variable_get('search_cron_limit', 100);
01408
01409   $result = db_query_range('SELECT n.nid, c.last_comment_timestamp FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE n.status = 1 AND n.moderate = 0 AND (n.created > %d OR n.changed > %d OR c.last_comment_timestamp > %d) ORDER BY GREATEST(n.created, n.changed, c.last_comment_timestamp) ASC', $last, $last, $last, 0, $limit);
01410
01411   while ($node = db_fetch_object($result)) {
01412     $last_comment = $node->last_comment_timestamp;
01413     $node = node_load(array('nid' => $node->nid));
01414
01415     // We update this variable per node in case cron times out, or if the node
01416     // cannot be indexed (PHP nodes which call drupal_goto, for example).
01417     // In rare cases this can mean a node is only partially indexed, but the
01418     // chances of this happening are very small.
01419     variable_set('node_cron_last', max($last_comment, $node->changed, $node->created));
01420
01421     // Get node output (filtered and with module-specific fields).
01422     if (node_hook($node, 'view')) {
01423       node_invoke($node, 'view', false, false);
01424     }
01425     else {
01426       $node = node_prepare($node, false);
01427     }
01428     // Allow modules to change $node->body before viewing.
01429     node_invoke_nodeapi($node, 'view', false, false);
01430
01431     $text = '<h1>'. drupal_specialchars($node->title) .'</h1>'. $node->body;
01432
01433     // Fetch extra data normally not visible
01434     $extra = node_invoke_nodeapi($node, 'update index');
01435     foreach ($extra as $t) {
01436       $text .= $t;
01437     }
01438
01439     // Update index
01440     search_index($node->nid, 'node', $text);
01441   }
01442 }
01443
01505 function hook_user($op, &$edit, &$account, $category = NULL) {
01506   if ($op == 'form' && $category == 'account') {
01507     $form['comment_settings'] = array(
01508       '#type' => 'fieldset',
01509       '#title' => t('Comment settings'),
01510       '#collapsible' => TRUE,
01511       '#weight' => 4);
01512     $form['comment_settings']['signature'] = array(
01513       '#type' => 'textarea',
01514       '#title' => t('Signature'),
01515       '#default_value' => $edit['signature'],
01516       '#description' => t('Your signature will be publicly displayed at the end of your comments.'));
01517     return $form;
01518   }
01519 }
01520
01538 function hook_user_operations() {
01539   $operations = array(
01540     'unblock' => array(
01541       'label' => t('Unblock the selected users'),
01542       'callback' => 'user_user_operations_unblock',
01543     ),
01544     'block' => array(
01545       'label' => t('Block the selected users'),
01546       'callback' => 'user_user_operations_block',
01547     ),
01548     'delete' => array(
01549       'label' => t('Delete the selected users'),
01550     ),
01551   );
01552   return $operations;
01553 }
01554
01588 function hook_xmlrpc() {
01589   return array(
01590     'drupal.login' => 'drupal_login',
01591     array(
01592       'drupal.site.ping',
01593       'drupal_directory_ping',
01594       array('boolean', 'string', 'string', 'string', 'string', 'string'),
01595       t('Handling ping request'))
01596   );
01597 }
01598
01629 function hook_watchdog($log_msg) {
01630   global $base_url;
01631
01632   $severity_list = array(
01633     WATCHDOG_EMERG    => t('Emergency'),
01634     WATCHDOG_ALERT    => t('Alert'),
01635     WATCHDOG_CRITICAL => t('Critical'),
01636     WATCHDOG_ERROR    => t('Error'),
01637     WATCHDOG_WARNING  => t('Warning'),
01638     WATCHDOG_NOTICE   => t('Notice'),
01639     WATCHDOG_INFO     => t('Info'),
01640     WATCHDOG_DEBUG    => t('Debug'),
01641   );
01642
01643   $to = "someone@example.com";
01644   $subject = t('[@site_name] @severity_desc: Alert from your web site', array(
01645       '@site_name' => variable_get('site_name', 'Drupal'),
01646       '@severity_desc' => $severity_list[$log['severity']]));
01647
01648   $message  = "\nSite:         @base_url";
01649   $message .= "\nSeverity:     (@severity) @severity_desc";
01650   $message .= "\nTimestamp:    @timestamp";
01651   $message .= "\nType:         @type";
01652   $message .= "\nIP Address:   @ip";
01653   $message .= "\nRequest URI:  @request_uri";
01654   $message .= "\nReferrer URI: @referer_uri";
01655   $message .= "\nUser:         (@uid) @name";
01656   $message .= "\nLink:         @link";
01657   $message .= "\nMessage:      \n\n@message";
01658
01659   $message = t($message, array(
01660     '@base_url'      => $base_url,
01661     '@severity'      => $log_msg['severity'],
01662     '@severity_desc' => $severity_list[$log_msg['severity']],
01663     '@timestamp'     => format_date($log_msg['timestamp']),
01664     '@type'          => $log_msg['type'],
01665     '@ip'            => $log_msg['ip'],
01666     '@request_uri'   => $log_msg['request_uri'],
01667     '@referer_uri'   => $log_msg['referer'],
01668     '@uid'           => $log_msg['user']->uid,
01669     '@name'          => $log_msg['user']->name,
01670     '@link'          => strip_tags($log_msg['link']),
01671     '@message'       => strip_tags($log_msg['message']),
01672   ));
01673
01674     drupal_mail('emaillog', $to, $subject, $body, $from = NULL, $headers = array());
01675   }
01676 }
01677
01707 function hook_mail($key, &$message, $params) {
01708   $account = $params['account'];
01709   $context = $params['context'];
01710   $variables = array(
01711     '%site_name' => variable_get('site_name', 'Drupal'),
01712     '%username' => $account->name,
01713   );
01714   if ($context['hook'] == 'taxonomy') {
01715     $object = $params['object'];
01716     $vocabulary = taxonomy_vocabulary_load($object->vid);
01717     $variables += array(
01718       '%term_name' => $object->name,
01719       '%term_description' => $object->description,
01720       '%term_id' => $object->tid,
01721       '%vocabulary_name' => $vocabulary->name,
01722       '%vocabulary_description' => $vocabulary->description,
01723       '%vocabulary_id' => $vocabulary->vid,
01724     );
01725   }
01726
01727   // Node-based variable translation is only available if we have a node.
01728   if (isset($params['node'])) {
01729     $node = $params['node'];
01730     $variables += array(
01731       '%uid' => $node->uid,
01732       '%node_url' => url('node/'. $node->nid, array('absolute' => TRUE)),
01733       '%node_type' => node_get_types('name', $node),
01734       '%title' => $node->title,
01735       '%teaser' => $node->teaser,
01736       '%body' => $node->body,
01737     );
01738   }
01739   $subject = strtr($context['subject'], $variables);
01740   $body = strtr($context['message'], $variables);
01741   $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
01742   $message['body'][] = drupal_html_to_text($body);
01743 }
01744
01761 function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
01762   global $user;
01763
01764   // Change all 'node' to 'article'.
01765   if (preg_match('|^node(/.*)|', $path, $matches)) {
01766     $path = 'article'. $matches[1];
01767   }
01768   // Create a path called 'e' which lands the user on her profile edit page.
01769   if ($path == 'user/'. $user->uid .'/edit') {
01770     $path = 'e';
01771   }
01772
01773 }
01774
01790 function custom_url_rewrite_inbound(&$result, $path, $path_language) {
01791   global $user;
01792
01793   // Change all article/x requests to node/x
01794   if (preg_match('|^article(/.*)|', $path, $matches)) {
01795     $result = 'node'. $matches[1];
01796   }
01797   // Redirect a path called 'e' to the user's profile edit page.
01798   if ($path == 'e') {
01799     $result = 'user/'. $user->uid .'/edit';
01800   }
01801 }
01802
01803
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: cron.php Source File

cron.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: cron.php,v 1.36 2006/08/09 07:42:55 dries Exp $
00003
00009 include_once './includes/bootstrap.inc';
00010 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
00011 drupal_cron_run();
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/database.inc Source File

includes

database.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: database.inc,v 1.92.2.1 2008/02/08 22:44:59 goba Exp $
00003
00014 define('DB_ERROR', 'a515ac9c2796ca0e23adbe92c68fc9fc');
00015
00064 function update_sql($sql) {
00065   $result = db_query($sql, true);
00066   return array('success' => $result !== FALSE, 'query' => check_plain($sql));
00067 }
00068
00082 function db_prefix_tables($sql) {
00083   global $db_prefix;
00084
00085   if (is_array($db_prefix)) {
00086     if (array_key_exists('default', $db_prefix)) {
00087       $tmp = $db_prefix;
00088       unset($tmp['default']);
00089       foreach ($tmp as $key => $val) {
00090         $sql = strtr($sql, array('{'. $key .'}' => $val . $key));
00091       }
00092       return strtr($sql, array('{' => $db_prefix['default'], '}' => ''));
00093     }
00094     else {
00095       foreach ($db_prefix as $key => $val) {
00096         $sql = strtr($sql, array('{'. $key .'}' => $val . $key));
00097       }
00098       return strtr($sql, array('{' => '', '}' => ''));
00099     }
00100   }
00101   else {
00102     return strtr($sql, array('{' => $db_prefix, '}' => ''));
00103   }
00104 }
00105
00124 function db_set_active($name = 'default') {
00125   global $db_url, $db_type, $active_db;
00126   static $db_conns, $active_name = FALSE;
00127
00128   if (empty($db_url)) {
00129     include_once 'includes/install.inc';
00130     install_goto('install.php');
00131   }
00132
00133   if (!isset($db_conns[$name])) {
00134     // Initiate a new connection, using the named DB URL specified.
00135     if (is_array($db_url)) {
00136       $connect_url = array_key_exists($name, $db_url) ? $db_url[$name] : $db_url['default'];
00137     }
00138     else {
00139       $connect_url = $db_url;
00140     }
00141
00142     $db_type = substr($connect_url, 0, strpos($connect_url, '://'));
00143     $handler = "./includes/database.$db_type.inc";
00144
00145     if (is_file($handler)) {
00146       include_once $handler;
00147     }
00148     else {
00149       _db_error_page("The database type '". $db_type ."' is unsupported. Please use either 'mysql' or 'mysqli' for MySQL, or 'pgsql' for PostgreSQL databases.");
00150     }
00151
00152     $db_conns[$name] = db_connect($connect_url);
00153   }
00154
00155   $previous_name = $active_name;
00156   // Set the active connection.
00157   $active_name = $name;
00158   $active_db = $db_conns[$name];
00159
00160   return $previous_name;
00161 }
00162
00173 function _db_error_page($error = '') {
00174   global $db_type;
00175   drupal_maintenance_theme();
00176   drupal_set_header('HTTP/1.1 503 Service Unavailable');
00177   drupal_set_title('Site off-line');
00178
00179   $message = '<p>The site is currently not available due to technical problems. Please try again later. Thank you for your understanding.</p>';
00180   $message .= '<hr /><p><small>If you are the maintainer of this site, please check your database settings in the <code>settings.php</code> file and ensure that your hosting provider\'s database server is running. For more help, see the <a href="http://drupal.org/node/258">handbook</a>, or contact your hosting provider.</small></p>';
00181
00182   if ($error && ini_get('display_errors')) {
00183     $message .= '<p><small>The '. theme('placeholder', $db_type) .' error was: '. theme('placeholder', $error) .'.</small></p>';
00184   }
00185
00186   print theme('maintenance_page', $message);
00187   exit;
00188 }
00189
00193 function db_is_active() {
00194   global $active_db;
00195   return !empty($active_db);
00196 }
00197
00201 function _db_query_callback($match, $init = FALSE) {
00202   static $args = NULL;
00203   if ($init) {
00204     $args = $match;
00205     return;
00206   }
00207
00208   switch ($match[1]) {
00209     case '%d': // We must use type casting to int to convert FALSE/NULL/(TRUE?)
00210       return (int) array_shift($args); // We don't need db_escape_string as numbers are db-safe
00211     case '%s':
00212       return db_escape_string(array_shift($args));
00213     case '%%':
00214       return '%';
00215     case '%f':
00216       return (float) array_shift($args);
00217     case '%b': // binary data
00218       return db_encode_blob(array_shift($args));
00219   }
00220 }
00221
00233 function db_placeholders($arguments, $type = 'int') {
00234   $placeholder = db_type_placeholder($type);
00235   return implode(',', array_fill(0, count($arguments), $placeholder));
00236 }
00237
00241 define('DB_QUERY_REGEXP', '/(%d|%s|%%|%f|%b)/');
00242
00263 function _db_rewrite_sql($query = '', $primary_table = 'n', $primary_field = 'nid', $args = array()) {
00264   $where = array();
00265   $join = array();
00266   $distinct = FALSE;
00267   foreach (module_implements('db_rewrite_sql') as $module) {
00268     $result = module_invoke($module, 'db_rewrite_sql', $query, $primary_table, $primary_field, $args);
00269     if (isset($result) && is_array($result)) {
00270       if (isset($result['where'])) {
00271         $where[] = $result['where'];
00272       }
00273       if (isset($result['join'])) {
00274         $join[] = $result['join'];
00275       }
00276       if (isset($result['distinct']) && $result['distinct']) {
00277         $distinct = TRUE;
00278       }
00279     }
00280     elseif (isset($result)) {
00281       $where[] = $result;
00282     }
00283   }
00284
00285   $where = empty($where) ? '' : '('. implode(') AND (', $where) .')';
00286   $join = empty($join) ? '' : implode(' ', $join);
00287
00288   return array($join, $where, $distinct);
00289 }
00290
00310 function db_rewrite_sql($query, $primary_table = 'n', $primary_field = 'nid',  $args = array()) {
00311   list($join, $where, $distinct) = _db_rewrite_sql($query, $primary_table, $primary_field, $args);
00312
00313   if ($distinct) {
00314     $query = db_distinct_field($primary_table, $primary_field, $query);
00315   }
00316
00317   if (!empty($where) || !empty($join)) {
00318     $pattern = '{
00319       # Beginning of the string
00320       ^
00321       ((?P<anonymous_view>
00322         # Everything within this set of parentheses is named "anonymous view"
00323         (?:
00324           [^()]++                   # anything not parentheses
00325         |
00326           \( (?P>anonymous_view) \)          # an open parenthesis, more "anonymous view" and finally a close parenthesis.
00327         )*
00328       )[^()]+WHERE)
00329     }x';
00330     preg_match($pattern, $query, $matches);
00331     if (!$where) {
00332       $where = '1 = 1';
00333     }
00334     if ($matches) {
00335       $n = strlen($matches[1]);
00336       $second_part = substr($query, $n);
00337       $first_part = substr($matches[1], 0, $n - 5) ." $join WHERE $where AND ( ";
00338       // PHP 4 does not support strrpos for strings. We emulate it.
00339       $haystack_reverse = strrev($second_part);
00340     }
00341     else {
00342       $haystack_reverse = strrev($query);
00343     }
00344     // No need to use strrev on the needle, we supply GROUP, ORDER, LIMIT
00345     // reversed.
00346     foreach (array('PUORG', 'REDRO', 'TIMIL') as $needle_reverse) {
00347       $pos = strpos($haystack_reverse, $needle_reverse);
00348       if ($pos !== FALSE) {
00349         // All needles are five characters long.
00350         $pos += 5;
00351         break;
00352       }
00353     }
00354     if ($matches) {
00355       if ($pos === FALSE) {
00356         $query = $first_part . $second_part .')';
00357       }
00358       else {
00359         $query = $first_part . substr($second_part, 0, -$pos) .')'. substr($second_part, -$pos);
00360       }
00361     }
00362     elseif ($pos === FALSE) {
00363       $query .= " $join WHERE $where";
00364     }
00365     else {
00366       $query = substr($query, 0, -$pos) . " $join WHERE $where " . substr($query, -$pos);
00367     }
00368   }
00369
00370   return $query;
00371 }
00372
00378 function db_escape_table($string) {
00379   return preg_replace('/[^A-Za-z0-9_]+/', '', $string);
00380 }
00381
00506 function db_create_table(&$ret, $name, $table) {
00507   $statements = db_create_table_sql($name, $table);
00508   foreach ($statements as $statement) {
00509     $ret[] = update_sql($statement);
00510   }
00511 }
00512
00524 function db_field_names($fields) {
00525   $ret = array();
00526   foreach ($fields as $field) {
00527     if (is_array($field)) {
00528       $ret[] = $field[0];
00529     }
00530     else {
00531       $ret[] = $field;
00532     }
00533   }
00534   return $ret;
00535 }
00536
00548 function db_type_placeholder($type) {
00549   switch ($type) {
00550     case 'varchar':
00551     case 'char':
00552     case 'text':
00553     case 'datetime':
00554       return '\'%s\'';
00555
00556     case 'numeric':
00557       // For 'numeric' values, we use '%s', not '\'%s\'' as with
00558       // string types, because numeric values should not be enclosed
00559       // in quotes in queries (though they can be, at least on mysql
00560       // and pgsql).  Numerics should only have [0-9.+-] and
00561       // presumably no db's "escape string" function will mess with
00562       // those characters.
00563       return '%s';
00564
00565     case 'serial':
00566     case 'int':
00567       return '%d';
00568
00569     case 'float':
00570       return '%f';
00571
00572     case 'blob':
00573       return '%b';
00574   }
00575
00576   // There is no safe value to return here, so return something that
00577   // will cause the query to fail.
00578   return 'unsupported type '. $type .'for db_type_placeholder';
00579 }
00580
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/database.mysql-common.inc Source File

includes

database.mysql-common.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: database.mysql-common.inc,v 1.17.2.1 2008/02/07 10:17:26 goba Exp $
00003
00033 function db_query($query) {
00034   $args = func_get_args();
00035   array_shift($args);
00036   $query = db_prefix_tables($query);
00037   if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax
00038     $args = $args[0];
00039   }
00040   _db_query_callback($args, TRUE);
00041   $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
00042   return _db_query($query);
00043 }
00044
00060 function db_create_table_sql($name, $table) {
00061
00062   if (empty($table['mysql_suffix'])) {
00063     $table['mysql_suffix'] = "/*!40100 DEFAULT CHARACTER SET UTF8 */";
00064   }
00065
00066   $sql = "CREATE TABLE {". $name ."} (\n";
00067
00068   // Add the SQL statement for each field.
00069   foreach ($table['fields'] as $field_name => $field) {
00070     $sql .= _db_create_field_sql($field_name, _db_process_field($field)) .", \n";
00071   }
00072
00073   // Process keys & indexes.
00074   $keys = _db_create_keys_sql($table);
00075   if (count($keys)) {
00076     $sql .= implode(", \n", $keys) .", \n";
00077   }
00078
00079   // Remove the last comma and space.
00080   $sql = substr($sql, 0, -3) ."\n) ";
00081
00082   $sql .= $table['mysql_suffix'];
00083
00084   return array($sql);
00085 }
00086
00087 function _db_create_keys_sql($spec) {
00088   $keys = array();
00089
00090   if (!empty($spec['primary key'])) {
00091     $keys[] = 'PRIMARY KEY ('. _db_create_key_sql($spec['primary key']) .')';
00092   }
00093   if (!empty($spec['unique keys'])) {
00094     foreach ($spec['unique keys'] as $key => $fields) {
00095       $keys[] = 'UNIQUE KEY '. $key .' ('. _db_create_key_sql($fields) .')';
00096     }
00097   }
00098   if (!empty($spec['indexes'])) {
00099     foreach ($spec['indexes'] as $index => $fields) {
00100       $keys[] = 'INDEX '. $index .' ('. _db_create_key_sql($fields) .')';
00101     }
00102   }
00103
00104   return $keys;
00105 }
00106
00107 function _db_create_key_sql($fields) {
00108   $ret = array();
00109   foreach ($fields as $field) {
00110     if (is_array($field)) {
00111       $ret[] = $field[0] .'('. $field[1] .')';
00112     }
00113     else {
00114       $ret[] = $field;
00115     }
00116   }
00117   return implode(', ', $ret);
00118 }
00119
00126 function _db_process_field($field) {
00127
00128   if (!isset($field['size'])) {
00129     $field['size'] = 'normal';
00130   }
00131
00132   // Set the correct database-engine specific datatype.
00133   if (!isset($field['mysql_type'])) {
00134     $map = db_type_map();
00135     $field['mysql_type'] = $map[$field['type'] .':'. $field['size']];
00136   }
00137
00138   if ($field['type'] == 'serial') {
00139     $field['auto_increment'] = TRUE;
00140   }
00141
00142   return $field;
00143 }
00144
00156 function _db_create_field_sql($name, $spec) {
00157   $sql = "`". $name ."` ". $spec['mysql_type'];
00158
00159   if (isset($spec['length'])) {
00160     $sql .= '('. $spec['length'] .')';
00161   }
00162   elseif (isset($spec['precision']) && isset($spec['scale'])) {
00163     $sql .= '('. $spec['precision'] .', '. $spec['scale'] .')';
00164   }
00165
00166   if (!empty($spec['unsigned'])) {
00167     $sql .= ' unsigned';
00168   }
00169
00170   if (!empty($spec['not null'])) {
00171     $sql .= ' NOT NULL';
00172   }
00173
00174   if (!empty($spec['auto_increment'])) {
00175     $sql .= ' auto_increment';
00176   }
00177
00178   if (isset($spec['default'])) {
00179     if (is_string($spec['default'])) {
00180       $spec['default'] = "'". $spec['default'] ."'";
00181     }
00182     $sql .= ' DEFAULT '. $spec['default'];
00183   }
00184
00185   if (empty($spec['not null']) && !isset($spec['default'])) {
00186     $sql .= ' DEFAULT NULL';
00187   }
00188
00189   return $sql;
00190 }
00191
00196 function db_type_map() {
00197   // Put :normal last so it gets preserved by array_flip.  This makes
00198   // it much easier for modules (such as schema.module) to map
00199   // database types back into schema types.
00200   $map = array(
00201     'varchar:normal'  => 'VARCHAR',
00202     'char:normal'     => 'CHAR',
00203
00204     'text:tiny'       => 'TINYTEXT',
00205     'text:small'      => 'TINYTEXT',
00206     'text:medium'     => 'MEDIUMTEXT',
00207     'text:big'        => 'LONGTEXT',
00208     'text:normal'     => 'TEXT',
00209
00210     'serial:tiny'     => 'TINYINT',
00211     'serial:small'    => 'SMALLINT',
00212     'serial:medium'   => 'MEDIUMINT',
00213     'serial:big'      => 'BIGINT',
00214     'serial:normal'   => 'INT',
00215
00216     'int:tiny'        => 'TINYINT',
00217     'int:small'       => 'SMALLINT',
00218     'int:medium'      => 'MEDIUMINT',
00219     'int:big'         => 'BIGINT',
00220     'int:normal'      => 'INT',
00221
00222     'float:tiny'      => 'FLOAT',
00223     'float:small'     => 'FLOAT',
00224     'float:medium'    => 'FLOAT',
00225     'float:big'       => 'DOUBLE',
00226     'float:normal'    => 'FLOAT',
00227
00228     'numeric:normal'  => 'DECIMAL',
00229
00230     'blob:big'        => 'LONGBLOB',
00231     'blob:normal'     => 'BLOB',
00232
00233     'datetime:normal' => 'DATETIME',
00234   );
00235   return $map;
00236 }
00237
00248 function db_rename_table(&$ret, $table, $new_name) {
00249   $ret[] = update_sql('ALTER TABLE {'. $table .'} RENAME TO {'. $new_name .'}');
00250 }
00251
00260 function db_drop_table(&$ret, $table) {
00261   $ret[] = update_sql('DROP TABLE {'. $table .'}');
00262 }
00263
00287 function db_add_field(&$ret, $table, $field, $spec, $keys_new = array()) {
00288   $fixnull = FALSE;
00289   if (!empty($spec['not null']) && !isset($spec['default'])) {
00290     $fixnull = TRUE;
00291     $spec['not null'] = FALSE;
00292   }
00293   $query = 'ALTER TABLE {'. $table .'} ADD ';
00294   $query .= _db_create_field_sql($field, _db_process_field($spec));
00295   if (count($keys_new)) {
00296     $query .= ', ADD '. implode(', ADD ', _db_create_keys_sql($keys_new));
00297   }
00298   $ret[] = update_sql($query);
00299   if (isset($spec['initial'])) {
00300     // All this because update_sql does not support %-placeholders.
00301     $sql = 'UPDATE {'. $table .'} SET '. $field .' = '. db_type_placeholder($spec['type']);
00302     $result = db_query($sql, $spec['initial']);
00303     $ret[] = array('success' => $result !== FALSE, 'query' => check_plain($sql .' ('. $spec['initial'] .')'));
00304   }
00305   if ($fixnull) {
00306     $spec['not null'] = TRUE;
00307     db_change_field($ret, $table, $field, $field, $spec);
00308   }
00309 }
00310
00321 function db_drop_field(&$ret, $table, $field) {
00322   $ret[] = update_sql('ALTER TABLE {'. $table .'} DROP '. $field);
00323 }
00324
00337 function db_field_set_default(&$ret, $table, $field, $default) {
00338   if ($default == NULL) {
00339     $default = 'NULL';
00340   }
00341   else {
00342     $default = is_string($default) ? "'$default'" : $default;
00343   }
00344
00345   $ret[] = update_sql('ALTER TABLE {'. $table .'} ALTER COLUMN '. $field .' SET DEFAULT '. $default);
00346 }
00347
00358 function db_field_set_no_default(&$ret, $table, $field) {
00359   $ret[] = update_sql('ALTER TABLE {'. $table .'} ALTER COLUMN '. $field .' DROP DEFAULT');
00360 }
00361
00372 function db_add_primary_key(&$ret, $table, $fields) {
00373   $ret[] = update_sql('ALTER TABLE {'. $table .'} ADD PRIMARY KEY ('.
00374     _db_create_key_sql($fields) .')');
00375 }
00376
00385 function db_drop_primary_key(&$ret, $table) {
00386   $ret[] = update_sql('ALTER TABLE {'. $table .'} DROP PRIMARY KEY');
00387 }
00388
00401 function db_add_unique_key(&$ret, $table, $name, $fields) {
00402   $ret[] = update_sql('ALTER TABLE {'. $table .'} ADD UNIQUE KEY '.
00403     $name .' ('. _db_create_key_sql($fields) .')');
00404 }
00405
00416 function db_drop_unique_key(&$ret, $table, $name) {
00417   $ret[] = update_sql('ALTER TABLE {'. $table .'} DROP KEY '. $name);
00418 }
00419
00432 function db_add_index(&$ret, $table, $name, $fields) {
00433   $query = 'ALTER TABLE {'. $table .'} ADD INDEX '. $name .' ('. _db_create_key_sql($fields) .')';
00434   $ret[] = update_sql($query);
00435 }
00436
00447 function db_drop_index(&$ret, $table, $name) {
00448   $ret[] = update_sql('ALTER TABLE {'. $table .'} DROP INDEX '. $name);
00449 }
00450
00514 function db_change_field(&$ret, $table, $field, $field_new, $spec, $keys_new = array()) {
00515   $sql = 'ALTER TABLE {'. $table .'} CHANGE '. $field .' '.
00516     _db_create_field_sql($field_new, _db_process_field($spec));
00517   if (count($keys_new)) {
00518     $sql .= ', ADD '. implode(', ADD ', _db_create_keys_sql($keys_new));
00519   }
00520   $ret[] = update_sql($sql);
00521 }
00522
00531 function db_last_insert_id($table, $field) {
00532   return db_result(db_query('SELECT LAST_INSERT_ID()'));
00533 }
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/database.mysql.inc Source File

includes

database.mysql.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: database.mysql.inc,v 1.89 2008/01/24 10:46:54 goba Exp $
00003
00014 // Include functions shared between mysql and mysqli.
00015 require_once './includes/database.mysql-common.inc';
00016
00020 function db_status_report($phase) {
00021   $t = get_t();
00022
00023   $version = db_version();
00024
00025   $form['mysql'] = array(
00026     'title' => $t('MySQL database'),
00027     'value' => ($phase == 'runtime') ? l($version, 'admin/reports/status/sql') : $version,
00028   );
00029
00030   if (version_compare($version, DRUPAL_MINIMUM_MYSQL) < 0) {
00031     $form['mysql']['severity'] = REQUIREMENT_ERROR;
00032     $form['mysql']['description'] = $t('Your MySQL Server is too old. Drupal requires at least MySQL %version.', array('%version' => DRUPAL_MINIMUM_MYSQL));
00033   }
00034
00035   return $form;
00036 }
00037
00043 function db_version() {
00044   list($version) = explode('-', mysql_get_server_info());
00045   return $version;
00046 }
00047
00051 function db_connect($url) {
00052   $url = parse_url($url);
00053
00054   // Check if MySQL support is present in PHP
00055   if (!function_exists('mysql_connect')) {
00056     _db_error_page('Unable to use the MySQL database because the MySQL extension for PHP is not installed. Check your <code>php.ini</code> to see how you can enable it.');
00057   }
00058
00059   // Decode url-encoded information in the db connection string
00060   $url['user'] = urldecode($url['user']);
00061   // Test if database url has a password.
00062   $url['pass'] = isset($url['pass']) ? urldecode($url['pass']) : '';
00063   $url['host'] = urldecode($url['host']);
00064   $url['path'] = urldecode($url['path']);
00065
00066   // Allow for non-standard MySQL port.
00067   if (isset($url['port'])) {
00068     $url['host'] = $url['host'] .':'. $url['port'];
00069   }
00070
00071   // - TRUE makes mysql_connect() always open a new link, even if
00072   //   mysql_connect() was called before with the same parameters.
00073   //   This is important if you are using two databases on the same
00074   //   server.
00075   // - 2 means CLIENT_FOUND_ROWS: return the number of found
00076   //   (matched) rows, not the number of affected rows.
00077   $connection = @mysql_connect($url['host'], $url['user'], $url['pass'], TRUE, 2);
00078   if (!$connection || !mysql_select_db(substr($url['path'], 1))) {
00079     // Show error screen otherwise
00080     _db_error_page(mysql_error());
00081   }
00082
00083   // Force UTF-8.
00084   mysql_query('SET NAMES "utf8"', $connection);
00085   return $connection;
00086 }
00087
00091 function _db_query($query, $debug = 0) {
00092   global $active_db, $queries, $user;
00093
00094   if (variable_get('dev_query', 0)) {
00095     list($usec, $sec) = explode(' ', microtime());
00096     $timer = (float)$usec + (float)$sec;
00097     // If devel.module query logging is enabled, prepend a comment with the username and calling function
00098     // to the SQL string. This is useful when running mysql's SHOW PROCESSLIST to learn what exact
00099     // code is issueing the slow query.
00100     $bt = debug_backtrace();
00101     // t() may not be available yet so we don't wrap 'Anonymous'.
00102     $name = $user->uid ? $user->name : variable_get('anonymous', 'Anonymous');
00103     // str_replace() to prevent SQL injection via username or anonymous name.
00104     $name = str_replace(array('*', '/'), '', $name);
00105     $query = '/* '. $name .' : '. $bt[2]['function'] .' */ '. $query;
00106   }
00107
00108   $result = mysql_query($query, $active_db);
00109
00110   if (variable_get('dev_query', 0)) {
00111     $query = $bt[2]['function'] ."\n". $query;
00112     list($usec, $sec) = explode(' ', microtime());
00113     $stop = (float)$usec + (float)$sec;
00114     $diff = $stop - $timer;
00115     $queries[] = array($query, $diff);
00116   }
00117
00118   if ($debug) {
00119     print '<p>query: '. $query .'<br />error:'. mysql_error($active_db) .'</p>';
00120   }
00121
00122   if (!mysql_errno($active_db)) {
00123     return $result;
00124   }
00125   else {
00126     // Indicate to drupal_error_handler that this is a database error.
00127     ${DB_ERROR} = TRUE;
00128     trigger_error(check_plain(mysql_error($active_db) ."\nquery: ". $query), E_USER_WARNING);
00129     return FALSE;
00130   }
00131 }
00132
00142 function db_fetch_object($result) {
00143   if ($result) {
00144     return mysql_fetch_object($result);
00145   }
00146 }
00147
00158 function db_fetch_array($result) {
00159   if ($result) {
00160     return mysql_fetch_array($result, MYSQL_ASSOC);
00161   }
00162 }
00163
00175 function db_result($result) {
00176   if ($result && mysql_num_rows($result) > 0) {
00177     // The mysql_fetch_row function has an optional second parameter $row
00178     // but that can't be used for compatibility with Oracle, DB2, etc.
00179     $array = mysql_fetch_row($result);
00180     return $array[0];
00181   }
00182   return FALSE;
00183 }
00184
00188 function db_error() {
00189   global $active_db;
00190   return mysql_errno($active_db);
00191 }
00192
00196 function db_affected_rows() {
00197   global $active_db;
00198   return mysql_affected_rows($active_db);
00199 }
00200
00229 function db_query_range($query) {
00230   $args = func_get_args();
00231   $count = array_pop($args);
00232   $from = array_pop($args);
00233   array_shift($args);
00234
00235   $query = db_prefix_tables($query);
00236   if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax
00237     $args = $args[0];
00238   }
00239   _db_query_callback($args, TRUE);
00240   $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
00241   $query .= ' LIMIT '. (int)$from .', '. (int)$count;
00242   return _db_query($query);
00243 }
00244
00277 function db_query_temporary($query) {
00278   $args = func_get_args();
00279   $tablename = array_pop($args);
00280   array_shift($args);
00281
00282   $query = preg_replace('/^SELECT/i', 'CREATE TEMPORARY TABLE '. $tablename .' Engine=HEAP SELECT', db_prefix_tables($query));
00283   if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax
00284     $args = $args[0];
00285   }
00286   _db_query_callback($args, TRUE);
00287   $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
00288   return _db_query($query);
00289 }
00290
00299 function db_encode_blob($data) {
00300   global $active_db;
00301   return "'". mysql_real_escape_string($data, $active_db) ."'";
00302 }
00303
00312 function db_decode_blob($data) {
00313   return $data;
00314 }
00315
00319 function db_escape_string($text) {
00320   global $active_db;
00321   return mysql_real_escape_string($text, $active_db);
00322 }
00323
00327 function db_lock_table($table) {
00328   db_query('LOCK TABLES {'. db_escape_table($table) .'} WRITE');
00329 }
00330
00334 function db_unlock_tables() {
00335   db_query('UNLOCK TABLES');
00336 }
00337
00341 function db_table_exists($table) {
00342   return (bool) db_fetch_object(db_query("SHOW TABLES LIKE '{". db_escape_table($table) ."}'"));
00343 }
00344
00348 function db_column_exists($table, $column) {
00349   return (bool) db_fetch_object(db_query("SHOW COLUMNS FROM {". db_escape_table($table) ."} LIKE '". db_escape_table($column) ."'"));
00350 }
00351
00363 function db_distinct_field($table, $field, $query) {
00364   $field_to_select = 'DISTINCT('. $table .'.'. $field .')';
00365   // (?<!text) is a negative look-behind (no need to rewrite queries that already use DISTINCT).
00366   return preg_replace('/(SELECT.*)(?:'. $table .'\.|\s)(?<!DISTINCT\()(?<!DISTINCT\('. $table .'\.)'. $field .'(.*FROM )/AUsi', '\1 '. $field_to_select .'\2', $query);
00367 }
00368
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/database.mysqli.inc Source File

includes

database.mysqli.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: database.mysqli.inc,v 1.54 2008/01/23 09:59:29 goba Exp $
00003
00009  // Maintainers of this file should consult:
00010  // http://www.php.net/manual/en/ref.mysqli.php
00011
00017 // Include functions shared between mysql and mysqli.
00018 require_once './includes/database.mysql-common.inc';
00019
00023 function db_status_report($phase) {
00024   $t = get_t();
00025
00026   $version = db_version();
00027
00028   $form['mysql'] = array(
00029     'title' => $t('MySQL database'),
00030     'value' => ($phase == 'runtime') ? l($version, 'admin/reports/status/sql') : $version,
00031   );
00032
00033   if (version_compare($version, DRUPAL_MINIMUM_MYSQL) < 0) {
00034     $form['mysql']['severity'] = REQUIREMENT_ERROR;
00035     $form['mysql']['description'] = $t('Your MySQL Server is too old. Drupal requires at least MySQL %version.', array('%version' => DRUPAL_MINIMUM_MYSQL));
00036   }
00037
00038   return $form;
00039 }
00040
00046 function db_version() {
00047   global $active_db;
00048   list($version) = explode('-', mysqli_get_server_info($active_db));
00049   return $version;
00050 }
00051
00057 function db_connect($url) {
00058   // Check if MySQLi support is present in PHP
00059   if (!function_exists('mysqli_init') && !extension_loaded('mysqli')) {
00060     _db_error_page('Unable to use the MySQLi database because the MySQLi extension for PHP is not installed. Check your <code>php.ini</code> to see how you can enable it.');
00061   }
00062
00063   $url = parse_url($url);
00064
00065   // Decode url-encoded information in the db connection string
00066   $url['user'] = urldecode($url['user']);
00067   // Test if database url has a password.
00068   $url['pass'] = isset($url['pass']) ? urldecode($url['pass']) : '';
00069   $url['host'] = urldecode($url['host']);
00070   $url['path'] = urldecode($url['path']);
00071   if (!isset($url['port'])) {
00072     $url['port'] = NULL;
00073   }
00074
00075   $connection = mysqli_init();
00076   @mysqli_real_connect($connection, $url['host'], $url['user'], $url['pass'], substr($url['path'], 1), $url['port'], NULL, MYSQLI_CLIENT_FOUND_ROWS);
00077
00078   if (mysqli_connect_errno() > 0) {
00079     _db_error_page(mysqli_connect_error());
00080   }
00081
00082   // Force UTF-8.
00083   mysqli_query($connection, 'SET NAMES "utf8"');
00084
00085   return $connection;
00086 }
00087
00091 function _db_query($query, $debug = 0) {
00092   global $active_db, $queries, $user;
00093
00094   if (variable_get('dev_query', 0)) {
00095     list($usec, $sec) = explode(' ', microtime());
00096     $timer = (float)$usec + (float)$sec;
00097     // If devel.module query logging is enabled, prepend a comment with the username and calling function
00098     // to the SQL string. This is useful when running mysql's SHOW PROCESSLIST to learn what exact
00099     // code is issueing the slow query.
00100     $bt = debug_backtrace();
00101     // t() may not be available yet so we don't wrap 'Anonymous'
00102     $name = $user->uid ? $user->name : variable_get('anonymous', 'Anonymous');
00103     // str_replace() to prevent SQL injection via username or anonymous name.
00104     $name = str_replace(array('*', '/'), '', $name);
00105     $query = '/* '. $name .' : '. $bt[2]['function'] .' */ '. $query;
00106   }
00107
00108   $result = mysqli_query($active_db, $query);
00109
00110   if (variable_get('dev_query', 0)) {
00111     $query = $bt[2]['function'] ."\n". $query;
00112     list($usec, $sec) = explode(' ', microtime());
00113     $stop = (float)$usec + (float)$sec;
00114     $diff = $stop - $timer;
00115     $queries[] = array($query, $diff);
00116   }
00117
00118   if ($debug) {
00119     print '<p>query: '. $query .'<br />error:'. mysqli_error($active_db) .'</p>';
00120   }
00121
00122   if (!mysqli_errno($active_db)) {
00123     return $result;
00124   }
00125   else {
00126     // Indicate to drupal_error_handler that this is a database error.
00127     ${DB_ERROR} = TRUE;
00128     trigger_error(check_plain(mysqli_error($active_db) ."\nquery: ". $query), E_USER_WARNING);
00129     return FALSE;
00130   }
00131 }
00132
00142 function db_fetch_object($result) {
00143   if ($result) {
00144     $object = mysqli_fetch_object($result);
00145     return isset($object) ? $object : FALSE;
00146   }
00147 }
00148
00159 function db_fetch_array($result) {
00160   if ($result) {
00161     $array = mysqli_fetch_array($result, MYSQLI_ASSOC);
00162     return isset($array) ? $array : FALSE;
00163   }
00164 }
00165
00177 function db_result($result) {
00178   if ($result && mysqli_num_rows($result) > 0) {
00179     // The mysqli_fetch_row function has an optional second parameter $row
00180     // but that can't be used for compatibility with Oracle, DB2, etc.
00181     $array = mysqli_fetch_row($result);
00182     return $array[0];
00183   }
00184   return FALSE;
00185 }
00186
00190 function db_error() {
00191   global $active_db;
00192   return mysqli_errno($active_db);
00193 }
00194
00198 function db_affected_rows() {
00199   global $active_db; /* mysqli connection resource */
00200   return mysqli_affected_rows($active_db);
00201 }
00202
00231 function db_query_range($query) {
00232   $args = func_get_args();
00233   $count = array_pop($args);
00234   $from = array_pop($args);
00235   array_shift($args);
00236
00237   $query = db_prefix_tables($query);
00238   if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax
00239     $args = $args[0];
00240   }
00241   _db_query_callback($args, TRUE);
00242   $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
00243   $query .= ' LIMIT '. (int)$from .', '. (int)$count;
00244   return _db_query($query);
00245 }
00246
00279 function db_query_temporary($query) {
00280   $args = func_get_args();
00281   $tablename = array_pop($args);
00282   array_shift($args);
00283
00284   $query = preg_replace('/^SELECT/i', 'CREATE TEMPORARY TABLE '. $tablename .' Engine=HEAP SELECT', db_prefix_tables($query));
00285   if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax
00286     $args = $args[0];
00287   }
00288   _db_query_callback($args, TRUE);
00289   $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
00290   return _db_query($query);
00291 }
00292
00301 function db_encode_blob($data) {
00302   global $active_db;
00303   return "'". mysqli_real_escape_string($active_db, $data) ."'";
00304 }
00305
00314 function db_decode_blob($data) {
00315   return $data;
00316 }
00317
00321 function db_escape_string($text) {
00322   global $active_db;
00323   return mysqli_real_escape_string($active_db, $text);
00324 }
00325
00329 function db_lock_table($table) {
00330   db_query('LOCK TABLES {'. db_escape_table($table) .'} WRITE');
00331 }
00332
00336 function db_unlock_tables() {
00337   db_query('UNLOCK TABLES');
00338 }
00339
00343 function db_table_exists($table) {
00344   return (bool) db_fetch_object(db_query("SHOW TABLES LIKE '{". db_escape_table($table) ."}'"));
00345 }
00346
00350 function db_column_exists($table, $column) {
00351   return (bool) db_fetch_object(db_query("SHOW COLUMNS FROM {". db_escape_table($table) ."} LIKE '". db_escape_table($column) ."'"));
00352 }
00353
00365 function db_distinct_field($table, $field, $query) {
00366   $field_to_select = 'DISTINCT('. $table .'.'. $field .')';
00367   // (?<!text) is a negative look-behind (no need to rewrite queries that already use DISTINCT).
00368   return preg_replace('/(SELECT.*)(?:'. $table .'\.|\s)(?<!DISTINCT\()(?<!DISTINCT\('. $table .'\.)'. $field .'(.*FROM )/AUsi', '\1 '. $field_to_select .'\2', $query);
00369 }
00370
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/database.pgsql.inc Source File

includes

database.pgsql.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: database.pgsql.inc,v 1.68.2.1 2008/02/07 10:17:26 goba Exp $
00003
00017 function db_status_report() {
00018   $t = get_t();
00019
00020   $version = db_version();
00021
00022   $form['pgsql'] = array(
00023     'title' => $t('PostgreSQL database'),
00024     'value' => $version,
00025   );
00026
00027   if (version_compare($version, DRUPAL_MINIMUM_PGSQL) < 0) {
00028     $form['pgsql']['severity'] = REQUIREMENT_ERROR;
00029     $form['pgsql']['description'] = $t('Your PostgreSQL Server is too old. Drupal requires at least PostgreSQL %version.', array('%version' => DRUPAL_MINIMUM_PGSQL));
00030   }
00031
00032   return $form;
00033 }
00034
00040 function db_version() {
00041   return db_result(db_query("SHOW SERVER_VERSION"));
00042 }
00043
00047 function db_connect($url) {
00048   // Check if PostgreSQL support is present in PHP
00049   if (!function_exists('pg_connect')) {
00050     _db_error_page('Unable to use the PostgreSQL database because the PostgreSQL extension for PHP is not installed. Check your <code>php.ini</code> to see how you can enable it.');
00051   }
00052
00053   $url = parse_url($url);
00054   $conn_string = '';
00055
00056   // Decode url-encoded information in the db connection string
00057   if (isset($url['user'])) {
00058     $conn_string .= ' user='. urldecode($url['user']);
00059   }
00060   if (isset($url['pass'])) {
00061     $conn_string .= ' password='. urldecode($url['pass']);
00062   }
00063   if (isset($url['host'])) {
00064     $conn_string .= ' host='. urldecode($url['host']);
00065   }
00066   if (isset($url['path'])) {
00067     $conn_string .= ' dbname='. substr(urldecode($url['path']), 1);
00068   }
00069   if (isset($url['port'])) {
00070     $conn_string .= ' port='. urldecode($url['port']);
00071   }
00072
00073   // pg_last_error() does not return a useful error message for database
00074   // connection errors. We must turn on error tracking to get at a good error
00075   // message, which will be stored in $php_errormsg.
00076   $track_errors_previous = ini_get('track_errors');
00077   ini_set('track_errors', 1);
00078
00079   $connection = @pg_connect($conn_string);
00080   if (!$connection) {
00081     require_once './includes/unicode.inc';
00082     _db_error_page(decode_entities($php_errormsg));
00083   }
00084
00085   // Restore error tracking setting
00086   ini_set('track_errors', $track_errors_previous);
00087
00088   return $connection;
00089 }
00090
00115 function db_query($query) {
00116   $args = func_get_args();
00117   array_shift($args);
00118   $query = db_prefix_tables($query);
00119   if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax
00120     $args = $args[0];
00121   }
00122   _db_query_callback($args, TRUE);
00123   $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
00124   return _db_query($query);
00125 }
00126
00130 function _db_query($query, $debug = 0) {
00131   global $active_db, $last_result, $queries;
00132
00133   if (variable_get('dev_query', 0)) {
00134     list($usec, $sec) = explode(' ', microtime());
00135     $timer = (float)$usec + (float)$sec;
00136   }
00137
00138   $last_result = pg_query($active_db, $query);
00139
00140   if (variable_get('dev_query', 0)) {
00141     $bt = debug_backtrace();
00142     $query = $bt[2]['function'] ."\n". $query;
00143     list($usec, $sec) = explode(' ', microtime());
00144     $stop = (float)$usec + (float)$sec;
00145     $diff = $stop - $timer;
00146     $queries[] = array($query, $diff);
00147   }
00148
00149   if ($debug) {
00150     print '<p>query: '. $query .'<br />error:'. pg_last_error($active_db) .'</p>';
00151   }
00152
00153   if ($last_result !== FALSE) {
00154     return $last_result;
00155   }
00156   else {
00157     // Indicate to drupal_error_handler that this is a database error.
00158     ${DB_ERROR} = TRUE;
00159     trigger_error(check_plain(pg_last_error($active_db) ."\nquery: ". $query), E_USER_WARNING);
00160     return FALSE;
00161   }
00162 }
00163
00173 function db_fetch_object($result) {
00174   if ($result) {
00175     return pg_fetch_object($result);
00176   }
00177 }
00178
00189 function db_fetch_array($result) {
00190   if ($result) {
00191     return pg_fetch_assoc($result);
00192   }
00193 }
00194
00206 function db_result($result) {
00207   if ($result && pg_num_rows($result) > 0) {
00208     $array = pg_fetch_row($result);
00209     return $array[0];
00210   }
00211   return FALSE;
00212 }
00213
00217 function db_error() {
00218   global $active_db;
00219   return pg_last_error($active_db);
00220 }
00221
00230 function db_last_insert_id($table, $field) {
00231   return db_result(db_query("SELECT CURRVAL('{". db_escape_table($table) ."}_". db_escape_table($field) ."_seq')"));
00232 }
00233
00237 function db_affected_rows() {
00238   global $last_result;
00239   return empty($last_result) ? 0 : pg_affected_rows($last_result);
00240 }
00241
00271 function db_query_range($query) {
00272   $args = func_get_args();
00273   $count = array_pop($args);
00274   $from = array_pop($args);
00275   array_shift($args);
00276
00277   $query = db_prefix_tables($query);
00278   if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax
00279     $args = $args[0];
00280   }
00281   _db_query_callback($args, TRUE);
00282   $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
00283   $query .= ' LIMIT '. (int)$count .' OFFSET '. (int)$from;
00284   return _db_query($query);
00285 }
00286
00319 function db_query_temporary($query) {
00320   $args = func_get_args();
00321   $tablename = array_pop($args);
00322   array_shift($args);
00323
00324   $query = preg_replace('/^SELECT/i', 'CREATE TEMPORARY TABLE '. $tablename .' AS SELECT', db_prefix_tables($query));
00325   if (isset($args[0]) and is_array($args[0])) { // 'All arguments in one array' syntax
00326     $args = $args[0];
00327   }
00328   _db_query_callback($args, TRUE);
00329   $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query);
00330   return _db_query($query);
00331 }
00332
00342 function db_encode_blob($data) {
00343   return "'". pg_escape_bytea($data) ."'";
00344 }
00345
00355 function db_decode_blob($data) {
00356   return pg_unescape_bytea($data);
00357 }
00358
00363 function db_escape_string($text) {
00364   return pg_escape_string($text);
00365 }
00366
00371 function db_lock_table($table) {
00372   db_query('BEGIN; LOCK TABLE {'. db_escape_table($table) .'} IN EXCLUSIVE MODE');
00373 }
00374
00379 function db_unlock_tables() {
00380   db_query('COMMIT');
00381 }
00382
00386 function db_table_exists($table) {
00387   return (bool) db_result(db_query("SELECT COUNT(*) FROM pg_class WHERE relname = '{". db_escape_table($table) ."}'"));
00388 }
00389
00393 function db_column_exists($table, $column) {
00394   return (bool) db_result(db_query("SELECT COUNT(pg_attribute.attname) FROM pg_class, pg_attribute WHERE pg_attribute.attrelid = pg_class.oid AND pg_class.relname = '{". db_escape_table($table) ."}' AND attname = '". db_escape_table($column) ."'"));
00395 }
00396
00400 function db_check_setup() {
00401   $t = get_t();
00402
00403   $encoding = db_result(db_query('SHOW server_encoding'));
00404   if (!in_array(strtolower($encoding), array('unicode', 'utf8'))) {
00405     drupal_set_message($t('Your PostgreSQL database is set up with the wrong character encoding (%encoding). It is possible it will not work as expected. It is advised to recreate it with UTF-8/Unicode encoding. More information can be found in the <a href="@url">PostgreSQL documentation</a>.', array('%encoding' => $encoding, '@url' => 'http://www.postgresql.org/docs/7.4/interactive/multibyte.html')), 'status');
00406   }
00407 }
00408
00420 function db_distinct_field($table, $field, $query) {
00421   $field_to_select = 'DISTINCT ON ('. $table .'.'. $field .") $table.$field";
00422   // (?<!text) is a negative look-behind (no need to rewrite queries that already use DISTINCT).
00423   $query = preg_replace('/(SELECT.*)(?:'. $table .'\.|\s)(?<!DISTINCT\()(?<!DISTINCT\('. $table .'\.)'. $field .'(.*FROM )/AUsi', '\1 '. $field_to_select .'\2', $query);
00424   $query = preg_replace('/(ORDER BY )(?!'. $table .'\.'. $field .')/', '\1'."$table.$field, ", $query);
00425   return $query;
00426 }
00427
00441 function db_type_map() {
00442   // Put :normal last so it gets preserved by array_flip.  This makes
00443   // it much easier for modules (such as schema.module) to map
00444   // database types back into schema types.
00445   $map = array(
00446     'varchar:normal' => 'varchar',
00447     'char:normal' => 'character',
00448
00449     'text:tiny' => 'text',
00450     'text:small' => 'text',
00451     'text:medium' => 'text',
00452     'text:big' => 'text',
00453     'text:normal' => 'text',
00454
00455     'int:tiny' => 'smallint',
00456     'int:small' => 'smallint',
00457     'int:medium' => 'int',
00458     'int:big' => 'bigint',
00459     'int:normal' => 'int',
00460
00461     'float:tiny' => 'real',
00462     'float:small' => 'real',
00463     'float:medium' => 'real',
00464     'float:big' => 'double precision',
00465     'float:normal' => 'real',
00466
00467     'numeric:normal' => 'numeric',
00468
00469     'blob:big' => 'bytea',
00470     'blob:normal' => 'bytea',
00471
00472     'datetime:normal' => 'timestamp',
00473
00474     'serial:tiny' => 'serial',
00475     'serial:small' => 'serial',
00476     'serial:medium' => 'serial',
00477     'serial:big' => 'bigserial',
00478     'serial:normal' => 'serial',
00479   );
00480   return $map;
00481 }
00482
00493 function db_create_table_sql($name, $table) {
00494   $sql_fields = array();
00495   foreach ($table['fields'] as $field_name => $field) {
00496     $sql_fields[] = _db_create_field_sql($field_name, _db_process_field($field));
00497   }
00498
00499   $sql_keys = array();
00500   if (isset($table['primary key']) && is_array($table['primary key'])) {
00501     $sql_keys[] = 'PRIMARY KEY ('. implode(', ', $table['primary key']) .')';
00502   }
00503   if (isset($table['unique keys']) && is_array($table['unique keys'])) {
00504     foreach ($table['unique keys'] as $key_name => $key) {
00505       $sql_keys[] = 'CONSTRAINT {'. $name .'}_'. $key_name .'_key UNIQUE ('. implode(', ', $key) .')';
00506     }
00507   }
00508
00509   $sql = "CREATE TABLE {". $name ."} (\n\t";
00510   $sql .= implode(",\n\t", $sql_fields);
00511   if (count($sql_keys) > 0) {
00512     $sql .= ",\n\t";
00513   }
00514   $sql .= implode(",\n\t", $sql_keys);
00515   $sql .= "\n)";
00516   $statements[] = $sql;
00517
00518   if (isset($table['indexes']) && is_array($table['indexes'])) {
00519     foreach ($table['indexes'] as $key_name => $key) {
00520       $statements[] = _db_create_index_sql($name, $key_name, $key);
00521     }
00522   }
00523
00524   return $statements;
00525 }
00526
00527 function _db_create_index_sql($table, $name, $fields) {
00528   $query = 'CREATE INDEX {'. $table .'}_'. $name .'_idx ON {'. $table .'} (';
00529   $query .= _db_create_key_sql($fields) .')';
00530   return $query;
00531 }
00532
00533 function _db_create_key_sql($fields) {
00534   $ret = array();
00535   foreach ($fields as $field) {
00536     if (is_array($field)) {
00537       $ret[] = 'substr('. $field[0] .', 1, '. $field[1] .')';
00538     }
00539     else {
00540       $ret[] = $field;
00541     }
00542   }
00543   return implode(', ', $ret);
00544 }
00545
00546 function _db_create_keys(&$ret, $table, $new_keys) {
00547   if (isset($new_keys['primary key'])) {
00548     db_add_primary_key($ret, $table, $new_keys['primary key']);
00549   }
00550   if (isset($new_keys['unique keys'])) {
00551     foreach ($new_keys['unique keys'] as $name => $fields) {
00552       db_add_unique_key($ret, $table, $name, $fields);
00553     }
00554   }
00555   if (isset($new_keys['indexes'])) {
00556     foreach ($new_keys['indexes'] as $name => $fields) {
00557       db_add_index($ret, $table, $name, $fields);
00558     }
00559   }
00560 }
00561
00568 function _db_process_field($field) {
00569   if (!isset($field['size'])) {
00570     $field['size'] = 'normal';
00571   }
00572   // Set the correct database-engine specific datatype.
00573   if (!isset($field['pgsql_type'])) {
00574     $map = db_type_map();
00575     $field['pgsql_type'] = $map[$field['type'] .':'. $field['size']];
00576   }
00577   if ($field['type'] == 'serial') {
00578     unset($field['not null']);
00579   }
00580   return $field;
00581 }
00582
00594 function _db_create_field_sql($name, $spec) {
00595   $sql = $name .' '. $spec['pgsql_type'];
00596
00597   if ($spec['type'] == 'serial') {
00598     unset($spec['not null']);
00599   }
00600   if (!empty($spec['unsigned'])) {
00601     if ($spec['type'] == 'serial') {
00602       $sql .= " CHECK ($name >= 0)";
00603     }
00604     else {
00605       $sql .= '_unsigned';
00606     }
00607   }
00608
00609   if (!empty($spec['length'])) {
00610     $sql .= '('. $spec['length'] .')';
00611   }
00612   elseif (isset($spec['precision']) && isset($spec['scale'])) {
00613     $sql .= '('. $spec['precision'] .', '. $spec['scale'] .')';
00614   }
00615
00616   if (isset($spec['not null']) && $spec['not null']) {
00617     $sql .= ' NOT NULL';
00618   }
00619   if (isset($spec['default'])) {
00620     $default = is_string($spec['default']) ? "'". $spec['default'] ."'" : $spec['default'];
00621     $sql .= " default $default";
00622   }
00623
00624   return $sql;
00625 }
00626
00637 function db_rename_table(&$ret, $table, $new_name) {
00638   $ret[] = update_sql('ALTER TABLE {'. $table .'} RENAME TO {'. $new_name .'}');
00639 }
00640
00649 function db_drop_table(&$ret, $table) {
00650   $ret[] = update_sql('DROP TABLE {'. $table .'}');
00651 }
00652
00676 function db_add_field(&$ret, $table, $field, $spec, $new_keys = array()) {
00677   $fixnull = FALSE;
00678   if (!empty($spec['not null']) && !isset($spec['default'])) {
00679     $fixnull = TRUE;
00680     $spec['not null'] = FALSE;
00681   }
00682   $query = 'ALTER TABLE {'. $table .'} ADD COLUMN ';
00683   $query .= _db_create_field_sql($field, _db_process_field($spec));
00684   $ret[] = update_sql($query);
00685   if (isset($spec['initial'])) {
00686     // All this because update_sql does not support %-placeholders.
00687     $sql = 'UPDATE {'. $table .'} SET '. $field .' = '. db_type_placeholder($spec['type']);
00688     $result = db_query($sql, $spec['initial']);
00689     $ret[] = array('success' => $result !== FALSE, 'query' => check_plain($sql .' ('. $spec['initial'] .')'));
00690   }
00691   if ($fixnull) {
00692     $ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $field SET NOT NULL");
00693   }
00694   if (isset($new_keys)) {
00695     _db_create_keys($ret, $table, $new_keys);
00696   }
00697 }
00698
00709 function db_drop_field(&$ret, $table, $field) {
00710   $ret[] = update_sql('ALTER TABLE {'. $table .'} DROP COLUMN '. $field);
00711 }
00712
00725 function db_field_set_default(&$ret, $table, $field, $default) {
00726   if ($default == NULL) {
00727     $default = 'NULL';
00728   }
00729   else {
00730     $default = is_string($default) ? "'$default'" : $default;
00731   }
00732
00733   $ret[] = update_sql('ALTER TABLE {'. $table .'} ALTER COLUMN '. $field .' SET DEFAULT '. $default);
00734 }
00735
00746 function db_field_set_no_default(&$ret, $table, $field) {
00747   $ret[] = update_sql('ALTER TABLE {'. $table .'} ALTER COLUMN '. $field .' DROP DEFAULT');
00748 }
00749
00760 function db_add_primary_key(&$ret, $table, $fields) {
00761   $ret[] = update_sql('ALTER TABLE {'. $table .'} ADD PRIMARY KEY ('.
00762     implode(',', $fields) .')');
00763 }
00764
00773 function db_drop_primary_key(&$ret, $table) {
00774   $ret[] = update_sql('ALTER TABLE {'. $table .'} DROP CONSTRAINT {'. $table .'}_pkey');
00775 }
00776
00789 function db_add_unique_key(&$ret, $table, $name, $fields) {
00790   $name = '{'. $table .'}_'. $name .'_key';
00791   $ret[] = update_sql('ALTER TABLE {'. $table .'} ADD CONSTRAINT '.
00792     $name .' UNIQUE ('. implode(',', $fields) .')');
00793 }
00794
00805 function db_drop_unique_key(&$ret, $table, $name) {
00806   $name = '{'. $table .'}_'. $name .'_key';
00807   $ret[] = update_sql('ALTER TABLE {'. $table .'} DROP CONSTRAINT '. $name);
00808 }
00809
00822 function db_add_index(&$ret, $table, $name, $fields) {
00823   $ret[] = update_sql(_db_create_index_sql($table, $name, $fields));
00824 }
00825
00836 function db_drop_index(&$ret, $table, $name) {
00837   $name = '{'. $table .'}_'. $name .'_idx';
00838   $ret[] = update_sql('DROP INDEX '. $name);
00839 }
00840
00903 function db_change_field(&$ret, $table, $field, $field_new, $spec, $new_keys = array()) {
00904   $ret[] = update_sql("ALTER TABLE {". $table ."} RENAME $field TO ". $field ."_old");
00905   $not_null = isset($spec['not null']) ? $spec['not null'] : FALSE;
00906   unset($spec['not null']);
00907
00908   db_add_field($ret, $table, "$field_new", $spec);
00909
00910   $ret[] = update_sql("UPDATE {". $table ."} SET $field_new = ". $field ."_old");
00911
00912   if ($not_null) {
00913     $ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $field_new SET NOT NULL");
00914   }
00915
00916   db_drop_field($ret, $table, $field .'_old');
00917
00918   if (isset($new_keys)) {
00919     _db_create_keys($ret, $table, $new_keys);
00920   }
00921 }
00922
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/dblog/dblog.admin.inc Source File

modules » dblog

dblog.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: dblog.admin.inc,v 1.6 2008/01/08 10:35:41 goba Exp $
00003
00015 function dblog_admin_settings() {
00016   $form['dblog_row_limit'] = array(
00017     '#type' => 'select',
00018     '#title' => t('Discard log entries above the following row limit'),
00019     '#default_value' => variable_get('dblog_row_limit', 1000),
00020     '#options' => drupal_map_assoc(array(100, 1000, 10000, 100000, 1000000)),
00021     '#description' => t('The maximum number of rows to keep in the database log. Older entries will be automatically discarded. (Requires a correctly configured <a href="@cron">cron maintenance task</a>.)', array('@cron' => url('admin/reports/status')))
00022   );
00023
00024   return system_settings_form($form);
00025 }
00026
00030 function dblog_overview() {
00031   $filter = dblog_build_filter_query();
00032   $rows = array();
00033   $icons = array(
00034     WATCHDOG_NOTICE  => '',
00035     WATCHDOG_WARNING => theme('image', 'misc/watchdog-warning.png', t('warning'), t('warning')),
00036     WATCHDOG_ERROR   => theme('image', 'misc/watchdog-error.png', t('error'), t('error')),
00037   );
00038   $classes = array(
00039     WATCHDOG_NOTICE => 'dblog-notice',
00040     WATCHDOG_WARNING => 'dblog-warning',
00041     WATCHDOG_ERROR => 'dblog-error',
00042   );
00043
00044   $output = drupal_get_form('dblog_filter_form');
00045
00046   $header = array(
00047     ' ',
00048     array('data' => t('Type'), 'field' => 'w.type'),
00049     array('data' => t('Date'), 'field' => 'w.wid', 'sort' => 'desc'),
00050     t('Message'),
00051     array('data' => t('User'), 'field' => 'u.name'),
00052     array('data' => t('Operations')),
00053   );
00054
00055   $sql = "SELECT w.wid, w.uid, w.severity, w.type, w.timestamp, w.message, w.variables, w.link, u.name FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid";
00056   $tablesort = tablesort_sql($header);
00057   if (!empty($filter['where'])) {
00058     $result = pager_query($sql ." WHERE ". $filter['where'] . $tablesort, 50, 0, NULL, $filter['args']);
00059   }
00060   else {
00061     $result = pager_query($sql . $tablesort, 50);
00062   }
00063
00064   while ($dblog = db_fetch_object($result)) {
00065     $rows[] = array('data' =>
00066       array(
00067         // Cells
00068         $icons[$dblog->severity],
00069         t($dblog->type),
00070         format_date($dblog->timestamp, 'small'),
00071         l(truncate_utf8(_dblog_format_message($dblog), 56, TRUE, TRUE), 'admin/reports/event/'. $dblog->wid, array('html' => TRUE)),
00072         theme('username', $dblog),
00073         $dblog->link,
00074       ),
00075       // Attributes for tr
00076       'class' => "dblog-". preg_replace('/[^a-z]/i', '-', $dblog->type) .' '. $classes[$dblog->severity]
00077     );
00078   }
00079
00080   if (!$rows) {
00081     $rows[] = array(array('data' => t('No log messages available.'), 'colspan' => 6));
00082   }
00083
00084   $output .= theme('table', $header, $rows, array('id' => 'admin-dblog'));
00085   $output .= theme('pager', NULL, 50, 0);
00086
00087   return $output;
00088 }
00089
00094 function dblog_top($type) {
00095
00096   $header = array(
00097     array('data' => t('Count'), 'field' => 'count', 'sort' => 'desc'),
00098     array('data' => t('Message'), 'field' => 'message')
00099   );
00100
00101   $result = pager_query("SELECT COUNT(wid) AS count, message, variables FROM {watchdog} WHERE type = '%s' GROUP BY message, variables ". tablesort_sql($header), 30, 0, "SELECT COUNT(DISTINCT(message)) FROM {watchdog} WHERE type = '%s'", $type);
00102
00103   $rows = array();
00104   while ($dblog = db_fetch_object($result)) {
00105     $rows[] = array($dblog->count, truncate_utf8(_dblog_format_message($dblog), 56, TRUE, TRUE));
00106   }
00107
00108   if (empty($rows)) {
00109     $rows[] = array(array('data' => t('No log messages available.'), 'colspan' => 2));
00110   }
00111
00112   $output  = theme('table', $header, $rows);
00113   $output .= theme('pager', NULL, 30, 0);
00114
00115   return $output;
00116 }
00117
00121 function dblog_event($id) {
00122   $severity = watchdog_severity_levels();
00123   $output = '';
00124   $result = db_query('SELECT w.*, u.name, u.uid FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid WHERE w.wid = %d', $id);
00125   if ($dblog = db_fetch_object($result)) {
00126     $rows = array(
00127       array(
00128         array('data' => t('Type'), 'header' => TRUE),
00129         t($dblog->type),
00130       ),
00131       array(
00132         array('data' => t('Date'), 'header' => TRUE),
00133         format_date($dblog->timestamp, 'large'),
00134       ),
00135       array(
00136         array('data' => t('User'), 'header' => TRUE),
00137         theme('username', $dblog),
00138       ),
00139       array(
00140         array('data' => t('Location'), 'header' => TRUE),
00141         l($dblog->location, $dblog->location),
00142       ),
00143       array(
00144         array('data' => t('Referrer'), 'header' => TRUE),
00145         l($dblog->referer, $dblog->referer),
00146       ),
00147       array(
00148         array('data' => t('Message'), 'header' => TRUE),
00149         _dblog_format_message($dblog),
00150       ),
00151       array(
00152         array('data' => t('Severity'), 'header' => TRUE),
00153         $severity[$dblog->severity],
00154       ),
00155       array(
00156         array('data' => t('Hostname'), 'header' => TRUE),
00157         check_plain($dblog->hostname),
00158       ),
00159       array(
00160         array('data' => t('Operations'), 'header' => TRUE),
00161         $dblog->link,
00162       ),
00163     );
00164     $attributes = array('class' => 'dblog-event');
00165     $output = theme('table', array(), $rows, $attributes);
00166   }
00167   return $output;
00168 }
00169
00173 function dblog_build_filter_query() {
00174   if (empty($_SESSION['dblog_overview_filter'])) {
00175     return;
00176   }
00177
00178   $filters = dblog_filters();
00179
00180   // Build query
00181   $where = $args = array();
00182   foreach ($_SESSION['dblog_overview_filter'] as $key => $filter) {
00183     $filter_where = array();
00184     foreach ($filter as $value) {
00185       $filter_where[] = $filters[$key]['where'];
00186       $args[] = $value;
00187     }
00188     if (!empty($filter_where)) {
00189       $where[] = '('. implode(' OR ', $filter_where) .')';
00190     }
00191   }
00192   $where = !empty($where) ? implode(' AND ', $where) : '';
00193
00194   return array(
00195     'where' => $where,
00196     'args' => $args,
00197   );
00198 }
00199
00200
00204 function dblog_filters() {
00205   $filters = array();
00206
00207   foreach (_dblog_get_message_types() as $type) {
00208     $types[$type] = $type;
00209   }
00210
00211   if (!empty($types)) {
00212     $filters['type'] = array(
00213       'title' => t('Type'),
00214       'where' => "w.type = '%s'",
00215       'options' => $types,
00216     );
00217   }
00218
00219   $filters['severity'] = array(
00220     'title' => t('Severity'),
00221     'where' => 'w.severity = %d',
00222     'options' => watchdog_severity_levels(),
00223   );
00224
00225   return $filters;
00226 }
00227
00234 function _dblog_format_message($dblog) {
00235   // Legacy messages and user specified text
00236   if ($dblog->variables === 'N;') {
00237     return $dblog->message;
00238   }
00239   // Message to translate with injected variables
00240   else {
00241     return t($dblog->message, unserialize($dblog->variables));
00242   }
00243 }
00244
00245
00253 function dblog_filter_form() {
00254   $session = &$_SESSION['dblog_overview_filter'];
00255   $session = is_array($session) ? $session : array();
00256   $filters = dblog_filters();
00257
00258   $form['filters'] = array(
00259     '#type' => 'fieldset',
00260     '#title' => t('Filter log messages'),
00261     '#theme' => 'dblog_filters',
00262     '#collapsible' => TRUE,
00263     '#collapsed' => empty($session),
00264   );
00265   foreach ($filters as $key => $filter) {
00266     $form['filters']['status'][$key] = array(
00267       '#title' => $filter['title'],
00268       '#type' => 'select',
00269       '#multiple' => TRUE,
00270       '#size' => 8,
00271       '#options' => $filter['options'],
00272     );
00273     if (!empty($session[$key])) {
00274       $form['filters']['status'][$key]['#default_value'] = $session[$key];
00275     }
00276   }
00277
00278   $form['filters']['buttons']['submit'] = array(
00279     '#type' => 'submit',
00280     '#value' => t('Filter'),
00281   );
00282   if (!empty($session)) {
00283     $form['filters']['buttons']['reset'] = array(
00284       '#type' => 'submit',
00285       '#value' => t('Reset')
00286     );
00287   }
00288
00289   return $form;
00290 }
00291
00295 function dblog_filter_form_validate($form, &$form_state) {
00296   if ($form_state['values']['op'] == t('Filter') && empty($form_state['values']['type']) && empty($form_state['values']['severity'])) {
00297     form_set_error('type', t('You must select something to filter by.'));
00298   }
00299 }
00300
00304 function dblog_filter_form_submit($form, &$form_state) {
00305   $op = $form_state['values']['op'];
00306   $filters = dblog_filters();
00307   switch ($op) {
00308     case t('Filter'):
00309       foreach ($filters as $name => $filter) {
00310         if (isset($form_state['values'][$name])) {
00311           $_SESSION['dblog_overview_filter'][$name] = $form_state['values'][$name];
00312         }
00313       }
00314       break;
00315     case t('Reset'):
00316       $_SESSION['dblog_overview_filter'] = array();
00317       break;
00318   }
00319   return 'admin/reports/dblog';
00320 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/dblog/dblog.install Source File

modules » dblog

dblog.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: dblog.install,v 1.6 2007/11/04 14:33:06 goba Exp $
00003
00007 function dblog_install() {
00008   // Create tables.
00009   drupal_install_schema('dblog');
00010 }
00011
00015 function dblog_uninstall() {
00016   // Remove tables.
00017   drupal_uninstall_schema('dblog');
00018 }
00019
00023 function dblog_schema() {
00024   $schema['watchdog'] = array(
00025     'description' => t('Table that contains logs of all system events.'),
00026     'fields' => array(
00027       'wid' => array(
00028         'type' => 'serial',
00029         'not null' => TRUE,
00030         'description' => t('Primary Key: Unique watchdog event ID.'),
00031       ),
00032       'uid' => array(
00033         'type' => 'int',
00034         'not null' => TRUE,
00035         'default' => 0,
00036         'description' => t('The {users}.uid of the user who triggered the event.'),
00037       ),
00038       'type' => array(
00039         'type' => 'varchar',
00040         'length' => 16,
00041         'not null' => TRUE,
00042         'default' => '',
00043         'description' => t('Type of log message, for example "user" or "page not found."'),
00044       ),
00045       'message' => array(
00046         'type' => 'text',
00047         'not null' => TRUE,
00048         'size' => 'big',
00049         'description' => t('Text of log message to be passed into the t() function.'),
00050       ),
00051       'variables' => array(
00052         'type' => 'text',
00053         'not null' => TRUE,
00054         'size' => 'big',
00055         'description' => t('Serialized array of variables that match the message string and that is passed into the t() function.'),
00056       ),
00057       'severity' => array(
00058         'type' => 'int',
00059         'unsigned' => TRUE,
00060         'not null' => TRUE,
00061         'default' => 0,
00062         'size' => 'tiny',
00063         'description' => t('The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)'),
00064       ),
00065       'link' => array(
00066         'type' => 'varchar',
00067         'length' => 255,
00068         'not null' => TRUE,
00069         'default' => '',
00070         'description' => t('Link to view the result of the event.'),
00071       ),
00072       'location'  => array(
00073         'type' => 'text',
00074         'not null' => TRUE,
00075         'description' => t('URL of the origin of the event.'),
00076       ),
00077       'referer' => array(
00078         'type' => 'varchar',
00079         'length' => 128,
00080         'not null' => TRUE,
00081         'default' => '',
00082         'description' => t('URL of referring page.'),
00083       ),
00084       'hostname' => array(
00085         'type' => 'varchar',
00086         'length' => 128,
00087         'not null' => TRUE,
00088         'default' => '',
00089         'description' => t('Hostname of the user who triggered the event.'),
00090       ),
00091       'timestamp' => array(
00092         'type' => 'int',
00093         'not null' => TRUE,
00094         'default' => 0,
00095         'description' => t('Unix timestamp of when event occurred.'),
00096       ),
00097     ),
00098     'primary key' => array('wid'),
00099     'indexes' => array('type' => array('type')),
00100   );
00101
00102   return $schema;
00103 }
00104
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/dblog/dblog.module Source File

modules » dblog

dblog.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: dblog.module,v 1.21 2008/01/08 10:35:41 goba Exp $
00003
00018 function dblog_help($path, $arg) {
00019   switch ($path) {
00020     case 'admin/help#dblog':
00021       $output = '<p>'. t('The dblog module monitors your system, capturing system events in a log to be reviewed by an authorized individual at a later time. This is useful for site administrators who want a quick overview of activities on their site. The logs also record the sequence of events, so it can be useful for debugging site errors.') .'</p>';
00022       $output .= '<p>'. t('The dblog log is simply a list of recorded events containing usage data, performance data, errors, warnings and operational information. Administrators should check the dblog report on a regular basis to ensure their site is working properly.') .'</p>';
00023       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@dblog">Dblog module</a>.', array('@dblog' => 'http://drupal.org/handbook/modules/dblog/')) .'</p>';
00024       return $output;
00025     case 'admin/reports/dblog':
00026       return '<p>'. t('The dblog module monitors your website, capturing system events in a log to be reviewed by an authorized individual at a later time. The dblog log is simply a list of recorded events containing usage data, performance data, errors, warnings and operational information. It is vital to check the dblog report on a regular basis as it is often the only way to tell what is going on.') .'</p>';
00027   }
00028 }
00029
00033 function dblog_theme() {
00034   return array(
00035     'dblog_filters' => array(
00036       'arguments' => array('form' => NULL),
00037     ),
00038   );
00039 }
00040
00044 function dblog_menu() {
00045   $items['admin/settings/logging/dblog'] = array(
00046     'title' => 'Database logging',
00047     'description' => 'Settings for logging to the Drupal database logs. This is the most common method for small to medium sites on shared hosting. The logs are viewable from the admin pages.',
00048     'page callback' => 'drupal_get_form',
00049     'page arguments' => array('dblog_admin_settings'),
00050     'file' => 'dblog.admin.inc',
00051   );
00052
00053   $items['admin/reports/dblog'] = array(
00054     'title' => 'Recent log entries',
00055     'description' => 'View events that have recently been logged.',
00056     'page callback' => 'dblog_overview',
00057     'weight' => -1,
00058     'file' => 'dblog.admin.inc',
00059   );
00060   $items['admin/reports/page-not-found'] = array(
00061     'title' => "Top 'page not found' errors",
00062     'description' => "View 'page not found' errors (404s).",
00063     'page callback' => 'dblog_top',
00064     'page arguments' => array('page not found'),
00065     'file' => 'dblog.admin.inc',
00066   );
00067   $items['admin/reports/access-denied'] = array(
00068     'title' => "Top 'access denied' errors",
00069     'description' => "View 'access denied' errors (403s).",
00070     'page callback' => 'dblog_top',
00071     'page arguments' => array('access denied'),
00072     'file' => 'dblog.admin.inc',
00073   );
00074   $items['admin/reports/event/%'] = array(
00075     'title' => 'Details',
00076     'page callback' => 'dblog_event',
00077     'page arguments' => array(3),
00078     'type' => MENU_CALLBACK,
00079     'file' => 'dblog.admin.inc',
00080   );
00081   return $items;
00082 }
00083
00084 function dblog_init() {
00085   if (arg(0) == 'admin' && arg(1) == 'reports') {
00086     // Add the CSS for this module
00087     drupal_add_css(drupal_get_path('module', 'dblog') .'/dblog.css', 'module', 'all', FALSE);
00088   }
00089 }
00090
00091
00092
00098 function dblog_cron() {
00099   // Cleanup the watchdog table
00100   $max = db_result(db_query('SELECT MAX(wid) FROM {watchdog}'));
00101   db_query('DELETE FROM {watchdog} WHERE wid < %d', $max - variable_get('dblog_row_limit', 1000));
00102 }
00103
00107 function dblog_user($op, &$edit, &$user) {
00108   if ($op == 'delete') {
00109     db_query('UPDATE {watchdog} SET uid = 0 WHERE uid = %d', $user->uid);
00110   }
00111 }
00112
00113 function _dblog_get_message_types() {
00114   $types = array();
00115
00116   $result = db_query('SELECT DISTINCT(type) FROM {watchdog} ORDER BY type');
00117   while ($object = db_fetch_object($result)) {
00118     $types[] = $object->type;
00119   }
00120
00121   return $types;
00122 }
00123
00124 function dblog_watchdog($log = array()) {
00125   $current_db = db_set_active();
00126   db_query("INSERT INTO {watchdog}
00127     (uid, type, message, variables, severity, link, location, referer, hostname, timestamp)
00128     VALUES
00129     (%d, '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', %d)",
00130     $log['user']->uid,
00131     $log['type'],
00132     $log['message'],
00133     serialize($log['variables']),
00134     $log['severity'],
00135     $log['link'],
00136     $log['request_uri'],
00137     $log['referer'],
00138     $log['ip'],
00139     $log['timestamp']);
00140
00141   if ($current_db) {
00142     db_set_active($current_db);
00143   }
00144 }
00145
00151 function theme_dblog_filters($form) {
00152   $output = '';
00153   foreach (element_children($form['status']) as $key) {
00154     $output .= drupal_render($form['status'][$key]);
00155   }
00156   $output .= '<div id="dblog-admin-buttons">'. drupal_render($form['buttons']) .'</div>';
00157   return $output;
00158 }
00159
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: profiles/default/default.profile Source File

profiles » default

default.profile

Go to the documentation of this file.
00001 <?php
00002 // $Id: default.profile,v 1.22 2007/12/17 12:43:34 goba Exp $
00003
00010 function default_profile_modules() {
00011   return array('color', 'comment', 'help', 'menu', 'taxonomy', 'dblog');
00012 }
00013
00022 function default_profile_details() {
00023   return array(
00024     'name' => 'Drupal',
00025     'description' => 'Select this profile to enable some basic Drupal functionality and the default theme.'
00026   );
00027 }
00028
00038 function default_profile_task_list() {
00039 }
00040
00092 function default_profile_tasks(&$task, $url) {
00093
00094   // Insert default user-defined node types into the database. For a complete
00095   // list of available node type attributes, refer to the node type API
00096   // documentation at: http://api.drupal.org/api/HEAD/function/hook_node_info.
00097   $types = array(
00098     array(
00099       'type' => 'page',
00100       'name' => st('Page'),
00101       'module' => 'node',
00102       'description' => st("A <em>page</em>, similar in form to a <em>story</em>, is a simple method for creating and displaying information that rarely changes, such as an \"About us\" section of a website. By default, a <em>page</em> entry does not allow visitor comments and is not featured on the site's initial home page."),
00103       'custom' => TRUE,
00104       'modified' => TRUE,
00105       'locked' => FALSE,
00106       'help' => '',
00107       'min_word_count' => '',
00108     ),
00109     array(
00110       'type' => 'story',
00111       'name' => st('Story'),
00112       'module' => 'node',
00113       'description' => st("A <em>story</em>, similar in form to a <em>page</em>, is ideal for creating and displaying content that informs or engages website visitors. Press releases, site announcements, and informal blog-like entries may all be created with a <em>story</em> entry. By default, a <em>story</em> entry is automatically featured on the site's initial home page, and provides the ability to post comments."),
00114       'custom' => TRUE,
00115       'modified' => TRUE,
00116       'locked' => FALSE,
00117       'help' => '',
00118       'min_word_count' => '',
00119     ),
00120   );
00121
00122   foreach ($types as $type) {
00123     $type = (object) _node_type_set_defaults($type);
00124     node_type_save($type);
00125   }
00126
00127   // Default page to not be promoted and have comments disabled.
00128   variable_set('node_options_page', array('status'));
00129   variable_set('comment_page', COMMENT_NODE_DISABLED);
00130
00131   // Don't display date and author information for page nodes by default.
00132   $theme_settings = variable_get('theme_settings', array());
00133   $theme_settings['toggle_node_info_page'] = FALSE;
00134   variable_set('theme_settings', $theme_settings);
00135
00136   // Update the menu router information.
00137   menu_rebuild();
00138 }
00139
00146 function default_form_alter(&$form, $form_state, $form_id) {
00147   if ($form_id == 'install_configure') {
00148     // Set default for site name field.
00149     $form['site_information']['site_name']['#default_value'] = $_SERVER['SERVER_NAME'];
00150   }
00151 }
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/hooks/install.php Source File

docs » hooks

install.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: install.php,v 1.14 2008/01/28 02:57:37 bdragon Exp $
00003
00069 function hook_requirements($phase) {
00070   $requirements = array();
00071   // Ensure translations don't break at install time
00072   $t = get_t();
00073
00074   // Report Drupal version
00075   if ($phase == 'runtime') {
00076     $requirements['drupal'] = array(
00077       'title' => $t('Drupal'),
00078       'value' => VERSION,
00079       'severity' => REQUIREMENT_INFO
00080     );
00081   }
00082
00083   // Test PHP version
00084   $requirements['php'] = array(
00085     'title' => $t('PHP'),
00086     'value' => ($phase == 'runtime') ? l(phpversion(), 'admin/logs/status/php') : phpversion(),
00087   );
00088   if (version_compare(phpversion(), DRUPAL_MINIMUM_PHP) < 0) {
00089     $requirements['php']['description'] = $t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => DRUPAL_MINIMUM_PHP));
00090     $requirements['php']['severity'] = REQUIREMENT_ERROR;
00091   }
00092
00093   // Report cron status
00094   if ($phase == 'runtime') {
00095     $cron_last = variable_get('cron_last', NULL);
00096
00097     if (is_numeric($cron_last)) {
00098       $requirements['cron']['value'] = $t('Last run !time ago', array('!time' => format_interval(time() - $cron_last)));
00099     }
00100     else {
00101       $requirements['cron'] = array(
00102         'description' => $t('Cron has not run. It appears cron jobs have not been setup on your system. Please check the help pages for <a href="@url">configuring cron jobs</a>.', array('@url' => 'http://drupal.org/cron')),
00103         'severity' => REQUIREMENT_ERROR,
00104         'value' => $t('Never run'),
00105       );
00106     }
00107
00108     $requirements['cron']['description'] .= ' '. t('You can <a href="@cron">run cron manually</a>.', array('@cron' => url('admin/logs/status/run-cron')));
00109
00110     $requirements['cron']['title'] = $t('Cron maintenance tasks');
00111   }
00112
00113   return $requirements;
00114 }
00115
00137 function hook_schema() {
00138   $schema['mytable1'] = array(
00139      // specification for mytable1
00140   );
00141   $schema['mytable2'] = array(
00142      // specification for mytable2
00143   );
00144   return $schema;
00145 }
00146
00164 function hook_install() {
00165   drupal_install_schema('upload');
00166 }
00167
00213 function hook_update_N() {
00214   $ret = array();
00215   db_add_field($ret, 'mytable1', 'newcol', array('type' => 'int', 'not null' => TRUE));
00216   return $ret;
00217 }
00218
00224 function hook_uninstall() {
00225   drupal_uninstall_schema('upload');
00226   variable_del('upload_file_types');
00227 }
00228
00234 function hook_enable() {
00235   mymodule_cache_rebuild();
00236 }
00237
00243 function hook_disable() {
00244   mymodule_cache_rebuild();
00245 }
00246
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/index.php Source File

docs

index.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: index.php,v 1.21 2008/02/05 00:56:19 pwolanin Exp $
00003
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/example.profile Source File

docs

example.profile

Go to the documentation of this file.
00001 <?php
00002 // $Id: example.profile,v 1.1 2007/12/08 18:12:38 wmostrey Exp $
00003
00010 function example_profile_modules() {
00011   // This example profile enables the same optional modules as default.profile,
00012   // plus the 'locale' module. But however, any available modules may be added
00013   // to the list, including contributed modules, which will be then reqired by
00014   // the installer. Configuration of these modules may be handled later by tasks.
00015   return array('color', 'comment', 'help', 'menu', 'taxonomy', 'dblog', 'locale');
00016 }
00017
00026 function example_profile_details() {
00027   return array(
00028     // These two strings will be displayed on the initial profile-selecion
00029     // page, as a radio-button label, and description below. Because the
00030     // page is shown before language selection, there's no point to attempt
00031     // translation in any way; it's always shown in English. But however,
00032     // if the profile is focused to install Drupal in some other language,
00033     // these strings may be provided in that language, assuming that the
00034     // maintainer of the installed new Drupal site understands that better.
00035     // To skip the untranslatable profile-selection page entirely, ensure
00036     // that there's just one profile available, by deleting the default
00037     // profile.
00038     'name' => 'Example installation profile',
00039     'description' => 'This is an example installation profile for Drupal 6.x, demonstrating some of the principles to developers.',
00040     // This example profile is supposed to be language-focused, so we
00041     // inject the language selection here, hiding the language selection
00042     // screen from the user, and so saving one unnecessary, untranslatable
00043     // step. Any profile focused to features rather than language, or
00044     // expecting more languages to choose from, should omit the line below.
00045     // We're using Czech as an example here; it only works if a valid file
00046     // cs.po (with installer translations) is provided in the
00047     // profiles/example/translations directory, otherwise default English
00048     // will be used instead.
00049     'language' => 'cs',
00050   );
00051 }
00052
00062 function example_profile_task_list() {
00063   return array(
00064     // Here we define names of the custom tasks we're about to perform
00065     // later, so that these will be shown in the tasks list on the
00066     // installer UI. The keys may be anything (internal use only),
00067     // excepting the reserved tasks (as listed in install_reserved_tasks()
00068     // inside install.php). The strings may be translated with the st()
00069     // wrapper (translations provided in the install profile's .po file),
00070     // but sometimes there's no point in doing that, if the profile is
00071     // only focused to a single language. We only need to list tasks,
00072     // for which a page will be displayed; internally, unlisted keys
00073     // may be well used too. It's also possible to return dynamic data
00074     // here, adding/removing tasks on-the-fly depending on previous
00075     // steps.
00076     'task1' => st('Example question'),
00077     'task2' => st('Example summary'),
00078   );
00079 }
00080
00131 function example_profile_tasks(&$task, $url) {
00132
00133   // First time, this function will be called with the 'profile' task.
00134   // In this case, we advance the pointer to our first custom task, to
00135   // indicate that this profile needs more runs to complete, and we
00136   // also perform some initial settings.
00137   if ($task == 'profile') {
00138     $task = 'task1';
00139
00140     // The following part is a verbatim from default.profile, doing some
00141     // basic settings, that may be easily customized here. For a simple
00142     // profile, with no need for custom UI screens, this will be the
00143     // only code inside hook_profile_tasks(); in that case there's
00144     // no need to modify $task, as demonstrated in default.profile:
00145     // If $task is not changed, this function gets only called once.
00146
00147     // Insert default user-defined node types into the database. For a complete
00148     // list of available node type attributes, refer to the node type API
00149     // documentation at: http://api.drupal.org/api/HEAD/function/hook_node_info.
00150     $types = array(
00151       array(
00152         'type' => 'page',
00153         'name' => st('Page'),
00154         'module' => 'node',
00155         'description' => st("A <em>page</em>, similar in form to a <em>story</em>, is a simple method for creating and displaying information that rarely changes, such as an \"About us\" section of a website. By default, a <em>page</em> entry does not allow visitor comments and is not featured on the site's initial home page."),
00156         'custom' => TRUE,
00157         'modified' => TRUE,
00158         'locked' => FALSE,
00159         'help' => '',
00160         'min_word_count' => '',
00161       ),
00162       array(
00163         'type' => 'story',
00164         'name' => st('Story'),
00165         'module' => 'node',
00166         'description' => st("A <em>story</em>, similar in form to a <em>page</em>, is ideal for creating and displaying content that informs or engages website visitors. Press releases, site announcements, and informal blog-like entries may all be created with a <em>story</em> entry. By default, a <em>story</em> entry is automatically featured on the site's initial home page, and provides the ability to post comments."),
00167         'custom' => TRUE,
00168         'modified' => TRUE,
00169         'locked' => FALSE,
00170         'help' => '',
00171         'min_word_count' => '',
00172       ),
00173     );
00174
00175     foreach ($types as $type) {
00176       $type = (object) _node_type_set_defaults($type);
00177       node_type_save($type);
00178     }
00179
00180     // Default page to not be promoted and have comments disabled.
00181     variable_set('node_options_page', array('status'));
00182     variable_set('comment_page', COMMENT_NODE_DISABLED);
00183
00184     // Don't display date and author information for page nodes by default.
00185     $theme_settings = variable_get('theme_settings', array());
00186     $theme_settings['toggle_node_info_page'] = FALSE;
00187     variable_set('theme_settings', $theme_settings);
00188
00189     // Update the menu router information.
00190     menu_rebuild();
00191   }
00192   // (End of verbatim from default.profile)
00193
00194   // Our custom tasks now follow. Just like install.php, we use a construct
00195   // of if() statements here, to allow passing from one task to another in
00196   // the same request, after the $task pointer got modified, and ensure
00197   // that correct code gets executed on page reloads.
00198
00199   // Our first custom task displays a form.
00200   if ($task == 'task1') {
00201     // FAPI takes care of most of the operations, as page reloads go.
00202     // We pass the $url to the form definition, to be used for form action.
00203     $output = drupal_get_form('example_form', $url);
00204
00205     // The forms inside installer profiles may not use redirection, because
00206     // that will break the installer workflow. So we need an other way to
00207     // detect whether the form was successfully submitted, meaning that
00208     // the submit handler already performed it's job. This depends on the
00209     // exact use case; in this example profile, we check whether some
00210     // user-submitted text was already stored into our variable.
00211     if (!variable_get('example_submitted_text', FALSE)) {
00212       // The variable is still empty, meaning that the drupal_get_form()
00213       // call above haven't finished the form yet. We set a page-title
00214       // here, and return the rendered form to the installer, to be
00215       // shown to the user. Since $task is still set to 'task1', this
00216       // code will be re-run on next page request, proceeding further
00217       // if possible.
00218       drupal_set_title(st('Example question'));
00219       return $output;
00220     }
00221     else {
00222       // The form was submitted, so now we advance to the next task.
00223       $task = 'task2';
00224     }
00225   }
00226
00227   // Our second custom task shows a simple page, summarizing the previous
00228   // step.
00229   if ($task == 'task2') {
00230
00231     // To display a simple HTML page through the installer, we just set
00232     // title, and return the content. But since this code is now run on
00233     // every page request (until we change the $task), we need to detect
00234     // whether the user already decided to finish this task by clicking
00235     // to the provided link (as opposed to showing the page first time,
00236     // or a reload). This is done through an extra GET string added to
00237     // the link.
00238     if (empty($_GET['example_finished'])) {
00239       // The GET string is not present, meaning that this page request
00240       // is not coming from the link being clicked, and so we need to
00241       // render the page.
00242       $output = '<p>'. st('This page is a demonstration of custom page shown by a custom task of installer profile.') .'</p>';
00243       $output .= '<p>'. st('On the previous page, the following text was entered: %text.', array('%text' => variable_get('example_submitted_text', ''))) .'</p>';
00244       // We build the link from $url provided by the installer, adding
00245       // the extra GET string mentioned above.
00246       $output .= '<p><a href="'. $url .'&example_finished=yes">'. st('Click here to continue') .'</a></p>';
00247       drupal_set_title(st('Example summary'));
00248       return $output;
00249     }
00250     else {
00251       // The GET string is present, meaning that the user already
00252       // reviewed the page and clicked the link. We can advance to
00253       // further tasks now, but since we haven't any left, we just
00254       // finish our business here:
00255
00256       // The variable 'example_submitted_text' was just a temporary
00257       // storage for our testing. Variables may be used for such
00258       // purposes here, but we should remove them before passing
00259       // control back to installer, to avoid leaving useless temporary
00260       // data in the variables table of the newly installed Drupal
00261       // site.
00262       variable_del('example_submitted_text');
00263
00264       // By advancing to the 'profile-finished' task, we hand control
00265       // back to the installer, when we are done.
00266       $task = 'profile-finished';
00267     }
00268   }
00269 }
00270
00274 function example_form(&$form_state, $url) {
00275
00276     // This is just a very simple form with one textfield, and a
00277     // submit button.
00278     $form['example_text'] = array(
00279       '#type' => 'textfield',
00280       '#title' => st('Testing text'),
00281       '#default_value' => '',
00282       '#size' => 45,
00283       '#maxlength' => 45,
00284       '#required' => TRUE,
00285       '#description' => st('This is an example form demonstrating forms usage in the installer profiles tasks. Enter any text to see what happens.'),
00286     );
00287
00288     $form['continue'] = array(
00289       '#type' => 'submit',
00290       '#value' => st('Continue'),
00291     );
00292
00293     // Note that #action is set to the url passed through from
00294     // installer, ensuring that it points to the same page, and
00295     // #redirect is FALSE to avoid broken installer workflow.
00296     $form['errors'] = array();
00297     $form['#action'] = $url;
00298     $form['#redirect'] = FALSE;
00299
00300   return $form;
00301 }
00302
00306 function example_form_submit($form, &$form_state) {
00307
00308   // This code is executed, while the form is submitted. There's
00309   // a wide range of possible operations to execute here, such as
00310   // process and store settings, enable extra modules, or save
00311   // contents to the new site (unless the operations are too
00312   // expensive: the Batch API is a good choice for such operations,
00313   // but it needs to be coded inside hook_profile_tasks(), not
00314   // here).
00315
00316   // In this example profile, we just store the submitted text to
00317   // a temporary variable, to be used in further tasks.
00318   variable_set('example_submitted_text', $form_state['values']['example_text']);
00319 }
00320
00327 function example_form_alter(&$form, $form_state, $form_id) {
00328   if ($form_id == 'install_configure') {
00329
00330     // Here we can play with the site configuration form provided
00331     // by the installer, by changing the prepopulated $form array.
00332     // See install_configure_form() inside install.php for its
00333     // default content.
00334
00335     // Set default for site name field.
00336     $form['site_information']['site_name']['#default_value'] = 'Drupal example';
00337
00338     // Set default for administrator account name.
00339     $form['admin_account']['account']['name']['#default_value'] = 'admin';
00340
00341     // Remove the timezone setting, as this profile is supposed to be
00342     // focused on Czech language as an example, where the timezone is
00343     // obvious.
00344     unset($form['server_settings']['date_default_timezone']);
00345     // Define the timezone as fixed value instead, so that the submit
00346     // handler of the site configuration form may still process it.
00347     $form['date_default_timezone'] = array(
00348       '#type' => 'value',
00349       '#value' => '3600',
00350     );
00351   }
00352 }
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/example_element.module Source File

docs » examples

example_element.module

Go to the documentation of this file.
00001 <?php
00002
00003 // $Id: example_element.module,v 1.4 2007/10/05 16:42:46 drewish Exp $
00004
00033 function example_element_menu() {
00034   $items['example/element'] = array(
00035     'title' => 'Example element demo',
00036     'page callback' => 'drupal_get_form',
00037     'page arguments' => array('example_element_demo_form'),
00038     'access arguments' => array('access content'),
00039   );
00040   return $items;
00041 }
00042
00046 function example_element_elements() {
00047   $type['phonenumber'] = array(
00048     '#input' => TRUE,
00049     '#process' => array('example_element_phonenumber_expand'),
00050     '#element_validate' => array('example_element_phonenumber_validate'),
00051     '#default_value' => array('areacode' => '', 'number' => '', 'extension' => ''),
00052   );
00053   return $type;
00054 }
00055
00059 function example_element_phonenumber_expand($element) {
00060   $element['#tree'] = TRUE;
00061
00062   if (!isset($element['#value'])) {
00063     $element['#value'] = array('areacode' => '', 'number' => '', 'extension' => '');
00064   }
00065
00066   $element['areacode'] = array(
00067     '#type' => 'textfield',
00068     '#size' => 3,
00069     '#maxlength' => 3,
00070     '#value' => $element['#value']['areacode'],
00071     '#prefix' => '(',
00072     '#suffix' => ')',
00073   );
00074   $element['number'] =  array(
00075     '#type' => 'textfield',
00076     '#size' => 8,
00077     '#maxlength' => 8,
00078     '#required' => TRUE,
00079     '#value' => $element['#value']['number'],
00080   );
00081   $element['extension'] =  array(
00082     '#type' => 'textfield',
00083     '#size' => 10,
00084     '#maxlength' => 10,
00085     '#prefix' => t('ext'),
00086     '#value' => $element['#value']['extension'],
00087   );
00088
00089   return $element;
00090 }
00091
00101 function example_element_phonenumber_validate($form, &$form_state) {
00102   if (isset($form['#value']['areacode'])) {
00103     if (0 == preg_match('/^\d{3}$/', $form['#value']['areacode'])) {
00104       form_error($form['areacode'], t('The areacode is invalid.'));
00105     }
00106   }
00107   if (isset($form['#value']['number'])) {
00108     if (0 == preg_match('/^\d{3}-?\d{4}$/', $form['#value']['number'])) {
00109       form_error($form['number'], t('The number is invalid.'));
00110     }
00111   }
00112   return $form;
00113
00114 }
00115
00121 function example_element_theme() {
00122   return array(
00123     'phonenumber' => array(
00124       'arguments' => array('element'),
00125     ),
00126   );
00127 }
00128
00135 function theme_phonenumber($element) {
00136   return theme('form_element', $element, '<div class="container-inline">'. $element['#children'] .'</div>');
00137 }
00138
00143 function example_element_demo_form() {
00144   $form['example_element_test_1'] = array(
00145     '#type' => 'phonenumber',
00146     '#title' => t('Phone number 1'),
00147     '#default_value' => variable_get('example_element_test_1',
00148       array('areacode' => '123', 'number' => '456-7890', 'extension' => '')
00149     ),
00150     '#description' => t('A phone number.'),
00151   );
00152
00153   $form['example_element_test_2'] = array(
00154     '#type' => 'phonenumber',
00155     '#title' => t('Phone number 2'),
00156     '#default_value' => variable_get('example_element_test_2',
00157       array('areacode' => '', 'number' => '456-7890', 'extension' => '23')
00158     ),
00159     '#description' => t('Another phone number, a fax perhaps?'),
00160   );
00161
00162   return system_settings_form($form);
00163 }
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/file.inc Source File

includes

file.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: file.inc,v 1.121.2.1 2008/02/07 18:20:37 goba Exp $
00003
00015 define('FILE_DOWNLOADS_PUBLIC', 1);
00016 define('FILE_DOWNLOADS_PRIVATE', 2);
00017 define('FILE_CREATE_DIRECTORY', 1);
00018 define('FILE_MODIFY_PERMISSIONS', 2);
00019 define('FILE_EXISTS_RENAME', 0);
00020 define('FILE_EXISTS_REPLACE', 1);
00021 define('FILE_EXISTS_ERROR', 2);
00022
00032 define('FILE_STATUS_TEMPORARY', 0);
00033 define('FILE_STATUS_PERMANENT', 1);
00034
00041 function file_create_url($path) {
00042   // Strip file_directory_path from $path. We only include relative paths in urls.
00043   if (strpos($path, file_directory_path() .'/') === 0) {
00044     $path = trim(substr($path, strlen(file_directory_path())), '\\/');
00045   }
00046   switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
00047     case FILE_DOWNLOADS_PUBLIC:
00048       return $GLOBALS['base_url'] .'/'. file_directory_path() .'/'. str_replace('\\', '/', $path);
00049     case FILE_DOWNLOADS_PRIVATE:
00050       return url('system/files/'. $path, array('absolute' => TRUE));
00051   }
00052 }
00053
00064 function file_create_path($dest = 0) {
00065   $file_path = file_directory_path();
00066   if (!$dest) {
00067     return $file_path;
00068   }
00069   // file_check_location() checks whether the destination is inside the Drupal files directory.
00070   if (file_check_location($dest, $file_path)) {
00071     return $dest;
00072   }
00073   // check if the destination is instead inside the Drupal temporary files directory.
00074   else if (file_check_location($dest, file_directory_temp())) {
00075     return $dest;
00076   }
00077   // Not found, try again with prefixed directory path.
00078   else if (file_check_location($file_path .'/'. $dest, $file_path)) {
00079     return $file_path .'/'. $dest;
00080   }
00081   // File not found.
00082   return FALSE;
00083 }
00084
00098 function file_check_directory(&$directory, $mode = 0, $form_item = NULL) {
00099   $directory = rtrim($directory, '/\\');
00100
00101   // Check if directory exists.
00102   if (!is_dir($directory)) {
00103     if (($mode & FILE_CREATE_DIRECTORY) && @mkdir($directory)) {
00104       drupal_set_message(t('The directory %directory has been created.', array('%directory' => $directory)));
00105       @chmod($directory, 0775); // Necessary for non-webserver users.
00106     }
00107     else {
00108       if ($form_item) {
00109         form_set_error($form_item, t('The directory %directory does not exist.', array('%directory' => $directory)));
00110       }
00111       return FALSE;
00112     }
00113   }
00114
00115   // Check to see if the directory is writable.
00116   if (!is_writable($directory)) {
00117     if (($mode & FILE_MODIFY_PERMISSIONS) && @chmod($directory, 0775)) {
00118       drupal_set_message(t('The permissions of directory %directory have been changed to make it writable.', array('%directory' => $directory)));
00119     }
00120     else {
00121       form_set_error($form_item, t('The directory %directory is not writable', array('%directory' => $directory)));
00122       watchdog('file system', 'The directory %directory is not writable, because it does not have the correct permissions set.', array('%directory' => $directory), WATCHDOG_ERROR);
00123       return FALSE;
00124     }
00125   }
00126
00127   if ((file_directory_path() == $directory || file_directory_temp() == $directory) && !is_file("$directory/.htaccess")) {
00128     $htaccess_lines = "SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006\nOptions None\nOptions +FollowSymLinks";
00129     if (($fp = fopen("$directory/.htaccess", 'w')) && fputs($fp, $htaccess_lines)) {
00130       fclose($fp);
00131       chmod($directory .'/.htaccess', 0664);
00132     }
00133     else {
00134       $variables = array('%directory' => $directory, '!htaccess' => '<br />'. nl2br(check_plain($htaccess_lines)));
00135       form_set_error($form_item, t("Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your %directory directory which contains the following lines: <code>!htaccess</code>", $variables));
00136       watchdog('security', "Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your %directory directory which contains the following lines: <code>!htaccess</code>", $variables, WATCHDOG_ERROR);
00137     }
00138   }
00139
00140   return TRUE;
00141 }
00142
00151 function file_check_path(&$path) {
00152   // Check if path is a directory.
00153   if (file_check_directory($path)) {
00154     return '';
00155   }
00156
00157   // Check if path is a possible dir/file.
00158   $filename = basename($path);
00159   $path = dirname($path);
00160   if (file_check_directory($path)) {
00161     return $filename;
00162   }
00163
00164   return FALSE;
00165 }
00166
00181 function file_check_location($source, $directory = '') {
00182   $check = realpath($source);
00183   if ($check) {
00184     $source = $check;
00185   }
00186   else {
00187     // This file does not yet exist
00188     $source = realpath(dirname($source)) .'/'. basename($source);
00189   }
00190   $directory = realpath($directory);
00191   if ($directory && strpos($source, $directory) !== 0) {
00192     return 0;
00193   }
00194   return $source;
00195 }
00196
00216 function file_copy(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) {
00217   $dest = file_create_path($dest);
00218
00219   $directory = $dest;
00220   $basename = file_check_path($directory);
00221
00222   // Make sure we at least have a valid directory.
00223   if ($basename === FALSE) {
00224     $source = is_object($source) ? $source->filepath : $source;
00225     drupal_set_message(t('The selected file %file could not be uploaded, because the destination %directory is not properly configured.', array('%file' => $source, '%directory' => $dest)), 'error');
00226     watchdog('file system', 'The selected file %file could not be uploaded, because the destination %directory could not be found, or because its permissions do not allow the file to be written.', array('%file' => $source, '%directory' => $dest), WATCHDOG_ERROR);
00227     return 0;
00228   }
00229
00230   // Process a file upload object.
00231   if (is_object($source)) {
00232     $file = $source;
00233     $source = $file->filepath;
00234     if (!$basename) {
00235       $basename = $file->filename;
00236     }
00237   }
00238
00239   $source = realpath($source);
00240   if (!file_exists($source)) {
00241     drupal_set_message(t('The selected file %file could not be copied, because no file by that name exists. Please check that you supplied the correct filename.', array('%file' => $source)), 'error');
00242     return 0;
00243   }
00244
00245   // If the destination file is not specified then use the filename of the source file.
00246   $basename = $basename ? $basename : basename($source);
00247   $dest = $directory .'/'. $basename;
00248
00249   // Make sure source and destination filenames are not the same, makes no sense
00250   // to copy it if they are. In fact copying the file will most likely result in
00251   // a 0 byte file. Which is bad. Real bad.
00252   if ($source != realpath($dest)) {
00253     if (!$dest = file_destination($dest, $replace)) {
00254       drupal_set_message(t('The selected file %file could not be copied, because a file by that name already exists in the destination.', array('%file' => $source)), 'error');
00255       return FALSE;
00256     }
00257
00258     if (!@copy($source, $dest)) {
00259       drupal_set_message(t('The selected file %file could not be copied.', array('%file' => $source)), 'error');
00260       return 0;
00261     }
00262
00263     // Give everyone read access so that FTP'd users or
00264     // non-webserver users can see/read these files,
00265     // and give group write permissions so group members
00266     // can alter files uploaded by the webserver.
00267     @chmod($dest, 0664);
00268   }
00269
00270   if (isset($file) && is_object($file)) {
00271     $file->filename = $basename;
00272     $file->filepath = $dest;
00273     $source = $file;
00274   }
00275   else {
00276     $source = $dest;
00277   }
00278
00279   return 1; // Everything went ok.
00280 }
00281
00295 function file_destination($destination, $replace) {
00296   if (file_exists($destination)) {
00297     switch ($replace) {
00298       case FILE_EXISTS_RENAME:
00299         $basename = basename($destination);
00300         $directory = dirname($destination);
00301         $destination = file_create_filename($basename, $directory);
00302         break;
00303
00304       case FILE_EXISTS_ERROR:
00305         drupal_set_message(t('The selected file %file could not be copied, because a file by that name already exists in the destination.', array('%file' => $destination)), 'error');
00306         return FALSE;
00307     }
00308   }
00309   return $destination;
00310 }
00311
00330 function file_move(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) {
00331   $path_original = is_object($source) ? $source->filepath : $source;
00332
00333   if (file_copy($source, $dest, $replace)) {
00334     $path_current = is_object($source) ? $source->filepath : $source;
00335
00336     if ($path_original == $path_current || file_delete($path_original)) {
00337       return 1;
00338     }
00339     drupal_set_message(t('The removal of the original file %file has failed.', array('%file' => $path_original)), 'error');
00340   }
00341   return 0;
00342 }
00343
00355 function file_munge_filename($filename, $extensions, $alerts = TRUE) {
00356   $original = $filename;
00357
00358   // Allow potentially insecure uploads for very savvy users and admin
00359   if (!variable_get('allow_insecure_uploads', 0)) {
00360     $whitelist = array_unique(explode(' ', trim($extensions)));
00361
00362     // Split the filename up by periods. The first part becomes the basename
00363     // the last part the final extension.
00364     $filename_parts = explode('.', $filename);
00365     $new_filename = array_shift($filename_parts); // Remove file basename.
00366     $final_extension = array_pop($filename_parts); // Remove final extension.
00367
00368     // Loop through the middle parts of the name and add an underscore to the
00369     // end of each section that could be a file extension but isn't in the list
00370     // of allowed extensions.
00371     foreach ($filename_parts as $filename_part) {
00372       $new_filename .= '.'. $filename_part;
00373       if (!in_array($filename_part, $whitelist) && preg_match("/^[a-zA-Z]{2,5}\d?$/", $filename_part)) {
00374         $new_filename .= '_';
00375       }
00376     }
00377     $filename = $new_filename .'.'. $final_extension;
00378
00379     if ($alerts && $original != $filename) {
00380       drupal_set_message(t('For security reasons, your upload has been renamed to %filename.', array('%filename' => $filename)));
00381     }
00382   }
00383
00384   return $filename;
00385 }
00386
00393 function file_unmunge_filename($filename) {
00394   return str_replace('_.', '.', $filename);
00395 }
00396
00405 function file_create_filename($basename, $directory) {
00406   $dest = $directory .'/'. $basename;
00407
00408   if (file_exists($dest)) {
00409     // Destination file already exists, generate an alternative.
00410     if ($pos = strrpos($basename, '.')) {
00411       $name = substr($basename, 0, $pos);
00412       $ext = substr($basename, $pos);
00413     }
00414     else {
00415       $name = $basename;
00416     }
00417
00418     $counter = 0;
00419     do {
00420       $dest = $directory .'/'. $name .'_'. $counter++ . $ext;
00421     } while (file_exists($dest));
00422   }
00423
00424   return $dest;
00425 }
00426
00433 function file_delete($path) {
00434   if (is_file($path)) {
00435     return unlink($path);
00436   }
00437 }
00438
00446 function file_space_used($uid = NULL) {
00447   if (isset($uid)) {
00448     return (int) db_result(db_query('SELECT SUM(filesize) FROM {files} WHERE uid = %d', $uid));
00449   }
00450   return (int) db_result(db_query('SELECT SUM(filesize) FROM {files}'));
00451 }
00452
00480 function file_save_upload($source, $validators = array(), $dest = FALSE, $replace = FILE_EXISTS_RENAME) {
00481   global $user;
00482   static $upload_cache;
00483
00484   // Add in our check of the the file name length.
00485   $validators['file_validate_name_length'] = array();
00486
00487   // Return cached objects without processing since the file will have
00488   // already been processed and the paths in _FILES will be invalid.
00489   if (isset($upload_cache[$source])) {
00490     return $upload_cache[$source];
00491   }
00492
00493   // If a file was uploaded, process it.
00494   if (isset($_FILES['files']) && $_FILES['files']['name'][$source] && is_uploaded_file($_FILES['files']['tmp_name'][$source])) {
00495     // Check for file upload errors and return FALSE if a
00496     // lower level system error occurred.
00497     switch ($_FILES['files']['error'][$source]) {
00498       // @see http://php.net/manual/en/features.file-upload.errors.php
00499       case UPLOAD_ERR_OK:
00500         break;
00501
00502       case UPLOAD_ERR_INI_SIZE:
00503       case UPLOAD_ERR_FORM_SIZE:
00504         drupal_set_message(t('The file %file could not be saved, because it exceeds %maxsize, the maximum allowed size for uploads.', array('%file' => $source, '%maxsize' => format_size(file_upload_max_size()))), 'error');
00505         return 0;
00506
00507       case UPLOAD_ERR_PARTIAL:
00508       case UPLOAD_ERR_NO_FILE:
00509         drupal_set_message(t('The file %file could not be saved, because the upload did not complete.', array('%file' => $source)), 'error');
00510         return 0;
00511
00512         // Unknown error
00513       default:
00514         drupal_set_message(t('The file %file could not be saved. An unknown error has occurred.', array('%file' => $source)), 'error');
00515         return 0;
00516     }
00517
00518     // Build the list of non-munged extensions.
00519     // @todo: this should not be here. we need to figure out the right place.
00520     $extensions = '';
00521     foreach ($user->roles as $rid => $name) {
00522       $extensions .= ' '. variable_get("upload_extensions_$rid",
00523       variable_get('upload_extensions_default', 'jpg jpeg gif png txt html doc xls pdf ppt pps odt ods odp'));
00524     }
00525
00526     // Begin building file object.
00527     $file = new stdClass();
00528     $file->filename = file_munge_filename(trim(basename($_FILES['files']['name'][$source]), '.'), $extensions);
00529     $file->filepath = $_FILES['files']['tmp_name'][$source];
00530     $file->filemime = $_FILES['files']['type'][$source];
00531
00532     // Rename potentially executable files, to help prevent exploits.
00533     if (preg_match('/\.(php|pl|py|cgi|asp|js)$/i', $file->filename) && (substr($file->filename, -4) != '.txt')) {
00534       $file->filemime = 'text/plain';
00535       $file->filepath .= '.txt';
00536       $file->filename .= '.txt';
00537     }
00538
00539     // If the destination is not provided, or is not writable, then use the
00540     // temporary directory.
00541     if (empty($dest) || file_check_path($dest) === FALSE) {
00542       $dest = file_directory_temp();
00543     }
00544
00545     $file->source = $source;
00546     $file->destination = file_destination(file_create_path($dest .'/'. $file->filename), $replace);
00547     $file->filesize = $_FILES['files']['size'][$source];
00548
00549     // Call the validation functions.
00550     $errors = array();
00551     foreach ($validators as $function => $args) {
00552       array_unshift($args, $file);
00553       $errors = array_merge($errors, call_user_func_array($function, $args));
00554     }
00555
00556     // Check for validation errors.
00557     if (!empty($errors)) {
00558       $message = t('The selected file %name could not be uploaded.', array('%name' => $file->filename));
00559       if (count($errors) > 1) {
00560         $message .= '<ul><li>'. implode('</li><li>', $errors) .'</li></ul>';
00561       }
00562       else {
00563         $message .= ' '. array_pop($errors);
00564       }
00565       form_set_error($source, $message);
00566       return 0;
00567     }
00568
00569     // Move uploaded files from PHP's upload_tmp_dir to Drupal's temporary directory.
00570     // This overcomes open_basedir restrictions for future file operations.
00571     $file->filepath = $file->destination;
00572     if (!move_uploaded_file($_FILES['files']['tmp_name'][$source], $file->filepath)) {
00573       form_set_error($source, t('File upload error. Could not move uploaded file.'));
00574       watchdog('file', 'Upload error. Could not move uploaded file %file to destination %destination.', array('%file' => $file->filename, '%destination' => $file->filepath));
00575       return 0;
00576     }
00577
00578     // If we made it this far it's safe to record this file in the database.
00579     $file->uid = $user->uid;
00580     $file->status = FILE_STATUS_TEMPORARY;
00581     $file->timestamp = time();
00582     drupal_write_record('files', $file);
00583
00584     // Add file to the cache.
00585     $upload_cache[$source] = $file;
00586     return $file;
00587   }
00588   return 0;
00589 }
00590
00599 function file_validate_name_length($file) {
00600   $errors = array();
00601
00602   if (strlen($file->filename) > 255) {
00603     $errors[] = t('Its name exceeds the 255 characters limit. Please rename the file and try again.');
00604   }
00605   return $errors;
00606 }
00607
00619 function file_validate_extensions($file, $extensions) {
00620   global $user;
00621
00622   $errors = array();
00623
00624   // Bypass validation for uid  = 1.
00625   if ($user->uid != 1) {
00626     $regex = '/\.('. ereg_replace(' +', '|', preg_quote($extensions)) .')$/i';
00627     if (!preg_match($regex, $file->filename)) {
00628       $errors[] = t('Only files with the following extensions are allowed: %files-allowed.', array('%files-allowed' => $extensions));
00629     }
00630   }
00631   return $errors;
00632 }
00633
00649 function file_validate_size($file, $file_limit = 0, $user_limit = 0) {
00650   global $user;
00651
00652   $errors = array();
00653
00654   // Bypass validation for uid  = 1.
00655   if ($user->uid != 1) {
00656     if ($file_limit && $file->filesize > $file_limit) {
00657       $errors[] = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size($file->filesize), '%maxsize' => format_size($file_limit)));
00658     }
00659
00660     $total_size = file_space_used($user->uid) + $file->filesize;
00661     if ($user_limit && $total_size > $user_limit) {
00662       $errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', array('%filesize' => format_size($file->filesize), '%quota' => format_size($user_limit)));
00663     }
00664   }
00665   return $errors;
00666 }
00667
00676 function file_validate_is_image(&$file) {
00677   $errors = array();
00678
00679   $info = image_get_info($file->filepath);
00680   if (!$info || empty($info['extension'])) {
00681     $errors[] = t('Only JPEG, PNG and GIF images are allowed.');
00682   }
00683
00684   return $errors;
00685 }
00686
00705 function file_validate_image_resolution(&$file, $maximum_dimensions = 0, $minimum_dimensions = 0) {
00706   $errors = array();
00707
00708   // Check first that the file is an image.
00709   if ($info = image_get_info($file->filepath)) {
00710     if ($maximum_dimensions) {
00711       // Check that it is smaller than the given dimensions.
00712       list($width, $height) = explode('x', $maximum_dimensions);
00713       if ($info['width'] > $width || $info['height'] > $height) {
00714         // Try to resize the image to fit the dimensions.
00715         if (image_get_toolkit() && image_scale($file->filepath, $file->filepath, $width, $height)) {
00716           drupal_set_message(t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', array('%dimensions' => $maximum_dimensions)));
00717
00718           // Clear the cached filesize and refresh the image information.
00719           clearstatcache();
00720           $info = image_get_info($file->filepath);
00721           $file->filesize = $info['file_size'];
00722         }
00723         else {
00724           $errors[] = t('The image is too large; the maximum dimensions are %dimensions pixels.', array('%dimensions' => $maximum_dimensions));
00725         }
00726       }
00727     }
00728
00729     if ($minimum_dimensions) {
00730       // Check that it is larger than the given dimensions.
00731       list($width, $height) = explode('x', $minimum_dimensions);
00732       if ($info['width'] < $width || $info['height'] < $height) {
00733         $errors[] = t('The image is too small; the minimum dimensions are %dimensions pixels.', array('%dimensions' => $minimum_dimensions));
00734       }
00735     }
00736   }
00737
00738   return $errors;
00739 }
00740
00753 function file_save_data($data, $dest, $replace = FILE_EXISTS_RENAME) {
00754   $temp = file_directory_temp();
00755   // On Windows, tempnam() requires an absolute path, so we use realpath().
00756   $file = tempnam(realpath($temp), 'file');
00757   if (!$fp = fopen($file, 'wb')) {
00758     drupal_set_message(t('The file could not be created.'), 'error');
00759     return 0;
00760   }
00761   fwrite($fp, $data);
00762   fclose($fp);
00763
00764   if (!file_move($file, $dest, $replace)) {
00765     return 0;
00766   }
00767
00768   return $file;
00769 }
00770
00779 function file_set_status(&$file, $status) {
00780   if (db_query('UPDATE {files} SET status = %d WHERE fid = %d', $status, $file->fid)) {
00781     $file->status = $status;
00782     return TRUE;
00783   }
00784   return FALSE;
00785 }
00786
00794 function file_transfer($source, $headers) {
00795   ob_end_clean();
00796
00797   foreach ($headers as $header) {
00798     // To prevent HTTP header injection, we delete new lines that are
00799     // not followed by a space or a tab.
00800     // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
00801     $header = preg_replace('/\r?\n(?!\t| )/', '', $header);
00802     drupal_set_header($header);
00803   }
00804
00805   $source = file_create_path($source);
00806
00807   // Transfer file in 1024 byte chunks to save memory usage.
00808   if ($fd = fopen($source, 'rb')) {
00809     while (!feof($fd)) {
00810       print fread($fd, 1024);
00811     }
00812     fclose($fd);
00813   }
00814   else {
00815     drupal_not_found();
00816   }
00817   exit();
00818 }
00819
00827 function file_download() {
00828   // Merge remainder of arguments from GET['q'], into relative file path.
00829   $args = func_get_args();
00830   $filepath = implode('/', $args);
00831
00832   // Maintain compatibility with old ?file=paths saved in node bodies.
00833   if (isset($_GET['file'])) {
00834     $filepath =  $_GET['file'];
00835   }
00836
00837   if (file_exists(file_create_path($filepath))) {
00838     $headers = module_invoke_all('file_download', $filepath);
00839     if (in_array(-1, $headers)) {
00840       return drupal_access_denied();
00841     }
00842     if (count($headers)) {
00843       file_transfer($filepath, $headers);
00844     }
00845   }
00846   return drupal_not_found();
00847 }
00848
00849
00882 function file_scan_directory($dir, $mask, $nomask = array('.', '..', 'CVS'), $callback = 0, $recurse = TRUE, $key = 'filename', $min_depth = 0, $depth = 0) {
00883   $key = (in_array($key, array('filename', 'basename', 'name')) ? $key : 'filename');
00884   $files = array();
00885
00886   if (is_dir($dir) && $handle = opendir($dir)) {
00887     while ($file = readdir($handle)) {
00888       if (!in_array($file, $nomask) && $file[0] != '.') {
00889         if (is_dir("$dir/$file") && $recurse) {
00890           // Give priority to files in this folder by merging them in after any subdirectory files.
00891           $files = array_merge(file_scan_directory("$dir/$file", $mask, $nomask, $callback, $recurse, $key, $min_depth, $depth + 1), $files);
00892         }
00893         elseif ($depth >= $min_depth && ereg($mask, $file)) {
00894           // Always use this match over anything already set in $files with the same $$key.
00895           $filename = "$dir/$file";
00896           $basename = basename($file);
00897           $name = substr($basename, 0, strrpos($basename, '.'));
00898           $files[$$key] = new stdClass();
00899           $files[$$key]->filename = $filename;
00900           $files[$$key]->basename = $basename;
00901           $files[$$key]->name = $name;
00902           if ($callback) {
00903             $callback($filename);
00904           }
00905         }
00906       }
00907     }
00908
00909     closedir($handle);
00910   }
00911
00912   return $files;
00913 }
00914
00920 function file_directory_temp() {
00921   $temporary_directory = variable_get('file_directory_temp', NULL);
00922
00923   if (is_null($temporary_directory)) {
00924     $directories = array();
00925
00926     // Has PHP been set with an upload_tmp_dir?
00927     if (ini_get('upload_tmp_dir')) {
00928       $directories[] = ini_get('upload_tmp_dir');
00929     }
00930
00931     // Operating system specific dirs.
00932     if (substr(PHP_OS, 0, 3) == 'WIN') {
00933       $directories[] = 'c:\\windows\\temp';
00934       $directories[] = 'c:\\winnt\\temp';
00935       $path_delimiter = '\\';
00936     }
00937     else {
00938       $directories[] = '/tmp';
00939       $path_delimiter = '/';
00940     }
00941
00942     foreach ($directories as $directory) {
00943       if (!$temporary_directory && is_dir($directory)) {
00944         $temporary_directory = $directory;
00945       }
00946     }
00947
00948     // if a directory has been found, use it, otherwise default to 'files/tmp' or 'files\\tmp';
00949     $temporary_directory = $temporary_directory ? $temporary_directory : file_directory_path() . $path_delimiter .'tmp';
00950     variable_set('file_directory_temp', $temporary_directory);
00951   }
00952
00953   return $temporary_directory;
00954 }
00955
00961 function file_directory_path() {
00962   return variable_get('file_directory_path', conf_path() .'/files');
00963 }
00964
00971 function file_upload_max_size() {
00972   static $max_size = -1;
00973
00974   if ($max_size < 0) {
00975     $upload_max = parse_size(ini_get('upload_max_filesize'));
00976     $post_max = parse_size(ini_get('post_max_size'));
00977     $max_size = ($upload_max < $post_max) ? $upload_max : $post_max;
00978   }
00979   return $max_size;
00980 }
00981
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/fileupload.module Source File

docs » examples

fileupload.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: fileupload.module,v 1.6 2007/03/13 15:53:12 alienbrain Exp $
00003
00024 function fileupload_menu($may_cache) {
00025   $items = array();
00026
00027   if ($may_cache) {
00028     $items[] = array('path' => 'node/add/fileupload', 'title' =>  t('file upload'),
00029       'access' => user_access('create files'));
00030   }
00031
00032   return $items;
00033 }
00034
00038 function fileupload_perm() {
00039   return array('create files');
00040 }
00041
00045 function fileupload_help($section) {
00046   switch ($section) {
00047     case 'admin/modules#description':
00048       return t('An example module to demonstrate file uploads.');
00049     case 'node/add#fileupload':
00050       return t('Simple file upload node example.');
00051   }
00052 }
00053
00057 function fileupload_node_info() {
00058   return array('fileupload' => array('name' => t('file upload'), 'base' => 'fileupload'));
00059 }
00060
00064 function fileupload_access($op, $node) {
00065   global $user;
00066
00067   switch ($op) {
00068     case 'create':
00069       return user_access("create file");
00070     case 'update':
00071     case 'delete':
00072       return user_access("create file") && ($user->uid == $node->uid);
00073   }
00074 }
00075
00079 function fileupload_file_download($file) {
00080   if (user_access('access content')) {
00081     if ($filemime = db_result(db_query("SELECT filemime FROM {fileupload} WHERE filepath = '%s'", file_create_path($file)))) {
00082       return array('Content-type:' . $filemime);
00083     }
00084   }
00085   else {
00086     return -1;
00087   }
00088 }
00089
00093 function fileupload_view(&$node, $teaser = FALSE, $page = FALSE) {
00094   if ($file = $node->file) {
00095     // Only create link to file when it is in the proper location.
00096     if ($file->filesize && file_check_location($file->filepath, file_directory_path())) {
00097       $node->body = l($file->filename, file_create_url($file->filepath));
00098     }
00099     else {
00100       $node->body = $file->filename;
00101     }
00102     // display the file's size
00103     $node->body .= ' ('. format_size($file->filesize) .')';
00104   }
00105
00106   return theme('node', $node, $teaser, $page);
00107 }
00108
00114 function fileupload_form(&$node) {
00115   // Set form parameters so we can accept file uploads.
00116   $form['#attributes'] = array('enctype' => 'multipart/form-data');
00117   // standard node title
00118   $form['title'] = array(
00119     '#type' => 'textfield',
00120     '#title' => t('Title'),
00121     '#size' => 60,
00122     '#maxlength' => 128,
00123     '#required' => TRUE,
00124     '#default_value' => $node->title
00125   );
00126   // file upload field
00127   $form['file'] = array(
00128     '#type' => 'file',
00129     '#title' => t('File'),
00130     '#size' => 40,
00131     '#default_value' => '',
00132   );
00133   if ($node->file->filepath) {
00134       $form['file']['#description'] .= t('A file already exists, if you upload another file the current file will be replaced.');
00135   }
00136
00137   if ($node->nid) {
00138     // the validate function doesn't get a full copy of the node, only the
00139     // data posted from the form. use this field to tell the validator
00140     // the path of the node's current file.
00141     $form['current_file'] = array(
00142       '#type' => 'value',
00143       '#value' => $node->file->filepath
00144     );
00145   }
00146
00147   return $form;
00148 }
00149
00155 function fileupload_validate(&$node) {
00156   // Check for a new file upload.
00157   if ($file = file_check_upload('file')) {
00158     $node->file = $file;
00159   }
00160
00161   // Make sure there is an upload or an existing file.
00162   if (!$file && !file_exists($node->current_file)) {
00163     form_set_error('file', t('A file must be provided.'));
00164   }
00165 }
00166
00172 function fileupload_submit(&$node) {
00173   // if a file was uploaded, move it to the files directory
00174   if ($file = file_check_upload('file')) {
00175     $node->file = file_save_upload($file, file_directory_path(), false);
00176   }
00177 }
00178
00185 function fileupload_load($node) {
00186   $extras = new StdClass();
00187   $extras->file = db_fetch_object(db_query('SELECT filename, filepath, filemime, filesize FROM {fileupload} WHERE nid = %d', $node->nid));
00188   return $extras;
00189 }
00190
00196 function fileupload_insert($node) {
00197   $file = $node->file;
00198   db_query("INSERT INTO {fileupload} (nid, filename, filepath, filemime, filesize) VALUES (%d, '%s', '%s', '%s', %d)", $node->nid, $file->filename, $file->filepath, $file->filemime, $file->filesize);
00199 }
00200
00206 function fileupload_update($node) {
00207   $newfile = $node->file->filepath;
00208   $oldfile = db_result(db_query('SELECT filepath FROM {fileupload} WHERE nid = %d', $node->nid));
00209
00210   // only make changes if there was a new file.
00211   if ($newfile) {
00212     if ($newfile != $oldfile) {
00213       // delete the old file
00214       file_delete($oldfile);
00215     }
00216
00217     // update the database
00218     $file = $node->file;
00219     db_query("UPDATE {fileupload} SET filename = '%s', filepath = '%s', filemime = '%s', filesize = %d WHERE nid = %d", $file->filename, $file->filepath, $file->filemime, $file->filesize, $node->nid);
00220   }
00221 }
00222
00228 function fileupload_delete($node) {
00229   file_delete($node->filepath);
00230   db_query("DELETE FROM {fileupload} WHERE nid = %d", $node->nid);
00231 }
00232
00233 ?>
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/filter/filter.admin.inc Source File

modules » filter

filter.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: filter.admin.inc,v 1.8 2008/01/08 10:35:41 goba Exp $
00003
00016 function filter_admin_overview() {
00017
00018   // Overview of all formats.
00019   $formats = filter_formats();
00020   $error = FALSE;
00021
00022   foreach ($formats as $id => $format) {
00023     $roles = array();
00024     foreach (user_roles() as $rid => $name) {
00025       // Prepare a roles array with roles that may access the filter.
00026       if (strstr($format->roles, ",$rid,")) {
00027         $roles[] = $name;
00028       }
00029     }
00030     $default = ($id == variable_get('filter_default_format', 1));
00031     $options[$id] = '';
00032     $form[$format->name]['id'] = array('#value' => $id);
00033     $form[$format->name]['roles'] = array('#value' => $default ? t('All roles may use default format') : ($roles ? implode(', ', $roles) : t('No roles may use this format')));
00034     $form[$format->name]['configure'] = array('#value' => l(t('configure'), 'admin/settings/filters/'. $id));
00035     $form[$format->name]['delete'] = array('#value' => $default ? '' : l(t('delete'), 'admin/settings/filters/delete/'. $id));
00036   }
00037   $form['default'] = array('#type' => 'radios', '#options' => $options, '#default_value' => variable_get('filter_default_format', 1));
00038   $form['submit'] = array('#type' => 'submit', '#value' => t('Set default format'));
00039   return $form;
00040 }
00041
00042 function filter_admin_overview_submit($form, &$form_state) {
00043   // Process form submission to set the default format.
00044   if (is_numeric($form_state['values']['default'])) {
00045     drupal_set_message(t('Default format updated.'));
00046     variable_set('filter_default_format', $form_state['values']['default']);
00047   }
00048 }
00049
00055 function theme_filter_admin_overview($form) {
00056   $rows = array();
00057   foreach ($form as $name => $element) {
00058     if (isset($element['roles']) && is_array($element['roles'])) {
00059       $rows[] = array(
00060         drupal_render($form['default'][$element['id']['#value']]),
00061         check_plain($name),
00062         drupal_render($element['roles']),
00063         drupal_render($element['configure']),
00064         drupal_render($element['delete'])
00065       );
00066       unset($form[$name]);
00067     }
00068   }
00069   $header = array(t('Default'), t('Name'), t('Roles'), array('data' => t('Operations'), 'colspan' => 2));
00070   $output = theme('table', $header, $rows);
00071   $output .= drupal_render($form);
00072
00073   return $output;
00074 }
00075
00079 function filter_admin_format_page($format = NULL) {
00080   if (!isset($format->name)) {
00081     drupal_set_title(t("Add input format"));
00082     $format = (object)array('name' => '', 'roles' => '', 'format' => '');
00083   }
00084   return drupal_get_form('filter_admin_format_form', $format);
00085 }
00086
00094 function filter_admin_format_form(&$form_state, $format) {
00095   $default = ($format->format == variable_get('filter_default_format', 1));
00096   if ($default) {
00097     $help = t('All roles for the default format must be enabled and cannot be changed.');
00098     $form['default_format'] = array('#type' => 'hidden', '#value' => 1);
00099   }
00100
00101   $form['name'] = array('#type' => 'textfield',
00102     '#title' => 'Name',
00103     '#default_value' => $format->name,
00104     '#description' => t('Specify a unique name for this filter format.'),
00105     '#required' => TRUE,
00106   );
00107
00108   // Add a row of checkboxes for form group.
00109   $form['roles'] = array('#type' => 'fieldset',
00110     '#title' => t('Roles'),
00111     '#description' => $default ? $help : t('Choose which roles may use this filter format. Note that roles with the "administer filters" permission can always use all the filter formats.'),
00112     '#tree' => TRUE,
00113   );
00114
00115   foreach (user_roles() as $rid => $name) {
00116     $checked = strstr($format->roles, ",$rid,");
00117     $form['roles'][$rid] = array('#type' => 'checkbox',
00118       '#title' => $name,
00119       '#default_value' => ($default || $checked),
00120     );
00121     if ($default) {
00122       $form['roles'][$rid]['#disabled'] = TRUE;
00123     }
00124   }
00125   // Table with filters
00126   $all = filter_list_all();
00127   $enabled = filter_list_format($format->format);
00128
00129   $form['filters'] = array('#type' => 'fieldset',
00130     '#title' => t('Filters'),
00131     '#description' => t('Choose the filters that will be used in this filter format.'),
00132     '#tree' => TRUE,
00133   );
00134   foreach ($all as $id => $filter) {
00135     $form['filters'][$id] = array('#type' => 'checkbox',
00136       '#title' => $filter->name,
00137       '#default_value' => isset($enabled[$id]),
00138       '#description' => module_invoke($filter->module, 'filter', 'description', $filter->delta),
00139     );
00140   }
00141   if (!empty($format->format)) {
00142     $form['format'] = array('#type' => 'hidden', '#value' => $format->format);
00143
00144     // Composition tips (guidelines)
00145     $tips = _filter_tips($format->format, FALSE);
00146     $extra = '<p>'. l(t('More information about formatting options'), 'filter/tips') .'</p>';
00147     $tiplist = theme('filter_tips', $tips, FALSE, $extra);
00148     if (!$tiplist) {
00149       $tiplist = '<p>'. t('No guidelines available.') .'</p>';
00150     }
00151     $group = '<p>'. t('These are the guidelines that users will see for posting in this input format. They are automatically generated from the filter settings.') .'</p>';
00152     $group .= $tiplist;
00153     $form['tips'] = array('#value' => '<h2>'. t('Formatting guidelines') .'</h2>'. $group);
00154   }
00155   $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
00156
00157   return $form;
00158 }
00159
00163 function filter_admin_format_form_validate($form, &$form_state) {
00164   if (!isset($form_state['values']['format'])) {
00165     $name = trim($form_state['values']['name']);
00166     $result = db_fetch_object(db_query("SELECT format FROM {filter_formats} WHERE name='%s'", $name));
00167     if ($result) {
00168       form_set_error('name', t('Filter format names need to be unique. A format named %name already exists.', array('%name' => $name)));
00169     }
00170   }
00171 }
00172
00176 function filter_admin_format_form_submit($form, &$form_state) {
00177   $format = isset($form_state['values']['format']) ? $form_state['values']['format'] : NULL;
00178   $current = filter_list_format($format);
00179   $name = trim($form_state['values']['name']);
00180   $cache = TRUE;
00181
00182   // Add a new filter format.
00183   if (!$format) {
00184     $new = TRUE;
00185     db_query("INSERT INTO {filter_formats} (name) VALUES ('%s')", $name);
00186     $format = db_result(db_query("SELECT MAX(format) AS format FROM {filter_formats}"));
00187     drupal_set_message(t('Added input format %format.', array('%format' => $name)));
00188   }
00189   else {
00190     drupal_set_message(t('The input format settings have been updated.'));
00191   }
00192
00193   db_query("DELETE FROM {filters} WHERE format = %d", $format);
00194   foreach ($form_state['values']['filters'] as $id => $checked) {
00195     if ($checked) {
00196       list($module, $delta) = explode('/', $id);
00197       // Add new filters to the bottom.
00198       $weight = isset($current[$id]->weight) ? $current[$id]->weight : 10;
00199       db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", $format, $module, $delta, $weight);
00200
00201       // Check if there are any 'no cache' filters.
00202       $cache &= !module_invoke($module, 'filter', 'no cache', $delta);
00203     }
00204   }
00205
00206   // We store the roles as a string for ease of use.
00207   // We should always set all roles to TRUE when saving a default role.
00208   // We use leading and trailing comma's to allow easy substring matching.
00209   $roles = array();
00210   if (isset($form_state['values']['roles'])) {
00211     foreach ($form_state['values']['roles'] as $id => $checked) {
00212       if ($checked) {
00213         $roles[] = $id;
00214       }
00215     }
00216   }
00217   if (!empty($form_state['values']['default_format'])) {
00218     $roles = ','. implode(',', array_keys(user_roles())) .',';
00219   }
00220   else {
00221     $roles = ','. implode(',', $roles) .',';
00222   }
00223
00224   db_query("UPDATE {filter_formats} SET cache = %d, name='%s', roles = '%s' WHERE format = %d", $cache, $name, $roles, $format);
00225
00226   cache_clear_all($format .':', 'cache_filter', TRUE);
00227
00228   // If a new filter was added, return to the main list of filters. Otherwise, stay on edit filter page to show new changes.
00229   $return = 'admin/settings/filters';
00230   if (!empty($new)) {
00231     $return .= '/'. $format;
00232   }
00233   $form_state['redirect'] = $return;
00234   return;
00235 }
00236
00243 function filter_admin_delete() {
00244   $format = arg(4);
00245   $format = db_fetch_object(db_query('SELECT * FROM {filter_formats} WHERE format = %d', $format));
00246
00247   if ($format) {
00248     if ($format->format != variable_get('filter_default_format', 1)) {
00249       $form['format'] = array('#type' => 'hidden', '#value' => $format->format);
00250       $form['name'] = array('#type' => 'hidden', '#value' => $format->name);
00251
00252       return confirm_form($form, t('Are you sure you want to delete the input format %format?', array('%format' => $format->name)), 'admin/settings/filters', t('If you have any content left in this input format, it will be switched to the default input format. This action cannot be undone.'), t('Delete'), t('Cancel'));
00253     }
00254     else {
00255       drupal_set_message(t('The default format cannot be deleted.'));
00256       drupal_goto('admin/settings/filters');
00257     }
00258   }
00259   else {
00260     drupal_not_found();
00261   }
00262 }
00263
00267 function filter_admin_delete_submit($form, &$form_state) {
00268   db_query("DELETE FROM {filter_formats} WHERE format = %d", $form_state['values']['format']);
00269   db_query("DELETE FROM {filters} WHERE format = %d", $form_state['values']['format']);
00270
00271   $default = variable_get('filter_default_format', 1);
00272   // Replace existing instances of the deleted format with the default format.
00273   db_query("UPDATE {node_revisions} SET format = %d WHERE format = %d", $default, $form_state['values']['format']);
00274   db_query("UPDATE {comments} SET format = %d WHERE format = %d", $default, $form_state['values']['format']);
00275   db_query("UPDATE {boxes} SET format = %d WHERE format = %d", $default, $form_state['values']['format']);
00276
00277   cache_clear_all($form_state['values']['format'] .':', 'cache_filter', TRUE);
00278   drupal_set_message(t('Deleted input format %format.', array('%format' => $form_state['values']['name'])));
00279
00280   $form_state['redirect'] = 'admin/settings/filters';
00281   return;
00282 }
00283
00284
00288 function filter_admin_configure_page($format) {
00289   drupal_set_title(t("Configure %format", array('%format' => $format->name)));
00290   return drupal_get_form('filter_admin_configure', $format);
00291 }
00292
00298 function filter_admin_configure(&$form_state, $format) {
00299   $list = filter_list_format($format->format);
00300   $form = array();
00301   foreach ($list as $filter) {
00302     $form_module = module_invoke($filter->module, 'filter', 'settings', $filter->delta, $format->format);
00303     if (isset($form_module) && is_array($form_module)) {
00304       $form = array_merge($form, $form_module);
00305     }
00306   }
00307
00308   if (!empty($form)) {
00309     $form = system_settings_form($form);
00310   }
00311   else {
00312     $form['error'] = array('#value' => t('No settings are available.'));
00313   }
00314   $form['format'] = array('#type' => 'hidden', '#value' => $format->format);
00315   $form['#submit'][] = 'filter_admin_configure_submit';
00316   return $form;
00317 }
00318
00322 function filter_admin_configure_submit($form, &$form_state) {
00323   cache_clear_all($form_state['values']['format'] .':', 'cache_filter', TRUE);
00324 }
00325
00329 function filter_admin_order_page($format) {
00330   drupal_set_title(t("Rearrange %format", array('%format' => $format->name)));
00331   return drupal_get_form('filter_admin_order', $format);
00332 }
00333
00341 function filter_admin_order(&$form_state, $format = NULL) {
00342   // Get list (with forced refresh).
00343   $filters = filter_list_format($format->format);
00344
00345   $form['weights'] = array('#tree' => TRUE);
00346   foreach ($filters as $id => $filter) {
00347     $form['names'][$id] = array('#value' => $filter->name);
00348     $form['weights'][$id] = array('#type' => 'weight', '#default_value' => $filter->weight);
00349   }
00350   $form['format'] = array('#type' => 'hidden', '#value' => $format->format);
00351   $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
00352
00353   return $form;
00354 }
00355
00361 function theme_filter_admin_order($form) {
00362   $header = array(t('Name'), t('Weight'));
00363   $rows = array();
00364   foreach (element_children($form['names']) as $id) {
00365     // Don't take form control structures.
00366     if (is_array($form['names'][$id])) {
00367       $form['weights'][$id]['#attributes']['class'] = 'filter-order-weight';
00368       $rows[] = array(
00369         'data' => array(drupal_render($form['names'][$id]), drupal_render($form['weights'][$id])),
00370         'class' => 'draggable',
00371       );
00372     }
00373   }
00374
00375   $output = theme('table', $header, $rows, array('id' => 'filter-order'));
00376   $output .= drupal_render($form);
00377
00378   drupal_add_tabledrag('filter-order', 'order', 'sibling', 'filter-order-weight', NULL, NULL, FALSE);
00379
00380   return $output;
00381 }
00382
00386 function filter_admin_order_submit($form, &$form_state) {
00387   foreach ($form_state['values']['weights'] as $id => $weight) {
00388     list($module, $delta) = explode('/', $id);
00389     db_query("UPDATE {filters} SET weight = %d WHERE format = %d AND module = '%s' AND delta = %d", $weight, $form_state['values']['format'], $module, $delta);
00390   }
00391   drupal_set_message(t('The filter ordering has been saved.'));
00392
00393   cache_clear_all($form_state['values']['format'] .':', 'cache_filter', TRUE);
00394 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/filter/filter.install Source File

modules » filter

filter.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: filter.install,v 1.5 2007/12/18 12:59:21 dries Exp $
00003
00007 function filter_schema() {
00008   $schema['filters'] = array(
00009     'description' => t('Table that maps filters (HTML corrector) to input formats (Filtered HTML).'),
00010     'fields' => array(
00011       'fid' => array(
00012         'type' => 'serial',
00013         'not null' => TRUE,
00014         'description' => t('Primary Key: Auto-incrementing filter ID.'),
00015       ),
00016       'format' => array(
00017         'type' => 'int',
00018         'not null' => TRUE,
00019         'default' => 0,
00020         'description' => t('Foreign key: The {filter_formats}.format to which this filter is assigned.'),
00021       ),
00022       'module' => array(
00023         'type' => 'varchar',
00024         'length' => 64,
00025         'not null' => TRUE,
00026         'default' => '',
00027         'description' => t('The origin module of the filter.'),
00028       ),
00029       'delta' => array(
00030         'type' => 'int',
00031         'not null' => TRUE,
00032         'default' => 0,
00033         'size' => 'tiny',
00034         'description' => t('ID to identify which filter within module is being referenced.'),
00035       ),
00036       'weight' => array(
00037         'type' => 'int',
00038         'not null' => TRUE,
00039         'default' => 0,
00040         'size' => 'tiny',
00041         'description' => t('Weight of filter within format.'),
00042       )
00043     ),
00044     'primary key' => array('fid'),
00045     'unique keys' => array(
00046       'fmd' => array('format', 'module', 'delta'),
00047     ),
00048     'indexes' => array(
00049       'list' => array('format', 'weight', 'module', 'delta'),
00050     ),
00051   );
00052   $schema['filter_formats'] = array(
00053     'description' => t('Stores input formats: custom groupings of filters, such as Filtered HTML.'),
00054     'fields' => array(
00055       'format' => array(
00056         'type' => 'serial',
00057         'not null' => TRUE,
00058         'description' => t('Primary Key: Unique ID for format.'),
00059       ),
00060       'name' => array(
00061         'type' => 'varchar',
00062         'length' => 255,
00063         'not null' => TRUE,
00064         'default' => '',
00065         'description' => t('Name of the input format (Filtered HTML).'),
00066       ),
00067       'roles' => array(
00068         'type' => 'varchar',
00069         'length' => 255,
00070         'not null' => TRUE,
00071         'default' => '',
00072         'description' => t('A comma-separated string of roles; references {role}.rid.'), // This is bad since you can't use joins, nor index.
00073       ),
00074       'cache' => array(
00075         'type' => 'int',
00076         'not null' => TRUE,
00077         'default' => 0,
00078         'size' => 'tiny',
00079         'description' => t('Flag to indicate whether format is cachable. (1 = cachable, 0 = not cachable)'),
00080       ),
00081     ),
00082     'primary key' => array('format'),
00083     'unique keys' => array('name' => array('name')),
00084   );
00085
00086   $schema['cache_filter'] = drupal_get_schema_unprocessed('system', 'cache');
00087   $schema['cache_filter']['description'] = t('Cache table for the Filter module to store already filtered pieces of text, identified by input format and md5 hash of the text.');
00088
00089   return $schema;
00090 }
00091
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/filter/filter.module Source File

modules » filter

filter.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: filter.module,v 1.204 2008/01/21 15:08:24 goba Exp $
00003
00009 // This is a special format ID which means "use the default format". This value
00010 // can be passed to the filter APIs as a format ID: this is equivalent to not
00011 // passing an explicit format at all.
00012 define('FILTER_FORMAT_DEFAULT', 0);
00013
00014 define('FILTER_HTML_STRIP', 1);
00015 define('FILTER_HTML_ESCAPE', 2);
00016
00020 function filter_help($path, $arg) {
00021   switch ($path) {
00022     case 'admin/help#filter':
00023       $output = '<p>'. t("The filter module allows administrators to configure text input formats for use on your site. An input format defines the HTML tags, codes, and other input allowed in both content and comments, and is a key feature in guarding against potentially damaging input from malicious users. Two input formats included by default are <em>Filtered HTML</em> (which allows only an administrator-approved subset of HTML tags) and <em>Full HTML</em> (which allows the full set of HTML tags). Additional input formats may be created by an administrator.") .'</p>';
00024       $output .= '<p>'. t('Each input format uses filters to manipulate text, and most input formats apply several different filters to text in a specific order. Each filter is designed for a specific purpose, and generally either adds, removes or transforms elements within user-entered text before it is displayed. A filter does not change the actual content of a post, but instead, modifies it temporarily before it is displayed. A filter may remove unapproved HTML tags, for instance, while another automatically adds HTML to make links referenced in text clickable.') .'</p>';
00025       $output .= '<p>'. t('Users can choose between the available input formats when creating or editing content. Administrators can configure which input formats are available to which user roles, as well as choose a default input format.') .'</p>';
00026       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@filter">Filter module</a>.', array('@filter' => 'http://drupal.org/handbook/modules/filter/')) .'</p>';
00027       return $output;
00028     case 'admin/settings/filters':
00029       $output = '<p>'. t('<em>Input formats</em> define a way of processing user-supplied text in Drupal. Each input format uses filters to manipulate text, and most input formats apply several different filters to text, in a specific order. Each filter is designed to accomplish a specific purpose, and generally either removes elements from or adds elements to text before it is displayed. Users can choose between the available input formats when submitting content.') .'</p>';
00030       $output .= '<p>'. t('Use the list below to configure which input formats are available to which roles, as well as choose a default input format (used for imported content, for example). The default format is always available to users. All input formats are available to users in a role with the "administer filters" permission.') .'</p>';
00031       return $output;
00032     case 'admin/settings/filters/%':
00033       return '<p>'. t('Every <em>filter</em> performs one particular change on the user input, for example stripping out malicious HTML or making URLs clickable. Choose which filters you want to apply to text in this input format. If you notice some filters are causing conflicts in the output, you can <a href="@rearrange">rearrange them</a>.', array('@rearrange' => url('admin/settings/filters/'. $arg[3] .'/order'))) .'</p>';
00034     case 'admin/settings/filters/%/configure':
00035       return '<p>'. t('If you cannot find the settings for a certain filter, make sure you have enabled it on the <a href="@url">view tab</a> first.', array('@url' => url('admin/settings/filters/'. $arg[3]))) .'</p>';
00036     case 'admin/settings/filters/%/order':
00037       $output = '<p>'. t('Because of the flexible filtering system, you might encounter a situation where one filter prevents another from doing its job. For example: a word in an URL gets converted into a glossary term, before the URL can be converted to a clickable link. When this happens, rearrange the order of the filters.') .'</p>';
00038       $output .= '<p>'. t("Filters are executed from top-to-bottom. To change the order of the filters, modify the values in the <em>Weight</em> column or grab a drag-and-drop handle under the <em>Name</em> column and drag filters to new locations in the list. (Grab a handle by clicking and holding the mouse while hovering over a handle icon.) Remember that your changes will not be saved until you click the <em>Save configuration</em> button at the bottom of the page.") .'</p>';
00039       return $output;
00040   }
00041 }
00042
00046 function filter_theme() {
00047   return array(
00048     'filter_admin_overview' => array(
00049       'arguments' => array('form' => NULL),
00050       'file' => 'filter.admin.inc',
00051     ),
00052     'filter_admin_order' => array(
00053       'arguments' => array('form' => NULL),
00054       'file' => 'filter.admin.inc',
00055     ),
00056     'filter_tips' => array(
00057       'arguments' => array('tips' => NULL, 'long' => FALSE, 'extra' => ''),
00058       'file' => 'filter.pages.inc',
00059     ),
00060     'filter_tips_more_info' => array(
00061       'arguments' => array(),
00062     ),
00063   );
00064 }
00065
00069 function filter_menu() {
00070   $items['admin/settings/filters'] = array(
00071     'title' => 'Input formats',
00072     'description' => 'Configure how content input by users is filtered, including allowed HTML tags. Also allows enabling of module-provided filters.',
00073     'page callback' => 'drupal_get_form',
00074     'page arguments' => array('filter_admin_overview'),
00075     'access arguments' => array('administer filters'),
00076     'file' => 'filter.admin.inc',
00077   );
00078   $items['admin/settings/filters/list'] = array(
00079     'title' => 'List',
00080     'type' => MENU_DEFAULT_LOCAL_TASK,
00081   );
00082   $items['admin/settings/filters/add'] = array(
00083     'title' => 'Add input format',
00084     'page callback' => 'filter_admin_format_page',
00085     'type' => MENU_LOCAL_TASK,
00086     'weight' => 1,
00087     'file' => 'filter.admin.inc',
00088   );
00089   $items['admin/settings/filters/delete'] = array(
00090     'title' => 'Delete input format',
00091     'page callback' => 'drupal_get_form',
00092     'page arguments' => array('filter_admin_delete'),
00093     'type' => MENU_CALLBACK,
00094     'file' => 'filter.admin.inc',
00095   );
00096   $items['filter/tips'] = array(
00097     'title' => 'Compose tips',
00098     'page callback' => 'filter_tips_long',
00099     'access callback' => TRUE,
00100     'type' => MENU_SUGGESTED_ITEM,
00101     'file' => 'filter.pages.inc',
00102   );
00103   $items['admin/settings/filters/%filter_format'] = array(
00104     'type' => MENU_CALLBACK,
00105     'title callback' => 'filter_admin_format_title',
00106     'title arguments' => array(3),
00107     'page callback' => 'filter_admin_format_page',
00108     'page arguments' => array(3),
00109     'access arguments' => array('administer filters'),
00110     'file' => 'filter.admin.inc',
00111   );
00112
00113   $items['admin/settings/filters/%filter_format/edit'] = array(
00114     'title' => 'Edit',
00115     'type' => MENU_DEFAULT_LOCAL_TASK,
00116     'weight' => 0,
00117     'file' => 'filter.admin.inc',
00118   );
00119   $items['admin/settings/filters/%filter_format/configure'] = array(
00120     'title' => 'Configure',
00121     'page callback' => 'filter_admin_configure_page',
00122     'page arguments' => array(3),
00123     'type' => MENU_LOCAL_TASK,
00124     'weight' => 1,
00125     'file' => 'filter.admin.inc',
00126   );
00127   $items['admin/settings/filters/%filter_format/order'] = array(
00128     'title' => 'Rearrange',
00129     'page callback' => 'filter_admin_order_page',
00130     'page arguments' => array(3),
00131     'type' => MENU_LOCAL_TASK,
00132     'weight' => 2,
00133     'file' => 'filter.admin.inc',
00134   );
00135   return $items;
00136 }
00137
00138 function filter_format_load($arg) {
00139   return filter_formats($arg);
00140 }
00141
00145 function filter_admin_format_title($format) {
00146   return $format->name;
00147 }
00148
00152 function filter_perm() {
00153   return array('administer filters');
00154 }
00155
00161 function filter_cron() {
00162   cache_clear_all(NULL, 'cache_filter');
00163 }
00164
00168 function filter_filter_tips($delta, $format, $long = FALSE) {
00169   global $base_url;
00170   switch ($delta) {
00171     case 0:
00172       if (variable_get("filter_html_$format", FILTER_HTML_STRIP) == FILTER_HTML_STRIP) {
00173         if ($allowed_html = variable_get("allowed_html_$format", '<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>')) {
00174           switch ($long) {
00175             case 0:
00176               return t('Allowed HTML tags: @tags', array('@tags' => $allowed_html));
00177             case 1:
00178               $output = '<p>'. t('Allowed HTML tags: @tags', array('@tags' => $allowed_html)) .'</p>';
00179               if (!variable_get("filter_html_help_$format", 1)) {
00180                 return $output;
00181               }
00182
00183               $output .= t('
00184 <p>This site allows HTML content. While learning all of HTML may feel intimidating, learning how to use a very small number of the most basic HTML "tags" is very easy. This table provides examples for each tag that is enabled on this site.</p>
00185 <p>For more information see W3C\'s <a href="http://www.w3.org/TR/html/">HTML Specifications</a> or use your favorite search engine to find other sites that explain HTML.</p>');
00186               $tips = array(
00187                 'a' => array( t('Anchors are used to make links to other pages.'), '<a href="'. $base_url .'">'. variable_get('site_name', 'Drupal') .'</a>'),
00188                 'br' => array( t('By default line break tags are automatically added, so use this tag to add additional ones. Use of this tag is different because it is not used with an open/close pair like all the others. Use the extra " /" inside the tag to maintain XHTML 1.0 compatibility'), t('Text with <br />line break')),
00189                 'p' => array( t('By default paragraph tags are automatically added, so use this tag to add additional ones.'), '<p>'. t('Paragraph one.') .'</p> <p>'. t('Paragraph two.') .'</p>'),
00190                 'strong' => array( t('Strong'), '<strong>'. t('Strong') .'</strong>'),
00191                 'em' => array( t('Emphasized'), '<em>'. t('Emphasized') .'</em>'),
00192                 'cite' => array( t('Cited'), '<cite>'. t('Cited') .'</cite>'),
00193                 'code' => array( t('Coded text used to show programming source code'), '<code>'. t('Coded') .'</code>'),
00194                 'b' => array( t('Bolded'), '<b>'. t('Bolded') .'</b>'),
00195                 'u' => array( t('Underlined'), '<u>'. t('Underlined') .'</u>'),
00196                 'i' => array( t('Italicized'), '<i>'. t('Italicized') .'</i>'),
00197                 'sup' => array( t('Superscripted'), t('<sup>Super</sup>scripted')),
00198                 'sub' => array( t('Subscripted'), t('<sub>Sub</sub>scripted')),
00199                 'pre' => array( t('Preformatted'), '<pre>'. t('Preformatted') .'</pre>'),
00200                 'abbr' => array( t('Abbreviation'), t('<abbr title="Abbreviation">Abbrev.</abbr>')),
00201                 'acronym' => array( t('Acronym'), t('<acronym title="Three-Letter Acronym">TLA</acronym>')),
00202                 'blockquote' => array( t('Block quoted'), '<blockquote>'. t('Block quoted') .'</blockquote>'),
00203                 'q' => array( t('Quoted inline'), '<q>'. t('Quoted inline') .'</q>'),
00204                 // Assumes and describes tr, td, th.
00205                 'table' => array( t('Table'), '<table> <tr><th>'. t('Table header') .'</th></tr> <tr><td>'. t('Table cell') .'</td></tr> </table>'),
00206                 'tr' => NULL, 'td' => NULL, 'th' => NULL,
00207                 'del' => array( t('Deleted'), '<del>'. t('Deleted') .'</del>'),
00208                 'ins' => array( t('Inserted'), '<ins>'. t('Inserted') .'</ins>'),
00209                  // Assumes and describes li.
00210                 'ol' => array( t('Ordered list - use the &lt;li&gt; to begin each list item'), '<ol> <li>'. t('First item') .'</li> <li>'. t('Second item') .'</li> </ol>'),
00211                 'ul' => array( t('Unordered list - use the &lt;li&gt; to begin each list item'), '<ul> <li>'. t('First item') .'</li> <li>'. t('Second item') .'</li> </ul>'),
00212                 'li' => NULL,
00213                 // Assumes and describes dt and dd.
00214                 'dl' => array( t('Definition lists are similar to other HTML lists. &lt;dl&gt; begins the definition list, &lt;dt&gt; begins the definition term and &lt;dd&gt; begins the definition description.'), '<dl> <dt>'. t('First term') .'</dt> <dd>'. t('First definition') .'</dd> <dt>'. t('Second term') .'</dt> <dd>'. t('Second definition') .'</dd> </dl>'),
00215                 'dt' => NULL, 'dd' => NULL,
00216                 'h1' => array( t('Header'), '<h1>'. t('Title') .'</h1>'),
00217                 'h2' => array( t('Header'), '<h2>'. t('Subtitle') .'</h2>'),
00218                 'h3' => array( t('Header'), '<h3>'. t('Subtitle three') .'</h3>'),
00219                 'h4' => array( t('Header'), '<h4>'. t('Subtitle four') .'</h4>'),
00220                 'h5' => array( t('Header'), '<h5>'. t('Subtitle five') .'</h5>'),
00221                 'h6' => array( t('Header'), '<h6>'. t('Subtitle six') .'</h6>')
00222               );
00223               $header = array(t('Tag Description'), t('You Type'), t('You Get'));
00224               preg_match_all('/<([a-z0-9]+)[^a-z0-9]/i', $allowed_html, $out);
00225               foreach ($out[1] as $tag) {
00226                 if (array_key_exists($tag, $tips)) {
00227                   if ($tips[$tag]) {
00228                     $rows[] = array(
00229                       array('data' => $tips[$tag][0], 'class' => 'description'),
00230                       array('data' => '<code>'. check_plain($tips[$tag][1]) .'</code>', 'class' => 'type'),
00231                       array('data' => $tips[$tag][1], 'class' => 'get')
00232                     );
00233                   }
00234                 }
00235                 else {
00236                   $rows[] = array(
00237                     array('data' => t('No help provided for tag %tag.', array('%tag' => $tag)), 'class' => 'description', 'colspan' => 3),
00238                   );
00239                 }
00240               }
00241               $output .= theme('table', $header, $rows);
00242
00243               $output .= t('
00244 <p>Most unusual characters can be directly entered without any problems.</p>
00245 <p>If you do encounter problems, try using HTML character entities. A common example looks like &amp;amp; for an ampersand &amp; character. For a full list of entities see HTML\'s <a href="http://www.w3.org/TR/html4/sgml/entities.html">entities</a> page. Some of the available characters include:</p>');
00246               $entities = array(
00247                 array( t('Ampersand'), '&amp;'),
00248                 array( t('Greater than'), '&gt;'),
00249                 array( t('Less than'), '&lt;'),
00250                 array( t('Quotation mark'), '&quot;'),
00251               );
00252               $header = array(t('Character Description'), t('You Type'), t('You Get'));
00253               unset($rows);
00254               foreach ($entities as $entity) {
00255                 $rows[] = array(
00256                   array('data' => $entity[0], 'class' => 'description'),
00257                   array('data' => '<code>'. check_plain($entity[1]) .'</code>', 'class' => 'type'),
00258                   array('data' => $entity[1], 'class' => 'get')
00259                 );
00260               }
00261               $output .= theme('table', $header, $rows);
00262               return $output;
00263           }
00264         }
00265         else {
00266           return t('No HTML tags allowed');
00267         }
00268       }
00269       break;
00270
00271     case 1:
00272       switch ($long) {
00273         case 0:
00274           return t('Lines and paragraphs break automatically.');
00275         case 1:
00276           return t('Lines and paragraphs are automatically recognized. The &lt;br /&gt; line break, &lt;p&gt; paragraph and &lt;/p&gt; close paragraph tags are inserted automatically. If paragraphs are not recognized simply add a couple blank lines.');
00277       }
00278       break;
00279     case 2:
00280       return t('Web page addresses and e-mail addresses turn into links automatically.');
00281   }
00282 }
00283
00287 function filter_formats($index = NULL) {
00288   global $user;
00289   static $formats;
00290
00291   // Administrators can always use all input formats.
00292   $all = user_access('administer filters');
00293
00294   if (!isset($formats)) {
00295     $formats = array();
00296
00297     $query = 'SELECT * FROM {filter_formats}';
00298
00299     // Build query for selecting the format(s) based on the user's roles.
00300     $args = array();
00301     if (!$all) {
00302       $where = array();
00303       foreach ($user->roles as $rid => $role) {
00304         $where[] = "roles LIKE '%%,%d,%%'";
00305         $args[] = $rid;
00306       }
00307       $query .= ' WHERE '. implode(' OR ', $where) .' OR format = %d';
00308       $args[] = variable_get('filter_default_format', 1);
00309     }
00310
00311     $result = db_query($query, $args);
00312     while ($format = db_fetch_object($result)) {
00313       $formats[$format->format] = $format;
00314     }
00315   }
00316   if (isset($index)) {
00317     return isset($formats[$index]) ? $formats[$index] : FALSE;
00318   }
00319   return $formats;
00320 }
00321
00325 function filter_list_all() {
00326   $filters = array();
00327
00328   foreach (module_list() as $module) {
00329     $list = module_invoke($module, 'filter', 'list');
00330     if (isset($list) && is_array($list)) {
00331       foreach ($list as $delta => $name) {
00332         $filters[$module .'/'. $delta] = (object)array('module' => $module, 'delta' => $delta, 'name' => $name);
00333       }
00334     }
00335   }
00336
00337   uasort($filters, '_filter_list_cmp');
00338
00339   return $filters;
00340 }
00341
00345 function _filter_list_cmp($a, $b) {
00346   return strcmp($a->name, $b->name);
00347 }
00348
00352 function filter_resolve_format($format) {
00353   return $format == FILTER_FORMAT_DEFAULT ? variable_get('filter_default_format', 1) : $format;
00354 }
00358 function filter_format_allowcache($format) {
00359   static $cache = array();
00360   $format = filter_resolve_format($format);
00361   if (!isset($cache[$format])) {
00362     $cache[$format] = db_result(db_query('SELECT cache FROM {filter_formats} WHERE format = %d', $format));
00363   }
00364   return $cache[$format];
00365 }
00366
00370 function filter_list_format($format) {
00371   static $filters = array();
00372
00373   if (!isset($filters[$format])) {
00374     $filters[$format] = array();
00375     $result = db_query("SELECT * FROM {filters} WHERE format = %d ORDER BY weight, module, delta", $format);
00376     while ($filter = db_fetch_object($result)) {
00377       $list = module_invoke($filter->module, 'filter', 'list');
00378       if (isset($list) && is_array($list) && isset($list[$filter->delta])) {
00379         $filter->name = $list[$filter->delta];
00380         $filters[$format][$filter->module .'/'. $filter->delta] = $filter;
00381       }
00382     }
00383   }
00384
00385   return $filters[$format];
00386 }
00387
00418 function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $check = TRUE) {
00419   // When $check = TRUE, do an access check on $format.
00420   if (isset($text) && (!$check || filter_access($format))) {
00421     $format = filter_resolve_format($format);
00422
00423     // Check for a cached version of this piece of text.
00424     $cache_id = $format .':'. md5($text);
00425     if ($cached = cache_get($cache_id, 'cache_filter')) {
00426       return $cached->data;
00427     }
00428
00429     // See if caching is allowed for this format.
00430     $cache = filter_format_allowcache($format);
00431
00432     // Convert all Windows and Mac newlines to a single newline,
00433     // so filters only need to deal with one possibility.
00434     $text = str_replace(array("\r\n", "\r"), "\n", $text);
00435
00436     // Get a complete list of filters, ordered properly.
00437     $filters = filter_list_format($format);
00438
00439     // Give filters the chance to escape HTML-like data such as code or formulas.
00440     foreach ($filters as $filter) {
00441       $text = module_invoke($filter->module, 'filter', 'prepare', $filter->delta, $format, $text, $cache_id);
00442     }
00443
00444     // Perform filtering.
00445     foreach ($filters as $filter) {
00446       $text = module_invoke($filter->module, 'filter', 'process', $filter->delta, $format, $text, $cache_id);
00447     }
00448
00449     // Store in cache with a minimum expiration time of 1 day.
00450     if ($cache) {
00451       cache_set($cache_id, $text, 'cache_filter', time() + (60 * 60 * 24));
00452     }
00453   }
00454   else {
00455     $text = t('n/a');
00456   }
00457
00458   return $text;
00459 }
00460
00475 function filter_form($value = FILTER_FORMAT_DEFAULT, $weight = NULL, $parents = array('format')) {
00476   $value = filter_resolve_format($value);
00477   $formats = filter_formats();
00478
00479   $extra = theme('filter_tips_more_info');
00480
00481   if (count($formats) > 1) {
00482     $form = array(
00483       '#type' => 'fieldset',
00484       '#title' => t('Input format'),
00485       '#collapsible' => TRUE,
00486       '#collapsed' => TRUE,
00487       '#weight' => $weight,
00488       '#element_validate' => array('filter_form_validate'),
00489     );
00490     // Multiple formats available: display radio buttons with tips.
00491     foreach ($formats as $format) {
00492       // Generate the parents as the autogenerator does, so we will have a
00493       // unique id for each radio button.
00494       $parents_for_id = array_merge($parents, array($format->format));
00495       $form[$format->format] = array(
00496         '#type' => 'radio',
00497         '#title' => $format->name,
00498         '#default_value' => $value,
00499         '#return_value' => $format->format,
00500         '#parents' => $parents,
00501         '#description' => theme('filter_tips', _filter_tips($format->format, FALSE)),
00502         '#id' => form_clean_id('edit-'. implode('-', $parents_for_id)),
00503       );
00504     }
00505   }
00506   else {
00507     // Only one format available: use a hidden form item and only show tips.
00508     $format = array_shift($formats);
00509     $form[$format->format] = array('#type' => 'value', '#value' => $format->format, '#parents' => $parents);
00510     $tips = _filter_tips(variable_get('filter_default_format', 1), FALSE);
00511     $form['format']['guidelines'] = array(
00512       '#title' => t('Formatting guidelines'),
00513       '#value' => theme('filter_tips', $tips, FALSE, $extra),
00514     );
00515   }
00516   $form[] = array('#value' => $extra);
00517   return $form;
00518 }
00519
00520 function filter_form_validate($form) {
00521   foreach (element_children($form) as $key) {
00522     if ($form[$key]['#value'] == $form[$key]['#return_value']) {
00523       return;
00524     }
00525   }
00526   form_error($form, t('An illegal choice has been detected. Please contact the site administrator.'));
00527   watchdog('form', 'Illegal choice %choice in %name element.', array('%choice' => $form[$key]['#value'], '%name' => empty($form['#title']) ? $form['#parents'][0] : $form['#title']), WATCHDOG_ERROR);
00528 }
00529
00533 function filter_access($format) {
00534   $format = filter_resolve_format($format);
00535   if (user_access('administer filters') || ($format == variable_get('filter_default_format', 1))) {
00536     return TRUE;
00537   }
00538   else {
00539     $formats = filter_formats();
00540     return isset($formats[$format]);
00541   }
00542 }
00543
00552 function _filter_tips($format, $long = FALSE) {
00553   if ($format == -1) {
00554     $formats = filter_formats();
00555   }
00556   else {
00557     $formats = array(db_fetch_object(db_query("SELECT * FROM {filter_formats} WHERE format = %d", $format)));
00558   }
00559
00560   $tips = array();
00561
00562   foreach ($formats as $format) {
00563     $filters = filter_list_format($format->format);
00564
00565     $tips[$format->name] = array();
00566     foreach ($filters as $id => $filter) {
00567       if ($tip = module_invoke($filter->module, 'filter_tips', $filter->delta, $format->format, $long)) {
00568         $tips[$format->name][] = array('tip' => $tip, 'id' => $id);
00569       }
00570     }
00571   }
00572
00573   return $tips;
00574 }
00575
00576
00582 function theme_filter_tips_more_info() {
00583   return '<p>'. l(t('More information about formatting options'), 'filter/tips') .'</p>';
00584 }
00585
00601 function filter_filter($op, $delta = 0, $format = -1, $text = '') {
00602   switch ($op) {
00603     case 'list':
00604       return array(0 => t('HTML filter'), 1 => t('Line break converter'), 2 => t('URL filter'), 3 => t('HTML corrector'));
00605
00606     case 'description':
00607       switch ($delta) {
00608         case 0:
00609           return t('Allows you to restrict whether users can post HTML and which tags to filter out. It will also remove harmful content such as JavaScript events, JavaScript URLs and CSS styles from those tags that are not removed.');
00610         case 1:
00611           return t('Converts line breaks into HTML (i.e. &lt;br&gt; and &lt;p&gt; tags).');
00612         case 2:
00613           return t('Turns web and e-mail addresses into clickable links.');
00614         case 3:
00615           return t('Corrects faulty and chopped off HTML in postings.');
00616         default:
00617           return;
00618       }
00619
00620     case 'process':
00621       switch ($delta) {
00622         case 0:
00623           return _filter_html($text, $format);
00624         case 1:
00625           return _filter_autop($text);
00626         case 2:
00627           return _filter_url($text, $format);
00628         case 3:
00629           return _filter_htmlcorrector($text);
00630         default:
00631           return $text;
00632       }
00633
00634     case 'settings':
00635       switch ($delta) {
00636         case 0:
00637           return _filter_html_settings($format);
00638         case 2:
00639           return _filter_url_settings($format);
00640         default:
00641           return;
00642       }
00643
00644     default:
00645       return $text;
00646   }
00647 }
00648
00652 function _filter_html_settings($format) {
00653   $form['filter_html'] = array(
00654     '#type' => 'fieldset',
00655     '#title' => t('HTML filter'),
00656     '#collapsible' => TRUE,
00657   );
00658   $form['filter_html']["filter_html_$format"] = array(
00659     '#type' => 'radios',
00660     '#title' => t('Filter HTML tags'),
00661     '#default_value' => variable_get("filter_html_$format", FILTER_HTML_STRIP),
00662     '#options' => array(FILTER_HTML_STRIP => t('Strip disallowed tags'), FILTER_HTML_ESCAPE => t('Escape all tags')),
00663     '#description' => t('How to deal with HTML tags in user-contributed content. If set to "Strip disallowed tags", dangerous tags are removed (see below). If set to "Escape tags", all HTML is escaped and presented as it was typed.'),
00664   );
00665   $form['filter_html']["allowed_html_$format"] = array(
00666     '#type' => 'textfield',
00667     '#title' => t('Allowed HTML tags'),
00668     '#default_value' => variable_get("allowed_html_$format", '<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>'),
00669     '#size' => 64,
00670     '#maxlength' => 255,
00671     '#description' => t('If "Strip disallowed tags" is selected, optionally specify tags which should not be stripped. JavaScript event attributes are always stripped.'),
00672   );
00673   $form['filter_html']["filter_html_help_$format"] = array(
00674     '#type' => 'checkbox',
00675     '#title' => t('Display HTML help'),
00676     '#default_value' => variable_get("filter_html_help_$format", 1),
00677     '#description' => t('If enabled, Drupal will display some basic HTML help in the long filter tips.'),
00678   );
00679   $form['filter_html']["filter_html_nofollow_$format"] = array(
00680     '#type' => 'checkbox',
00681     '#title' => t('Spam link deterrent'),
00682     '#default_value' => variable_get("filter_html_nofollow_$format", FALSE),
00683     '#description' => t('If enabled, Drupal will add rel="nofollow" to all links, as a measure to reduce the effectiveness of spam links. Note: this will also prevent valid links from being followed by search engines, therefore it is likely most effective when enabled for anonymous users.'),
00684   );
00685   return $form;
00686 }
00687
00691 function _filter_html($text, $format) {
00692   if (variable_get("filter_html_$format", FILTER_HTML_STRIP) == FILTER_HTML_STRIP) {
00693     $allowed_tags = preg_split('/\s+|<|>/', variable_get("allowed_html_$format", '<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>'), -1, PREG_SPLIT_NO_EMPTY);
00694     $text = filter_xss($text, $allowed_tags);
00695   }
00696
00697   if (variable_get("filter_html_$format", FILTER_HTML_STRIP) == FILTER_HTML_ESCAPE) {
00698     // Escape HTML
00699     $text = check_plain($text);
00700   }
00701
00702   if (variable_get("filter_html_nofollow_$format", FALSE)) {
00703     $text = preg_replace('/<a([^>]+)>/i', '<a\\1 rel="nofollow">', $text);
00704   }
00705
00706   return trim($text);
00707 }
00708
00712 function _filter_url_settings($format) {
00713   $form['filter_urlfilter'] = array(
00714     '#type' => 'fieldset',
00715     '#title' => t('URL filter'),
00716     '#collapsible' => TRUE,
00717   );
00718   $form['filter_urlfilter']['filter_url_length_'. $format] = array(
00719     '#type' => 'textfield',
00720     '#title' => t('Maximum link text length'),
00721     '#default_value' => variable_get('filter_url_length_'. $format, 72),
00722     '#maxlength' => 4,
00723     '#description' => t('URLs longer than this number of characters will be truncated to prevent long strings that break formatting. The link itself will be retained; just the text portion of the link will be truncated.'),
00724   );
00725   return $form;
00726 }
00727
00732 function _filter_url($text, $format) {
00733   // Pass length to regexp callback
00734   _filter_url_trim(NULL, variable_get('filter_url_length_'. $format, 72));
00735
00736   $text = ' '. $text .' ';
00737
00738   // Match absolute URLs.
00739   $text = preg_replace_callback("`(<p>|<li>|<br\s*/?>|[ \n\r\t\(])((http://|https://|ftp://|mailto:|smb://|afp://|file://|gopher://|news://|ssl://|sslv2://|sslv3://|tls://|tcp://|udp://)([a-zA-Z0-9@:%_+*~#?&=.,/;-]*[a-zA-Z0-9@:%_+*~#&=/;-]))([.,?!]*?)(?=(</p>|</li>|<br\s*/?>|[ \n\r\t\)]))`i", '_filter_url_parse_full_links', $text);
00740
00741   // Match e-mail addresses.
00742   $text = preg_replace("`(<p>|<li>|<br\s*/?>|[ \n\r\t\(])([A-Za-z0-9._-]+@[A-Za-z0-9._+-]+\.[A-Za-z]{2,4})([.,?!]*?)(?=(</p>|</li>|<br\s*/?>|[ \n\r\t\)]))`i", '\1<a href="mailto:\2">\2</a>\3', $text);
00743
00744   // Match www domains/addresses.
00745   $text = preg_replace_callback("`(<p>|<li>|[ \n\r\t\(])(www\.[a-zA-Z0-9@:%_+*~#?&=.,/;-]*[a-zA-Z0-9@:%_+~#\&=/;-])([.,?!]*?)(?=(</p>|</li>|<br\s*/?>|[ \n\r\t\)]))`i", '_filter_url_parse_partial_links', $text);
00746   $text = substr($text, 1, -1);
00747
00748   return $text;
00749 }
00750
00754 function _filter_htmlcorrector($text) {
00755   // Prepare tag lists.
00756   static $no_nesting, $single_use;
00757   if (!isset($no_nesting)) {
00758     // Tags which cannot be nested but are typically left unclosed.
00759     $no_nesting = drupal_map_assoc(array('li', 'p'));
00760
00761     // Single use tags in HTML4
00762     $single_use = drupal_map_assoc(array('base', 'meta', 'link', 'hr', 'br', 'param', 'img', 'area', 'input', 'col', 'frame'));
00763   }
00764
00765   // Properly entify angles.
00766   $text = preg_replace('!<([^a-zA-Z/])!', '&lt;\1', $text);
00767
00768   // Split tags from text.
00769   $split = preg_split('/<([^>]+?)>/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
00770   // Note: PHP ensures the array consists of alternating delimiters and literals
00771   // and begins and ends with a literal (inserting $null as required).
00772
00773   $tag = false; // Odd/even counter. Tag or no tag.
00774   $stack = array();
00775   $output = '';
00776   foreach ($split as $value) {
00777     // Process HTML tags.
00778     if ($tag) {
00779       list($tagname) = explode(' ', strtolower($value), 2);
00780       // Closing tag
00781       if ($tagname{0} == '/') {
00782         $tagname = substr($tagname, 1);
00783         // Discard XHTML closing tags for single use tags.
00784         if (!isset($single_use[$tagname])) {
00785           // See if we possibly have a matching opening tag on the stack.
00786           if (in_array($tagname, $stack)) {
00787             // Close other tags lingering first.
00788             do {
00789               $output .= '</'. $stack[0] .'>';
00790             } while (array_shift($stack) != $tagname);
00791           }
00792           // Otherwise, discard it.
00793         }
00794       }
00795       // Opening tag
00796       else {
00797         // See if we have an identical 'no nesting' tag already open and close it if found.
00798         if (count($stack) && ($stack[0] == $tagname) && isset($no_nesting[$stack[0]])) {
00799           $output .= '</'. array_shift($stack) .'>';
00800         }
00801         // Push non-single-use tags onto the stack
00802         if (!isset($single_use[$tagname])) {
00803           array_unshift($stack, $tagname);
00804         }
00805         // Add trailing slash to single-use tags as per X(HT)ML.
00806         else {
00807           $value = rtrim($value, ' /') .' /';
00808         }
00809         $output .= '<'. $value .'>';
00810       }
00811     }
00812     else {
00813       // Passthrough all text.
00814       $output .= $value;
00815     }
00816     $tag = !$tag;
00817   }
00818   // Close remaining tags.
00819   while (count($stack) > 0) {
00820     $output .= '</'. array_shift($stack) .'>';
00821   }
00822   return $output;
00823 }
00824
00828 function _filter_url_parse_full_links($match) {
00829   $match[2] = decode_entities($match[2]);
00830   $caption = check_plain(_filter_url_trim($match[2]));
00831   $match[2] = check_url($match[2]);
00832   return $match[1] .'<a href="'. $match[2] .'" title="'. $match[2] .'">'. $caption .'</a>'. $match[5];
00833 }
00834
00838 function _filter_url_parse_partial_links($match) {
00839   $match[2] = decode_entities($match[2]);
00840   $caption = check_plain(_filter_url_trim($match[2]));
00841   $match[2] = check_plain($match[2]);
00842   return $match[1] .'<a href="http://'. $match[2] .'" title="'. $match[2] .'">'. $caption .'</a>'. $match[3];
00843 }
00844
00848 function _filter_url_trim($text, $length = NULL) {
00849   static $_length;
00850   if ($length !== NULL) {
00851     $_length = $length;
00852   }
00853
00854   // Use +3 for '...' string length.
00855   if (strlen($text) > $_length + 3) {
00856     $text = substr($text, 0, $_length) .'...';
00857   }
00858
00859   return $text;
00860 }
00861
00866 function _filter_autop($text) {
00867   // All block level tags
00868   $block = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|p|h[1-6]|hr)';
00869
00870   // Split at <pre>, <script>, <style> and </pre>, </script>, </style> tags.
00871   // We don't apply any processing to the contents of these tags to avoid messing
00872   // up code. We look for matched pairs and allow basic nesting. For example:
00873   // "processed <pre> ignored <script> ignored </script> ignored </pre> processed"
00874   $chunks = preg_split('@(</?(?:pre|script|style|object)[^>]*>)@i', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
00875   // Note: PHP ensures the array consists of alternating delimiters and literals
00876   // and begins and ends with a literal (inserting NULL as required).
00877   $ignore = FALSE;
00878   $ignoretag = '';
00879   $output = '';
00880   foreach ($chunks as $i => $chunk) {
00881     if ($i % 2) {
00882       // Opening or closing tag?
00883       $open = ($chunk[1] != '/');
00884       list($tag) = split('[ >]', substr($chunk, 2 - $open), 2);
00885       if (!$ignore) {
00886         if ($open) {
00887           $ignore = TRUE;
00888           $ignoretag = $tag;
00889         }
00890       }
00891       // Only allow a matching tag to close it.
00892       else if (!$open && $ignoretag == $tag) {
00893         $ignore = FALSE;
00894         $ignoretag = '';
00895       }
00896     }
00897     else if (!$ignore) {
00898       $chunk = preg_replace('|\n*$|', '', $chunk) ."\n\n"; // just to make things a little easier, pad the end
00899       $chunk = preg_replace('|<br />\s*<br />|', "\n\n", $chunk);
00900       $chunk = preg_replace('!(<'. $block .'[^>]*>)!', "\n$1", $chunk); // Space things out a little
00901       $chunk = preg_replace('!(</'. $block .'>)!', "$1\n\n", $chunk); // Space things out a little
00902       $chunk = preg_replace("/\n\n+/", "\n\n", $chunk); // take care of duplicates
00903       $chunk = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $chunk); // make paragraphs, including one at the end
00904       $chunk = preg_replace('|<p>\s*</p>\n|', '', $chunk); // under certain strange conditions it could create a P of entirely whitespace
00905       $chunk = preg_replace("|<p>(<li.+?)</p>|", "$1", $chunk); // problem with nested lists
00906       $chunk = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $chunk);
00907       $chunk = str_replace('</blockquote></p>', '</p></blockquote>', $chunk);
00908       $chunk = preg_replace('!<p>\s*(</?'. $block .'[^>]*>)!', "$1", $chunk);
00909       $chunk = preg_replace('!(</?'. $block .'[^>]*>)\s*</p>!', "$1", $chunk);
00910       $chunk = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $chunk); // make line breaks
00911       $chunk = preg_replace('!(</?'. $block .'[^>]*>)\s*<br />!', "$1", $chunk);
00912       $chunk = preg_replace('!<br />(\s*</?(?:p|li|div|th|pre|td|ul|ol)>)!', '$1', $chunk);
00913       $chunk = preg_replace('/&([^#])(?![A-Za-z0-9]{1,8};)/', '&amp;$1', $chunk);
00914     }
00915     $output .= $chunk;
00916   }
00917   return $output;
00918 }
00919
00930 function filter_xss_admin($string) {
00931   return filter_xss($string, array('a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'dd', 'del', 'dfn', 'div', 'dl', 'dt', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'img', 'ins', 'kbd', 'li', 'object', 'ol', 'p', 'param', 'pre', 'q', 'samp', 'small', 'span', 'strong', 'sub', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'tt', 'ul', 'var'));
00932 }
00933
00955 function filter_xss($string, $allowed_tags = array('a', 'em', 'strong', 'cite', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd')) {
00956   // Only operate on valid UTF-8 strings. This is necessary to prevent cross
00957   // site scripting issues on Internet Explorer 6.
00958   if (!drupal_validate_utf8($string)) {
00959     return '';
00960   }
00961   // Store the input format
00962   _filter_xss_split($allowed_tags, TRUE);
00963   // Remove NUL characters (ignored by some browsers)
00964   $string = str_replace(chr(0), '', $string);
00965   // Remove Netscape 4 JS entities
00966   $string = preg_replace('%&\s*\{[^}]*(\}\s*;?|$)%', '', $string);
00967
00968   // Defuse all HTML entities
00969   $string = str_replace('&', '&amp;', $string);
00970   // Change back only well-formed entities in our whitelist
00971   // Named entities
00972   $string = preg_replace('/&amp;([A-Za-z][A-Za-z0-9]*;)/', '&\1', $string);
00973   // Decimal numeric entities
00974   $string = preg_replace('/&amp;#([0-9]+;)/', '&#\1', $string);
00975   // Hexadecimal numeric entities
00976   $string = preg_replace('/&amp;#[Xx]0*((?:[0-9A-Fa-f]{2})+;)/', '&#x\1', $string);
00977
00978   return preg_replace_callback('%
00979     (
00980     <(?=[^a-zA-Z!/])  # a lone <
00981     |                 # or
00982     <[^>]*.(>|$)      # a string that starts with a <, up until the > or the end of the string
00983     |                 # or
00984     >                 # just a >
00985     )%x', '_filter_xss_split', $string);
00986 }
00987
01001 function _filter_xss_split($m, $store = FALSE) {
01002   static $allowed_html;
01003
01004   if ($store) {
01005     $allowed_html = array_flip($m);
01006     return;
01007   }
01008
01009   $string = $m[1];
01010
01011   if (substr($string, 0, 1) != '<') {
01012     // We matched a lone ">" character
01013     return '&gt;';
01014   }
01015   else if (strlen($string) == 1) {
01016     // We matched a lone "<" character
01017     return '&lt;';
01018   }
01019
01020   if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $string, $matches)) {
01021     // Seriously malformed
01022     return '';
01023   }
01024
01025   $slash = trim($matches[1]);
01026   $elem = &$matches[2];
01027   $attrlist = &$matches[3];
01028
01029   if (!isset($allowed_html[strtolower($elem)])) {
01030     // Disallowed HTML element
01031     return '';
01032   }
01033
01034   if ($slash != '') {
01035     return "</$elem>";
01036   }
01037
01038   // Is there a closing XHTML slash at the end of the attributes?
01039   // In PHP 5.1.0+ we could count the changes, currently we need a separate match
01040   $xhtml_slash = preg_match('%\s?/\s*$%', $attrlist) ? ' /' : '';
01041   $attrlist = preg_replace('%(\s?)/\s*$%', '\1', $attrlist);
01042
01043   // Clean up attributes
01044   $attr2 = implode(' ', _filter_xss_attributes($attrlist));
01045   $attr2 = preg_replace('/[<>]/', '', $attr2);
01046   $attr2 = strlen($attr2) ? ' '. $attr2 : '';
01047
01048   return "<$elem$attr2$xhtml_slash>";
01049 }
01050
01057 function _filter_xss_attributes($attr) {
01058   $attrarr = array();
01059   $mode = 0;
01060   $attrname = '';
01061
01062   while (strlen($attr) != 0) {
01063     // Was the last operation successful?
01064     $working = 0;
01065
01066     switch ($mode) {
01067       case 0:
01068         // Attribute name, href for instance
01069         if (preg_match('/^([-a-zA-Z]+)/', $attr, $match)) {
01070           $attrname = strtolower($match[1]);
01071           $skip = ($attrname == 'style' || substr($attrname, 0, 2) == 'on');
01072           $working = $mode = 1;
01073           $attr = preg_replace('/^[-a-zA-Z]+/', '', $attr);
01074         }
01075
01076         break;
01077
01078       case 1:
01079         // Equals sign or valueless ("selected")
01080         if (preg_match('/^\s*=\s*/', $attr)) {
01081           $working = 1; $mode = 2;
01082           $attr = preg_replace('/^\s*=\s*/', '', $attr);
01083           break;
01084         }
01085
01086         if (preg_match('/^\s+/', $attr)) {
01087           $working = 1; $mode = 0;
01088           if (!$skip) {
01089             $attrarr[] = $attrname;
01090           }
01091           $attr = preg_replace('/^\s+/', '', $attr);
01092         }
01093
01094         break;
01095
01096       case 2:
01097         // Attribute value, a URL after href= for instance
01098         if (preg_match('/^"([^"]*)"(\s+|$)/', $attr, $match)) {
01099           $thisval = filter_xss_bad_protocol($match[1]);
01100
01101           if (!$skip) {
01102             $attrarr[] = "$attrname=\"$thisval\"";
01103           }
01104           $working = 1;
01105           $mode = 0;
01106           $attr = preg_replace('/^"[^"]*"(\s+|$)/', '', $attr);
01107           break;
01108         }
01109
01110         if (preg_match("/^'([^']*)'(\s+|$)/", $attr, $match)) {
01111           $thisval = filter_xss_bad_protocol($match[1]);
01112
01113           if (!$skip) {
01114             $attrarr[] = "$attrname='$thisval'";;
01115           }
01116           $working = 1; $mode = 0;
01117           $attr = preg_replace("/^'[^']*'(\s+|$)/", '', $attr);
01118           break;
01119         }
01120
01121         if (preg_match("%^([^\s\"']+)(\s+|$)%", $attr, $match)) {
01122           $thisval = filter_xss_bad_protocol($match[1]);
01123
01124           if (!$skip) {
01125             $attrarr[] = "$attrname=\"$thisval\"";
01126           }
01127           $working = 1; $mode = 0;
01128           $attr = preg_replace("%^[^\s\"']+(\s+|$)%", '', $attr);
01129         }
01130
01131         break;
01132     }
01133
01134     if ($working == 0) {
01135       // not well formed, remove and try again
01136       $attr = preg_replace('/
01137         ^
01138         (
01139         "[^"]*("|$)     # - a string that starts with a double quote, up until the next double quote or the end of the string
01140         |               # or
01141         \'[^\']*(\'|$)| # - a string that starts with a quote, up until the next quote or the end of the string
01142         |               # or
01143         \S              # - a non-whitespace character
01144         )*              # any number of the above three
01145         \s*             # any number of whitespaces
01146         /x', '', $attr);
01147       $mode = 0;
01148     }
01149   }
01150
01151   // the attribute list ends with a valueless attribute like "selected"
01152   if ($mode == 1) {
01153     $attrarr[] = $attrname;
01154   }
01155   return $attrarr;
01156 }
01157
01170 function filter_xss_bad_protocol($string, $decode = TRUE) {
01171   static $allowed_protocols;
01172   if (!isset($allowed_protocols)) {
01173     $allowed_protocols = array_flip(variable_get('filter_allowed_protocols', array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal')));
01174   }
01175
01176   // Get the plain text representation of the attribute value (i.e. its meaning).
01177   if ($decode) {
01178     $string = decode_entities($string);
01179   }
01180
01181   // Iteratively remove any invalid protocol found.
01182
01183   do {
01184     $before = $string;
01185     $colonpos = strpos($string, ':');
01186     if ($colonpos > 0) {
01187       // We found a colon, possibly a protocol. Verify.
01188       $protocol = substr($string, 0, $colonpos);
01189       // If a colon is preceded by a slash, question mark or hash, it cannot
01190       // possibly be part of the URL scheme. This must be a relative URL,
01191       // which inherits the (safe) protocol of the base document.
01192       if (preg_match('![/?#]!', $protocol)) {
01193         break;
01194       }
01195       // Per RFC2616, section 3.2.3 (URI Comparison) scheme comparison must be case-insensitive
01196       // Check if this is a disallowed protocol.
01197       if (!isset($allowed_protocols[strtolower($protocol)])) {
01198         $string = substr($string, $colonpos + 1);
01199       }
01200     }
01201   } while ($before != $string);
01202   return check_plain($string);
01203 }
01204
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/filter/filter.pages.inc Source File

modules » filter

filter.pages.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: filter.pages.inc,v 1.2 2007/11/10 17:41:18 dries Exp $
00003
00013 function filter_tips_long() {
00014   $format = arg(2);
00015   if ($format) {
00016     $output = theme('filter_tips', _filter_tips($format, TRUE), TRUE);
00017   }
00018   else {
00019     $output = theme('filter_tips', _filter_tips(-1, TRUE), TRUE);
00020   }
00021   return $output;
00022 }
00023
00024
00030 function theme_filter_tips($tips, $long = FALSE, $extra = '') {
00031   $output = '';
00032
00033   $multiple = count($tips) > 1;
00034   if ($multiple) {
00035     $output = t('input formats') .':';
00036   }
00037
00038   if (count($tips)) {
00039     if ($multiple) {
00040       $output .= '<ul>';
00041     }
00042     foreach ($tips as $name => $tiplist) {
00043       if ($multiple) {
00044         $output .= '<li>';
00045         $output .= '<strong>'. $name .'</strong>:<br />';
00046       }
00047
00048       if (count($tiplist) > 0) {
00049         $output .= '<ul class="tips">';
00050         foreach ($tiplist as $tip) {
00051           $output .= '<li'. ($long ? ' id="filter-'. str_replace("/", "-", $tip['id']) .'">' : '>') . $tip['tip'] .'</li>';
00052         }
00053         $output .= '</ul>';
00054       }
00055
00056       if ($multiple) {
00057         $output .= '</li>';
00058       }
00059     }
00060     if ($multiple) {
00061       $output .= '</ul>';
00062     }
00063   }
00064
00065   return $output;
00066 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/filter_example.module Source File

docs » examples

filter_example.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: filter_example.module,v 1.8 2007/01/29 16:19:57 bdragon Exp $
00003
00023 function filter_example_filter_tips($delta, $format, $long = FALSE) {
00024   switch ($delta) {
00025     case 0:
00026       if ($long) {
00027         return t('Every instance of "foo" in the input text will be replaced with "%replacement".', array('%replacement' => variable_get('filter_example_foo_'. $format, 'bar')));
00028       }
00029       break;
00030
00031     case 1:
00032       if ($long) {
00033         return t('Every instance of the special &lt;time /&gt; tag will be replaced with the current date and time in the user\'s specified time zone.');
00034       }
00035       else {
00036         return t('Use &lt;time /&gt; to display the current date/time.');
00037       }
00038       break;
00039   }
00040 }
00041
00048 function filter_example_filter($op, $delta = 0, $format = -1, $text = '') {
00049   // The "list" operation provides the module an opportunity to declare both how
00050   // many filters it defines and a human-readable name for each filter. Note that
00051   // the returned name should be passed through t() for translation.
00052   if ($op == 'list') {
00053     return array(
00054       0 => t('Substitute "foo"'),
00055       1 => t('Current time'));
00056   }
00057
00058   // All operations besides "list" provide a $delta argument so we know which
00059   // filter they refer to. We'll switch on that argument now so that we can
00060   // discuss each filter in turn.
00061   switch ($delta) {
00062
00063     // First we define the simple string substitution filter.
00064     case 0:
00065
00066       switch ($op) {
00067         // This description is shown in the administrative interface, unlike the
00068         // filter tips which are shown in the content editing interface.
00069         case 'description':
00070           return t('Substitutes a custom string for the string "foo" in the text.');
00071
00072         // We don't need the "prepare" operation for this filter, but it's required
00073         // to at least return the input text as-is.
00074         case 'prepare':
00075           return $text;
00076
00077         // The actual filtering is performed here. The supplied text should be
00078         // returned, once any necessary substitutions have taken place.
00079         case 'process':
00080           return str_replace('foo', variable_get("filter_example_foo_$format", 'bar'), $text);
00081
00082         // Since we allow the administrator to define the string that gets
00083         // substituted when "foo" is encountered, we need to provide an
00084         // interface for this customization. Note that the value of $format
00085         // needs to be provided as part of the form name, so that different
00086         // customization can be done for this filter in each of the different
00087         // input formats that may use it.
00088         case 'settings':
00089           $form['filter_example'] = array(
00090             '#type' => 'fieldset',
00091             '#title' => t('Foo filter'),
00092             '#collapsible' => TRUE,
00093             '#collapsed' => TRUE,
00094           );
00095           $form['filter_example']["filter_example_foo_$format"] = array(
00096             '#type' => 'textfield',
00097             '#title' => t('Substitution string'),
00098             '#default_value' => variable_get("filter_example_foo_$format", 'bar'),
00099             '#description' => t('The string to substitute for "foo" everywhere in the text.')
00100           );
00101           return $form;
00102       }
00103       break;
00104
00105     // Next is our "time tag" filter.
00106     case 1:
00107
00108       switch ($op) {
00109         // This description is shown in the administrative interface, unlike the
00110         // filter tips which are shown in the content editing interface.
00111         case 'description':
00112           return t('Inserts the current time in the place of a &lt;time /&gt; tags.');
00113
00114         // Since this filter will return a different result on each page load, we
00115         // need to return TRUE for "no cache" to ensure that the filter is run
00116         // every time the text is requested.
00117         case 'no cache':
00118           return TRUE;
00119
00120         // This filter is a little trickier to implement than the previous one.
00121         // Since the input involves special HTML characters (< and >) we have to
00122         // run the filter before HTML is escaped/stripped by other filters. But
00123         // we want to use HTML in our result as well, and so if we run this filter
00124         // first our replacement string could be escaped or stripped. The solution
00125         // is to use the "prepare" operation to escape the special characters, and
00126         // to later replace our escaped version in the "process" step.
00127         //
00128         // We'll use the bytes 0xFE and 0xFF to replace < and > here. These bytes
00129         // are not valid in UTF-8 data and thus unlikely to cause problems.
00130         case 'prepare':
00131           return preg_replace('!<time ?/>!', '\xFEtime /\xFF', $text);
00132
00133         // Now, in the "process" step, we'll search for our escaped time tags and
00134         // to the real filtering.
00135         case 'process':
00136           return str_replace('\xFEtime /\xFF', '<em>'. format_date(time()) .'</em>', $text);
00137       }
00138       break;
00139   }
00140 }
00141
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/form.inc Source File

includes

form.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: form.inc,v 1.265.2.4 2008/02/11 14:45:57 goba Exp $
00003
00069 function drupal_get_form($form_id) {
00070   $form_state = array('storage' => NULL, 'submitted' => FALSE);
00071
00072   $args = func_get_args();
00073   $cacheable = FALSE;
00074
00075   if (isset($_SESSION['batch_form_state'])) {
00076     // We've been redirected here after a batch processing : the form has
00077     // already been processed, so we grab the post-process $form_state value
00078     // and move on to form display. See _batch_finished() function.
00079     $form_state = $_SESSION['batch_form_state'];
00080     unset($_SESSION['batch_form_state']);
00081   }
00082   else {
00083     // If the incoming $_POST contains a form_build_id, we'll check the
00084     // cache for a copy of the form in question. If it's there, we don't
00085     // have to rebuild the form to proceed. In addition, if there is stored
00086     // form_state data from a previous step, we'll retrieve it so it can
00087     // be passed on to the form processing code.
00088     if (isset($_POST['form_id']) && $_POST['form_id'] == $form_id && !empty($_POST['form_build_id'])) {
00089       $form = form_get_cache($_POST['form_build_id'], $form_state);
00090     }
00091
00092     // If the previous bit of code didn't result in a populated $form
00093     // object, we're hitting the form for the first time and we need
00094     // to build it from scratch.
00095     if (!isset($form)) {
00096       $form_state['post'] = $_POST;
00097       // Use a copy of the function's arguments for manipulation
00098       $args_temp = $args;
00099       $args_temp[0] = &$form_state;
00100       array_unshift($args_temp, $form_id);
00101
00102       $form = call_user_func_array('drupal_retrieve_form', $args_temp);
00103       $form_build_id = 'form-'. md5(mt_rand());
00104       $form['#build_id'] = $form_build_id;
00105       drupal_prepare_form($form_id, $form, $form_state);
00106       // Store a copy of the unprocessed form for caching and indicate that it
00107       // is cacheable if #cache will be set.
00108       $original_form = $form;
00109       $cacheable = TRUE;
00110       unset($form_state['post']);
00111     }
00112     $form['#post'] = $_POST;
00113
00114     // Now that we know we have a form, we'll process it (validating,
00115     // submitting, and handling the results returned by its submission
00116     // handlers. Submit handlers accumulate data in the form_state by
00117     // altering the $form_state variable, which is passed into them by
00118     // reference.
00119     drupal_process_form($form_id, $form, $form_state);
00120     if ($cacheable && !empty($form['#cache'])) {
00121       // Caching is done past drupal_process_form so #process callbacks can
00122       // set #cache. By not sending the form state, we avoid storing
00123       // $form_state['storage'].
00124       form_set_cache($form_build_id, $original_form, NULL);
00125     }
00126   }
00127
00128   // Most simple, single-step forms will be finished by this point --
00129   // drupal_process_form() usually redirects to another page (or to
00130   // a 'fresh' copy of the form) once processing is complete. If one
00131   // of the form's handlers has set $form_state['redirect'] to FALSE,
00132   // the form will simply be re-rendered with the values still in its
00133   // fields.
00134   //
00135   // If $form_state['storage'] or $form_state['rebuild'] have been
00136   // set by any submit or validate handlers, however, we know that
00137   // we're in a complex multi-part process of some sort and the form's
00138   // workflow is NOT complete. We need to construct a fresh copy of
00139   // the form, passing in the latest $form_state in addition to any
00140   // other variables passed into drupal_get_form().
00141
00142   if (!empty($form_state['rebuild']) || !empty($form_state['storage'])) {
00143     $form = drupal_rebuild_form($form_id, $form_state, $args);
00144   }
00145
00146   // If we haven't redirected to a new location by now, we want to
00147   // render whatever form array is currently in hand.
00148   return drupal_render_form($form_id, $form);
00149 }
00150
00188 function drupal_rebuild_form($form_id, &$form_state, $args, $form_build_id = NULL) {
00189   // Remove the first argument. This is $form_id.when called from
00190   // drupal_get_form and the original $form_state when called from some AHAH
00191   // callback. Neither is needed. After that, put in the current state.
00192   $args[0] = &$form_state;
00193   // And the form_id.
00194   array_unshift($args, $form_id);
00195   $form = call_user_func_array('drupal_retrieve_form', $args);
00196
00197   if (!isset($form_build_id)) {
00198     // We need a new build_id for the new version of the form.
00199     $form_build_id = 'form-'. md5(mt_rand());
00200   }
00201   $form['#build_id'] = $form_build_id;
00202   drupal_prepare_form($form_id, $form, $form_state);
00203
00204   // Now, we cache the form structure so it can be retrieved later for
00205   // validation. If $form_state['storage'] is populated, we'll also cache
00206   // it so that it can be used to resume complex multi-step processes.
00207   form_set_cache($form_build_id, $form, $form_state);
00208
00209   // Clear out all post data, as we don't want the previous step's
00210   // data to pollute this one and trigger validate/submit handling,
00211   // then process the form for rendering.
00212   $_POST = array();
00213   $form['#post'] = array();
00214   drupal_process_form($form_id, $form, $form_state);
00215   return $form;
00216 }
00217
00221 function form_get_cache($form_build_id, &$form_state) {
00222   if ($cached = cache_get('form_'. $form_build_id, 'cache_form')) {
00223     $form = $cached->data;
00224     if ($cached = cache_get('storage_'. $form_build_id, 'cache_form')) {
00225       $form_state['storage'] = $cached->data;
00226     }
00227     return $form;
00228   }
00229 }
00230
00234 function form_set_cache($form_build_id, $form, $form_state) {
00235   $expire = max(ini_get('session.cookie_lifetime'), 86400);
00236
00237   cache_set('form_'. $form_build_id, $form, 'cache_form', $expire);
00238   if (!empty($form_state['storage'])) {
00239     cache_set('storage_'. $form_build_id, $form_state['storage'], 'cache_form', $expire);
00240   }
00241 }
00242
00285 function drupal_execute($form_id, &$form_state) {
00286   $args = func_get_args();
00287   $form = call_user_func_array('drupal_retrieve_form', $args);
00288   $form['#post'] = $form_state['values'];
00289   drupal_prepare_form($form_id, $form, $form_state);
00290   drupal_process_form($form_id, $form, $form_state);
00291 }
00292
00312 function drupal_retrieve_form($form_id, &$form_state) {
00313   static $forms;
00314
00315   // We save two copies of the incoming arguments: one for modules to use
00316   // when mapping form ids to constructor functions, and another to pass to
00317   // the constructor function itself. We shift out the first argument -- the
00318   // $form_id itself -- from the list to pass into the constructor function,
00319   // since it's already known.
00320   $args = func_get_args();
00321   $saved_args = $args;
00322   array_shift($args);
00323   if (isset($form_state)) {
00324     array_shift($args);
00325   }
00326
00327   // We first check to see if there's a function named after the $form_id.
00328   // If there is, we simply pass the arguments on to it to get the form.
00329   if (!function_exists($form_id)) {
00330     // In cases where many form_ids need to share a central constructor function,
00331     // such as the node editing form, modules can implement hook_forms(). It
00332     // maps one or more form_ids to the correct constructor functions.
00333     //
00334     // We cache the results of that hook to save time, but that only works
00335     // for modules that know all their form_ids in advance. (A module that
00336     // adds a small 'rate this comment' form to each comment in a list
00337     // would need a unique form_id for each one, for example.)
00338     //
00339     // So, we call the hook if $forms isn't yet populated, OR if it doesn't
00340     // yet have an entry for the requested form_id.
00341     if (!isset($forms) || !isset($forms[$form_id])) {
00342       $forms = module_invoke_all('forms', $form_id, $args);
00343     }
00344     $form_definition = $forms[$form_id];
00345     if (isset($form_definition['callback arguments'])) {
00346       $args = array_merge($form_definition['callback arguments'], $args);
00347     }
00348     if (isset($form_definition['callback'])) {
00349       $callback = $form_definition['callback'];
00350     }
00351   }
00352
00353   array_unshift($args, NULL);
00354   $args[0] = &$form_state;
00355
00356   // If $callback was returned by a hook_forms() implementation, call it.
00357   // Otherwise, call the function named after the form id.
00358   $form = call_user_func_array(isset($callback) ? $callback : $form_id, $args);
00359
00360   // We store the original function arguments, rather than the final $arg
00361   // value, so that form_alter functions can see what was originally
00362   // passed to drupal_retrieve_form(). This allows the contents of #parameters
00363   // to be saved and passed in at a later date to recreate the form.
00364   $form['#parameters'] = $saved_args;
00365   return $form;
00366 }
00367
00383 function drupal_process_form($form_id, &$form, &$form_state) {
00384   $form_state['values'] = array();
00385
00386   $form = form_builder($form_id, $form, $form_state);
00387   // Only process the form if it is programmed or the form_id coming
00388   // from the POST data is set and matches the current form_id.
00389   if ((!empty($form['#programmed'])) || (!empty($form['#post']) && (isset($form['#post']['form_id']) && ($form['#post']['form_id'] == $form_id)))) {
00390     drupal_validate_form($form_id, $form, $form_state);
00391
00392     // form_clean_id() maintains a cache of element IDs it has seen,
00393     // so it can prevent duplicates. We want to be sure we reset that
00394     // cache when a form is processed, so scenerios that result in
00395     // the form being built behind the scenes and again for the
00396     // browser don't increment all the element IDs needlessly.
00397     form_clean_id(NULL, TRUE);
00398
00399     if ((!empty($form_state['submitted'])) && !form_get_errors() && empty($form_state['rebuild'])) {
00400       $form_state['redirect'] = NULL;
00401       form_execute_handlers('submit', $form, $form_state);
00402
00403       // We'll clear out the cached copies of the form and its stored data
00404       // here, as we've finished with them. The in-memory copies are still
00405       // here, though.
00406       if (variable_get('cache', CACHE_DISABLED) == CACHE_DISABLED && !empty($form_state['values']['form_build_id'])) {
00407         cache_clear_all('form_'. $form_state['values']['form_build_id'], 'cache_form');
00408         cache_clear_all('storage_'. $form_state['values']['form_build_id'], 'cache_form');
00409       }
00410
00411       // If batches were set in the submit handlers, we process them now,
00412       // possibly ending execution. We make sure we do not react to the batch
00413       // that is already being processed (if a batch operation performs a
00414       // drupal_execute).
00415       if ($batch =& batch_get() && !isset($batch['current_set'])) {
00416         // The batch uses its own copies of $form and $form_state for
00417         // late execution of submit handers and post-batch redirection.
00418         $batch['form'] = $form;
00419         $batch['form_state'] = $form_state;
00420         $batch['progressive'] = !$form['#programmed'];
00421         batch_process();
00422         // Execution continues only for programmatic forms.
00423         // For 'regular' forms, we get redirected to the batch processing
00424         // page. Form redirection will be handled in _batch_finished(),
00425         // after the batch is processed.
00426       }
00427
00428       // If no submit handlers have populated the $form_state['storage']
00429       // bundle, and the $form_state['rebuild'] flag has not been set,
00430       // we're finished and should redirect to a new destination page
00431       // if one has been set (and a fresh, unpopulated copy of the form
00432       // if one hasn't). If the form was called by drupal_execute(),
00433       // however, we'll skip this and let the calling function examine
00434       // the resulting $form_state bundle itself.
00435       if (!$form['#programmed'] && empty($form_state['rebuild']) && empty($form_state['storage'])) {
00436         drupal_redirect_form($form, $form_state['redirect']);
00437       }
00438     }
00439   }
00440 }
00441
00456 function drupal_prepare_form($form_id, &$form, &$form_state) {
00457   global $user;
00458
00459   $form['#type'] = 'form';
00460   $form['#programmed'] = isset($form['#post']);
00461
00462   if (isset($form['#build_id'])) {
00463     $form['form_build_id'] = array(
00464       '#type' => 'hidden',
00465       '#value' => $form['#build_id'],
00466       '#id' => $form['#build_id'],
00467       '#name' => 'form_build_id',
00468     );
00469   }
00470
00471   // Add a token, based on either #token or form_id, to any form displayed to
00472   // authenticated users. This ensures that any submitted form was actually
00473   // requested previously by the user and protects against cross site request
00474   // forgeries.
00475   if (isset($form['#token'])) {
00476     if ($form['#token'] === FALSE || $user->uid == 0 || $form['#programmed']) {
00477       unset($form['#token']);
00478     }
00479     else {
00480       $form['form_token'] = array('#type' => 'token', '#default_value' => drupal_get_token($form['#token']));
00481     }
00482   }
00483   else if (isset($user->uid) && $user->uid && !$form['#programmed']) {
00484     $form['#token'] = $form_id;
00485     $form['form_token'] = array(
00486       '#id' => form_clean_id('edit-'. $form_id .'-form-token'),
00487       '#type' => 'token',
00488       '#default_value' => drupal_get_token($form['#token']),
00489     );
00490   }
00491
00492   if (isset($form_id)) {
00493     $form['form_id'] = array(
00494       '#type' => 'hidden',
00495       '#value' => $form_id,
00496       '#id' => form_clean_id("edit-$form_id"),
00497     );
00498   }
00499   if (!isset($form['#id'])) {
00500     $form['#id'] = form_clean_id($form_id);
00501   }
00502
00503   $form += _element_info('form');
00504
00505   if (!isset($form['#validate'])) {
00506     if (function_exists($form_id .'_validate')) {
00507       $form['#validate'] = array($form_id .'_validate');
00508     }
00509   }
00510
00511   if (!isset($form['#submit'])) {
00512     if (function_exists($form_id .'_submit')) {
00513       // We set submit here so that it can be altered.
00514       $form['#submit'] = array($form_id .'_submit');
00515     }
00516   }
00517
00518   // Normally, we would call drupal_alter($form_id, $form, $form_state).
00519   // However, drupal_alter() normally supports just one byref parameter. Using
00520   // the __drupal_alter_by_ref key, we can store any additional parameters
00521   // that need to be altered, and they'll be split out into additional params
00522   // for the hook_form_alter() implementations.
00523   // @todo: Remove this in Drupal 7.
00524   $data = &$form;
00525   $data['__drupal_alter_by_ref'] = array(&$form_state);
00526   drupal_alter('form_'. $form_id, $data);
00527
00528   // __drupal_alter_by_ref is unset in the drupal_alter() function, we need
00529   // to repopulate it to ensure both calls get the data.
00530   $data['__drupal_alter_by_ref'] = array(&$form_state);
00531   drupal_alter('form', $data, $form_id);
00532 }
00533
00534
00555 function drupal_validate_form($form_id, $form, &$form_state) {
00556   static $validated_forms = array();
00557
00558   if (isset($validated_forms[$form_id])) {
00559     return;
00560   }
00561
00562   // If the session token was set by drupal_prepare_form(), ensure that it
00563   // matches the current user's session.
00564   if (isset($form['#token'])) {
00565     if (!drupal_valid_token($form_state['values']['form_token'], $form['#token'])) {
00566       // Setting this error will cause the form to fail validation.
00567       form_set_error('form_token', t('Validation error, please try again. If this error persists, please contact the site administrator.'));
00568     }
00569   }
00570
00571   _form_validate($form, $form_state, $form_id);
00572   $validated_forms[$form_id] = TRUE;
00573 }
00574
00587 function drupal_render_form($form_id, &$form) {
00588   // Don't override #theme if someone already set it.
00589   if (!isset($form['#theme'])) {
00590     init_theme();
00591     $registry = theme_get_registry();
00592     if (isset($registry[$form_id])) {
00593       $form['#theme'] = $form_id;
00594     }
00595   }
00596
00597   $output = drupal_render($form);
00598   return $output;
00599 }
00600
00610 function drupal_redirect_form($form, $redirect = NULL) {
00611   $goto = NULL;
00612   if (isset($redirect)) {
00613     $goto = $redirect;
00614   }
00615   if ($goto !== FALSE && isset($form['#redirect'])) {
00616     $goto = $form['#redirect'];
00617   }
00618   if (!isset($goto) || ($goto !== FALSE)) {
00619     if (isset($goto)) {
00620       if (is_array($goto)) {
00621         call_user_func_array('drupal_goto', $goto);
00622       }
00623       else {
00624         drupal_goto($goto);
00625       }
00626     }
00627     drupal_goto($_GET['q']);
00628   }
00629 }
00630
00652 function _form_validate($elements, &$form_state, $form_id = NULL) {
00653   static $complete_form;
00654
00655   // Also used in the installer, pre-database setup.
00656   $t = get_t();
00657
00658   // Recurse through all children.
00659   foreach (element_children($elements) as $key) {
00660     if (isset($elements[$key]) && $elements[$key]) {
00661       _form_validate($elements[$key], $form_state);
00662     }
00663   }
00664   // Validate the current input.
00665   if (!isset($elements['#validated']) || !$elements['#validated']) {
00666     if (isset($elements['#needs_validation'])) {
00667       // Make sure a value is passed when the field is required.
00668       // A simple call to empty() will not cut it here as some fields, like
00669       // checkboxes, can return a valid value of '0'. Instead, check the
00670       // length if it's a string, and the item count if it's an array.
00671       if ($elements['#required'] && (!count($elements['#value']) || (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0))) {
00672         form_error($elements, $t('!name field is required.', array('!name' => $elements['#title'])));
00673       }
00674
00675       // Verify that the value is not longer than #maxlength.
00676       if (isset($elements['#maxlength']) && drupal_strlen($elements['#value']) > $elements['#maxlength']) {
00677         form_error($elements, $t('!name cannot be longer than %max characters but is currently %length characters long.', array('!name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'], '%max' => $elements['#maxlength'], '%length' => drupal_strlen($elements['#value']))));
00678       }
00679
00680       if (isset($elements['#options']) && isset($elements['#value'])) {
00681         if ($elements['#type'] == 'select') {
00682           $options = form_options_flatten($elements['#options']);
00683         }
00684         else {
00685           $options = $elements['#options'];
00686         }
00687         if (is_array($elements['#value'])) {
00688           $value = $elements['#type'] == 'checkboxes' ? array_keys(array_filter($elements['#value'])) : $elements['#value'];
00689           foreach ($value as $v) {
00690             if (!isset($options[$v])) {
00691               form_error($elements, $t('An illegal choice has been detected. Please contact the site administrator.'));
00692               watchdog('form', 'Illegal choice %choice in !name element.', array('%choice' => $v, '!name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']), WATCHDOG_ERROR);
00693             }
00694           }
00695         }
00696         elseif (!isset($options[$elements['#value']])) {
00697           form_error($elements, $t('An illegal choice has been detected. Please contact the site administrator.'));
00698           watchdog('form', 'Illegal choice %choice in %name element.', array('%choice' => $elements['#value'], '%name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']), WATCHDOG_ERROR);
00699         }
00700       }
00701     }
00702
00703     // Call user-defined form level validators and store a copy of the full
00704     // form so that element-specific validators can examine the entire structure
00705     // if necessary.
00706     if (isset($form_id)) {
00707       form_execute_handlers('validate', $elements, $form_state);
00708       $complete_form = $elements;
00709     }
00710     // Call any element-specific validators. These must act on the element
00711     // #value data.
00712     elseif (isset($elements['#element_validate'])) {
00713       foreach ($elements['#element_validate'] as $function) {
00714         if (function_exists($function))  {
00715           $function($elements, $form_state, $complete_form);
00716         }
00717       }
00718     }
00719     $elements['#validated'] = TRUE;
00720   }
00721 }
00722
00738 function form_execute_handlers($type, &$form, &$form_state) {
00739   $return = FALSE;
00740   if (isset($form_state[$type .'_handlers'])) {
00741     $handlers = $form_state[$type .'_handlers'];
00742   }
00743   elseif (isset($form['#'. $type])) {
00744     $handlers = $form['#'. $type];
00745   }
00746   else {
00747     $handlers = array();
00748   }
00749
00750   foreach ($handlers as $function) {
00751     if (function_exists($function))  {
00752       if ($type == 'submit' && ($batch =& batch_get())) {
00753         // Some previous _submit handler has set a batch. We store the call
00754         // in a special 'control' batch set, for execution at the correct
00755         // time during the batch processing workflow.
00756         $batch['sets'][] = array('form_submit' => $function);
00757       }
00758       else {
00759         $function($form, $form_state);
00760       }
00761       $return = TRUE;
00762     }
00763   }
00764   return $return;
00765 }
00766
00781 function form_set_error($name = NULL, $message = '') {
00782   static $form = array();
00783   if (isset($name) && !isset($form[$name])) {
00784     $form[$name] = $message;
00785     if ($message) {
00786       drupal_set_message($message, 'error');
00787     }
00788   }
00789   return $form;
00790 }
00791
00795 function form_get_errors() {
00796   $form = form_set_error();
00797   if (!empty($form)) {
00798     return $form;
00799   }
00800 }
00801
00805 function form_get_error($element) {
00806   $form = form_set_error();
00807   $key = $element['#parents'][0];
00808   if (isset($form[$key])) {
00809     return $form[$key];
00810   }
00811   $key = implode('][', $element['#parents']);
00812   if (isset($form[$key])) {
00813     return $form[$key];
00814   }
00815 }
00816
00820 function form_error(&$element, $message = '') {
00821   form_set_error(implode('][', $element['#parents']), $message);
00822 }
00823
00840 function form_builder($form_id, $form, &$form_state) {
00841   static $complete_form, $cache;
00842
00843   // Initialize as unprocessed.
00844   $form['#processed'] = FALSE;
00845
00846   // Use element defaults.
00847   if ((!empty($form['#type'])) && ($info = _element_info($form['#type']))) {
00848     // Overlay $info onto $form, retaining preexisting keys in $form.
00849     $form += $info;
00850   }
00851
00852   if (isset($form['#type']) && $form['#type'] == 'form') {
00853     $cache = NULL;
00854     $complete_form = $form;
00855     if (!empty($form['#programmed'])) {
00856       $form_state['submitted'] = TRUE;
00857     }
00858   }
00859
00860   if (isset($form['#input']) && $form['#input']) {
00861     _form_builder_handle_input_element($form_id, $form, $form_state, $complete_form);
00862   }
00863   $form['#defaults_loaded'] = TRUE;
00864
00865   // We start off assuming all form elements are in the correct order.
00866   $form['#sorted'] = TRUE;
00867
00868   // Recurse through all child elements.
00869   $count = 0;
00870   foreach (element_children($form) as $key) {
00871     $form[$key]['#post'] = $form['#post'];
00872     $form[$key]['#programmed'] = $form['#programmed'];
00873     // Don't squash an existing tree value.
00874     if (!isset($form[$key]['#tree'])) {
00875       $form[$key]['#tree'] = $form['#tree'];
00876     }
00877
00878     // Deny access to child elements if parent is denied.
00879     if (isset($form['#access']) && !$form['#access']) {
00880       $form[$key]['#access'] = FALSE;
00881     }
00882
00883     // Don't squash existing parents value.
00884     if (!isset($form[$key]['#parents'])) {
00885       // Check to see if a tree of child elements is present. If so,
00886       // continue down the tree if required.
00887       $form[$key]['#parents'] = $form[$key]['#tree'] && $form['#tree'] ? array_merge($form['#parents'], array($key)) : array($key);
00888       $array_parents = isset($form['#array_parents']) ? $form['#array_parents'] : array();
00889       $array_parents[] = $key;
00890       $form[$key]['#array_parents'] = $array_parents;
00891     }
00892
00893     // Assign a decimal placeholder weight to preserve original array order.
00894     if (!isset($form[$key]['#weight'])) {
00895       $form[$key]['#weight'] = $count/1000;
00896     }
00897     else {
00898       // If one of the child elements has a weight then we will need to sort
00899       // later.
00900       unset($form['#sorted']);
00901     }
00902     $form[$key] = form_builder($form_id, $form[$key], $form_state);
00903     $count++;
00904   }
00905
00906   // The #after_build flag allows any piece of a form to be altered
00907   // after normal input parsing has been completed.
00908   if (isset($form['#after_build']) && !isset($form['#after_build_done'])) {
00909     foreach ($form['#after_build'] as $function) {
00910       $form = $function($form, $form_state);
00911       $form['#after_build_done'] = TRUE;
00912     }
00913   }
00914
00915   // Now that we've processed everything, we can go back to handle the funky
00916   // Internet Explorer button-click scenario.
00917   _form_builder_ie_cleanup($form, $form_state);
00918
00919   // We shoud keep the buttons array until the IE clean up function
00920   // has recognized the submit button so the form has been marked
00921   // as submitted. If we already know which button was submitted,
00922   // we don't need the array.
00923   if (!empty($form_state['submitted'])) {
00924     unset($form_state['buttons']);
00925   }
00926
00927   // If some callback set #cache, we need to flip a static flag so later it
00928   // can be found.
00929   if (isset($form['#cache'])) {
00930     $cache = $form['#cache'];
00931   }
00932   // We are on the top form, we can copy back #cache if it's set.
00933   if (isset($form['#type']) && $form['#type'] == 'form' && isset($cache)) {
00934     $form['#cache'] = TRUE;
00935   }
00936   return $form;
00937 }
00938
00944 function _form_builder_handle_input_element($form_id, &$form, &$form_state, $complete_form) {
00945   if (!isset($form['#name'])) {
00946     $name = array_shift($form['#parents']);
00947     $form['#name'] = $name;
00948     if ($form['#type'] == 'file') {
00949       // To make it easier to handle $_FILES in file.inc, we place all
00950       // file fields in the 'files' array. Also, we do not support
00951       // nested file names.
00952       $form['#name'] = 'files['. $form['#name'] .']';
00953     }
00954     elseif (count($form['#parents'])) {
00955       $form['#name'] .= '['. implode('][', $form['#parents']) .']';
00956     }
00957     array_unshift($form['#parents'], $name);
00958   }
00959   if (!isset($form['#id'])) {
00960     $form['#id'] = form_clean_id('edit-'. implode('-', $form['#parents']));
00961   }
00962
00963   unset($edit);
00964   if (!empty($form['#disabled'])) {
00965     $form['#attributes']['disabled'] = 'disabled';
00966   }
00967
00968   if (!isset($form['#value']) && !array_key_exists('#value', $form)) {
00969     $function = !empty($form['#value_callback']) ? $form['#value_callback'] : 'form_type_'. $form['#type'] .'_value';
00970     if (($form['#programmed']) || ((!isset($form['#access']) || $form['#access']) && isset($form['#post']) && (isset($form['#post']['form_id']) && $form['#post']['form_id'] == $form_id))) {
00971       $edit = $form['#post'];
00972       foreach ($form['#parents'] as $parent) {
00973         $edit = isset($edit[$parent]) ? $edit[$parent] : NULL;
00974       }
00975       if (!$form['#programmed'] || isset($edit)) {
00976         // Call #type_value to set the form value;
00977         if (function_exists($function)) {
00978           $form['#value'] = $function($form, $edit);
00979         }
00980         if (!isset($form['#value']) && isset($edit)) {
00981           $form['#value'] = $edit;
00982         }
00983       }
00984       // Mark all posted values for validation.
00985       if (isset($form['#value']) || (isset($form['#required']) && $form['#required'])) {
00986         $form['#needs_validation'] = TRUE;
00987       }
00988     }
00989     // Load defaults.
00990     if (!isset($form['#value'])) {
00991       // Call #type_value without a second argument to request default_value handling.
00992       if (function_exists($function)) {
00993         $form['#value'] = $function($form);
00994       }
00995       // Final catch. If we haven't set a value yet, use the explicit default value.
00996       // Avoid image buttons (which come with garbage value), so we only get value
00997       // for the button actually clicked.
00998       if (!isset($form['#value']) && empty($form['#has_garbage_value'])) {
00999         $form['#value'] = isset($form['#default_value']) ? $form['#default_value'] : '';
01000       }
01001     }
01002   }
01003
01004   // Determine which button (if any) was clicked to submit the form.
01005   // We compare the incoming values with the buttons defined in the form,
01006   // and flag the one that matches. We have to do some funky tricks to
01007   // deal with Internet Explorer's handling of single-button forms, though.
01008   if (!empty($form['#post']) && isset($form['#executes_submit_callback'])) {
01009     // First, accumulate a collection of buttons, divided into two bins:
01010     // those that execute full submit callbacks and those that only validate.
01011     $button_type = $form['#executes_submit_callback'] ? 'submit' : 'button';
01012     $form_state['buttons'][$button_type][] = $form;
01013
01014     if (_form_button_was_clicked($form)) {
01015       $form_state['submitted'] = $form_state['submitted'] || $form['#executes_submit_callback'];
01016
01017       // In most cases, we want to use form_set_value() to manipulate
01018       // the global variables. In this special case, we want to make sure that
01019       // the value of this element is listed in $form_variables under 'op'.
01020       $form_state['values'][$form['#name']] = $form['#value'];
01021       $form_state['clicked_button'] = $form;
01022
01023       if (isset($form['#validate'])) {
01024         $form_state['validate_handlers'] = $form['#validate'];
01025       }
01026       if (isset($form['#submit'])) {
01027         $form_state['submit_handlers'] = $form['#submit'];
01028       }
01029     }
01030   }
01031   // Allow for elements to expand to multiple elements, e.g., radios,
01032   // checkboxes and files.
01033   if (isset($form['#process']) && !$form['#processed']) {
01034     foreach ($form['#process'] as $process) {
01035       if (function_exists($process)) {
01036         $form = $process($form, isset($edit) ? $edit : NULL, $form_state, $complete_form);
01037       }
01038     }
01039     $form['#processed'] = TRUE;
01040   }
01041   form_set_value($form, $form['#value'], $form_state);
01042 }
01043
01053 function _form_button_was_clicked($form) {
01054   // First detect normal 'vanilla' button clicks. Traditionally, all
01055   // standard buttons on a form share the same name (usually 'op'),
01056   // and the specific return value is used to determine which was
01057   // clicked. This ONLY works as long as $form['#name'] puts the
01058   // value at the top level of the tree of $_POST data.
01059   if (isset($form['#post'][$form['#name']]) && $form['#post'][$form['#name']] == $form['#value']) {
01060     return TRUE;
01061   }
01062   // When image buttons are clicked, browsers do NOT pass the form element
01063   // value in $_POST. Instead they pass an integer representing the
01064   // coordinates of the click on the button image. This means that image
01065   // buttons MUST have unique $form['#name'] values, but the details of
01066   // their $_POST data should be ignored.
01067   elseif (!empty($form['#has_garbage_value']) && isset($form['#value']) && $form['#value'] !== '') {
01068     return TRUE;
01069   }
01070   return FALSE;
01071 }
01072
01081 function _form_builder_ie_cleanup($form, &$form_state) {
01082   // Quick check to make sure we're always looking at the full form
01083   // and not a sub-element.
01084   if (!empty($form['#type']) && $form['#type'] == 'form') {
01085     // If we haven't recognized a submission yet, and there's a single
01086     // submit button, we know that we've hit the right conditions. Grab
01087     // the first one and treat it as the clicked button.
01088     if (empty($form_state['submitted']) && !empty($form_state['buttons']['submit']) && empty($form_state['buttons']['button'])) {
01089       $button = $form_state['buttons']['submit'][0];
01090
01091       // Set up all the $form_state information that would have been
01092       // populated had the button been recognized earlier.
01093       $form_state['submitted'] = TRUE;
01094       $form_state['submit_handlers'] = empty($button['#submit']) ? NULL : $button['#submit'];
01095       $form_state['validate_handlers'] = empty($button['#validate']) ? NULL : $button['#validate'];
01096       $form_state['values'][$button['#name']] = $button['#value'];
01097       $form_state['clicked_button'] = $button;
01098     }
01099   }
01100 }
01101
01114 function form_type_image_button_value($form, $edit = FALSE) {
01115   if ($edit !== FALSE) {
01116     if (!empty($edit)) {
01117       // If we're dealing with Mozilla or Opera, we're lucky. It will
01118       // return a proper value, and we can get on with things.
01119       return $form['#return_value'];
01120     }
01121     else {
01122       // Unfortunately, in IE we never get back a proper value for THIS
01123       // form element. Instead, we get back two split values: one for the
01124       // X and one for the Y coordinates on which the user clicked the
01125       // button. We'll find this element in the #post data, and search
01126       // in the same spot for its name, with '_x'.
01127       $post = $form['#post'];
01128       foreach (split('\[', $form['#name']) as $element_name) {
01129         // chop off the ] that may exist.
01130         if (substr($element_name, -1) == ']') {
01131           $element_name = substr($element_name, 0, -1);
01132         }
01133
01134         if (!isset($post[$element_name])) {
01135           if (isset($post[$element_name .'_x'])) {
01136             return $form['#return_value'];
01137           }
01138           return NULL;
01139         }
01140         $post = $post[$element_name];
01141       }
01142       return $form['#return_value'];
01143     }
01144   }
01145 }
01146
01159 function form_type_checkbox_value($form, $edit = FALSE) {
01160   if ($edit !== FALSE) {
01161     return !empty($edit) ? $form['#return_value'] : 0;
01162   }
01163 }
01164
01177 function form_type_checkboxes_value($form, $edit = FALSE) {
01178   if ($edit === FALSE) {
01179     $value = array();
01180     $form += array('#default_value' => array());
01181     foreach ($form['#default_value'] as $key) {
01182       $value[$key] = 1;
01183     }
01184     return $value;
01185   }
01186   elseif (!isset($edit)) {
01187     return array();
01188   }
01189 }
01190
01204 function form_type_password_confirm_value($form, $edit = FALSE) {
01205   if ($edit === FALSE) {
01206     $form += array('#default_value' => array());
01207     return $form['#default_value'] + array('pass1' => '', 'pass2' => '');
01208   }
01209 }
01210
01223 function form_type_select_value($form, $edit = FALSE) {
01224   if ($edit !== FALSE) {
01225     if (isset($form['#multiple']) && $form['#multiple']) {
01226       return (is_array($edit)) ? drupal_map_assoc($edit) : array();
01227     }
01228     else {
01229       return $edit;
01230     }
01231   }
01232 }
01233
01246 function form_type_textfield_value($form, $edit = FALSE) {
01247   if ($edit !== FALSE) {
01248     // Equate $edit to the form value to ensure it's marked for
01249     // validation.
01250     return str_replace(array("\r", "\n"), '', $edit);
01251   }
01252 }
01253
01266 function form_type_token_value($form, $edit = FALSE) {
01267   if ($edit !== FALSE) {
01268     return (string)$edit;
01269   }
01270 }
01271
01285 function form_set_value($form, $value, &$form_state) {
01286   _form_set_value($form_state['values'], $form, $form['#parents'], $value);
01287 }
01288
01296 function _form_set_value(&$form_values, $form, $parents, $value) {
01297   $parent = array_shift($parents);
01298   if (empty($parents)) {
01299     $form_values[$parent] = $value;
01300   }
01301   else {
01302     if (!isset($form_values[$parent])) {
01303       $form_values[$parent] = array();
01304     }
01305     _form_set_value($form_values[$parent], $form, $parents, $value);
01306   }
01307 }
01308
01312 function _element_info($type, $refresh = NULL) {
01313   static $cache;
01314
01315   $basic_defaults = array(
01316     '#description' => NULL,
01317     '#attributes' => array(),
01318     '#required' => FALSE,
01319     '#tree' => FALSE,
01320     '#parents' => array()
01321   );
01322   if (!isset($cache) || $refresh) {
01323     $cache = array();
01324     foreach (module_implements('elements') as $module) {
01325       $elements = module_invoke($module, 'elements');
01326       if (isset($elements) && is_array($elements)) {
01327         $cache = array_merge_recursive($cache, $elements);
01328       }
01329     }
01330     if (sizeof($cache)) {
01331       foreach ($cache as $element_type => $info) {
01332         $cache[$element_type] = array_merge_recursive($basic_defaults, $info);
01333       }
01334     }
01335   }
01336
01337   return $cache[$type];
01338 }
01339
01340 function form_options_flatten($array, $reset = TRUE) {
01341   static $return;
01342
01343   if ($reset) {
01344     $return = array();
01345   }
01346
01347   foreach ($array as $key => $value) {
01348     if (is_object($value)) {
01349       form_options_flatten($value->option, FALSE);
01350     }
01351     else if (is_array($value)) {
01352       form_options_flatten($value, FALSE);
01353     }
01354     else {
01355       $return[$key] = 1;
01356     }
01357   }
01358
01359   return $return;
01360 }
01361
01377 function theme_select($element) {
01378   $select = '';
01379   $size = $element['#size'] ? ' size="'. $element['#size'] .'"' : '';
01380   _form_set_class($element, array('form-select'));
01381   $multiple = $element['#multiple'];
01382   return theme('form_element', $element, '<select name="'. $element['#name'] .''. ($multiple ? '[]' : '') .'"'. ($multiple ? ' multiple="multiple" ' : '') . drupal_attributes($element['#attributes']) .' id="'. $element['#id'] .'" '. $size .'>'. form_select_options($element) .'</select>');
01383 }
01384
01385 function form_select_options($element, $choices = NULL) {
01386   if (!isset($choices)) {
01387     $choices = $element['#options'];
01388   }
01389   // array_key_exists() accommodates the rare event where $element['#value'] is NULL.
01390   // isset() fails in this situation.
01391   $value_valid = isset($element['#value']) || array_key_exists('#value', $element);
01392   $value_is_array = is_array($element['#value']);
01393   $options = '';
01394   foreach ($choices as $key => $choice) {
01395     if (is_array($choice)) {
01396       $options .= '<optgroup label="'. $key .'">';
01397       $options .= form_select_options($element, $choice);
01398       $options .= '</optgroup>';
01399     }
01400     elseif (is_object($choice)) {
01401       $options .= form_select_options($element, $choice->option);
01402     }
01403     else {
01404       $key = (string)$key;
01405       if ($value_valid && (!$value_is_array && (string)$element['#value'] === $key || ($value_is_array && in_array($key, $element['#value'])))) {
01406         $selected = ' selected="selected"';
01407       }
01408       else {
01409         $selected = '';
01410       }
01411       $options .= '<option value="'. check_plain($key) .'"'. $selected .'>'. check_plain($choice) .'</option>';
01412     }
01413   }
01414   return $options;
01415 }
01416
01449 function form_get_options($element, $key) {
01450   $keys = array();
01451   foreach ($element['#options'] as $index => $choice) {
01452     if (is_array($choice)) {
01453       return FALSE;
01454     }
01455     else if (is_object($choice)) {
01456       if (isset($choice->option[$key])) {
01457         $keys[] = $index;
01458       }
01459     }
01460     else if ($index == $key) {
01461       $keys[] = $index;
01462     }
01463   }
01464   return $keys;
01465 }
01466
01478 function theme_fieldset($element) {
01479   if ($element['#collapsible']) {
01480     drupal_add_js('misc/collapse.js');
01481
01482     if (!isset($element['#attributes']['class'])) {
01483       $element['#attributes']['class'] = '';
01484     }
01485
01486     $element['#attributes']['class'] .= ' collapsible';
01487     if ($element['#collapsed']) {
01488       $element['#attributes']['class'] .= ' collapsed';
01489     }
01490   }
01491
01492   return '<fieldset'. drupal_attributes($element['#attributes']) .'>'. ($element['#title'] ? '<legend>'. $element['#title'] .'</legend>' : '') . (isset($element['#description']) && $element['#description'] ? '<div class="description">'. $element['#description'] .'</div>' : '') . (!empty($element['#children']) ? $element['#children'] : '') . $element['#value'] ."</fieldset>\n";
01493 }
01494
01506 function theme_radio($element) {
01507   _form_set_class($element, array('form-radio'));
01508   $output = '<input type="radio" ';
01509   $output .= 'name="'. $element['#name'] .'" ';
01510   $output .= 'value="'. $element['#return_value'] .'" ';
01511   $output .= (check_plain($element['#value']) == $element['#return_value']) ? ' checked="checked" ' : ' ';
01512   $output .= drupal_attributes($element['#attributes']) .' />';
01513   if (!is_null($element['#title'])) {
01514     $output = '<label class="option">'. $output .' '. $element['#title'] .'</label>';
01515   }
01516
01517   unset($element['#title']);
01518   return theme('form_element', $element, $output);
01519 }
01520
01532 function theme_radios($element) {
01533   $class = 'form-radios';
01534   if (isset($element['#attributes']['class'])) {
01535     $class .= ' '. $element['#attributes']['class'];
01536   }
01537   $element['#children'] = '<div class="'. $class .'">'. (!empty($element['#children']) ? $element['#children'] : '') .'</div>';
01538   if ($element['#title'] || $element['#description']) {
01539     unset($element['#id']);
01540     return theme('form_element', $element, $element['#children']);
01541   }
01542   else {
01543     return $element['#children'];
01544   }
01545 }
01546
01558 function theme_password_confirm($element) {
01559   return theme('form_element', $element, $element['#children']);
01560 }
01561
01565 function expand_password_confirm($element) {
01566   $element['pass1'] =  array(
01567     '#type' => 'password',
01568     '#title' => t('Password'),
01569     '#value' => empty($element['#value']) ? NULL : $element['#value']['pass1'],
01570     '#required' => $element['#required'],
01571     '#attributes' => array('class' => 'password-field'),
01572   );
01573   $element['pass2'] =  array(
01574     '#type' => 'password',
01575     '#title' => t('Confirm password'),
01576     '#value' => empty($element['#value']) ? NULL : $element['#value']['pass2'],
01577     '#required' => $element['#required'],
01578     '#attributes' => array('class' => 'password-confirm'),
01579   );
01580   $element['#element_validate'] = array('password_confirm_validate');
01581   $element['#tree'] = TRUE;
01582
01583   if (isset($element['#size'])) {
01584     $element['pass1']['#size'] = $element['pass2']['#size'] = $element['#size'];
01585   }
01586
01587   return $element;
01588 }
01589
01593 function password_confirm_validate($form, &$form_state) {
01594   $pass1 = trim($form['pass1']['#value']);
01595   if (!empty($pass1)) {
01596     $pass2 = trim($form['pass2']['#value']);
01597     if ($pass1 != $pass2) {
01598       form_error($form, t('The specified passwords do not match.'));
01599     }
01600   }
01601   elseif ($form['#required'] && !empty($form['#post'])) {
01602     form_error($form, t('Password field is required.'));
01603   }
01604
01605   // Password field must be converted from a two-element array into a single
01606   // string regardless of validation results.
01607   form_set_value($form['pass1'], NULL, $form_state);
01608   form_set_value($form['pass2'], NULL, $form_state);
01609   form_set_value($form, $pass1, $form_state);
01610
01611   return $form;
01612
01613 }
01614
01626 function theme_date($element) {
01627   return theme('form_element', $element, '<div class="container-inline">'. $element['#children'] .'</div>');
01628 }
01629
01633 function expand_date($element) {
01634   // Default to current date
01635   if (empty($element['#value'])) {
01636     $element['#value'] = array('day' => format_date(time(), 'custom', 'j'),
01637                             'month' => format_date(time(), 'custom', 'n'),
01638                             'year' => format_date(time(), 'custom', 'Y'));
01639   }
01640
01641   $element['#tree'] = TRUE;
01642
01643   // Determine the order of day, month, year in the site's chosen date format.
01644   $format = variable_get('date_format_short', 'm/d/Y - H:i');
01645   $sort = array();
01646   $sort['day'] = max(strpos($format, 'd'), strpos($format, 'j'));
01647   $sort['month'] = max(strpos($format, 'm'), strpos($format, 'M'));
01648   $sort['year'] = strpos($format, 'Y');
01649   asort($sort);
01650   $order = array_keys($sort);
01651
01652   // Output multi-selector for date.
01653   foreach ($order as $type) {
01654     switch ($type) {
01655       case 'day':
01656         $options = drupal_map_assoc(range(1, 31));
01657         break;
01658       case 'month':
01659         $options = drupal_map_assoc(range(1, 12), 'map_month');
01660         break;
01661       case 'year':
01662         $options = drupal_map_assoc(range(1900, 2050));
01663         break;
01664     }
01665     $parents = $element['#parents'];
01666     $parents[] = $type;
01667     $element[$type] = array(
01668       '#type' => 'select',
01669       '#value' => $element['#value'][$type],
01670       '#attributes' => $element['#attributes'],
01671       '#options' => $options,
01672     );
01673   }
01674
01675   return $element;
01676 }
01677
01681 function date_validate($form) {
01682   if (!checkdate($form['#value']['month'], $form['#value']['day'], $form['#value']['year'])) {
01683     form_error($form, t('The specified date is invalid.'));
01684   }
01685 }
01686
01690 function map_month($month) {
01691   return format_date(gmmktime(0, 0, 0, $month, 2, 1970), 'custom', 'M', 0);
01692 }
01693
01697 function weight_value(&$form) {
01698   if (isset($form['#default_value'])) {
01699     $form['#value'] = $form['#default_value'];
01700   }
01701   else {
01702     $form['#value'] = 0;
01703   }
01704 }
01705
01710 function expand_radios($element) {
01711   if (count($element['#options']) > 0) {
01712     foreach ($element['#options'] as $key => $choice) {
01713       if (!isset($element[$key])) {
01714         // Generate the parents as the autogenerator does, so we will have a
01715         // unique id for each radio button.
01716         $parents_for_id = array_merge($element['#parents'], array($key));
01717         $element[$key] = array(
01718           '#type' => 'radio',
01719           '#title' => $choice,
01720           '#return_value' => check_plain($key),
01721           '#default_value' => isset($element['#default_value']) ? $element['#default_value'] : NULL,
01722           '#attributes' => $element['#attributes'],
01723           '#parents' => $element['#parents'],
01724           '#id' => form_clean_id('edit-'. implode('-', $parents_for_id)),
01725         );
01726       }
01727     }
01728   }
01729   return $element;
01730 }
01731
01746 function form_expand_ahah($element) {
01747   static $js_added = array();
01748   // Add a reasonable default event handler if none specified.
01749   if (isset($element['#ahah']['path']) && !isset($element['#ahah']['event'])) {
01750     switch ($element['#type']) {
01751       case 'submit':
01752       case 'button':
01753       case 'image_button':
01754         // Use the mousedown instead of the click event because form
01755         // submission via pressing the enter key triggers a click event on
01756         // submit inputs, inappropriately triggering AHAH behaviors.
01757         $element['#ahah']['event'] = 'mousedown';
01758         // Attach an additional event handler so that AHAH behaviours
01759         // can be triggered still via keyboard input.
01760         $element['#ahah']['keypress'] = TRUE;
01761         break;
01762       case 'password':
01763       case 'textfield':
01764       case 'textarea':
01765         $element['#ahah']['event'] = 'blur';
01766         break;
01767       case 'radio':
01768       case 'checkbox':
01769       case 'select':
01770         $element['#ahah']['event'] = 'change';
01771         break;
01772     }
01773   }
01774
01775   // Adding the same javascript settings twice will cause a recursion error,
01776   // we avoid the problem by checking if the javascript has already been added.
01777   if (isset($element['#ahah']['path']) && isset($element['#ahah']['event']) && !isset($js_added[$element['#id']])) {
01778     drupal_add_js('misc/jquery.form.js');
01779     drupal_add_js('misc/ahah.js');
01780
01781     $ahah_binding = array(
01782       'url'      => url($element['#ahah']['path']),
01783       'event'    => $element['#ahah']['event'],
01784       'keypress' => empty($element['#ahah']['keypress']) ? NULL : $element['#ahah']['keypress'],
01785       'wrapper'  => empty($element['#ahah']['wrapper']) ? NULL : $element['#ahah']['wrapper'],
01786       'selector' => empty($element['#ahah']['selector']) ? '#'. $element['#id'] : $element['#ahah']['selector'],
01787       'effect'   => empty($element['#ahah']['effect']) ? 'none' : $element['#ahah']['effect'],
01788       'method'   => empty($element['#ahah']['method']) ? 'replace' : $element['#ahah']['method'],
01789       'progress' => empty($element['#ahah']['progress']) ? array('type' => 'throbber') : $element['#ahah']['progress'],
01790       'button'   => isset($element['#executes_submit_callback']) ? array($element['#name'] => $element['#value']) : FALSE,
01791     );
01792
01793     // Convert a simple #ahah[progress] type string into an array.
01794     if (is_string($ahah_binding['progress'])) {
01795       $ahah_binding['progress'] = array('type' => $ahah_binding['progress']);
01796     }
01797     // Change progress path to a full url.
01798     if (isset($ahah_binding['progress']['path'])) {
01799       $ahah_binding['progress']['url'] = url($ahah_binding['progress']['path']);
01800     }
01801
01802     // Add progress.js if we're doing a bar display.
01803     if ($ahah_binding['progress']['type'] == 'bar') {
01804       drupal_add_js('misc/progress.js');
01805     }
01806
01807     drupal_add_js(array('ahah' => array($element['#id'] => $ahah_binding)), 'setting');
01808
01809     $js_added[$element['#id']] = TRUE;
01810     $element['#cache'] = TRUE;
01811   }
01812   return $element;
01813 }
01814
01826 function theme_item($element) {
01827   return theme('form_element', $element, $element['#value'] . (!empty($element['#children']) ? $element['#children'] : ''));
01828 }
01829
01841 function theme_checkbox($element) {
01842   _form_set_class($element, array('form-checkbox'));
01843   $checkbox = '<input ';
01844   $checkbox .= 'type="checkbox" ';
01845   $checkbox .= 'name="'. $element['#name'] .'" ';
01846   $checkbox .= 'id="'. $element['#id'] .'" ' ;
01847   $checkbox .= 'value="'. $element['#return_value'] .'" ';
01848   $checkbox .= $element['#value'] ? ' checked="checked" ' : ' ';
01849   $checkbox .= drupal_attributes($element['#attributes']) .' />';
01850
01851   if (!is_null($element['#title'])) {
01852     $checkbox = '<label class="option">'. $checkbox .' '. $element['#title'] .'</label>';
01853   }
01854
01855   unset($element['#title']);
01856   return theme('form_element', $element, $checkbox);
01857 }
01858
01869 function theme_checkboxes($element) {
01870   $class = 'form-checkboxes';
01871   if (isset($element['#attributes']['class'])) {
01872     $class .= ' '. $element['#attributes']['class'];
01873   }
01874   $element['#children'] = '<div class="'. $class .'">'. (!empty($element['#children']) ? $element['#children'] : '') .'</div>';
01875   if ($element['#title'] || $element['#description']) {
01876     unset($element['#id']);
01877     return theme('form_element', $element, $element['#children']);
01878   }
01879   else {
01880     return $element['#children'];
01881   }
01882 }
01883
01884 function expand_checkboxes($element) {
01885   $value = is_array($element['#value']) ? $element['#value'] : array();
01886   $element['#tree'] = TRUE;
01887   if (count($element['#options']) > 0) {
01888     if (!isset($element['#default_value']) || $element['#default_value'] == 0) {
01889       $element['#default_value'] = array();
01890     }
01891     foreach ($element['#options'] as $key => $choice) {
01892       if (!isset($element[$key])) {
01893         $element[$key] = array('#type' => 'checkbox', '#processed' => TRUE, '#title' => $choice, '#return_value' => $key, '#default_value' => isset($value[$key]), '#attributes' => $element['#attributes']);
01894       }
01895     }
01896   }
01897   return $element;
01898 }
01899
01905 function theme_submit($element) {
01906   return theme('button', $element);
01907 }
01908
01914 function theme_button($element) {
01915   // Make sure not to overwrite classes.
01916   if (isset($element['#attributes']['class'])) {
01917     $element['#attributes']['class'] = 'form-'. $element['#button_type'] .' '. $element['#attributes']['class'];
01918   }
01919   else {
01920     $element['#attributes']['class'] = 'form-'. $element['#button_type'];
01921   }
01922
01923   return '<input type="submit" '. (empty($element['#name']) ? '' : 'name="'. $element['#name'] .'" ') .'id="'. $element['#id'] .'" value="'. check_plain($element['#value']) .'" '. drupal_attributes($element['#attributes']) ." />\n";
01924 }
01925
01931 function theme_image_button($element) {
01932   // Make sure not to overwrite classes.
01933   if (isset($element['#attributes']['class'])) {
01934     $element['#attributes']['class'] = 'form-'. $element['#button_type'] .' '. $element['#attributes']['class'];
01935   }
01936   else {
01937     $element['#attributes']['class'] = 'form-'. $element['#button_type'];
01938   }
01939
01940   return '<input type="image" name="'. $element['#name'] .'" '.
01941     (!empty($element['#value']) ? ('value="'. check_plain($element['#value']) .'" ') : '') .
01942     'id="'. $element['#id'] .'" '.
01943     drupal_attributes($element['#attributes']) .
01944     ' src="'. base_path() . $element['#src'] .'" '.
01945     (!empty($element['#title']) ? 'alt="'. check_plain($element['#title']) .'" title="'. check_plain($element['#title']) .'" ' : '' ) .
01946     "/>\n";
01947 }
01948
01960 function theme_hidden($element) {
01961   return '<input type="hidden" name="'. $element['#name'] .'" id="'. $element['#id'] .'" value="'. check_plain($element['#value']) ."\" ". drupal_attributes($element['#attributes']) ." />\n";
01962 }
01963
01969 function theme_token($element) {
01970   return theme('hidden', $element);
01971 }
01972
01984 function theme_textfield($element) {
01985   $size = empty($element['#size']) ? '' : ' size="'. $element['#size'] .'"';
01986   $maxlength = empty($element['#maxlength']) ? '' : ' maxlength="'. $element['#maxlength'] .'"';
01987   $class = array('form-text');
01988   $extra = '';
01989   $output = '';
01990
01991   if ($element['#autocomplete_path']) {
01992     drupal_add_js('misc/autocomplete.js');
01993     $class[] = 'form-autocomplete';
01994     $extra =  '<input class="autocomplete" type="hidden" id="'. $element['#id'] .'-autocomplete" value="'. check_url(url($element['#autocomplete_path'], array('absolute' => TRUE))) .'" disabled="disabled" />';
01995   }
01996   _form_set_class($element, $class);
01997
01998   if (isset($element['#field_prefix'])) {
01999     $output .= '<span class="field-prefix">'. $element['#field_prefix'] .'</span> ';
02000   }
02001
02002   $output .= '<input type="text"'. $maxlength .' name="'. $element['#name'] .'" id="'. $element['#id'] .'"'. $size .' value="'. check_plain($element['#value']) .'"'. drupal_attributes($element['#attributes']) .' />';
02003
02004   if (isset($element['#field_suffix'])) {
02005     $output .= ' <span class="field-suffix">'. $element['#field_suffix'] .'</span>';
02006   }
02007
02008   return theme('form_element', $element, $output) . $extra;
02009 }
02010
02022 function theme_form($element) {
02023   // Anonymous div to satisfy XHTML compliance.
02024   $action = $element['#action'] ? 'action="'. check_url($element['#action']) .'" ' : '';
02025   return '<form '. $action .' accept-charset="UTF-8" method="'. $element['#method'] .'" id="'. $element['#id'] .'"'. drupal_attributes($element['#attributes']) .">\n<div>". $element['#children'] ."\n</div></form>\n";
02026 }
02027
02039 function theme_textarea($element) {
02040   $class = array('form-textarea');
02041
02042   // Add teaser behavior (must come before resizable)
02043   if (!empty($element['#teaser'])) {
02044     drupal_add_js('misc/teaser.js');
02045     // Note: arrays are merged in drupal_get_js().
02046     drupal_add_js(array('teaserCheckbox' => array($element['#id'] => $element['#teaser_checkbox'])), 'setting');
02047     drupal_add_js(array('teaser' => array($element['#id'] => $element['#teaser'])), 'setting');
02048     $class[] = 'teaser';
02049   }
02050
02051   // Add resizable behavior
02052   if ($element['#resizable'] !== FALSE) {
02053     drupal_add_js('misc/textarea.js');
02054     $class[] = 'resizable';
02055   }
02056
02057   _form_set_class($element, $class);
02058   return theme('form_element', $element, '<textarea cols="'. $element['#cols'] .'" rows="'. $element['#rows'] .'" name="'. $element['#name'] .'" id="'. $element['#id'] .'" '. drupal_attributes($element['#attributes']) .'>'. check_plain($element['#value']) .'</textarea>');
02059 }
02060
02075 function theme_markup($element) {
02076   return (isset($element['#value']) ? $element['#value'] : '') . (isset($element['#children']) ? $element['#children'] : '');
02077 }
02078
02090 function theme_password($element) {
02091   $size = $element['#size'] ? ' size="'. $element['#size'] .'" ' : '';
02092   $maxlength = $element['#maxlength'] ? ' maxlength="'. $element['#maxlength'] .'" ' : '';
02093
02094   _form_set_class($element, array('form-text'));
02095   $output = '<input type="password" name="'. $element['#name'] .'" id="'. $element['#id'] .'" '. $maxlength . $size . drupal_attributes($element['#attributes']) .' />';
02096   return theme('form_element', $element, $output);
02097 }
02098
02102 function process_weight($element) {
02103   for ($n = (-1 * $element['#delta']); $n <= $element['#delta']; $n++) {
02104     $weights[$n] = $n;
02105   }
02106   $element['#options'] = $weights;
02107   $element['#type'] = 'select';
02108   $element['#is_weight'] = TRUE;
02109   $element += _element_info('select');
02110   return $element;
02111 }
02112
02134 function theme_file($element) {
02135   _form_set_class($element, array('form-file'));
02136   return theme('form_element', $element, '<input type="file" name="'. $element['#name'] .'"'. ($element['#attributes'] ? ' '. drupal_attributes($element['#attributes']) : '') .' id="'. $element['#id'] .'" size="'. $element['#size'] ."\" />\n");
02137 }
02138
02152 function theme_form_element($element, $value) {
02153   // This is also used in the installer, pre-database setup.
02154   $t = get_t();
02155
02156   $output = '<div class="form-item"';
02157   if (!empty($element['#id'])) {
02158     $output .= ' id="'. $element['#id'] .'-wrapper"';
02159   }
02160   $output .= ">\n";
02161   $required = !empty($element['#required']) ? '<span class="form-required" title="'. $t('This field is required.') .'">*</span>' : '';
02162
02163   if (!empty($element['#title'])) {
02164     $title = $element['#title'];
02165     if (!empty($element['#id'])) {
02166       $output .= ' <label for="'. $element['#id'] .'">'. $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) ."</label>\n";
02167     }
02168     else {
02169       $output .= ' <label>'. $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) ."</label>\n";
02170     }
02171   }
02172
02173   $output .= " $value\n";
02174
02175   if (!empty($element['#description'])) {
02176     $output .= ' <div class="description">'. $element['#description'] ."</div>\n";
02177   }
02178
02179   $output .= "</div>\n";
02180
02181   return $output;
02182 }
02183
02194 function _form_set_class(&$element, $class = array()) {
02195   if ($element['#required']) {
02196     $class[] = 'required';
02197   }
02198   if (form_get_error($element)) {
02199     $class[] = 'error';
02200   }
02201   if (isset($element['#attributes']['class'])) {
02202     $class[] = $element['#attributes']['class'];
02203   }
02204   $element['#attributes']['class'] = implode(' ', $class);
02205 }
02206
02223 function form_clean_id($id = NULL, $flush = FALSE) {
02224   static $seen_ids = array();
02225
02226   if ($flush) {
02227     $seen_ids = array();
02228     return;
02229   }
02230   $id = str_replace(array('][', '_', ' '), '-', $id);
02231
02232   // Ensure IDs are unique. The first occurrence is held but left alone.
02233   // Subsequent occurrences get a number appended to them. This incrementing
02234   // will almost certainly break code that relies on explicit HTML IDs in
02235   // forms that appear more than once on the page, but the alternative is
02236   // outputting duplicate IDs, which would break JS code and XHTML
02237   // validity anyways. For now, it's an acceptable stopgap solution.
02238   if (isset($seen_ids[$id])) {
02239     $id = $id .'-'. $seen_ids[$id]++;
02240   }
02241   else {
02242     $seen_ids[$id] = 1;
02243   }
02244
02245   return $id;
02246 }
02247
02388 function batch_set($batch_definition) {
02389   if ($batch_definition) {
02390     $batch =& batch_get();
02391     // Initialize the batch
02392     if (empty($batch)) {
02393       $batch = array(
02394         'sets' => array(),
02395       );
02396     }
02397
02398     $init = array(
02399       'sandbox' => array(),
02400       'results' => array(),
02401       'success' => FALSE,
02402     );
02403     // Use get_t() to allow batches at install time.
02404     $t = get_t();
02405     $defaults = array(
02406       'title' => $t('Processing'),
02407       'init_message' => $t('Initializing.'),
02408       'progress_message' => $t('Remaining @remaining of @total.'),
02409       'error_message' => $t('An error has occurred.'),
02410     );
02411     $batch_set = $init + $batch_definition + $defaults;
02412
02413     // Tweak init_message to avoid the bottom of the page flickering down after init phase.
02414     $batch_set['init_message'] .= '<br/>&nbsp;';
02415     $batch_set['total'] = count($batch_set['operations']);
02416
02417     // If the batch is being processed (meaning we are executing a stored submit handler),
02418     // insert the new set after the current one.
02419     if (isset($batch['current_set'])) {
02420       // array_insert does not exist...
02421       $slice1 = array_slice($batch['sets'], 0, $batch['current_set'] + 1);
02422       $slice2 = array_slice($batch['sets'], $batch['current_set'] + 1);
02423       $batch['sets'] = array_merge($slice1, array($batch_set), $slice2);
02424     }
02425     else {
02426       $batch['sets'][] = $batch_set;
02427     }
02428   }
02429 }
02430
02446 function batch_process($redirect = NULL, $url = NULL) {
02447   $batch =& batch_get();
02448
02449   if (isset($batch)) {
02450     // Add process information
02451     $url = isset($url) ? $url : 'batch';
02452     $process_info = array(
02453       'current_set' => 0,
02454       'progressive' => TRUE,
02455       'url' => isset($url) ? $url : 'batch',
02456       'source_page' => $_GET['q'],
02457       'redirect' => $redirect,
02458     );
02459     $batch += $process_info;
02460
02461     if ($batch['progressive']) {
02462       // Clear the way for the drupal_goto redirection to the batch processing
02463       // page, by saving and unsetting the 'destination' if any, on both places
02464       // drupal_goto looks for it.
02465       if (isset($_REQUEST['destination'])) {
02466         $batch['destination'] = $_REQUEST['destination'];
02467         unset($_REQUEST['destination']);
02468       }
02469       elseif (isset($_REQUEST['edit']['destination'])) {
02470         $batch['destination'] = $_REQUEST['edit']['destination'];
02471         unset($_REQUEST['edit']['destination']);
02472       }
02473
02474       // Initiate db storage in order to get a batch id. We have to provide
02475       // at least an empty string for the (not null) 'token' column.
02476       db_query("INSERT INTO {batch} (token, timestamp) VALUES ('', %d)", time());
02477       $batch['id'] = db_last_insert_id('batch', 'bid');
02478
02479       // Now that we have a batch id, we can generate the redirection link in
02480       // the generic error message.
02481       $t = get_t();
02482       $batch['error_message'] = $t('Please continue to <a href="@error_url">the error page</a>', array('@error_url' => url($url, array('query' => array('id' => $batch['id'], 'op' => 'finished')))));
02483
02484       // Actually store the batch data and the token generated form the batch id.
02485       db_query("UPDATE {batch} SET token = '%s', batch = '%s' WHERE bid = %d", drupal_get_token($batch['id']), serialize($batch), $batch['id']);
02486
02487       drupal_goto($batch['url'], 'op=start&id='. $batch['id']);
02488     }
02489     else {
02490       // Non-progressive execution: bypass the whole progressbar workflow
02491       // and execute the batch in one pass.
02492       require_once './includes/batch.inc';
02493       _batch_process();
02494     }
02495   }
02496 }
02497
02501 function &batch_get() {
02502   static $batch = array();
02503   return $batch;
02504 }
02505
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Forms API Quickstart Guide

Warning - this page has only been partially updated for the Drupal 6.x API

Until it has been fully updated, reference this page as well: Drupal 5.x to 6.x FormAPI changes

The Drupal forms API is a powerful leap forward. It also allows for almost unlimited possibilities for custom theming, validation, and execution of forms. Even better, ANY form (even those in core) can be altered in almost any way imaginable--elements can be removed, added, and rearranged. The following pages are certainly not a comprehensive guide to this functionality, but should provide a good working foundation with which to do the most basic form creation, theming, validation, and execution.

Creating Forms

Form elements are now declared in array fashion, with the hierarchical structure of the form elements themselves as array elements (which can be nested), and each form elements properties/attributes listed as array elements in key/value pairs--the key being the name of the property/attribute, and the value being the value of the property/attribute. For example, here's how to go about constructing a textfield form element:

<?php
$form['foo'] = array(
  '#type' => 'textfield',
  '#title' => t('bar'),
  '#default_value' => $object['foo'],
  '#size' => 60,
  '#maxlength' => 64,
  '#description' => t('baz'),
);
?>

and a submit button:

<?php
$form['submit'] = array(
  '#type' => 'submit',
  '#value' => t('Save'),
);
?>

a few things to note:

  1. The element's name property is declared in the $form array, at the very end of the array tree. For example, if an element in the form tree was structured like this:

    <?php
    $form    ['account_settings']['username']
    ?>

    ...then that element's name property is 'username'--this is the key it will be available under in $form_state['values'], in your validation and submission functions, as the form code flattens the array in this fashion before it passes the key/value pairs. NOTE: if you wish to have the full tree structure passed to $form_state['values'], this is possible, and will be discussed later.
  2. The type of form element is declared as an attribute with the '#type' property.
  3. Properties/attributes keys are declared with surrounding quotes, beginning with a # sign. Values are strings.
  4. The order of the properties/attributes doesn't matter, and any attributes that you don't need don't need to be declared. Many properties/attributes also have a default fallback value if not explicitly declared.
  5. Don't use the '#value' attribute for any form elements that can be changed by the user. Use the '#default_value' attribute instead. Don't put values from $form_state['values'] (or $_POST) here! FormsAPI will deal with that for you; only put the original value of the field here.

One great advantages of this system is that the explicitly named keys make deciphering the form element much easier.

Let's take a look at a working piece of code using the API:

<?php
function test_form($form_state) {
  // Access log settings:
  $options = array('1' => t('Enabled'), '0' => t('Disabled'));
  $form['access'] = array(
    '#type' => 'fieldset',
    '#title' => t('Access log settings'),
    '#tree' => TRUE,
  );
  $form['access']['log'] = array(
    '#type' => 'radios',
    '#title' => t('Log'),
    '#default_value' =>  variable_get('log', 0),
    '#options' => $options,
    '#description' => t('The log.'),
  );
  $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
  $form['access']['timer'] = array(
    '#type' => 'select',
    '#title' => t('Discard logs older than'),
    '#default_value' => variable_get('timer', 259200),
    '#options' => $period,
    '#description' => t('The timer.'),
  );
  // Description
  $form['details'] = array(
    '#type' => 'fieldset',
    '#title' => t('Details'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['details']['description'] = array(
    '#type' => 'textarea',
    '#title' => t('Describe it'),
    '#default_value' =>  variable_get('description', ''),
    '#cols' => 60,
    '#rows' => 5,
    '#description' => t('Log description.'),
  );
  $form['details']['admin'] = array(
    '#type' => 'checkbox',
    '#title' => t('Only admin can view'),
    '#default_value' => variable_get('admin', 0),
  );
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#size' => 30,
    '#maxlength' => 64,
    '#description' => t('Enter the name for this group of settings'),
  );
  $form['hidden'] = array('#type' => 'value', '#value' => 'is_it_here');
  $form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
  return $form;
}

function test_page() {
  return drupal_get_form('test_form');
}
?>

This example demonstrates how form elements can be built in a hierarchical fashion by expanding and layering the form array. There are two functions involved - the function that builds the form, and another that displays the form using drupal_get_form(). Note that the form builder function always takes $form_state as its first argument, though for basic usage (as here) it is not used.

Notice that the first layer is made up of two form groups, 'access', and 'details', and that inside each of these groups, one layer down, are some individual form elements. Order of construction is important here, as the form building code will default to the constructed order of the $form array when it builds the form (this can be overridden, and will be discussed later in the custom theming section).

For form groups, the '#type' parameter is set to 'fieldset', and notice how the 'details' form group is made into a collapsed form group with the addition of a few attributes.

All groups/elements are been built into the master $form array by the builder function.

The drupal_get_form function is the "key" function in the Forms API. Note that in its basic usage, it takes just one argument, a string which is both the form ID and also the name of the function that builds the $form array. drupal_get_form can take optional additional arguments, which will be simply passed on to the $form builder function.

drupal_get_form does the following:

  • Starts the entire form-building process by getting the $form from the builder function
  • Translates the $form['name'] items into actual form elements
  • Performs any validation and "clean-up" that needs to be done, and calls custom validation functions if declared
  • Submits the form if a submit function is declared, and the form has been submitted
  • Calls any custom theming functions that have been declared
  • Returns an HTML string which contains the actual form.

For more detailed information, also see the API page for drupal_get_form()

An important thing to note: notice that $form['access'] has a '#tree' => TRUE attribute. this setting retains the full tree structure for all elements under it when it is passed to $form_state['values']. you must explicitly declare this anywhere you wish to retain an array's full hierarchy when it is passed.

Theming Forms

The API makes custom theming of all forms (including those found in core) possible. This custom theming becomes possible when all hard coded theming elements have been abstracted, so that they can be overridden at time of form generation. The abstraction is accomplished using one of the following two methods:

  1. Including any markup directly as an element in the $form array:
    • There are '#prefix' and '#suffix' attributes, and these will place the declared markup either before or after the form element in question. for example:
      <?php
      $form      ['access'] = array(
        '#type'       => 'fieldset',
        '#title'       => t('Access log settings'),
        '#prefix'       => '<div class="foo">',
        '#suffix'       => '</div>',
      );
      ?>

      ...will place the div tags before and after the entire form group (meaning the form elements of the group will also be enclosed in the div). if you were to put those attributes in one of the form elements inside that form group, then they would only wrap that particular element, etc.

    • There is a '#markup' type which you can place anywhere in the form, and its value will be output directly in its specified location in the forms hierarchy when the form is rendered. example:

      <?php
      $form      ['div_tag'] = array('#type' => 'markup', '#value' => '<div class="foo">');
      ?>

      This markup form element can then be accessed/altered through its name in the array, 'div_tag'

      NOTE: it's not necessary to explicitly declare the type as markup, since type will default to markup if none is declared.

  2. Break out any markup into a separate theme function. This is the preferred method if the markup has any degree of complication. it is accomplished by creating a theme function with theme_ prepended to the name of the form ID that is to be themed. in cases where you want to use the same theming function for more than one form, you can include the optional callback arg in drupal_get_form--in which case the third arg of drupal_get_form will be a string containing the name of the callback function which the form building code will call, and the theming function will be theme_ prepended to the name of the callback.

    example:

    For our above form, we could create a custom theming function as follows:

    <?php
    function theme_test_form($form) {
          $output = '';
          $output .= drupal_render($form['name']);
          $output .= '<div class="foo">';
          $output .= drupal_render($form['access']);
          $output .= '<div class="bar">';
          $output .= drupal_render($form['details']);
          $output .= '</div></div>';
          $output .= drupal_render($form);
      return     $output;
    }
    ?>

    A few things to note:

    1. The theme function has one argument, which is the form array that it will theme
    2. You build and return an output string just as you would do in a regular theming function
    3. Form elements are rendered using the drupal_render function
    4. If you call drupal_render and pass it an array of elements (as in a fieldset), it will render all the elements in the passed array, in the order in which they were built in the form array.
    5. While the default order of rendering for a form is the order in which it was built, you can override that in the theme function by calling drupal_render for any element in the place where you would like it to be rendered. In the above example, this was done with $form['name'].
    6. The rendering code keeps track of which elements have been rendered, and will only allow them to be rendered once. Notice that drupal_render is called for the entire form array at the very end of the theming function, but it will only render the remaining unrendered element, which in this case is the submit button. calling drupal_render($form) is a common way to end a theming function, as it will then render any submit buttons and/or hidden fields that have been declared in the form in a single call.

Validating Forms

The form API has general form validation which it performs on all submitted forms. If there is additional validation you wish to perform on a submitted form, you can create a validation function. the name of the validation function is the form ID with _validate appended to it. the function has two args: $form and $form_state. $form is the form array of the executed form, and $form_state['values'] contains the form values which you may perform validation on. (Note - in more advanced usage, several forms may share a _validate or _submit function - so if the form's ID is needed, it can be retrieved from $form['form_id']['#value'], or $form_state['values']['form_id'].)

Here's an example validation function for our example code:

<?php
function test_form_validate($form, &$form_state) {
  if ($form_state['values']['name'] == '') {
    form_set_error('', t('You must select a name for this group of settings.'));
  }
}
?>

Submitting Forms

The normal method of submitting forms with the API is through the use of a form submit function. This has the same naming convention and arguments as the validation function, except _submit is appended instead. Any forms which are submitted from a button of type => 'submit' will be passed to their corresponding submit function if it is available.

example:

<?php
function test_form_submit($form, &$form_state) {
  db_query("INSERT INTO {table} (name, log, hidden) VALUES ('%s', %d, '%s')", $form_state['values']['name'], $form_state['values']['access']['log'],  $form_state['values']['hidden']);
  drupal_set_message(t('Your form has been saved.'));
}
?>

a few things to note:

  1. A submit function is called only if a submit button was present and exists in the $_POST, and validation did not fail.
  2. The $form_state['values'] array will not usually have the same hierarchical structure as the constructed $form array (due to the flattening discussed previously), so be aware of what arrays have been flattened, and what arrays have retained their hierarchy by use of the tree => TRUE attribute. notice above that 'statistics_enable_access_log' belongs to a tree'd array, and the full array structure must be used to access the value.
  3. If a form has a submit function, then hidden form values are not needed. Instead, any values that you need to pass to $form_state['values'] can be declared in the $form array as such:

    <?php
    $form    ['foo'] = array('#type' => 'value', '#value' => 'bar')
    ?>

    This is accessed in $form_state['values']['foo'], with a value of bar. This method is preferred because the values are not sent to the browser.

  4. To determine where the user should be sent after the form is processed, the _submit function can place a path or URL in $form_state['redirect'] which will be the target of a drupal_goto; every form is redirected after a submit. If you store nothing in $form_state['redirect'], the form will simply be redirected to itself after a submit. It is polite to use drupal_set_message() to explain to the user that the submission was successful.

Understanding the Flow

An important concept with Forms API compared to using raw HTML forms (as in Drupal 4.6 and before) is that the drupal_get_form() function handles both presenting and responding to the form. What this means is that the $form array you construct in your function will be built first when the form is presented, and again when the form is submitted.

The practical upshot to this is that many developers immediately find themselves asking the question of "where does my data get stored?". The answer is simply that it doesn't. You put your $form data together, perhaps loading your object from the database and filling in #default_values, the form builder then checks this against what was posted. What you gain from this, however, is that the FormsAPI can deal with your data securely. Faking a POST is much harder since it won't let values that weren't actually on the form come through to the $form_state['values'] in your submit function, and in your 'select' types, it will check to ensure that the value actually existed in the select and reject the form if it was not. In addition, Drupal adds, by default, a security token to each form that will protect against cross-site forgery.


Forms API Reference

This document provides a programmer's reference to the Drupal Forms API. If you're interested in step-by-step documentation to help you write forms, please see the Forms API QuickStart guide.

Skip to: Properties | Default Values | Elements

Form Controls

Legend:
X = attribute can be used with this type
- = this attribute is not applicable to this type

#type | checkbox | checkboxes | date | fieldset | file | password | radio | radios | select | textarea | textfield | weight
#access | X | X | X | X | X | X | X | X | X | X | X | X
#ahah | X | - | - | - | - | X | X | - | X | X | X | -
#after_build | X | X | X | X | X | X | X | X | X | X | X | X
#attributes | X | X | X | X | X | X | X | X | X | X | X | X
#autocomplete_path | - | - | - | - | - | - | - | - | - | - | X | -
#collapsed | - | - | - | X | - | - | - | - | - | - | - | -
#collapsible | - | - | - | X | - | - | - | - | - | - | - | -
#cols | - | - | - | - | - | - | - | - | - | X | - | -
#default_value | X | X | X | - | - | - | X | X | X | X | X | X
#delta | - | - | - | - | - | - | - | - | - | - | - | X
#description | X | X | X | X | X | X | X | X | X | X | X | X
#disabled | X | X | X | - | X | X | X | X | X | X | X | X
#element_validate | X | X | X | X | X | X | X | X | X | X | X | X
#field_prefix | - | - | - | - | - | - | - | - | - | - | X | -
#field_suffix | - | - | - | - | - | - | - | - | - | - | X | -
#maxlength | - | - | - | - | - | - | - | - | - | - | X | -
#multiple | - | - | - | - | - | - | - | - | X | - | - | -
#options | - | X | - | - | - | - | - | X | X | - | - | -
#parents | X | X | X | X | X | X | X | X | X | X | X | X
#prefix | X | X | X | X | X | X | X | X | X | X | X | X
#required | X | X | X | - | - | X | X | X | X | X | X | X
#return_value | X | X | - | - | - | - | X | X | - | - | - | -
#rows | - | - | - | - | - | - | - | - | - | X | - | -
#size | - | - | - | - | - | - | - | - | X | - | X | -
#suffix | X | X | X | X | X | X | X | X | X | X | X | X
#theme | X | X | X | X | X | X | X | X | X | X | X | X
#title | X | X | X | X | X | X | X | X | X | X | X | X
#tree | X | X | X | X | X | X | X | X | X | X | X | X
#weight | X | X | X | X | X | X | X | X | X | X | X | X

Special Elements

# type | button | image_button | submit | form | hidden | markup | item | value
#after_build | X | X | X | X | X | X | X | -
#ahah | X | X | X | - | - | - | - | -
#action | - | - | - | X | - | - | - | -
#attributes | X | X | X | X | X | X | X | -
#button_type | X | X | X | - | - | - | - | -
#default_value | - | - | - | - | X | - | - | -
#description | - | - | - | - | - | - | X | -
#element_validate | X | X | X | - | X | X | X | X
#executes_submit_callback | X | X | X | - | - | - | - | -
#method | - | - | - | X | - | - | - | -
#parents | X | X | X | - | X | - | - | X
#prefix | X | X | X | X | X | X | X | -
#redirect | - | - | - | X | - | - | - | -
#required | - | - | - | - | X | - | - | -
#src | - | X | - | - | - | - | - | -
#submit | X | X | X | X | - | - | - | -
#suffix | X | X | X | X | X | X | X | -
#theme | X | X | X | X | X | X | X | -
#title | - | - | - | - | - | - | X | -
#tree | X | X | X | X | X | - | - | X
#validate | X | X | X | X | - | - | - | -
#value | X | X | X | - | - | X | X | X
#weight | X | X | X | - | - | X | X | -

Default Values

Every element automatically has these default values (see _element_info):

  • #description = NULL
  • #attributes = array()
  • #required = FALSE
  • #tree = FALSE
  • #parents = array()

The following is a list of default values which do not need to be set (found in system_elements):

  • button
    • #name = 'op'
    • #button_type = 'submit'
    • #executes_submit_callback = FALSE
    • #ahah['event'] = 'click'
  • checkbox
    • #return_value = 1
    • #ahah['event'] = 'change'
  • checkboxes
    • #tree = 1
  • fieldset
    • #collapsible = FALSE
    • #collapsed = FALSE
  • file
    • #size = 60
  • form
    • #method = 'post'
    • #action = request_uri()
  • image_button
    • #button_type = 'submit'
    • #executes_submit_callback = TRUE
    • #ahah['event'] = 'click'
  • item
    • #prefix = ''
    • #suffix = ''
  • markup
    • #prefix = ''
    • #suffix = ''
  • radio
    • #ahah['event'] = 'change'
  • password
    • #size = 30
    • #maxlength = 64
    • #ahah['event'] = 'blur'
  • submit
    • #name = 'op'
    • #button_type = 'submit'
    • #executes_submit_callback = TRUE
    • #ahah['event'] = 'click'
  • textarea
    • #cols = 60
    • #rows = 5
    • #ahah['event'] = 'blur'
  • textfield
    • #size = 60
    • #maxlength = 128
    • #autocomplete_path = FALSE
    • #ahah['event'] = 'blur'
  • weight
    • #delta = 10

Elements

Note that property names in bold are those that will generally need to be defined when creating this form element. Default values are indicated in parentheses next to property names, if they exist.

button

Description: Format an action button. When the button is pressed, the form will be submitted to Drupal, where it is validated and rebuilt. The submit handler is not invoked.

Properties: #ahah, #attributes, #button_type (default: submit), #executes_submit_callback (default: FALSE), #name (default: op), #prefix, #suffix, #type. #value, #weight

Usage example (node.module):

<?php
$form['preview'] = array(
  '#type' => 'button',
  '#value' => t('Preview'),
  '#weight' => 19,
);
 ?>

checkbox

Description: Format a checkbox.

Properties: #ahah, #attributes, #default_value, #description, #prefix, #required, #return_value (default: 1), #suffix, #title, #type. #weight

Usage example (contact.module):

<?php
$form['copy'] = array(
  '#type' => 'checkbox',
  '#title' => t('Send me a copy.'),
);
?>

checkboxes

Description: Format a set of checkboxes. #options is an associative array, where the key is the #return_value of the checkbox and the value is displayed. The #options array can not have a 0 key, as it would not be possible to discern checked and unchecked states.

Properties: #attributes, #default_value, #description, #options, #prefix, #required, #suffix, #title, #tree (default: TRUE), #type. #weight

Usage example (node.module):

<?php
$form['node_options_'. $node->type] = array(
   '#type' => 'checkboxes',
  '#title' => t('Default options'),
  '#default_value' => variable_get('node_options_'. $node->type, array('status', 'promote')),
   '#options' => array(
    'status' => t('Published'),
    'moderate' => t('In moderation queue'),
    'promote' => t('Promoted to front page'),
    'sticky' => t('Sticky at top of lists'),
    'revision' => t('Create new revision'),
  ),
   '#description' => t('Users with the <em>administer nodes</em> permission will be able to override these options.'),
);
 ?>

date

Description: Format a date selection box. The #default_value will be today's date if no value is supplied. The format for the #default_value and the #return_value is an array with three elements with the keys: 'year', month', and 'day'. For example, array('year' => 2007, 'month' => 2, 'day' => 15)

Properties: #attributes, #default_value, #description, #prefix, #required, #suffix, #title, #type. #weight

Usage example (profile.module):

<?php
$fields[$category][$field->name] = array(
  '#type' => 'date',
  '#title' => check_plain($field->title),
  '#default_value' => $edit[$field->name],
  '#description' => _profile_form_explanation($field),
  '#required' => $field->required
);
?>

fieldset

Description: Format a group of form items.

Properties: #attributes, #collapsed (default: FALSE), #collapsible (default: FALSE), #description, #prefix, #suffix, #title, #type. #weight

Usage example (contact.module):

<?php
$form['contact'] = array(
  '#type' => 'fieldset',
  '#title' => t('Contact settings'),
  '#weight' => 5,
  '#collapsible' => TRUE,
  '#collapsed' => FALSE,
);
?>

file

Description: Format a file upload field.

Note: you will need to include $form['#attributes'] = array('enctype' => "multipart/form-data"); in your form. See this handbook page for an example http://drupal.org/node/111782.

Properties: #attributes, #description, #prefix, #required, #size (default: 60), #suffix, #title, #type. #weight

Usage example (upload.module):

<?php
$form['new']['upload'] = array(
  '#type' => 'file',
  '#title' => t('Attach new file'),
  '#size' => 40,
);
?>

form

Description: A form containing form elements

Properties: #action (default: request_uri()), #attributes, #method (default: 'post'), #prefix, #submit, #suffix, #theme, #validate

Usage example:

N/A

hidden

Description: Store data in a hidden form field.

Properties: #prefix, #suffix, #type, #value

Usage example (block.module):

<?php
$form['bid'] = array('#type' => 'hidden', '#value' => $bid);
?>

image_button

Description: Format a form submit button with an image.

Properties: #ahah, #attributes, #button_type (default: 'submit'), #executes_submit_callback (default: TRUE), #name (default: 'op'), #prefix, #src, #suffix, #submit, #type. #value, #weight

markup

Description: Generate generic markup for display inside forms. Note that there is no need to declare a form element as #type = 'markup', as this is the default type.

Note: if you use markup, if your content is not wrapped in tags (generally <p> or <div>), your content will fall outside of collapsed fieldsets.

Properties: #attributes, #prefix (default: ''), #suffix (default: ''), #type. #value, #weight

Usage example (contact.module):

<?php
$form['contact_information'] = array(
  '#value' => variable_get('contact_form_information', t('You can leave us a message using the contact form below.')),
);
?>

item

Description: Generate a display-only form element allowing for an optional title and description.

Note: since this is a read-only field, setting the #required property will do nothing except theme the form element to look as if it were actually required (i.e. by placing a red star next to the #title).

Properties: #attributes, #description, #prefix (default: ''), #required, #suffix (default: ''), #title, #type, #value, #weight

Usage example (contact.module):

<?php
 $form['from'] = array(
  '#type' => 'item',
  '#title' => t('From'),
  '#value' => $user->name .' &lt;'. $user->mail .'&gt;',
);
 ?>

password

Description: Format a single-line text field that does not display its contents visibly.

Properties: #ahah, #attributes, #description, #maxlength (default: 30), #prefix, #required, #size (default: 64), #suffix, #title, #type. #weight

Usage example (user.module):

<?php
$form['pass'] = array(
  '#type' => 'password',
  '#title' => t('Password'),
  '#maxlength' => 64,
  '#size' => 15,
);
?>

radio

Description: Format a radio button.

Properties: #ahah, #attributes, #default_value, #description, #prefix, #required, #suffix, #title, #type. #weight

Usage example:

N/A

radios

Description: Format a set of radio buttons.

Properties: #attributes, #default_value, #description, #options, #prefix, #required, #suffix, #title, #type. #weight

Usage example (comment.module):

<?php
$form['posting_settings']['comment_preview'] = array(
  '#type' => 'radios',
  '#title' => t('Preview comment'),
  '#default_value' => variable_get('comment_preview', 1),
  '#options' => array(t('Optional'), t('Required')),
);
?>

select

Description: Format a drop-down menu or scrolling selection box.

Properties: #ahah, #attributes, #default_value, #description, #multiple, #options, #prefix, #required, #suffix, #title, #type. #weight

Usage example (system.module):

<?php
$form['feed']['feed_item_length'] = array(
   '#type' => 'select',
  '#title' => t('Display of XML feed items'),
  '#default_value' => variable_get('feed_item_length','teaser'),
   '#options' => array(
    'title' => t('Titles only'),
    'teaser' => t('Titles plus teaser'),
    'fulltext' => t('Full text'),
  ),
   '#description' => t('Global setting for the length of XML feed items that are output by default.'),
);
?>

submit

Description: Format a form submit button.

Properties: #ahah, #attributes, #button_type (default: 'submit'), #executes_submit_callback (default: TRUE), #name (default: 'op'), #prefix, #suffix, #type. #value, #weight

Usage example (locale.module):

<?php
$form['submit'] = array('#type' => 'submit', '#value' => t('Import'));
?>

textarea

Description: Format a multiple-line text field.

Properties: #ahah, #attributes, #cols (default: 60), #default_value, #description, #prefix, #required, #suffix, #title, #type. #rows (default: 5), #weight

Usage example (forum.module):

<?php
$form['body'] = array(
  '#type' => 'textarea',
  '#title' => t('Body'),
  '#default_value' => $node->body,
  '#required' => TRUE
);
 ?>

textfield

Description: Format a single-line text field.

Properties: #ahah, #attributes, #autocomplete_path (default: FALSE), #default_value, #description, #field_prefix, #field_suffix, #maxlength (default: 128), #prefix, #required, #size (default: 60), #suffix, #title, #type. #weight

Usage example (forum.module):

<?php
$form['title'] = array(
  '#type' => 'textfield',
  '#title' => t('Subject'),
  '#default_value' => $node->title,
  '#size' => 60,
  '#maxlength' => 128,
  '#required' => TRUE,
);
?>

value

Description: A form value that is internal to the form and never displayed to the screen.

Properties: #type, #value

Usage example (node.module):

<?php
$form['vid'] = array('#type' => 'value', '#value' => $node->vid);
?>

weight

Description: Format a weight selection menu.

Properties: #attributes, #delta (default: 10), #default_value, #description, #prefix, #required, #suffix, #title, #type. #weight

Usage example (menu.module):

<?php
$form['weight'] = array(
  '#type' => 'weight',
  '#title' => t('Weight'),
  '#default_value' => $edit['weight'],
  '#delta' => 10,
  '#description' => t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'),
);
?>

Properties

#access

Description: Whether the element is accessible or not, when FALSE, the element is not rendered and the user submitted value is not taken into consideration.

Values: TRUE of FALSE.

#action

Used by: form

Description: The path to which the form will be submitted.

Values: An internal path

Usage example (comment.module):

<?php
$form['#action'] = url('comment/reply/'. $edit['nid']);
 ?>

Do not forget the # before property names.

#after_build

An array of function names which will be called after the form is built. Example: node preview.

Usage example (system.module):

<?php
$form['files']['file_directory_path'] = array(
   '#type' => 'textfield',
   '#title' => t('File system path'),
   '#default_value' => file_directory_path(),
   '#maxlength' => 255,
   '#description' => t('A file system path where the files will be stored. This directory has to exist and be writable by Drupal. If the download method is set to public this directory has to be relative to Drupal installation directory, and be accessible over the web. When download method is set to private this directory should not be accessible over the web. Changing this location after the site has been in use will cause problems so only change this setting on an existing site if you know what you are doing.'),
);
$form['#after_build'] = array('system_check_directory');

...

function system_check_directory($form, $form_element) {
   file_check_directory($form_element['#value'], FILE_CREATE_DIRECTORY, $form_element['#parents'][0]);
   return $form_element;
}
 ?>

Property names without # signs causes havoc.

#ahah

Used by: button, checkbox, image button, password, radio, select, submit, textarea, textfield

An array of elements whose values control the behavior of the element with respect to the Drupal AHAH javascript methods.

The #ahah name refers to AHAH javascript replacement (Asychronous HTML and HTTP), a relative of AJAX. AHAH is a form of javascript page replacement that is both easy and straight forward. In a nutshell an AHAH request follows these steps:

  1. Drupal builds a form element with a set of #ahah properties. The misc/ahah.js file is included on the page automatically.
  2. ahah.js finds all the form elements on the page that have an #ahah['path'] set and adds an event handler for the #ahah['event'] set on that form element.
  3. When the #ahah['event'] occurs on the element (such as 'click'), the AHAH request is made to the Drupal path of the element's #ahah['path'].
  4. Drupal generates HTML in a second request in the background. While the user waits for the callback to execute a throbber or progress bar is shown as determined by #ahah['progress']. The result is returned to the original page containing the form element.
  5. ahah.js gets the result and inserts the returned HTML into the #ahah['wrapper']. Depending on the #ahah['method'], the result may affect the wrapper in different ways.

#ahah['effect']

Description: Specifies the effect used when adding the content from an AHAH request.

Values: String. Possible values: 'none' (default), 'fade', 'slide'. If the interface elements library is installed, any effect with the name effectToggle may also be used.

Usage example (poll.module):

  $form['choice_wrapper']['poll_more'] = array(
    '#type' => 'submit',
    '#value' => t('More choices'),
    '#description' => t("If the amount of boxes above isn't enough, click here to add more choices."),
    '#weight' => 1,
    '#submit' => array('poll_more_choices_submit'), // If no javascript action.
    '#ahah' => array(
      'path' => 'poll/js',
      'wrapper' => 'poll-choices',
      'method' => 'replace',
      'effect' => 'fade',
    ),

#ahah['event']

Description: When this event occurs to this element, Drupal will perform an HTTP request in the background via Javascript.

Values: String. Possible values: 'click', 'blur', 'change'. Note that #ahah['event'] does not need to be explicitly specified. Although it can be manually set, usually the default value will be sufficient.

#ahah['method']

Description: Modify the behavior of the returned HTML from an AHAH request when inserting into the #ahah_wrapper. If not set, the returned HTML will replace the contents of the wrapper element, but it's also possible to use any of the available jQuery operations for DOM manipulation.

Values: String. Possible values: 'replace' (default), 'after', 'append', 'before', 'prepend'.

#ahah['path']

Description: If set, this property triggers AHAH behaviors on a form element. This is the Drupal menu path to a callback function which will generate HTML and return the string of HTML to Drupal. The result will be placed in the div specified in #ahah['wrapper'].

Values: String containing a Drupal menu path.

Usage example (upload.module):

<?php
/**
* Implementation of hook_menu().
*/
function upload_menu() {
  $items['upload/js'] = array(
    'page callback' => 'upload_js',
    'access arguments' => array('upload files'),
    'type' => MENU_CALLBACK,
  );
  ...
  return $items;
}

...

function _upload_form($node) {
  ...
    $form['new']['attach'] = array(
      '#type' => 'submit',
      '#value' => t('Attach'),
      '#name' => 'attach',
      '#ahah' => array(
        'path' => 'upload/js',
        'wrapper' => 'attach-wrapper',
        'progress' => array('type' => 'bar', 'message' => t('Please wait...')),
      ),
      '#submit' => array('node_form_submit_build_node'),
    );
  ...
return $form;
?>

#ahah['path'] is set to 'upload/js', which has a menu item defined in the same module. Then the menu hook will call the 'upload_js' function which generates HTML and returns it to original page.

#ahah['progress']

Description: Choose either a throbber or progress bar that is displayed while awaiting a response from the callback, and add an optional message.

Values: Array.

Possible keys: 'type', 'message', 'url', 'interval'

Possible values:

  • #ahah['progress']['type'] String. Possible values: 'throbber' (default), 'bar'.
  • #ahah['progress']['message'] String. An optional message to the user; should be wrapped with t().
  • #ahah['progress']['url'] String. The optional callback path to use to determine how full the progress bar is (as defined in progress.js). Only useable when 'type' is 'progress'.
  • #ahah['progress']['interval'] String. The iterval to be used in updating the progress bar (as defined in progress.js). Ony used if 'url' is defined and 'type' is 'progress'.

Usage example: see above useage in upload.module

#ahah['wrapper']

Description: This property defines the HTML id attribute of an element on the page will server as the destination for HTML returned by an AHAH request. Usually, a div element is used as the wrapper, as it provides the most flexibility for placement of elements before, after, or inside of it's HTML tags. This property is required for using AHAH requests in on a form element.

Values: String containg a valid id attribute of an HTML element on the same page.

Usage example (upload.module):

    $form['new']['attach'] = array(
      '#type' => 'submit',
      '#value' => t('Attach'),
      '#name' => 'attach',
      '#ahah' => array(
        'path' => 'upload/js',
        'wrapper' => 'attach-wrapper',
        'progress' => array('type' => 'bar', 'message' => t('Please wait...')),
      ),
      '#submit' => array('node_form_submit_build_node'),
    );

#attributes

Used by: button, checkbox, checkboxes, date, fieldset, file, form, markup, password, radio, radios, select, submit, textarea, textfield, weight

Description: Additional HTML attributes, such as 'class' can be set using this mechanism.

Values: Any HTML attribute not covered by other properties, e.g. class (for control types), enctype (for forms).

Usage example (search.module):

<?php
$form['#attributes'] = array('class' => 'search-form');
?>

The # is mandatory before property names.

#autocomplete_path

Used by: textfield

Description: The path the AJAX autocomplete script uses as the source for autocompletion.

Usage example (node.module):

<?php
$form['author']['name'] = array(
  '#type' => 'textfield',
  '#title' => t('Authored by'),
  '#maxlength' => 60,
  '#autocomplete_path' => 'user/autocomplete',
  '#default_value' => $node->name,
  '#weight' => -1,
);
?>

It's very important that you do not forget the # before property names.

#built

Used by: form

Description: Used to ascertain whether or not a form element has been built yet.

Values: TRUE or FALSE

Usage example: INTERNAL. See the _form_builder function in form.inc.

The first character of property names is #.

#button_type

Used by: button, submit

Description: Indicates CSS class to use for button(form-button_type)

Values: submit, ???

Usage example: (system.module):

<?php
$type['submit'] = array(
  '#input' => TRUE,
  '#name' => 'op',
  '#button_type' => 'submit',
  '#submit' => TRUE,
);
?>

Developers should take care to not forget the first # character in property names.

#collapsed

Used by: fieldset

Description: Indicates whether or not the fieldset is collapsed by default. See #collapsible property.

Values: TRUE or FALSE

Usage example (block.module) :

<?php
$form['block'] = array(
  '#type' => 'fieldset',
  '#title' => t('Block configuration'),
  '#weight' => 3,
  '#collapsible' => TRUE,
  '#collapsed' => FALSE,
  '#tree' => TRUE,
);
?>

Child names do not have a # as first char, but property names do.

#collapsible

Used by: fieldset

Description: Indicates whether or not the fieldset can be collapsed with JavaScript. See #collapsed property.

Values: TRUE or FALSE

Usage example (block.module):

<?php
$form['block'] = array(
  '#type' => 'fieldset',
  '#title' => t('Block configuration'),
  '#weight' => 3,
  '#collapsible' => TRUE,
  '#collapsed' => FALSE,
  '#tree' => TRUE,
);
?>

One of the most important things about form API is not forgetting the # where it's appropriate.

#cols

Used by: textarea

Description: How many columns wide the textarea should be (see also #rows)

Values: A positive number

Usage example (aggregator.module):

<?php
$form['description'] = array(
  '#type' => 'textarea',
  '#title' => t('Description'),
  '#default_value' => $edit['description'],
  '#cols' => 60,
  '#rows' => 5,
);
?>

The first # lets form API decide between a property name and a child.

#default_value

Used by: button, checkbox, checkboxes, date, file, markup, password, radio, radios, select, submit, textarea, textfield, weight

Description: The value of the form element that will be displayed or selected initially if the form has not been submitted yet. Should NOT be confused with #value, which is a hard-coded value the user cannot change!

Values: Mixed

Usage example (forum.module):

<?php
$form['body'] = array(
  '#type' => 'textarea',
  '#title' => t('Body'),
  '#default_value' => $node->body,
  '#required' => TRUE,
);
?>

How many different forms of warnings can I figure out to tell you that the first # in property names are important?

#delta

Used by: weight

Description: Number of weights to have selectable. For example, with $delta => 10, the weight selection box would display numbers from -10 to 10.

Values: A positive number

Usage example (menu.module):

<?php
$form['weight'] = array(
  '#type' => 'weight',
  '#title' => t('Weight'),
  '#default_value' => $edit['weight'],
  '#delta' => 10,
  '#description' => t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'),
);
?>

One of the most common errors for 4.7 is leaving out the # in the beginning of property names.

#description

Used by: checkbox, checkboxes, date, fieldset, file, markup, password, radio, radios, select, textarea, textfield, weight

Description: The description of the form element. Make sure to enclose inside the t() function so this property can be translated.

Values: Mixed

Usage example (menu.module):

<?php
$form['weight'] = array(
  '#type' => 'weight',
  '#title' => t('Weight'),
  '#default_value' => $edit['weight'],
  '#delta' => 10,
  '#description' => t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'),
);
?>

#disabled

Used by: checkbox, checkboxes, date, file, password, radio, radios, select, textarea, textfield, weight

Description: Disables (greys out) a form input element.

Values: TRUE or FALSE

Usage example (system.module):

<?php
      if (isset($disabled[$name])) {
        $form['theme_settings'][$name]['#disabled'] = TRUE;
      }
?>

It can not be stressed enough that property names begin with a #.

#element_validate

Used by: any element

Description: A list of custom validation functions that need to be passed. The functions must use form_error() or form_set_error() to set an error if the validation fails.

Values: an array of function names to be called to validate this element (and/or its children)

A validation function for an element takes the element and the form state as parameters, and has the form:

function myelement_validate($element, &$form_state) {
   if (empty($element['#value']) {
     form_error($element, t('This field is required.'));
   }
}

Usage example (filter.module):

<?php
  if (count($formats) > 1) {
    $form = array(
      '#type' => 'fieldset',
      '#title' => t('Input format'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#weight' => $weight,
      '#element_validate' => array('filter_form_validate'),
    );
   ...
?>

While #element_validate makes sure that user data is valid, nothing validates the form for missing # in the beginning of property name.

#error

INTERNAL. Indicates whether or not a form element has been flagged as having an error.

#executes_submit_callback

Used by: button, submit, image_button

Description: Indicates whether or not button should submit the form.

Values: TRUE or FALSE

#id

INTERNAL. Used to populate form elements' id property.

#input

INTERNAL. Indicates whether or not input is possible for this form element.

#field_prefix

Used by: textfield

Description: Text or code that is placed directly in front of the textfield. This can be used to prefix a textfield with a constant string.

Values: Mixed

Usage example (system.module):

<?php
$form['site_403'] = array(
  '#type' => 'textfield',
  '#title' => t('Default 403 (access denied) page'),
  '#default_value' => variable_get('site_403', ''),
  '#size' => 40,
  '#description' => t('This page is displayed when the requested document is denied to the current user. If unsure, specify nothing.'),
  '#field_prefix' => url(NULL, NULL, NULL, TRUE) . (variable_get('clean_url', 0) ? '' : '?q=')
);
?>

#field_suffix

Used by: textfield

Description: Text or code that is placed directly after a textfield. This can be used to add a unit to a textfield.

Values: Mixed

Usage example (system.module):

<?php
$form['settings_general']['upload_usersize_default'] = array(
  '#type' => 'textfield',
  '#title' => t('Default total file size per user'),
  '#default_value' => $upload_usersize_default,
  '#size' => 5,
  '#maxlength' => 5,
  '#description' => t('The default maximum size of all files a user can have on the site.'),
  '#field_suffix' => t('MB')
);

#maxlength

Used by: textfield

Description: The maximum amount of characters to accept as input.

Values: A positive number.

Usage example (forum.module):

<?php
$form['title'] = array(
  '#type' => 'textfield',
  '#title' => t('Subject'),
  '#default_value' => $node->title,
  '#size' => 60,
  '#maxlength' => 128,
  '#required' => TRUE,
);
?>

You can spare lots of debug time by not forgetting the # in the beginning of property names.

#method

Used by: form

Description: The HTTP method with which the form will be submitted.

Values: GET or POST. Default is POST.

Usage example (node.module):

<?php
$form['#method'] = 'post';
?>

#multiple

Used by: select

Description: Indicates whether the user may select more than one item.

Values: TRUE or FALSE

Usage example (taxonomy.module):

<?php
 return array(
  '#type' => 'select',
  '#title' => $title,
  '#default_value' => $value,
  '#options' => $options,
  '#description' => $description,
  '#multiple' => $multiple,
  '#size' => $multiple ? 'size="'. min(12, count($options)) .'"' : 0,
  '#weight' => -15,
);
?>

By now, you probably know that the first character of property names is # but I thought some repetition can't hurt.

#name

INTERNAL. Refers to the name of an element ('foo' in $form['foo'])

#options

Used by: checkboxes, radios, select

Description: Selectable options for a form element that allows multiple choices.

Values: An array in the form of array(t('Display value 1'), t('Display value 2')) or array('return_value1' => t('Display Value 1'), 'return_value2' => t('Display Value 2')) if specific return values are required.

Usage example (comment.module):

<?php
$form['posting_settings']['comment_preview'] = array(
  '#type' => 'radios',
  '#title' => t('Preview comment'),
  '#default_value' => variable_get('comment_preview', 1),
  '#options' => array(t('Optional'), t('Required')),
);
?>

If you are fed up with comments about # being the first character of property names, then sorry, but it's important.

#parents

Used by: All

Description: Identifies parent form elements. See #tree and #parents in the handbook.

Values: An array of element names.

Usage example (comment.module):

<?php
$form['admin']['status'] = array(
  '#type' => 'radios',
  '#parents' => array('status'),
  '#title' => t('Status'),
  '#default_value' => $status,
  '#options' => array(t('Published'), t('Not published')),
  '#weight' => -1,
);
?>

While the first character of the words parents and property is P, the first character of every property is #.

#prefix

Used by: button, checkbox, checkboxes, date, fieldset, file, form, hidden, markup, password, radio, radios, select, submit, textarea, textfield, weight

Description: Text or markup to include before the form element. Also see #suffix.

Values: Mixed

Usage example (poll.module):

<?php
$form['choice'] = array(
  '#type' => 'fieldset',
  '#title' => t('Choices'),
  '#prefix' => '<div class="poll-form">',
  '#suffix' => '</div>',
  '#tree' => TRUE,
);
?>

The correct prefix of a property name is the #.

#printed

INTERNAL. Used to determine whether or not a form element has been printed yet.

#process

Description: An array of functions, each with an array of arguments, that are called when an element is processed. Using this callback, modules can "register" further actions. For example the "radios" form type is expanded to multiple radio buttons using a processing function.

Values: Array of arrays

Usage example (system.module) in system_elements():

$type['radios'] = array('#input' => TRUE, '#process' => array('expand_radios' => array()));

In this example, the function expand_radios with no arguments is called. This function adds new elements of type radio to the array with values corresponding to the processed element's #options.

#processed

INTERNAL. Used to ascertain whether or not a form element has been processed (ie: expanded to multiple elements).

#redirect

Used by: form

Description: The default goto value after form is submitted. This value should be returned by a form's submit callback function, but altering another form's #redirect value by using hook_form_alter() can be useful to change where that form redirects after it is submitted. Also see #action.

Values: An internal path or an array of arguments to pass to url(). The value may also be set to FALSE to prevent redirection after form submission.

Usage example (locale.inc):

<?php
$form['#redirect'] = 'node';
?>

<?php
$form['#redirect'] = array('user/login', 'destination=node');
?>

<?php
$form['#redirect'] = FALSE;
?>

Only heathens leave out the # before property names.

#ref

Used by: checkbox, checkboxes, date, file, password, radio, radios, select, textarea, textfield, weight

Description: Creates a reference that can then be accessed at any point during the form processing cycle. This is a very useful property if for example you wish to make changes to a property on _validate, and see those changes on _submit.

See the #ref handbook page

#required

Used by: checkbox, checkboxes, date, file, password, radio, radios, select, textarea, textfield, weight

Description: Indicates whether or not the element is required. This automatically validates for empty fields, and flags inputs as required. File fields are NOT allowed to be required.

Values: TRUE or FALSE

Usage example (forum.module):

<?php
$form['title'] = array(
  '#type' => 'textfield',
  '#title' => t('Subject'),
  '#default_value' => $node->title,
  '#size' => 60,
  '#maxlength' => 128,
  '#required' => TRUE,
);
?>

You know what's absolutely required? The # in the beginning of property names.

#return_value

Used by: checkbox, checkboxes, radio, radios

Description: Value element should return when selected

Values: Mixed

Usage example (poll.module):

<?php
$form['morechoices'] = array(
  '#type' => 'checkbox',
  '#title' => t('Need more choices'),
  '#return_value' => 1,
  '#default_value' => 0,
  '#description' => t("If the amount of boxes above isn't enough, check this box and click the Preview button below to add some more."),
);
?>

Let's make this remark short: #

#rows

Used by: textarea

Description: How many rows high the textarea should be (see also #cols)

Values: A positive number

Usage example (aggregator.module):

<?php
$form['description'] = array(
  '#type' => 'textarea',
  '#title' => t('Description'),
  '#default_value' => $edit['description'],
  '#cols' => 60,
  '#rows' => 5,
);
?>

Your code will row with you if you forget the # in the beginning of property names.

#size

Used by: select, textfield

Description: Width of the textfield (in characters) or size of multiselect box (in lines).

Values: A positive number.

Usage example (comment.module):

<?php
        $form['admin']['homepage'] = array(
          '#type' => 'textfield',
          '#title' => t('Homepage'),
          '#maxlength' => 255,
          '#size' => 30,
          '#default_value' => $edit['homepage'],
        );
?>

If you forget the # sign...

#src

Used by: image_button

Description: The URL of the image of the button.

Values: An URL.

#submit

Used by: form, button, submit, image_button

Description: Contains a list of submit callbacks to be excuted on the form or only when a specific button is clicked.

Values: An array of function names.

Usage example (menu.module):

<?php
function menu_form_alter(&$form, $form_state, $form_id) {
   ...
    $form['menu']['parent'] = array(
      '#type' => 'select',
      '#title' => t('Parent item'),
      '#default_value' => $default,
      '#options' => $options,
      '#attributes' => array('class' => 'menu-title-select'),
    );
    $form['#submit'][] = 'menu_node_form_submit';
}
?>

Usage example (menu.module):

<?php
    $form['menu_name'] = array('#type' => 'value', '#value' => $menu['menu_name']);
    $form['#insert'] = FALSE;
    $form['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
      '#access' => !in_array($menu['menu_name'], menu_list_system_menus()),
      '#submit' => array('menu_custom_delete_submit'),
      '#weight' => 10,
    );
?>

#suffix

Used by: button, checkbox, checkboxes, date, fieldset, file, form, hidden, markup, password, radio, radios, select, submit, textarea, textfield, weight

Description: Text or markup to include after the form element. Also see #prefix.

Values: Mixed

Usage example (poll.module):

<?php
$form['choice'] = array(
  '#type' => 'fieldset',
  '#title' => t('Choices'),
  '#prefix' => '<div class="poll-form">',
  '#suffix' => '</div>',
  '#tree' => TRUE,
);
?>

Suffix is almost suffer which will happen if you forget the # in the beginning of property names.

#theme

Used by: button, checkbox, checkboxes, date, fieldset, file, form, hidden, markup, password, radio, radios, select, submit, textarea, textfield

Description: Theme function to call for element.

Values: The name of a theme function, without the initial theme_.

Usage example (upload.module):

<?php
$form['#theme'] = 'upload_form_new';
?>

#title

Used by: checkbox, checkboxes, fieldset, date, file, password, radio, radios, select, textarea, textfield, weight

Description: The title of the form element. Make sure to enclose inside the t() function so this property can be translated.

Values: Mixed

Usage example (aggregator.module):

<?php
$form['description'] = array(
  '#type' => 'textarea',
  '#title' => t('Description'),
  '#default_value' => $edit['description'],
  '#cols' => 60,
  '#rows' => 5,
);
?>

#tree

Used by: button, checkbox, checkboxes, date, fieldset, file, form, hidden, markup, password, radio, radios, select, submit, textarea, textfield, weight

Description: Used to allow collections of form elements. Normally applied to the "parent" element, as the #tree property cascades to sub-elements. Use where you previously used ][ in form_ calls. For more information, see #tree and #parents in the handbook.

Values: TRUE or FALSE

Usage example (system.module):

<?php
$form['status'] = array(
  '#type' => 'checkboxes',
  '#default_value' => $status,
  '#options' => $options,
  '#tree' => TRUE,
);
 $required = array('block', 'filter', 'system', 'user', 'watchdog');
foreach ($required as $require) {
   $form['status'][$require] = array(
    '#type' => 'hidden',
    '#value' => 1,
    '#suffix' => t('required'),
  );
}
?>

#type

Used by: All

Description: Used to determine the type of form element.

Values: button, checkbox, checkboxes, date, fieldset, file, form, hidden, markup, password, radio, radios, select, submit, textarea, textfield, value, weight

Usage example (locale.module):

<?php
$form['submit'] = array('#type' => 'submit', '#value' => t('Import'));
?>

#validate

Used by: button, form, submit, image_button

Description: A list of custom validation functions that need to be passed.This is usually used to add additional vlidation functions to a form, or to use an alternate function rather than the default form validation function which is the form ID with _validate appended to it.

Values: An array of function names. Each such function will take $form and $form_state as parameters and should use form_set_error() if the form values do not pass validation. For example:

function test_form_validate($form, &$form_state) {
  if ($form_state['values']['name'] == '') {
    form_set_error('name', t('You must select a name for this group of settings.'));
  }
}

Usage example (node.module):

<?php
    // Node types:
    $types = array_map('check_plain', node_get_types('names'));
    $form['advanced']['type'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Only of the type(s)'),
      '#prefix' => '<div class="criterion">',
      '#suffix' => '</div>',
      '#options' => $types,
    );
    $form['advanced']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Advanced search'),
      '#prefix' => '<div class="action">',
      '#suffix' => '</div>',
    );

    $form['#validate'][] = 'node_search_validate';
?>

#validation_arguments

INTERNAL

#value

Used by: button, hidden, image_button, item, markup, submit, value

Description: Used to set values that cannot be edited by the user. Should NOT be confused with #default_value, which is for form inputs where users can override the default value.

Values: Mixed (text or numbers)

Usage example (locale.module):

<?php
$form['submit'] = array('#type' => 'submit', '#value' => t('Import'));
?>

#weight

Used by: button, checkbox, checkboxes, date, fieldset, file, markup, password, radio, radios, select, submit, textarea, textfield, weight

Description: Used to sort the list of form elements before being output; lower numbers appear before higher numbers.

Values: A positive or negative number (integer or decimal)

Usage example (book.module):

<?php
$form['parent'] = array(
   '#type' => 'select',
  '#title' => t('Parent'),
  '#default_value' => ($node->parent ? $node->parent : arg(4)),
  '#options' => book_toc($node->nid),
  '#weight' => -15,
  '#description' => t('The parent that this page belongs in. Note that pages whose parent is &lt;top-level&gt; are regarded as independent, top-level books.'),
);
?>


Drupal 6: modules/forum/forum-icon.tpl.php Source File

modules » forum

forum-icon.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: forum-icon.tpl.php,v 1.3 2007/12/20 09:35:09 goba Exp $
00003
00016 ?>
00017 <?php if ($new_posts): ?>
00018   <a name="new">
00019 <?php endif; ?>
00020
00021 <?php print theme('image', "misc/forum-$icon.png") ?>
00022
00023 <?php if ($new_posts): ?>
00024   </a>
00025 <?php endif; ?>
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forum-list.tpl.php Source File

modules » forum

forum-list.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: forum-list.tpl.php,v 1.4 2007/08/30 18:58:12 goba Exp $
00003
00033 ?>
00034 <table id="forum-<?php print $forum_id; ?>">
00035   <thead>
00036     <tr>
00037       <th><?php print t('Forum'); ?></th>
00038       <th><?php print t('Topics');?></th>
00039       <th><?php print t('Posts'); ?></th>
00040       <th><?php print t('Last post'); ?></th>
00041     </tr>
00042   </thead>
00043   <tbody>
00044   <?php foreach ($forums as $child_id => $forum): ?>
00045     <tr id="forum-list-<?php print $child_id; ?>" class="<?php print $forum->zebra; ?>">
00046       <td <?php print $forum->is_container ? 'colspan="4" class="container"' : 'class="forum"'; ?>>
00047         <?php /* Enclose the contents of this cell with X divs, where X is the
00048                * depth this forum resides at. This will allow us to use CSS
00049                * left-margin for indenting.
00050                */ ?>
00051         <?php print str_repeat('<div class="indent">', $forum->depth); ?>
00052           <div class="name"><a href="<?php print $forum->link; ?>"><?php print $forum->name; ?></a></div>
00053           <?php if ($forum->description): ?>
00054             <div class="description"><?php print $forum->description; ?></div>
00055           <?php endif; ?>
00056         <?php print str_repeat('</div>', $forum->depth); ?>
00057       </td>
00058       <?php if (!$forum->is_container): ?>
00059         <td class="topics">
00060           <?php print $forum->num_topics ?>
00061           <?php if ($forum->new_topics): ?>
00062             <br />
00063             <a href="<?php print $forum->new_url; ?>"><?php print $forum->new_text; ?></a>
00064           <?php endif; ?>
00065         </td>
00066         <td class="posts"><?php print $forum->num_posts ?></td>
00067         <td class="last-reply"><?php print $forum->last_reply ?></td>
00068       <?php endif; ?>
00069     </tr>
00070   <?php endforeach; ?>
00071   </tbody>
00072 </table>
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forum-submitted.tpl.php Source File

modules » forum

forum-submitted.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: forum-submitted.tpl.php,v 1.3 2007/08/07 08:39:35 goba Exp $
00003
00019 ?>
00020 <?php if ($time): ?>
00021   <?php print t(
00022   '@time ago<br />by !author', array(
00023     '@time' => $time,
00024     '!author' => $author,
00025     )); ?>
00026 <?php else: ?>
00027   <?php print t('n/a'); ?>
00028 <?php endif; ?>
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forum-topic-list.tpl.php Source File

modules » forum

forum-topic-list.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: forum-topic-list.tpl.php,v 1.4 2007/08/30 18:58:12 goba Exp $
00003
00035 ?>
00036 <table id="forum-topic-<?php print $topic_id; ?>">
00037   <thead>
00038     <tr><?php print $header; ?></tr>
00039   </thead>
00040   <tbody>
00041   <?php foreach ($topics as $topic): ?>
00042     <tr class="<?php print $topic->zebra;?>">
00043       <td class="icon"><?php print $topic->icon; ?></td>
00044       <td class="title"><?php print $topic->title; ?></td>
00045     <?php if ($topic->moved): ?>
00046       <td colspan="3"><?php print $topic->message; ?></td>
00047     <?php else: ?>
00048       <td class="replies">
00049         <?php print $topic->num_comments; ?>
00050         <?php if ($topic->new_replies): ?>
00051           <br />
00052           <a href="<?php print $topic->new_url; ?>"><?php print $topic->new_text; ?></a>
00053         <?php endif; ?>
00054       </td>
00055       <td class="created"><?php print $topic->created; ?>
00056       <td class="last-reply"><?php print $topic->last_reply; ?>
00057     <?php endif; ?>
00058     </tr>
00059   <?php endforeach; ?>
00060   </tbody>
00061 </table>
00062 <?php print $pager; ?>
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forum-topic-navigation.tpl.php Source File

modules » forum

forum-topic-navigation.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: forum-topic-navigation.tpl.php,v 1.2 2007/08/07 08:39:35 goba Exp $
00003
00025 ?>
00026 <?php if ($prev || $next): ?>
00027   <div class="forum-topic-navigation clear-block">
00028     <?php if ($prev): ?>
00029       <a href="<?php print $prev_url; ?>" class="topic-previous" title="<?php print t('Go to previous forum topic') ?>">‹ <?php print $prev_title ?></a>
00030     <?php endif; ?>
00031     <?php if ($next): ?>
00032       <a href="<?php print $next_url; ?>" class="topic-next" title="<?php print t('Go to next forum topic') ?>"><?php print $next_title ?> ›</a>
00033     <?php endif; ?>
00034   </div>
00035 <?php endif; ?>
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forum.admin.inc Source File

modules » forum

forum.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: forum.admin.inc,v 1.8 2008/01/30 10:14:42 goba Exp $
00003
00009 function forum_form_main($type, $edit = array()) {
00010   if ((isset($_POST['op']) && $_POST['op'] == t('Delete')) || !empty($_POST['confirm'])) {
00011     return drupal_get_form('forum_confirm_delete', $edit['tid']);
00012   }
00013   switch ($type) {
00014     case 'forum':
00015       return drupal_get_form('forum_form_forum', $edit);
00016       break;
00017     case 'container':
00018       return drupal_get_form('forum_form_container', $edit);
00019       break;
00020   }
00021 }
00022
00030 function forum_form_forum(&$form_state, $edit = array()) {
00031   $edit += array(
00032     'name' => '',
00033     'description' => '',
00034     'tid' => NULL,
00035     'weight' => 0,
00036   );
00037   $form['name'] = array('#type' => 'textfield',
00038     '#title' => t('Forum name'),
00039     '#default_value' => $edit['name'],
00040     '#maxlength' => 255,
00041     '#description' => t('Short but meaningful name for this collection of threaded discussions.'),
00042     '#required' => TRUE,
00043   );
00044   $form['description'] = array('#type' => 'textarea',
00045     '#title' => t('Description'),
00046     '#default_value' => $edit['description'],
00047     '#description' => t('Description and guidelines for discussions within this forum.'),
00048   );
00049   $form['parent']['#tree'] = TRUE;
00050   $form['parent'][0] = _forum_parent_select($edit['tid'], t('Parent'), 'forum');
00051   $form['weight'] = array('#type' => 'weight',
00052     '#title' => t('Weight'),
00053     '#default_value' => $edit['weight'],
00054     '#description' => t('Forums are displayed in ascending order by weight (forums with equal weights are displayed alphabetically).'),
00055   );
00056
00057   $form['vid'] = array('#type' => 'hidden', '#value' => variable_get('forum_nav_vocabulary', ''));
00058   $form['submit' ] = array('#type' => 'submit', '#value' => t('Save'));
00059   if ($edit['tid']) {
00060     $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
00061     $form['tid'] = array('#type' => 'hidden', '#value' => $edit['tid']);
00062   }
00063   $form['#submit'][] = 'forum_form_submit';
00064   $form['#theme'] = 'forum_form';
00065
00066   return $form;
00067 }
00068
00072 function forum_form_submit($form, &$form_state) {
00073   if ($form['form_id']['#value'] == 'forum_form_container') {
00074     $container = TRUE;
00075     $type = t('forum container');
00076   }
00077   else {
00078     $container = FALSE;
00079     $type = t('forum');
00080   }
00081
00082   $status = taxonomy_save_term($form_state['values']);
00083   switch ($status) {
00084     case SAVED_NEW:
00085       if ($container) {
00086         $containers = variable_get('forum_containers', array());
00087         $containers[] = $form_state['values']['tid'];
00088         variable_set('forum_containers', $containers);
00089       }
00090       drupal_set_message(t('Created new @type %term.', array('%term' => $form_state['values']['name'], '@type' => $type)));
00091       break;
00092     case SAVED_UPDATED:
00093       drupal_set_message(t('The @type %term has been updated.', array('%term' => $form_state['values']['name'], '@type' => $type)));
00094       break;
00095   }
00096   $form_state['redirect'] = 'admin/content/forum';
00097   return;
00098 }
00099
00107 function forum_form_container(&$form_state, $edit = array()) {
00108   $edit += array(
00109     'name' => '',
00110     'description' => '',
00111     'tid' => NULL,
00112     'weight' => 0,
00113   );
00114   // Handle a delete operation.
00115   $form['name'] = array(
00116     '#title' => t('Container name'),
00117     '#type' => 'textfield',
00118     '#default_value' => $edit['name'],
00119     '#maxlength' => 255,
00120     '#description' => t('Short but meaningful name for this collection of related forums.'),
00121     '#required' => TRUE
00122   );
00123
00124   $form['description'] = array(
00125     '#type' => 'textarea',
00126     '#title' => t('Description'),
00127     '#default_value' => $edit['description'],
00128     '#description' => t('Description and guidelines for forums within this container.')
00129   );
00130   $form['parent']['#tree'] = TRUE;
00131   $form['parent'][0] = _forum_parent_select($edit['tid'], t('Parent'), 'container');
00132   $form['weight'] = array(
00133     '#type' => 'weight',
00134     '#title' => t('Weight'),
00135     '#default_value' => $edit['weight'],
00136     '#description' => t('Containers are displayed in ascending order by weight (containers with equal weights are displayed alphabetically).')
00137   );
00138
00139   $form['vid'] = array(
00140     '#type' => 'hidden',
00141     '#value' => variable_get('forum_nav_vocabulary', ''),
00142   );
00143   $form['submit'] = array(
00144     '#type' => 'submit',
00145     '#value' => t('Save')
00146   );
00147   if ($edit['tid']) {
00148     $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
00149     $form['tid'] = array('#type' => 'value', '#value' => $edit['tid']);
00150   }
00151   $form['#submit'][] = 'forum_form_submit';
00152   $form['#theme'] = 'forum_form';
00153
00154   return $form;
00155 }
00156
00162 function forum_confirm_delete(&$form_state, $tid) {
00163   $term = taxonomy_get_term($tid);
00164
00165   $form['tid'] = array('#type' => 'value', '#value' => $tid);
00166   $form['name'] = array('#type' => 'value', '#value' => $term->name);
00167
00168   return confirm_form($form, t('Are you sure you want to delete the forum %name?', array('%name' => $term->name)), 'admin/content/forum', t('Deleting a forum or container will also delete its sub-forums, if any. To delete posts in this forum, visit <a href="@content">content administration</a> first. This action cannot be undone.', array('@content' => url('admin/content/node'))), t('Delete'), t('Cancel'));
00169 }
00170
00174 function forum_confirm_delete_submit($form, &$form_state) {
00175   taxonomy_del_term($form_state['values']['tid']);
00176   drupal_set_message(t('The forum %term and all sub-forums and associated posts have been deleted.', array('%term' => $form_state['values']['name'])));
00177   watchdog('content', 'forum: deleted %term and all its sub-forums and associated posts.', array('%term' => $form_state['values']['name']));
00178
00179   $form_state['redirect'] = 'admin/content/forum';
00180   return;
00181 }
00182
00188 function forum_admin_settings() {
00189   $form = array();
00190   $number = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500));
00191   $form['forum_hot_topic'] = array('#type' => 'select',
00192     '#title' => t('Hot topic threshold'),
00193     '#default_value' => variable_get('forum_hot_topic', 15),
00194     '#options' => $number,
00195     '#description' => t('The number of posts a topic must have to be considered "hot".'),
00196   );
00197   $number = drupal_map_assoc(array(10, 25, 50, 75, 100));
00198   $form['forum_per_page'] = array('#type' => 'select',
00199     '#title' => t('Topics per page'),
00200     '#default_value' => variable_get('forum_per_page', 25),
00201     '#options' => $number,
00202     '#description' => t('Default number of forum topics displayed per page.'),
00203   );
00204   $forder = array(1 => t('Date - newest first'), 2 => t('Date - oldest first'), 3 => t('Posts - most active first'), 4 => t('Posts - least active first'));
00205   $form['forum_order'] = array('#type' => 'radios',
00206     '#title' => t('Default order'),
00207     '#default_value' => variable_get('forum_order', '1'),
00208     '#options' => $forder,
00209     '#description' => t('Default display order for topics.'),
00210   );
00211   return system_settings_form($form);
00212 }
00213
00217 function forum_overview(&$form_state) {
00218   module_load_include('inc', 'taxonomy', 'taxonomy.admin');
00219
00220   $vid = variable_get('forum_nav_vocabulary', '');
00221   $vocabulary = taxonomy_vocabulary_load($vid);
00222   $form = taxonomy_overview_terms($form_state, $vocabulary);
00223   drupal_set_title('Forums');
00224
00225   foreach (element_children($form) as $key) {
00226     if (isset($form[$key]['#term'])) {
00227       $term = $form[$key]['#term'];
00228       $form[$key]['view']['#value'] = l($term['name'], 'forum/'. $term['tid']);
00229       if (in_array($form[$key]['#term']['tid'], variable_get('forum_containers', array()))) {
00230         $form[$key]['edit']['#value'] = l(t('edit container'), 'admin/content/forum/edit/container/'. $term['tid']);
00231       }
00232       else {
00233         $form[$key]['edit']['#value'] = l(t('edit forum'), 'admin/content/forum/edit/forum/'. $term['tid']);
00234       }
00235     }
00236   }
00237
00238   // Remove the alphabetical reset.
00239   unset($form['reset_alphabetical']);
00240
00241   // The form needs to have submit and validate handlers set explicitly.
00242   $form['#theme'] = 'taxonomy_overview_terms';
00243   $form['#submit'] = array('taxonomy_overview_terms_submit'); // Use the existing taxonomy overview submit handler.
00244   $form['#validate'] = array('taxonomy_overview_terms_validate');
00245   $form['#empty_text'] = '<em>'. t('There are no existing containers or forums. Containers and forums may be added using the <a href="@container">add container</a> and <a href="@forum">add forum</a> pages.', array('@container' => url('admin/content/forum/add/container'), '@forum' => url('admin/content/forum/add/forum'))) .'</em>';
00246   return $form;
00247 }
00248
00256 function _forum_parent_select($tid, $title, $child_type) {
00257
00258   $parents = taxonomy_get_parents($tid);
00259   if ($parents) {
00260     $parent = array_shift($parents);
00261     $parent = $parent->tid;
00262   }
00263   else {
00264     $parent = 0;
00265   }
00266
00267   $vid = variable_get('forum_nav_vocabulary', '');
00268   $children = taxonomy_get_tree($vid, $tid);
00269
00270   // A term can't be the child of itself, nor of its children.
00271   foreach ($children as $child) {
00272     $exclude[] = $child->tid;
00273   }
00274   $exclude[] = $tid;
00275
00276   $tree = taxonomy_get_tree($vid);
00277   $options[0] = '<'. t('root') .'>';
00278   if ($tree) {
00279     foreach ($tree as $term) {
00280       if (!in_array($term->tid, $exclude)) {
00281         $options[$term->tid] = str_repeat(' -- ', $term->depth) . $term->name;
00282       }
00283     }
00284   }
00285   if ($child_type == 'container') {
00286     $description = t('Containers are usually placed at the top (root) level, but may also be placed inside another container or forum.');
00287   }
00288   else if ($child_type == 'forum') {
00289     $description = t('Forums may be placed at the top (root) level, or inside another container or forum.');
00290   }
00291
00292   return array('#type' => 'select', '#title' => $title, '#default_value' => $parent, '#options' => $options, '#description' => $description, '#required' => TRUE);
00293 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forum.install Source File

modules » forum

forum.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: forum.install,v 1.16 2007/12/31 16:58:34 goba Exp $
00003
00007 function forum_install() {
00008   // Create tables.
00009   drupal_install_schema('forum');
00010   // Set the weight of the forum.module to 1 so it is loaded after the taxonomy.module.
00011   db_query("UPDATE {system} SET weight = 1 WHERE name = 'forum'");
00012 }
00013
00014 function forum_enable() {
00015   if ($vocabulary = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', 0))) {
00016     // Existing install. Add back forum node type, if the forums
00017     // vocabulary still exists. Keep all other node types intact there.
00018     $vocabulary = (array) $vocabulary;
00019     $vocabulary['nodes']['forum'] = 1;
00020     taxonomy_save_vocabulary($vocabulary);
00021   }
00022   else {
00023     // Create the forum vocabulary if it does not exist. Assign the vocabulary
00024     // a low weight so it will appear first in forum topic create and edit
00025     // forms.
00026     $vocabulary = array(
00027       'name' => t('Forums'),
00028       'multiple' => 0,
00029       'required' => 0,
00030       'hierarchy' => 1,
00031       'relations' => 0,
00032       'module' => 'forum',
00033       'weight' => -10,
00034       'nodes' => array('forum' => 1),
00035     );
00036     taxonomy_save_vocabulary($vocabulary);
00037
00038     variable_set('forum_nav_vocabulary', $vocabulary['vid']);
00039   }
00040 }
00041
00045 function forum_uninstall() {
00046   // Load the dependent Taxonomy module, in case it has been disabled.
00047   drupal_load('module', 'taxonomy');
00048
00049   // Delete the vocabulary.
00050   $vid = variable_get('forum_nav_vocabulary', '');
00051   taxonomy_del_vocabulary($vid);
00052
00053   db_query("DELETE FROM {node} WHERE type = 'forum'");
00054   db_query('DROP TABLE {forum}');
00055   variable_del('forum_containers');
00056   variable_del('forum_nav_vocabulary');
00057   variable_del('forum_hot_topic');
00058   variable_del('forum_per_page');
00059   variable_del('forum_order');
00060   variable_del('forum_block_num_0');
00061   variable_del('forum_block_num_1');
00062 }
00063
00067 function forum_schema() {
00068   $schema['forum'] = array(
00069     'description' => t('Stores the relationship of nodes to forum terms.'),
00070     'fields' => array(
00071       'nid' => array(
00072         'type' => 'int',
00073         'unsigned' => TRUE,
00074         'not null' => TRUE,
00075         'default' => 0,
00076         'description' => t('The {node}.nid of the node.'),
00077       ),
00078       'vid' => array(
00079         'type' => 'int',
00080         'unsigned' => TRUE,
00081         'not null' => TRUE,
00082         'default' => 0,
00083         'description' => t('Primary Key: The {node}.vid of the node.'),
00084       ),
00085       'tid' => array(
00086         'type' => 'int',
00087         'unsigned' => TRUE,
00088         'not null' => TRUE,
00089         'default' => 0,
00090         'description' => t('The {term_data}.tid of the forum term assigned to the node.'),
00091       ),
00092     ),
00093     'indexes' => array(
00094       'nid' => array('nid'),
00095       'tid' => array('tid')
00096     ),
00097     'primary key' => array('vid'),
00098   );
00099
00100   return $schema;
00101 }
00102
00109 function forum_update_6000() {
00110   $ret = array();
00111
00112   $vid = variable_get('forum_nav_vocabulary', 0);
00113   $vocabularies = taxonomy_get_vocabularies();
00114   if (!isset($vocabularies[$vid])) {
00115     $vocabulary = array(
00116       'name' => t('Forums'),
00117       'multiple' => 0,
00118       'required' => 0,
00119       'hierarchy' => 1,
00120       'relations' => 0,
00121       'module' => 'forum',
00122       'weight' => -10,
00123       'nodes' => array('forum' => 1),
00124     );
00125     taxonomy_save_vocabulary($vocabulary);
00126
00127     variable_set('forum_nav_vocabulary', $vocabulary['vid']);
00128   }
00129
00130   return $ret;
00131 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forum.module Source File

modules » forum

forum.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: forum.module,v 1.448.2.1 2008/02/07 11:13:51 goba Exp $
00003
00012 function forum_help($path, $arg) {
00013   switch ($path) {
00014     case 'admin/help#forum':
00015       $output = '<p>'. t('The forum module lets you create threaded discussion forums with functionality similar to other message board systems. Forums are useful because they allow community members to discuss topics with one another while ensuring those conversations are archived for later reference. The <a href="@create-topic">forum topic</a> menu item (under <em>Create content</em> on the Navigation menu) creates the initial post of a new threaded discussion, or thread.', array('@create-topic' => url('node/add/forum'))) .'</p>';
00016       $output .= '<p>'. t('A threaded discussion occurs as people leave comments on a forum topic (or on other comments within that topic). A forum topic is contained within a forum, which may hold many similar or related forum topics. Forums are (optionally) nested within a container, which may hold many similar or related forums. Both containers and forums may be nested within other containers and forums, and provide structure for your message board. By carefully planning this structure, you make it easier for users to find and comment on a specific forum topic.') .'</p>';
00017       $output .= '<p>'. t('When administering a forum, note that:') .'</p>';
00018       $output .= '<ul><li>'. t('a forum topic (and all of its comments) may be moved between forums by selecting a different forum while editing a forum topic.') .'</li>';
00019       $output .= '<li>'. t('when moving a forum topic between forums, the <em>Leave shadow copy</em> option creates a link in the original forum pointing to the new location.') .'</li>';
00020       $output .= '<li>'. t('selecting <em>Read only</em> under <em>Comment settings</em> while editing a forum topic will lock (prevent new comments) on the thread.') .'</li>';
00021       $output .= '<li>'. t('selecting <em>Disabled</em> under <em>Comment settings</em> while editing a forum topic will hide all existing comments on the thread, and prevent new ones.') .'</li></ul>';
00022       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@forum">Forum module</a>.', array('@forum' => 'http://drupal.org/handbook/modules/forum/')) .'</p>';
00023       return $output;
00024     case 'admin/content/forum':
00025       return '<p>'. t('This page displays a list of existing forums and containers. Containers (optionally) hold forums, and forums hold forum topics (a forum topic is the initial post to a threaded discussion). To provide structure, both containers and forums may be placed inside other containers and forums. To rearrange forums and containers, grab a drag-and-drop handle under the <em>Name</em> column and drag the forum or container to a new location in the list. (Grab a handle by clicking and holding the mouse while hovering over a handle icon.) Remember that your changes will not be saved until you click the <em>Save</em> button at the bottom of the page.') .'</p>';
00026     case 'admin/content/forum/add/container':
00027       return '<p>'. t('By grouping related or similar forums, containers help organize forums. For example, a container named "Food" may hold two forums named "Fruit" and "Vegetables", respectively.') .'</p>';
00028     case 'admin/content/forum/add/forum':
00029       return '<p>'. t('A forum holds related or similar forum topics (a forum topic is the initial post to a threaded discussion). For example, a forum named "Fruit" may contain forum topics titled "Apples" and "Bananas", respectively.') .'</p>';
00030     case 'admin/content/forum/settings':
00031       return '<p>'. t('These settings allow you to adjust the display of your forum topics. The content types available for use within a forum may be selected by editing the <em>Content types</em> on the <a href="@forum-vocabulary">forum vocabulary page</a>.', array('@forum-vocabulary' => url('admin/content/taxonomy/edit/vocabulary/'. variable_get('forum_nav_vocabulary', '')))) .'</p>';
00032   }
00033 }
00034
00038 function forum_theme() {
00039   return array(
00040     'forums' => array(
00041       'template' => 'forums',
00042       'arguments' => array('forums' => NULL, 'topics' => NULL, 'parents' => NULL, 'tid' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL),
00043     ),
00044     'forum_list' => array(
00045       'template' => 'forum-list',
00046       'arguments' => array('forums' => NULL, 'parents' => NULL, 'tid' => NULL),
00047     ),
00048     'forum_topic_list' => array(
00049       'template' => 'forum-topic-list',
00050       'arguments' => array('tid' => NULL, 'topics' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL),
00051     ),
00052     'forum_icon' => array(
00053       'template' => 'forum-icon',
00054       'arguments' => array('new_posts' => NULL, 'num_posts' => 0, 'comment_mode' => 0, 'sticky' => 0),
00055     ),
00056     'forum_topic_navigation' => array(
00057       'template' => 'forum-topic-navigation',
00058       'arguments' => array('node' => NULL),
00059     ),
00060     'forum_submitted' => array(
00061       'template' => 'forum-submitted',
00062       'arguments' => array('topic' => NULL),
00063     ),
00064   );
00065 }
00066
00076 function forum_term_load($tid) {
00077   $result = db_query(db_rewrite_sql('SELECT t.tid, t.vid, t.name, t.description, t.weight FROM {term_data} t WHERE t.tid = %d AND t.vid = %d', 't', 'tid'), $tid, variable_get('forum_nav_vocabulary', ''));
00078   return db_fetch_array($result);
00079 }
00080
00084 function forum_menu() {
00085   $items['forum'] = array(
00086     'title' => 'Forums',
00087     'page callback' => 'forum_page',
00088     'access arguments' => array('access content'),
00089     'type' => MENU_SUGGESTED_ITEM,
00090     'file' => 'forum.pages.inc',
00091   );
00092   $items['admin/content/forum'] = array(
00093     'title' => 'Forums',
00094     'description' => 'Control forums and their hierarchy and change forum settings.',
00095     'page callback' => 'drupal_get_form',
00096     'page arguments' => array('forum_overview'),
00097     'access arguments' => array('administer forums'),
00098     'file' => 'forum.admin.inc',
00099   );
00100   $items['admin/content/forum/list'] = array(
00101     'title' => 'List',
00102     'type' => MENU_DEFAULT_LOCAL_TASK,
00103     'weight' => -10,
00104   );
00105   $items['admin/content/forum/add/container'] = array(
00106     'title' => 'Add container',
00107     'page callback' => 'forum_form_main',
00108     'page arguments' => array('container'),
00109     'type' => MENU_LOCAL_TASK,
00110     'parent' => 'admin/content/forum',
00111     'file' => 'forum.admin.inc',
00112   );
00113   $items['admin/content/forum/add/forum'] = array(
00114     'title' => 'Add forum',
00115     'page callback' => 'forum_form_main',
00116     'page arguments' => array('forum'),
00117     'type' => MENU_LOCAL_TASK,
00118     'parent' => 'admin/content/forum',
00119     'file' => 'forum.admin.inc',
00120   );
00121   $items['admin/content/forum/settings'] = array(
00122     'title' => 'Settings',
00123     'page callback' => 'drupal_get_form',
00124     'page arguments' => array('forum_admin_settings'),
00125     'weight' => 5,
00126     'type' => MENU_LOCAL_TASK,
00127     'parent' => 'admin/content/forum',
00128     'file' => 'forum.admin.inc',
00129   );
00130   $items['admin/content/forum/edit/%forum_term'] = array(
00131     'page callback' => 'forum_form_main',
00132     'type' => MENU_CALLBACK,
00133     'file' => 'forum.admin.inc',
00134   );
00135   $items['admin/content/forum/edit/container/%forum_term'] = array(
00136     'title' => 'Edit container',
00137     'page callback' => 'forum_form_main',
00138     'page arguments' => array('container', 5),
00139     'type' => MENU_CALLBACK,
00140     'file' => 'forum.admin.inc',
00141   );
00142   $items['admin/content/forum/edit/forum/%forum_term'] = array(
00143     'title' => 'Edit forum',
00144     'page callback' => 'forum_form_main',
00145     'page arguments' => array('forum', 5),
00146     'type' => MENU_CALLBACK,
00147     'file' => 'forum.admin.inc',
00148   );
00149   return $items;
00150 }
00151
00152
00156 function forum_init() {
00157   drupal_add_css(drupal_get_path('module', 'forum') .'/forum.css');
00158 }
00159
00163 function forum_nodeapi(&$node, $op, $teaser, $page) {
00164   // We are going to return if $node->type is not one of the node
00165   // types assigned to the forum vocabulary.  If forum_nav_vocabulary
00166   // is undefined or the vocabulary does not exist, it clearly cannot
00167   // be assigned to $node->type, so return to avoid E_ALL warnings.
00168   $vid = variable_get('forum_nav_vocabulary', '');
00169   $vocabulary = taxonomy_vocabulary_load($vid);
00170   if (empty($vocabulary)) {
00171     return;
00172   }
00173
00174   // Operate only on node types assigned for the forum vocabulary.
00175   if (!in_array($node->type, $vocabulary->nodes)) {
00176     return;
00177   }
00178
00179   switch ($op) {
00180     case 'view':
00181       if ($page && taxonomy_node_get_terms_by_vocabulary($node, $vid) && $tree = taxonomy_get_tree($vid)) {
00182         // Get the forum terms from the (cached) tree
00183         foreach ($tree as $term) {
00184           $forum_terms[] = $term->tid;
00185         }
00186         foreach ($node->taxonomy as $term_id => $term) {
00187           if (in_array($term_id, $forum_terms)) {
00188             $node->tid = $term_id;
00189           }
00190         }
00191         // Breadcrumb navigation
00192         $breadcrumb[] = l(t('Home'), NULL);
00193         $breadcrumb[] = l($vocabulary->name, 'forum');
00194         if ($parents = taxonomy_get_parents_all($node->tid)) {
00195           $parents = array_reverse($parents);
00196           foreach ($parents as $p) {
00197             $breadcrumb[] = l($p->name, 'forum/'. $p->tid);
00198           }
00199         }
00200         drupal_set_breadcrumb($breadcrumb);
00201
00202         if (!$teaser) {
00203           $node->content['forum_navigation'] = array(
00204             '#value' => theme('forum_topic_navigation', $node),
00205             '#weight' => 100,
00206           );
00207         }
00208       }
00209       break;
00210
00211     case 'prepare':
00212       if (empty($node->nid)) {
00213         // New topic
00214         $node->taxonomy[arg(3)]->vid = $vid;
00215         $node->taxonomy[arg(3)]->tid = arg(3);
00216       }
00217       break;
00218
00219     // Check in particular that only a "leaf" term in the associated taxonomy
00220     // vocabulary is selected, not a "container" term.
00221     case 'validate':
00222       if ($node->taxonomy) {
00223         // Extract the node's proper topic ID.
00224         $vocabulary = $vid;
00225         $containers = variable_get('forum_containers', array());
00226         foreach ($node->taxonomy as $term) {
00227           if (db_result(db_query('SELECT COUNT(*) FROM {term_data} WHERE tid = %d AND vid = %d', $term, $vocabulary))) {
00228             if (in_array($term, $containers)) {
00229               $term = taxonomy_get_term($term);
00230               form_set_error('taxonomy', t('The item %forum is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name)));
00231             }
00232           }
00233         }
00234       }
00235       break;
00236
00237     // Assign forum taxonomy when adding a topic from within a forum.
00238     case 'presave':
00239       // Make sure all fields are set properly:
00240       $node->icon = !empty($node->icon) ? $node->icon : '';
00241
00242       if ($node->taxonomy && $tree = taxonomy_get_tree($vid)) {
00243         // Get the forum terms from the (cached) tree if we have a taxonomy.
00244         foreach ($tree as $term) {
00245           $forum_terms[] = $term->tid;
00246         }
00247         foreach ($node->taxonomy as $term_id) {
00248           if (in_array($term_id, $forum_terms)) {
00249             $node->tid = $term_id;
00250           }
00251         }
00252         $old_tid = db_result(db_query_range("SELECT t.tid FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.nid = %d ORDER BY t.vid DESC", $node->nid, 0, 1));
00253         if ($old_tid && isset($node->tid) && ($node->tid != $old_tid) && !empty($node->shadow)) {
00254           // A shadow copy needs to be created. Retain new term and add old term.
00255           $node->taxonomy[] = $old_tid;
00256         }
00257       }
00258       break;
00259
00260     case 'update':
00261       if (empty($node->revision) && db_result(db_query('SELECT tid FROM {forum} WHERE nid=%d', $node->nid))) {
00262         if (!empty($node->tid)) {
00263           db_query('UPDATE {forum} SET tid = %d WHERE vid = %d', $node->tid, $node->vid);
00264         }
00265         // The node is removed from the forum.
00266         else {
00267           db_query('DELETE FROM {forum} WHERE nid = %d', $node->nid);
00268         }
00269         break;
00270       }
00271       // Deliberate no break -- for new revisions and for previously unassigned terms we need an insert.
00272
00273     case 'insert':
00274       if (!empty($node->tid)) {
00275         db_query('INSERT INTO {forum} (tid, vid, nid) VALUES (%d, %d, %d)', $node->tid, $node->vid, $node->nid);
00276       }
00277       break;
00278
00279     case 'delete':
00280       db_query('DELETE FROM {forum} WHERE nid = %d', $node->nid);
00281       break;
00282
00283     case 'load':
00284       return db_fetch_array(db_query('SELECT tid AS forum_tid FROM {forum} WHERE vid = %d', $node->vid));
00285   }
00286
00287   return;
00288 }
00289
00293 function forum_node_info() {
00294   return array(
00295     'forum' => array(
00296       'name' => t('Forum topic'),
00297       'module' => 'forum',
00298       'description' => t('A <em>forum topic</em> is the initial post to a new discussion thread within a forum.'),
00299       'title_label' => t('Subject'),
00300     )
00301   );
00302 }
00303
00307 function forum_access($op, $node, $account) {
00308   switch ($op) {
00309     case 'create':
00310       return user_access('create forum topics', $account);
00311     case 'update':
00312       return user_access('edit any forum topic', $account) || (user_access('edit own forum topics', $account) && ($account->uid == $node->uid));
00313     case 'delete':
00314       return user_access('delete any forum topic', $account) || (user_access('delete own forum topics', $account) && ($account->uid == $node->uid));
00315   }
00316 }
00317
00321 function forum_perm() {
00322   return array('create forum topics', 'delete own forum topics', 'delete any forum topic', 'edit own forum topics', 'edit any forum topic', 'administer forums');
00323 }
00324
00328 function forum_taxonomy($op, $type, $term = NULL) {
00329   if ($op == 'delete' && $term['vid'] == variable_get('forum_nav_vocabulary', '')) {
00330     switch ($type) {
00331       case 'term':
00332         $results = db_query('SELECT tn.nid FROM {term_node} tn WHERE tn.tid = %d', $term['tid']);
00333         while ($node = db_fetch_object($results)) {
00334           // node_delete will also remove any association with non-forum vocabularies.
00335           node_delete($node->nid);
00336         }
00337
00338         // For containers, remove the tid from the forum_containers variable.
00339         $containers = variable_get('forum_containers', array());
00340         $key = array_search($term['tid'], $containers);
00341         if ($key !== FALSE) {
00342           unset($containers[$key]);
00343         }
00344         variable_set('forum_containers', $containers);
00345         break;
00346       case 'vocabulary':
00347         variable_del('forum_nav_vocabulary');
00348     }
00349   }
00350 }
00351
00355 function forum_form_alter(&$form, $form_state, $form_id) {
00356   $vid = variable_get('forum_nav_vocabulary', '');
00357   if (isset($form['vid']) && $form['vid']['#value'] == $vid) {
00358     // Hide critical options from forum vocabulary.
00359     if ($form_id == 'taxonomy_form_vocabulary') {
00360       $form['help_forum_vocab'] = array(
00361         '#value' => t('This is the designated forum vocabulary. Some of the normal vocabulary options have been removed.'),
00362         '#weight' => -1,
00363       );
00364       $form['content_types']['nodes']['#required'] = TRUE;
00365       $form['hierarchy'] = array('#type' => 'value', '#value' => 1);
00366       $form['settings']['required'] = array('#type' => 'value', '#value' => FALSE);
00367       $form['settings']['relations'] = array('#type' => 'value', '#value' => FALSE);
00368       $form['settings']['tags'] = array('#type' => 'value', '#value' => FALSE);
00369       $form['settings']['multiple'] = array('#type' => 'value', '#value' => FALSE);
00370       unset($form['delete']);
00371     }
00372     // Hide multiple parents select from forum terms.
00373     elseif ($form_id == 'taxonomy_form_term') {
00374       $form['advanced']['parent']['#access'] = FALSE;
00375     }
00376   }
00377   if ($form_id == 'forum_node_form') {
00378     // Make the vocabulary required for 'real' forum-nodes.
00379     $vid = variable_get('forum_nav_vocabulary', '');
00380     $form['taxonomy'][$vid]['#required'] = TRUE;
00381     $form['taxonomy'][$vid]['#options'][''] = t('- Please choose -');
00382   }
00383 }
00384
00388 function forum_load($node) {
00389   $forum = db_fetch_object(db_query('SELECT * FROM {term_node} WHERE vid = %d', $node->vid));
00390
00391   return $forum;
00392 }
00393
00400 function forum_block($op = 'list', $delta = 0, $edit = array()) {
00401   switch ($op) {
00402     case 'list':
00403       $blocks[0]['info'] = t('Active forum topics');
00404       $blocks[1]['info'] = t('New forum topics');
00405       return $blocks;
00406
00407     case 'configure':
00408       $form['forum_block_num_'. $delta] = array('#type' => 'select', '#title' => t('Number of topics'), '#default_value' => variable_get('forum_block_num_'. $delta, '5'), '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)));
00409       return $form;
00410
00411     case 'save':
00412       variable_set('forum_block_num_'. $delta, $edit['forum_block_num_'. $delta]);
00413       break;
00414
00415     case 'view':
00416       if (user_access('access content')) {
00417         switch ($delta) {
00418           case 0:
00419             $title = t('Active forum topics');
00420             $sql = db_rewrite_sql("SELECT n.nid, n.title, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid INNER JOIN {term_data} td ON td.tid = tn.tid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND td.vid = %d ORDER BY l.last_comment_timestamp DESC");
00421             $result = db_query_range($sql, variable_get('forum_nav_vocabulary', ''), 0, variable_get('forum_block_num_0', '5'));
00422             $content = node_title_list($result);
00423             break;
00424
00425           case 1:
00426             $title = t('New forum topics');
00427             $sql = db_rewrite_sql("SELECT n.nid, n.title, l.comment_count FROM {node} n INNER JOIN {term_node} tn ON tn.vid = n.vid INNER JOIN {term_data} td ON td.tid = tn.tid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND td.vid = %d ORDER BY n.nid DESC");
00428             $result = db_query_range($sql, variable_get('forum_nav_vocabulary', ''), 0, variable_get('forum_block_num_1', '5'));
00429             $content = node_title_list($result);
00430             break;
00431         }
00432
00433         if (!empty($content)) {
00434           $block['subject'] = $title;
00435           $block['content'] = $content . theme('more_link', url('forum'), t('Read the latest forum topics.'));
00436           return $block;
00437         }
00438       }
00439   }
00440 }
00441
00445 function forum_form(&$node, $form_state) {
00446   $type = node_get_types('type', $node);
00447   $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#default_value' => !empty($node->title) ? $node->title : '', '#required' => TRUE, '#weight' => -5);
00448
00449   if (!empty($node->nid)) {
00450     $vid = variable_get('forum_nav_vocabulary', '');
00451     $forum_terms = taxonomy_node_get_terms_by_vocabulary($node, $vid);
00452     // if editing, give option to leave shadows
00453     $shadow = (count($forum_terms) > 1);
00454     $form['shadow'] = array('#type' => 'checkbox', '#title' => t('Leave shadow copy'), '#default_value' => $shadow, '#description' => t('If you move this topic, you can leave a link in the old forum to the new forum.'));
00455   }
00456
00457   $form['body_field'] = node_body_field($node, $type->body_label, 1);
00458
00459   $form['#submit'][] = 'forum_submit';
00460   // Assign the forum topic submit handler.
00461
00462   return $form;
00463 }
00464
00465 function forum_link_alter(&$links, $node) {
00466   foreach ($links as $module => $link) {
00467     if (strstr($module, 'taxonomy_term')) {
00468       // Link back to the forum and not the taxonomy term page. We'll only
00469       // do this if the taxonomy term in question belongs to forums.
00470       $tid = str_replace('taxonomy/term/', '', $link['href']);
00471       $vid = variable_get('forum_nav_vocabulary', '');
00472       $term = taxonomy_get_term($tid);
00473       if ($term->vid == $vid) {
00474         $links[$module]['href'] = str_replace('taxonomy/term', 'forum', $link['href']);
00475       }
00476     }
00477   }
00478 }
00479
00493 function forum_get_forums($tid = 0) {
00494
00495   $forums = array();
00496   $vid = variable_get('forum_nav_vocabulary', '');
00497   $_forums = taxonomy_get_tree($vid, $tid);
00498
00499   if (count($_forums)) {
00500
00501     $counts = array();
00502
00503     $sql = "SELECT r.tid, COUNT(n.nid) AS topic_count, SUM(l.comment_count) AS comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.vid = r.vid WHERE n.status = 1 GROUP BY r.tid";
00504     $sql = db_rewrite_sql($sql);
00505     $_counts = db_query($sql);
00506     while ($count = db_fetch_object($_counts)) {
00507       $counts[$count->tid] = $count;
00508     }
00509   }
00510
00511   foreach ($_forums as $forum) {
00512     if (in_array($forum->tid, variable_get('forum_containers', array()))) {
00513       $forum->container = 1;
00514     }
00515
00516     if (!empty($counts[$forum->tid])) {
00517       $forum->num_topics = $counts[$forum->tid]->topic_count;
00518       $forum->num_posts = $counts[$forum->tid]->topic_count + $counts[$forum->tid]->comment_count;
00519     }
00520     else {
00521       $forum->num_topics = 0;
00522       $forum->num_posts = 0;
00523     }
00524
00525     // This query does not use full ANSI syntax since MySQL 3.x does not support
00526     // table1 INNER JOIN table2 INNER JOIN table3 ON table2_criteria ON table3_criteria
00527     // used to join node_comment_statistics to users.
00528     $sql = "SELECT ncs.last_comment_timestamp, IF (ncs.last_comment_uid != 0, u2.name, ncs.last_comment_name) AS last_comment_name, ncs.last_comment_uid FROM {node} n INNER JOIN {users} u1 ON n.uid = u1.uid INNER JOIN {term_node} tn ON n.vid = tn.vid INNER JOIN {node_comment_statistics} ncs ON n.nid = ncs.nid INNER JOIN {users} u2 ON ncs.last_comment_uid=u2.uid WHERE n.status = 1 AND tn.tid = %d ORDER BY ncs.last_comment_timestamp DESC";
00529     $sql = db_rewrite_sql($sql);
00530     $topic = db_fetch_object(db_query_range($sql, $forum->tid, 0, 1));
00531
00532     $last_post = new stdClass();
00533     if (!empty($topic->last_comment_timestamp)) {
00534       $last_post->timestamp = $topic->last_comment_timestamp;
00535       $last_post->name = $topic->last_comment_name;
00536       $last_post->uid = $topic->last_comment_uid;
00537     }
00538     $forum->last_post = $last_post;
00539
00540     $forums[$forum->tid] = $forum;
00541   }
00542
00543   return $forums;
00544 }
00545
00550 function _forum_topics_unread($term, $uid) {
00551   $sql = "SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid AND tn.tid = %d LEFT JOIN {history} h ON n.nid = h.nid AND h.uid = %d WHERE n.status = 1 AND n.created > %d AND h.nid IS NULL";
00552   $sql = db_rewrite_sql($sql);
00553   return db_result(db_query($sql, $term, $uid, NODE_NEW_LIMIT));
00554 }
00555
00556 function forum_get_topics($tid, $sortby, $forum_per_page) {
00557   global $user, $forum_topic_list_header;
00558
00559   $forum_topic_list_header = array(
00560     array('data' => '&nbsp;', 'field' => NULL),
00561     array('data' => t('Topic'), 'field' => 'n.title'),
00562     array('data' => t('Replies'), 'field' => 'l.comment_count'),
00563     array('data' => t('Created'), 'field' => 'n.created'),
00564     array('data' => t('Last reply'), 'field' => 'l.last_comment_timestamp'),
00565   );
00566
00567   $order = _forum_get_topic_order($sortby);
00568   for ($i = 0; $i < count($forum_topic_list_header); $i++) {
00569     if ($forum_topic_list_header[$i]['field'] == $order['field']) {
00570       $forum_topic_list_header[$i]['sort'] = $order['sort'];
00571     }
00572   }
00573
00574   $term = taxonomy_get_term($tid);
00575
00576   $sql = db_rewrite_sql("SELECT n.nid, r.tid, n.title, n.sticky, u.name, u.uid, n.created AS timestamp, n.comment AS comment_mode, l.last_comment_timestamp, IF(l.last_comment_uid != 0, cu.name, l.last_comment_name) AS last_comment_name, l.last_comment_uid, l.comment_count AS num_comments, f.tid AS forum_tid FROM {node_comment_statistics} l INNER JOIN {node} n ON n.nid = l.nid INNER JOIN {users} cu ON l.last_comment_uid = cu.uid INNER JOIN {term_node} r ON n.vid = r.vid INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {forum} f ON n.vid = f.vid WHERE n.status = 1 AND r.tid = %d");
00577   $sql .= tablesort_sql($forum_topic_list_header, 'n.sticky DESC,');
00578   $sql .= ', n.created DESC';  // Always add a secondary sort order so that the news forum topics are on top.
00579
00580   $sql_count = db_rewrite_sql("SELECT COUNT(n.nid) FROM {node} n INNER JOIN {term_node} r ON n.vid = r.vid AND r.tid = %d WHERE n.status = 1");
00581
00582   $result = pager_query($sql, $forum_per_page, 0, $sql_count, $tid);
00583   $topics = array();
00584   while ($topic = db_fetch_object($result)) {
00585     if ($user->uid) {
00586       // folder is new if topic is new or there are new comments since last visit
00587       if ($topic->tid != $tid) {
00588         $topic->new = 0;
00589       }
00590       else {
00591         $history = _forum_user_last_visit($topic->nid);
00592         $topic->new_replies = comment_num_new($topic->nid, $history);
00593         $topic->new = $topic->new_replies || ($topic->timestamp > $history);
00594       }
00595     }
00596     else {
00597       // Do not track "new replies" status for topics if the user is anonymous.
00598       $topic->new_replies = 0;
00599       $topic->new = 0;
00600     }
00601
00602     if ($topic->num_comments > 0) {
00603       $last_reply = new stdClass();
00604       $last_reply->timestamp = $topic->last_comment_timestamp;
00605       $last_reply->name = $topic->last_comment_name;
00606       $last_reply->uid = $topic->last_comment_uid;
00607       $topic->last_reply = $last_reply;
00608     }
00609     $topics[] = $topic;
00610   }
00611
00612   return $topics;
00613 }
00614
00618 function _forum_new($tid) {
00619   global $user;
00620
00621   $sql = "SELECT n.nid FROM {node} n LEFT JOIN {history} h ON n.nid = h.nid AND h.uid = %d INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND h.nid IS NULL AND n.created > %d ORDER BY created";
00622   $sql = db_rewrite_sql($sql);
00623   $nid = db_result(db_query_range($sql, $user->uid, $tid, NODE_NEW_LIMIT, 0, 1));
00624
00625   return $nid ? $nid : 0;
00626 }
00627
00641 function template_preprocess_forums(&$variables) {
00642   global $user;
00643
00644   $vid = variable_get('forum_nav_vocabulary', '');
00645   $vocabulary = taxonomy_vocabulary_load($vid);
00646   $title = !empty($vocabulary->name) ? $vocabulary->name : '';
00647
00648   // Breadcrumb navigation:
00649   $breadcrumb[] = l(t('Home'), NULL);
00650   if ($variables['tid']) {
00651     $breadcrumb[] = l($vocabulary->name, 'forum');
00652   }
00653   if ($variables['parents']) {
00654     $variables['parents'] = array_reverse($variables['parents']);
00655     foreach ($variables['parents'] as $p) {
00656       if ($p->tid == $variables['tid']) {
00657         $title = $p->name;
00658       }
00659       else {
00660         $breadcrumb[] = l($p->name, 'forum/'. $p->tid);
00661       }
00662     }
00663   }
00664   drupal_set_breadcrumb($breadcrumb);
00665   drupal_set_title(check_plain($title));
00666
00667   if ($variables['forums_defined'] = count($variables['forums']) || count($variables['parents'])) {
00668     // Format the "post new content" links listing.
00669     $forum_types = array();
00670
00671     // Loop through all node types for forum vocabulary.
00672     foreach ($vocabulary->nodes as $type) {
00673       // Check if the current user has the 'create' permission for this node type.
00674       if (node_access('create', $type)) {
00675         // Fetch the "General" name of the content type;
00676         // Push the link with title and url to the array.
00677         $forum_types[$type] = array('title' => t('Post new @node_type', array('@node_type' => node_get_types('name', $type))), 'href' => 'node/add/'. str_replace('_', '-', $type) .'/'. $variables['tid']);
00678       }
00679     }
00680
00681     if (empty($forum_types)) {
00682       // The user is logged-in; but denied access to create any new forum content type.
00683       if ($user->uid) {
00684         $forum_types['disallowed'] = array('title' => t('You are not allowed to post new content in forum.'));
00685       }
00686       // The user is not logged-in; and denied access to create any new forum content type.
00687       else {
00688         $forum_types['login'] = array('title' => t('<a href="@login">Login</a> to post new content in forum.', array('@login' => url('user/login', array('query' => drupal_get_destination())))), 'html' => TRUE);
00689       }
00690     }
00691     $variables['links'] = $forum_types;
00692
00693     if (!empty($variables['forums'])) {
00694       $variables['forums'] = theme('forum_list', $variables['forums'], $variables['parents'], $variables['tid']);
00695     }
00696     else {
00697       $variables['forums'] = '';
00698     }
00699
00700     if ($variables['tid'] && !in_array($variables['tid'], variable_get('forum_containers', array()))) {
00701       $variables['topics'] = theme('forum_topic_list', $variables['tid'], $variables['topics'], $variables['sortby'], $variables['forum_per_page']);
00702       drupal_add_feed(url('taxonomy/term/'. $variables['tid'] .'/0/feed'), 'RSS - '. $title);
00703     }
00704     else {
00705       $variables['topics'] = '';
00706     }
00707
00708     // Provide separate template suggestions based on what's being output. Topic id is also accounted for.
00709     // Check both variables to be safe then the inverse. Forums with topic ID's take precedence.
00710     if ($variables['forums'] && !$variables['topics']) {
00711       $variables['template_files'][] = 'forums-containers';
00712       $variables['template_files'][] = 'forums-'. $variables['tid'];
00713       $variables['template_files'][] = 'forums-containers-'. $variables['tid'];
00714     }
00715     elseif (!$variables['forums'] && $variables['topics']) {
00716       $variables['template_files'][] = 'forums-topics';
00717       $variables['template_files'][] = 'forums-'. $variables['tid'];
00718       $variables['template_files'][] = 'forums-topics-'. $variables['tid'];
00719     }
00720     else {
00721       $variables['template_files'][] = 'forums-'. $variables['tid'];
00722     }
00723
00724   }
00725   else {
00726     drupal_set_title(t('No forums defined'));
00727     $variables['links'] = array();
00728     $variables['forums'] = '';
00729     $variables['topics'] = '';
00730   }
00731 }
00732
00744 function template_preprocess_forum_list(&$variables) {
00745   global $user;
00746   $row = 0;
00747   // Sanitize each forum so that the template can safely print the data.
00748   foreach ($variables['forums'] as $id => $forum) {
00749     $variables['forums'][$id]->description = !empty($forum->description) ? filter_xss_admin($forum->description) : '';
00750     $variables['forums'][$id]->link = url("forum/$forum->tid");
00751     $variables['forums'][$id]->name = check_plain($forum->name);
00752     $variables['forums'][$id]->is_container = !empty($forum->container);
00753     $variables['forums'][$id]->zebra = $row % 2 == 0 ? 'odd' : 'even';
00754     $row++;
00755
00756     $variables['forums'][$id]->new_text = '';
00757     $variables['forums'][$id]->new_url = '';
00758     $variables['forums'][$id]->new_topics = 0;
00759     $variables['forums'][$id]->old_topics = $forum->num_topics;
00760     if ($user->uid) {
00761       $variables['forums'][$id]->new_topics = _forum_topics_unread($forum->tid, $user->uid);
00762       if ($variables['forums'][$id]->new_topics) {
00763         $variables['forums'][$id]->new_text = format_plural($variables['forums'][$id]->new_topics, '1 new', '@count new');
00764         $variables['forums'][$id]->new_url = url("forum/$forum->tid", array('fragment' => 'new'));
00765       }
00766       $variables['forums'][$id]->old_topics = $forum->num_topics - $variables['forums'][$id]->new_topics;
00767     }
00768     $variables['forums'][$id]->last_reply = theme('forum_submitted', $forum->last_post);
00769   }
00770   // Give meaning to $tid for themers. $tid actually stands for term id.
00771   $variables['forum_id'] = $variables['tid'];
00772   unset($variables['tid']);
00773 }
00774
00787 function template_preprocess_forum_topic_list(&$variables) {
00788   global $forum_topic_list_header;
00789
00790   // Create the tablesorting header.
00791   $ts = tablesort_init($forum_topic_list_header);
00792   $header = '';
00793   foreach ($forum_topic_list_header as $cell) {
00794     $cell = tablesort_header($cell, $forum_topic_list_header, $ts);
00795     $header .= _theme_table_cell($cell, TRUE);
00796   }
00797   $variables['header'] = $header;
00798
00799   if (!empty($variables['topics'])) {
00800     $row = 0;
00801     foreach ($variables['topics'] as $id => $topic) {
00802       $variables['topics'][$id]->icon = theme('forum_icon', $topic->new, $topic->num_comments, $topic->comment_mode, $topic->sticky);
00803       $variables['topics'][$id]->zebra = $row % 2 == 0 ? 'odd' : 'even';
00804       $row++;
00805
00806       // We keep the actual tid in forum table, if it's different from the
00807       // current tid then it means the topic appears in two forums, one of
00808       // them is a shadow copy.
00809       if ($topic->forum_tid != $variables['tid']) {
00810         $variables['topics'][$id]->moved = TRUE;
00811         $variables['topics'][$id]->title = check_plain($topic->title);
00812         $variables['topics'][$id]->message = l(t('This topic has been moved'), "forum/$topic->forum_tid");
00813       }
00814       else {
00815         $variables['topics'][$id]->moved = FALSE;
00816         $variables['topics'][$id]->title = l($topic->title, "node/$topic->nid");
00817         $variables['topics'][$id]->message = '';
00818       }
00819       $variables['topics'][$id]->created = theme('forum_submitted', $topic);
00820       $variables['topics'][$id]->last_reply = theme('forum_submitted', isset($topic->last_reply) ? $topic->last_reply : NULL);
00821
00822       $variables['topics'][$id]->new_text = '';
00823       $variables['topics'][$id]->new_url = '';
00824       if ($topic->new_replies) {
00825         $variables['topics'][$id]->new_text = format_plural($topic->new_replies, '1 new', '@count new');
00826         $variables['topics'][$id]->new_url = url("node/$topic->nid", array('query' => comment_new_page_count($topic->num_comments, $topic->new_replies, $topic), 'fragment' => 'new'));
00827       }
00828
00829     }
00830   }
00831   else {
00832     // Make this safe for the template
00833     $variables['topics'] = array();
00834   }
00835   // Give meaning to $tid for themers. $tid actually stands for term id.
00836   $variables['topic_id'] = $variables['tid'];
00837   unset($variables['tid']);
00838
00839   $variables['pager'] = theme('pager', NULL, $variables['forum_per_page'], 0);
00840 }
00841
00854 function template_preprocess_forum_icon(&$variables) {
00855   $variables['hot_threshold'] = variable_get('forum_hot_topic', 15);
00856   if ($variables['num_posts'] > $variables['hot_threshold']) {
00857     $variables['icon'] = $variables['new_posts'] ? 'hot-new' : 'hot';
00858   }
00859   else {
00860     $variables['icon'] = $variables['new_posts'] ? 'new' : 'default';
00861   }
00862
00863   if ($variables['comment_mode'] == COMMENT_NODE_READ_ONLY || $variables['comment_mode'] == COMMENT_NODE_DISABLED) {
00864     $variables['icon'] = 'closed';
00865   }
00866
00867   if ($variables['sticky'] == 1) {
00868     $variables['icon'] = 'sticky';
00869   }
00870 }
00871
00880 function template_preprocess_forum_topic_navigation(&$variables) {
00881   $output = '';
00882
00883   // get previous and next topic
00884   $sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 ORDER BY n.sticky DESC, ". _forum_get_topic_order_sql(variable_get('forum_order', 1));
00885   $result = db_query(db_rewrite_sql($sql), isset($variables['node']->tid) ? $variables['node']->tid : 0);
00886
00887   $stop = $variables['prev'] = $variables['next'] = 0;
00888
00889   while ($topic = db_fetch_object($result)) {
00890     if ($stop == 1) {
00891       $variables['next'] = $topic->nid;
00892       $variables['next_title'] = check_plain($topic->title);
00893       $variables['next_url'] = url("node/$topic->nid");
00894       break;
00895     }
00896     if ($topic->nid == $variables['node']->nid) {
00897       $stop = 1;
00898     }
00899     else {
00900       $variables['prev'] = $topic->nid;
00901       $variables['prev_title'] = check_plain($topic->title);
00902       $variables['prev_url'] = url("node/$topic->nid");
00903     }
00904   }
00905 }
00906
00915 function template_preprocess_forum_submitted(&$variables) {
00916   $variables['author'] = isset($variables['topic']->uid) ? theme('username', $variables['topic']) : '';
00917   $variables['time'] = isset($variables['topic']->timestamp) ? format_interval(time() - $variables['topic']->timestamp) : '';
00918 }
00919
00920 function _forum_user_last_visit($nid) {
00921   global $user;
00922   static $history = array();
00923
00924   if (empty($history)) {
00925     $result = db_query('SELECT nid, timestamp FROM {history} WHERE uid = %d', $user->uid);
00926     while ($t = db_fetch_object($result)) {
00927       $history[$t->nid] = $t->timestamp > NODE_NEW_LIMIT ? $t->timestamp : NODE_NEW_LIMIT;
00928     }
00929   }
00930   return isset($history[$nid]) ? $history[$nid] : NODE_NEW_LIMIT;
00931 }
00932
00933 function _forum_get_topic_order($sortby) {
00934   switch ($sortby) {
00935     case 1:
00936       return array('field' => 'l.last_comment_timestamp', 'sort' => 'desc');
00937       break;
00938     case 2:
00939       return array('field' => 'l.last_comment_timestamp', 'sort' => 'asc');
00940       break;
00941     case 3:
00942       return array('field' => 'l.comment_count', 'sort' => 'desc');
00943       break;
00944     case 4:
00945       return array('field' => 'l.comment_count', 'sort' => 'asc');
00946       break;
00947   }
00948 }
00949
00950 function _forum_get_topic_order_sql($sortby) {
00951   $order = _forum_get_topic_order($sortby);
00952   return $order['field'] .' '. strtoupper($order['sort']);
00953 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forum.pages.inc Source File

modules » forum

forum.pages.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: forum.pages.inc,v 1.2 2007/07/26 06:48:03 dries Exp $
00003
00012 function forum_page($tid = 0) {
00013   $topics = '';
00014   $forum_per_page = variable_get('forum_per_page', 25);
00015   $sortby = variable_get('forum_order', 1);
00016
00017   $forums = forum_get_forums($tid);
00018   $parents = taxonomy_get_parents_all($tid);
00019   if ($tid && !in_array($tid, variable_get('forum_containers', array()))) {
00020     $topics = forum_get_topics($tid, $sortby, $forum_per_page);
00021   }
00022
00023   return theme('forums', $forums, $topics, $parents, $tid, $sortby, $forum_per_page);
00024 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/forum/forums.tpl.php Source File

modules » forum

forums.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: forums.tpl.php,v 1.4 2007/08/07 08:39:35 goba Exp $
00003
00020 ?>
00021 <?php if ($forums_defined): ?>
00022 <div id="forum">
00023   <?php print theme('links', $links); ?>
00024   <?php print $forums; ?>
00025   <?php print $topics; ?>
00026 </div>
00027 <?php endif; ?>
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members - Functions

  • Alphabetical List
  • Class List
  • Class Members
  • All
  • Functions
  • Variables

  • data() : update_xml_parser
  • end() : update_xml_parser
  • parse() : update_xml_parser
  • start() : update_xml_parser
Generated on Tue Feb 12 15:30:51 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members - Variables

  • Alphabetical List
  • Class List
  • Class Members
  • All
  • Functions
  • Variables

  • $current_object : update_xml_parser
  • $current_project : update_xml_parser
  • $current_release : update_xml_parser
  • $current_tag : update_xml_parser
  • $current_term : update_xml_parser
  • $projects : update_xml_parser
Generated on Tue Feb 12 15:30:51 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- _ -

  • __pad0__ : forum-submitted.tpl.php , update.php
  • __pad1__ : update.php
  • __pad2__ : update.php
  • __pad3__ : update.php
  • _aggregator_category_title() : aggregator.module
  • _aggregator_has_categories() : aggregator.module
  • _aggregator_items() : aggregator.module
  • _aggregator_page_list() : aggregator.pages.inc
  • _batch_current_set() : batch.inc
  • _batch_do() : batch.inc
  • _batch_finished() : batch.inc
  • _batch_next_set() : batch.inc
  • _batch_page() : batch.inc
  • _batch_process() : batch.inc
  • _batch_progress_page_js() : batch.inc
  • _batch_progress_page_nojs() : batch.inc
  • _batch_shutdown() : batch.inc
  • _batch_start() : batch.inc
  • _block_compare() : block.admin.inc
  • _block_get_cache_id() : block.module
  • _block_rehash() : block.module
  • _block_themes_access() : block.module
  • _blogapi_get_node_types() : blogapi.module
  • _blogapi_get_post() : blogapi.module
  • _blogapi_mt_extra() : blogapi.module
  • _blogapi_validate_blogid() : blogapi.module
  • _book_add_form_elements() : book.module
  • _book_admin_compare() : book.admin.inc
  • _book_admin_sort_tree() : book.admin.inc
  • _book_admin_table() : book.admin.inc
  • _book_admin_table_tree() : book.admin.inc
  • _book_flatten_menu() : book.module
  • _book_install_type_create() : book.install
  • _book_link_defaults() : book.module
  • _book_outline_access() : book.module
  • _book_outline_remove_access() : book.module
  • _book_parent_depth_limit() : book.module
  • _book_parent_select() : book.module
  • _book_toc_recurse() : book.module
  • _book_update_outline() : book.module
  • _color_blend() : color.module
  • _color_gd() : color.module
  • _color_hsl2rgb() : color.module
  • _color_hue2rgb() : color.module
  • _color_pack() : color.module
  • _color_page_alter() : color.module
  • _color_render_images() : color.module
  • _color_rewrite_stylesheet() : color.module
  • _color_rgb2hsl() : color.module
  • _color_save_stylesheet() : color.module
  • _color_shift() : color.module
  • _color_unpack() : color.module
  • _comment_delete_thread() : comment.admin.inc
  • _comment_form_submit() : comment.module
  • _comment_get_display_setting() : comment.module
  • _comment_get_modes() : comment.module
  • _comment_get_orders() : comment.module
  • _comment_load() : comment.module
  • _comment_per_page() : comment.module
  • _comment_update_node_statistics() : comment.module
  • _contact_user_tab_access() : contact.module
  • _db_create_field_sql() : database.pgsql.inc , database.mysql-common.inc
  • _db_create_index_sql() : database.pgsql.inc
  • _db_create_key_sql() : database.mysql-common.inc , database.pgsql.inc
  • _db_create_keys() : database.pgsql.inc
  • _db_create_keys_sql() : database.mysql-common.inc
  • _db_error_page() : database.inc
  • _db_process_field() : database.mysql-common.inc , database.pgsql.inc
  • _db_query() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • _db_query_callback() : database.inc
  • _db_rewrite_sql() : database.inc
  • _dblog_format_message() : dblog.admin.inc
  • _dblog_get_message_types() : dblog.module
  • _decode_entities() : unicode.inc
  • _drupal_bootstrap() : bootstrap.inc
  • _drupal_bootstrap_full() : common.inc
  • _drupal_build_css_path() : common.inc
  • _drupal_flush_css_js() : common.inc
  • _drupal_html_to_mail_urls() : mail.inc
  • _drupal_html_to_text_clean() : mail.inc
  • _drupal_html_to_text_pad() : mail.inc
  • _drupal_initialize_schema() : common.inc
  • _drupal_install_module() : install.inc
  • _drupal_load_stylesheet() : common.inc
  • _drupal_maintenance_theme() : theme.maintenance.inc
  • _drupal_wrap_mail_line() : mail.inc
  • _element_info() : form.inc
  • _filter_autop() : filter.module
  • _filter_html() : filter.module
  • _filter_html_settings() : filter.module
  • _filter_htmlcorrector() : filter.module
  • _filter_list_cmp() : filter.module
  • _filter_tips() : filter.module
  • _filter_url() : filter.module
  • _filter_url_parse_full_links() : filter.module
  • _filter_url_parse_partial_links() : filter.module
  • _filter_url_settings() : filter.module
  • _filter_url_trim() : filter.module
  • _filter_xss_attributes() : filter.module
  • _filter_xss_split() : filter.module
  • _fix_gpc_magic() : common.inc
  • _fix_gpc_magic_files() : common.inc
  • _form_builder_handle_input_element() : form.inc
  • _form_builder_ie_cleanup() : form.inc
  • _form_button_was_clicked() : form.inc
  • _form_set_class() : form.inc
  • _form_set_value() : form.inc
  • _form_validate() : form.inc
  • _forum_get_topic_order() : forum.module
  • _forum_get_topic_order_sql() : forum.module
  • _forum_new() : forum.module
  • _forum_parent_select() : forum.admin.inc
  • _forum_topics_unread() : forum.module
  • _forum_user_last_visit() : forum.module
  • _init_theme() : theme.inc
  • _install_locale_initial_batch_finished() : install.php
  • _install_locale_remaining_batch_finished() : install.php
  • _install_module_batch() : install.php
  • _install_profile_batch_finished() : install.php
  • _install_settings_form_validate() : install.php
  • _locale_batch_build() : locale.inc
  • _locale_batch_import() : locale.inc
  • _locale_batch_language_finished() : locale.inc
  • _locale_batch_system_finished() : locale.inc
  • _locale_export_get_strings() : locale.inc
  • _locale_export_po() : locale.inc
  • _locale_export_po_generate() : locale.inc
  • _locale_export_remove_plural() : locale.inc
  • _locale_export_string() : locale.inc
  • _locale_export_wrap() : locale.inc
  • _locale_get_predefined_list() : locale.inc
  • _locale_import_append_plural() : locale.inc
  • _locale_import_message() : locale.inc
  • _locale_import_one_string() : locale.inc
  • _locale_import_one_string_db() : locale.inc
  • _locale_import_parse_arithmetic() : locale.inc
  • _locale_import_parse_header() : locale.inc
  • _locale_import_parse_plural_forms() : locale.inc
  • _locale_import_parse_quoted() : locale.inc
  • _locale_import_po() : locale.inc
  • _locale_import_read_po() : locale.inc
  • _locale_import_shorten_comments() : locale.inc
  • _locale_import_tokenize_formula() : locale.inc
  • _locale_invalidate_js() : locale.inc
  • _locale_languages_common_controls() : locale.inc
  • _locale_parse_js_file() : locale.inc
  • _locale_prepare_predefined_list() : locale.inc
  • _locale_rebuild_js() : locale.inc
  • _locale_translate_language_list() : locale.inc
  • _locale_translate_seek() : locale.inc
  • _locale_translate_seek_query() : locale.inc
  • _menu_check_access() : menu.inc
  • _menu_clear_page_cache() : menu.inc
  • _menu_delete_item() : menu.inc
  • _menu_find_router_path() : menu.inc
  • _menu_item_localize() : menu.inc
  • _menu_link_build() : menu.inc
  • _menu_link_map_translate() : menu.inc
  • _menu_link_move_children() : menu.inc
  • _menu_link_parents_set() : menu.inc
  • _menu_link_translate() : menu.inc
  • _menu_load_objects() : menu.inc
  • _menu_navigation_links_rebuild() : menu.inc
  • _menu_overview_tree_form() : menu.admin.inc
  • _menu_parent_depth_limit() : menu.module
  • _menu_parents_recurse() : menu.module
  • _menu_router_build() : menu.inc
  • _menu_set_expanded_menus() : menu.inc
  • _menu_site_is_offline() : menu.inc
  • _menu_translate() : menu.inc
  • _menu_tree_check_access() : menu.inc
  • _menu_tree_data() : menu.inc
  • _menu_update_parental_status() : menu.inc
  • _mime_header_decode() : unicode.inc
  • _module_build_dependencies() : module.inc
  • _node_access_join_sql() : node.module
  • _node_access_rebuild_batch_finished() : node.module
  • _node_access_rebuild_batch_operation() : node.module
  • _node_access_where_sql() : node.module
  • _node_add_access() : node.module
  • _node_index_node() : node.module
  • _node_mass_update_batch_finished() : node.admin.inc
  • _node_mass_update_batch_process() : node.admin.inc
  • _node_mass_update_helper() : node.admin.inc
  • _node_revision_access() : node.module
  • _node_save_revision() : node.module
  • _node_type_set_defaults() : node.module
  • _node_types_build() : node.module
  • _openid_create_message() : openid.inc
  • _openid_dh_base64_to_long() : openid.inc
  • _openid_dh_binary_to_long() : openid.inc
  • _openid_dh_long_to_base64() : openid.inc
  • _openid_dh_long_to_binary() : openid.inc
  • _openid_dh_rand() : openid.inc
  • _openid_dh_xorsecret() : openid.inc
  • _openid_encode_message() : openid.inc
  • _openid_get_bytes() : openid.inc
  • _openid_get_params() : openid.inc
  • _openid_hmac() : openid.inc
  • _openid_is_xri() : openid.inc
  • _openid_link_href() : openid.inc
  • _openid_meta_httpequiv() : openid.inc
  • _openid_nonce() : openid.inc
  • _openid_normalize() : openid.inc
  • _openid_normalize_url() : openid.inc
  • _openid_normalize_xri() : openid.inc
  • _openid_parse_message() : openid.inc
  • _openid_response() : openid.inc
  • _openid_sha1() : openid.inc
  • _openid_signature() : openid.inc
  • _ping_notify() : ping.module
  • _poll_choice_form() : poll.module
  • _poll_menu_access() : poll.module
  • _profile_field_serialize() : profile.module
  • _profile_field_types() : profile.module
  • _profile_form_explanation() : profile.module
  • _profile_get_fields() : profile.module
  • _profile_update_user_fields() : profile.module
  • _search_excerpt_replace() : search.module
  • _search_index_truncate() : search.module
  • _search_menu() : search.module
  • _search_parse_query() : search.module
  • _statistics_format_item() : statistics.module
  • _statistics_link() : statistics.module
  • _system_is_incompatible() : system.admin.inc
  • _system_sort_requirements() : system.module
  • _system_sql() : system.admin.inc
  • _system_theme_data() : system.module
  • _system_themes_access() : system.module
  • _system_zonelist() : system.module
  • _taxonomy_get_tid_from_term() : taxonomy.module
  • _taxonomy_term_children() : taxonomy.module
  • _taxonomy_term_select() : taxonomy.module
  • _theme_build_registry() : theme.inc
  • _theme_load_offline_registry() : theme.maintenance.inc
  • _theme_load_registry() : theme.inc
  • _theme_process_registry() : theme.inc
  • _theme_save_registry() : theme.inc
  • _theme_set_registry() : theme.inc
  • _theme_table_cell() : theme.inc
  • _translation_tab_access() : translation.module
  • _trigger_get_hook_actions() : trigger.admin.inc
  • _trigger_get_hook_aids() : trigger.module
  • _trigger_normalize_comment_context() : trigger.module
  • _trigger_normalize_node_context() : trigger.module
  • _trigger_normalize_user_context() : trigger.module
  • _unicode_caseflip() : unicode.inc
  • _unicode_check() : unicode.inc
  • _update_build_fetch_url() : update.fetch.inc
  • _update_cron_notify() : update.fetch.inc
  • _update_message_text() : update.module
  • _update_no_data() : update.module
  • _update_process_info_list() : update.compare.inc
  • _update_project_status_sort() : update.module
  • _update_refresh() : update.fetch.inc
  • _update_remove_update_status_variables() : update.install
  • _update_requirement_check() : update.module
  • _upload_file_limits() : upload.module
  • _upload_form() : upload.module
  • _user_categories() : user.module
  • _user_edit_submit() : user.module
  • _user_edit_validate() : user.module
  • _user_forms() : user.module
  • _user_mail_notify() : user.module
  • _user_mail_text() : user.module
  • _user_password_dynamic_validation() : user.module
  • _user_sort() : user.module
  • _xmlrpc() : xmlrpc.inc
  • _xrds_cdata() : xrds.inc
  • _xrds_element_end() : xrds.inc
  • _xrds_element_start() : xrds.inc
  • _xrds_strip_namespace() : xrds.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- l -

  • l() : common.inc
  • language : book-export-html.tpl.php
  • language_default() : bootstrap.inc
  • language_from_browser() : language.inc
  • language_initialize() : language.inc
  • language_list() : bootstrap.inc
  • LANGUAGE_LTR : locale.module
  • LANGUAGE_NEGOTIATION_DOMAIN : bootstrap.inc
  • LANGUAGE_NEGOTIATION_NONE : bootstrap.inc
  • LANGUAGE_NEGOTIATION_PATH : bootstrap.inc
  • LANGUAGE_NEGOTIATION_PATH_DEFAULT : bootstrap.inc
  • LANGUAGE_RTL : locale.module
  • language_url_rewrite() : language.inc
  • link : forum-list.tpl.php
  • list_themes() : theme.inc
  • locale() : locale.module
  • locale_add_language() : locale.inc
  • locale_batch_by_component() : locale.inc
  • locale_batch_by_language() : locale.inc
  • locale_block() : locale.module
  • locale_form_alter() : locale.module
  • locale_get_plural() : locale.module
  • locale_help() : locale.module
  • LOCALE_IMPORT_KEEP : locale.inc
  • LOCALE_IMPORT_OVERWRITE : locale.inc
  • locale_inc_callback() : locale.module
  • locale_install() : locale.install
  • LOCALE_JS_STRING : locale.inc
  • locale_language_list() : locale.module
  • locale_language_name() : locale.module
  • locale_languages_add_screen() : locale.inc
  • locale_languages_configure_form() : locale.inc
  • locale_languages_configure_form_submit() : locale.inc
  • locale_languages_custom_form() : locale.inc
  • locale_languages_delete_form() : locale.inc
  • locale_languages_delete_form_submit() : locale.inc
  • locale_languages_edit_form() : locale.inc
  • locale_languages_edit_form_submit() : locale.inc
  • locale_languages_edit_form_validate() : locale.inc
  • locale_languages_overview_form() : locale.inc
  • locale_languages_overview_form_submit() : locale.inc
  • locale_languages_predefined_form() : locale.inc
  • locale_languages_predefined_form_submit() : locale.inc
  • locale_languages_predefined_form_validate() : locale.inc
  • locale_locale() : locale.module
  • locale_menu() : locale.module
  • locale_perm() : locale.module
  • locale_schema() : locale.install
  • locale_system_update() : locale.module
  • locale_theme() : locale.module
  • locale_translate_delete() : locale.inc
  • locale_translate_edit_form() : locale.inc
  • locale_translate_edit_form_submit() : locale.inc
  • locale_translate_export_po_form() : locale.inc
  • locale_translate_export_po_form_submit() : locale.inc
  • locale_translate_export_pot_form() : locale.inc
  • locale_translate_export_screen() : locale.inc
  • locale_translate_import_form() : locale.inc
  • locale_translate_import_form_submit() : locale.inc
  • locale_translate_overview_screen() : locale.inc
  • locale_translate_seek_form() : locale.inc
  • locale_translate_seek_screen() : locale.inc
  • locale_uninstall() : locale.install
  • locale_update_6000() : locale.install
  • locale_update_6001() : locale.install
  • locale_update_6002() : locale.install
  • locale_update_6003() : locale.install
  • locale_update_6004() : locale.install
  • locale_update_6005() : locale.install
  • locale_update_js_files() : locale.module
  • locale_user() : locale.module
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- m -

  • MAINTENANCE_MODE : install.php , update.php
  • map_month() : form.inc
  • MARK_NEW : theme.inc
  • MARK_READ : theme.inc
  • MARK_UPDATED : theme.inc
  • MENU_ACCESS_DENIED : index.php , menu.inc
  • menu_block() : menu.module
  • menu_cache_clear() : menu.inc
  • menu_cache_clear_all() : menu.inc
  • MENU_CALLBACK : menu.inc
  • menu_configure() : menu.admin.inc
  • MENU_CREATED_BY_ADMIN : menu.inc
  • menu_custom_delete_submit() : menu.admin.inc
  • MENU_DEFAULT_LOCAL_TASK : menu.inc
  • menu_delete_menu_confirm() : menu.admin.inc
  • menu_delete_menu_confirm_submit() : menu.admin.inc
  • menu_delete_menu_page() : menu.admin.inc
  • menu_edit_item() : menu.admin.inc
  • menu_edit_item_submit() : menu.admin.inc
  • menu_edit_item_validate() : menu.admin.inc
  • menu_edit_menu() : menu.admin.inc
  • menu_edit_menu_submit() : menu.admin.inc
  • menu_edit_menu_validate() : menu.admin.inc
  • menu_enable() : menu.module
  • menu_execute_active_handler() : menu.inc
  • menu_form_alter() : menu.module
  • MENU_FOUND : menu.inc
  • menu_get_active_breadcrumb() : menu.inc
  • menu_get_active_help() : menu.inc
  • menu_get_active_menu_name() : menu.inc
  • menu_get_active_title() : menu.inc
  • menu_get_active_trail() : menu.inc
  • menu_get_ancestors() : menu.inc
  • menu_get_item() : menu.inc
  • menu_get_menus() : menu.module
  • menu_get_names() : menu.inc
  • menu_get_object() : menu.inc
  • menu_help() : menu.module
  • menu_install() : menu.install
  • MENU_IS_LOCAL_TASK : menu.inc
  • MENU_IS_ROOT : menu.inc
  • menu_item_delete_form() : menu.admin.inc
  • menu_item_delete_form_submit() : menu.admin.inc
  • menu_item_delete_page() : menu.admin.inc
  • menu_item_delete_submit() : menu.admin.inc
  • menu_link_children_relative_depth() : menu.inc
  • menu_link_delete() : menu.inc
  • menu_link_load() : menu.inc
  • menu_link_maintain() : menu.inc
  • menu_link_save() : menu.inc
  • MENU_LINKS_TO_PARENT : menu.inc
  • menu_list_system_menus() : menu.inc
  • menu_load() : menu.module
  • MENU_LOCAL_TASK : menu.inc
  • menu_local_tasks() : menu.inc
  • MENU_MAX_DEPTH : menu.inc
  • MENU_MAX_MENU_NAME_LENGTH_UI : menu.module
  • MENU_MAX_PARTS : menu.inc
  • menu_menu() : menu.module
  • MENU_MODIFIED_BY_ADMIN : menu.inc
  • menu_navigation_links() : menu.inc
  • menu_node_form_submit() : menu.module
  • menu_nodeapi() : menu.module
  • MENU_NORMAL_ITEM : menu.inc
  • MENU_NOT_FOUND : menu.inc
  • menu_overview_form() : menu.admin.inc
  • menu_overview_form_submit() : menu.admin.inc
  • menu_overview_page() : menu.admin.inc
  • menu_overview_title() : menu.module
  • menu_parent_options() : menu.module
  • menu_path_is_external() : menu.inc
  • menu_perm() : menu.module
  • menu_primary_links() : menu.inc
  • menu_primary_local_tasks() : menu.inc
  • menu_rebuild() : menu.inc
  • menu_reset_item() : menu.module
  • menu_reset_item_confirm() : menu.admin.inc
  • menu_reset_item_confirm_submit() : menu.admin.inc
  • menu_router_build() : menu.inc
  • menu_schema() : menu.install
  • menu_secondary_links() : menu.inc
  • menu_secondary_local_tasks() : menu.inc
  • menu_set_active_item() : menu.inc
  • menu_set_active_menu_name() : menu.inc
  • menu_set_active_trail() : menu.inc
  • menu_set_item() : menu.inc
  • MENU_SITE_OFFLINE : menu.inc , index.php
  • MENU_SUGGESTED_ITEM : menu.inc
  • menu_tab_root_path() : menu.inc
  • menu_tail_to_arg() : menu.inc
  • menu_theme() : menu.module
  • menu_tree() : menu.inc
  • menu_tree_all_data() : menu.inc
  • menu_tree_check_access() : menu.inc
  • menu_tree_collect_node_links() : menu.inc
  • menu_tree_data() : menu.inc
  • menu_tree_output() : menu.inc
  • menu_tree_page_data() : menu.inc
  • menu_uninstall() : menu.install
  • menu_unserialize() : menu.inc
  • menu_valid_path() : menu.inc
  • MENU_VISIBLE_IN_BREADCRUMB : menu.inc
  • MENU_VISIBLE_IN_TREE : menu.inc
  • mime_header_decode() : unicode.inc
  • mime_header_encode() : unicode.inc
  • module : block.tpl.php
  • module_disable() : module.inc
  • module_enable() : module.inc
  • module_exists() : module.inc
  • module_hook() : module.inc
  • module_implements() : module.inc
  • module_invoke() : module.inc
  • module_invoke_all() : module.inc
  • module_iterate() : module.inc
  • module_list() : module.inc
  • module_load_all() : module.inc
  • module_load_all_includes() : module.inc
  • module_load_include() : module.inc
  • module_load_install() : module.inc
  • module_rebuild_cache() : module.inc
  • multipage_form_example_access() : multipage_form_example.module
  • multipage_form_example_custom_submit() : multipage_form_example.module
  • multipage_form_example_custom_validate() : multipage_form_example.module
  • multipage_form_example_delete() : multipage_form_example.module
  • multipage_form_example_elements() : multipage_form_example.module
  • multipage_form_example_form() : multipage_form_example.module
  • multipage_form_example_form_alter() : multipage_form_example.module
  • multipage_form_example_help() : multipage_form_example.module
  • multipage_form_example_load() : multipage_form_example.module
  • multipage_form_example_menu() : multipage_form_example.module
  • multipage_form_example_node_info() : multipage_form_example.module
  • multipage_form_example_pre_render() : multipage_form_example.module
  • multipage_form_example_view() : multipage_form_example.module
  • multipage_form_restore_attributes() : multipage_form_example.module
  • multipage_form_set_attribute() : multipage_form_example.module
  • multipage_form_set_element_visibility() : multipage_form_example.module
  • mysql_is_available() : install.mysql.inc
  • mysqli_is_available() : install.mysqli.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- n -

  • name : forum-list.tpl.php
  • nid : book-node-export-html.tpl.php , node.tpl.php
  • node_access() : node.module
  • node_access_acquire_grants() : node.module
  • node_access_example_form_alter() : node_access_example.module
  • node_access_example_install() : node_access_example.install
  • node_access_example_node_access_records() : node_access_example.module
  • node_access_example_node_grants() : node_access_example.module
  • node_access_example_nodeapi() : node_access_example.module
  • node_access_example_perm() : node_access_example.module
  • node_access_example_schema() : node_access_example.install
  • node_access_example_uninstall() : node_access_example.install
  • node_access_grants() : node.module
  • node_access_needs_rebuild() : node.module
  • node_access_rebuild() : node.module
  • node_access_view_all_nodes() : node.module
  • node_access_write_grants() : node.module
  • node_action_info() : node.module
  • node_add() : node.pages.inc
  • node_add_page() : node.pages.inc
  • node_admin_content() : node.admin.inc
  • node_admin_nodes() : node.admin.inc
  • node_admin_nodes_submit() : node.admin.inc
  • node_admin_nodes_validate() : node.admin.inc
  • node_assign_owner_action() : node.module
  • node_assign_owner_action_form() : node.module
  • node_assign_owner_action_submit() : node.module
  • node_assign_owner_action_validate() : node.module
  • node_block() : node.module
  • node_body_field() : node.pages.inc
  • node_build_content() : node.module
  • node_build_filter_query() : node.admin.inc
  • NODE_BUILD_NORMAL : node.module
  • NODE_BUILD_PREVIEW : node.module
  • NODE_BUILD_PRINT : node.module
  • NODE_BUILD_RSS : node.module
  • NODE_BUILD_SEARCH_INDEX : node.module
  • NODE_BUILD_SEARCH_RESULT : node.module
  • node_comment_mode() : node.module
  • node_configure() : node.admin.inc
  • node_configure_rebuild_confirm() : node.admin.inc
  • node_configure_rebuild_confirm_submit() : node.admin.inc
  • node_configure_validate() : node.admin.inc
  • node_content_access() : node.module
  • node_content_form() : node.module
  • node_cron() : node.module
  • node_db_rewrite_sql() : node.module
  • node_delete() : node.module
  • node_delete_confirm() : node.pages.inc
  • node_delete_confirm_submit() : node.pages.inc
  • node_example_access() : node_example.module
  • node_example_delete() : node_example.module
  • node_example_form() : node_example.module
  • node_example_insert() : node_example.module
  • node_example_install() : node_example.install
  • node_example_load() : node_example.module
  • node_example_node_info() : node_example.module
  • node_example_nodeapi() : node_example.module
  • node_example_perm() : node_example.module
  • node_example_schema() : node_example.install
  • node_example_theme() : node_example.module
  • node_example_uninstall() : node_example.install
  • node_example_update() : node_example.module
  • node_example_validate() : node_example.module
  • node_example_view() : node_example.module
  • node_feed() : node.module
  • node_filter_form() : node.admin.inc
  • node_filter_form_submit() : node.admin.inc
  • node_filters() : node.admin.inc
  • node_form() : node.pages.inc
  • node_form_alter() : node.module
  • node_form_build_preview() : node.pages.inc
  • node_form_delete_submit() : node.pages.inc
  • node_form_submit() : node.pages.inc
  • node_form_submit_build_node() : node.pages.inc
  • node_form_validate() : node.pages.inc
  • node_forms() : node.module
  • node_get_types() : node.module
  • node_help() : node.module
  • node_hook() : node.module
  • node_hook_info() : node.module
  • node_init() : node.module
  • node_invoke() : node.module
  • node_invoke_nodeapi() : node.module
  • node_last_changed() : node.module
  • node_last_viewed() : node.module
  • node_link() : node.module
  • node_load() : node.module
  • node_make_sticky_action() : node.module
  • node_make_unsticky_action() : node.module
  • node_mark() : node.module
  • node_mass_update() : node.admin.inc
  • node_menu() : node.module
  • node_multiple_delete_confirm() : node.admin.inc
  • node_multiple_delete_confirm_submit() : node.admin.inc
  • NODE_NEW_LIMIT : node.module
  • node_node_operations() : node.admin.inc
  • node_node_type() : content_types.inc
  • node_object_prepare() : node.pages.inc
  • node_overview_types() : content_types.inc
  • node_page_default() : node.module
  • node_page_edit() : node.pages.inc
  • node_page_title() : node.module
  • node_page_view() : node.module
  • node_perm() : node.module
  • node_prepare() : node.module
  • node_preview() : node.pages.inc
  • node_promote_action() : node.module
  • node_publish_action() : node.module
  • node_revision_delete_confirm() : node.pages.inc
  • node_revision_delete_confirm_submit() : node.pages.inc
  • node_revision_list() : node.module
  • node_revision_overview() : node.pages.inc
  • node_revision_revert_confirm() : node.pages.inc
  • node_revision_revert_confirm_submit() : node.pages.inc
  • node_save() : node.module
  • node_save_action() : node.module
  • node_schema() : node.install
  • node_search() : node.module
  • node_search_validate() : node.module
  • node_show() : node.module
  • node_submit() : node.module
  • node_tag_new() : node.module
  • node_teaser() : node.module
  • node_teaser_include_verify() : node.module
  • node_teaser_js() : node.module
  • node_theme() : node.module
  • node_title_list() : node.module
  • node_type_delete() : node.module
  • node_type_delete_confirm() : content_types.inc
  • node_type_delete_confirm_submit() : content_types.inc
  • node_type_form() : content_types.inc
  • node_type_form_submit() : content_types.inc
  • node_type_form_validate() : content_types.inc
  • node_type_reset() : content_types.inc
  • node_type_save() : node.module
  • node_type_update_nodes() : node.module
  • node_types_rebuild() : node.module
  • node_unpromote_action() : node.module
  • node_unpublish_action() : node.module
  • node_unpublish_by_keyword_action() : node.module
  • node_unpublish_by_keyword_action_form() : node.module
  • node_unpublish_by_keyword_action_submit() : node.module
  • node_update_index() : node.module
  • node_user() : node.module
  • node_validate() : node.module
  • node_view() : node.module
  • nodeapi_example_form_alter() : nodeapi_example.module
  • nodeapi_example_install() : nodeapi_example.install
  • nodeapi_example_nodeapi() : nodeapi_example.module
  • nodeapi_example_schema() : nodeapi_example.install
  • nodeapi_example_theme() : nodeapi_example.module
  • nodeapi_example_uninstall() : nodeapi_example.install
  • nodeapi_example_update_1() : nodeapi_example.install
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- o -

  • openid_association() : openid.module
  • openid_association_request() : openid.module
  • openid_authentication() : openid.module
  • openid_authentication_page() : openid.pages.inc
  • openid_authentication_request() : openid.module
  • openid_begin() : openid.module
  • openid_complete() : openid.module
  • OPENID_DH_DEFAULT_GEN : openid.inc
  • OPENID_DH_DEFAULT_MOD : openid.inc
  • openid_discovery() : openid.module
  • openid_form_alter() : openid.module
  • openid_help() : openid.module
  • openid_install() : openid.install
  • openid_login_validate() : openid.module
  • openid_menu() : openid.module
  • OPENID_NS_1_0 : openid.inc
  • OPENID_NS_1_1 : openid.inc
  • OPENID_NS_2_0 : openid.inc
  • OPENID_RAND_SOURCE : openid.inc
  • openid_redirect() : openid.inc
  • openid_redirect_form() : openid.inc
  • openid_redirect_http() : openid.inc
  • openid_schema() : openid.install
  • OPENID_SHA1_BLOCKSIZE : openid.inc
  • openid_uninstall() : openid.install
  • openid_user() : openid.module
  • openid_user_add() : openid.pages.inc
  • openid_user_add_validate() : openid.pages.inc
  • openid_user_delete() : openid.pages.inc
  • openid_user_identities() : openid.pages.inc
  • openid_verify_assertion() : openid.module
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- a -

  • actions_actions_map() : actions.inc
  • actions_delete() : actions.inc
  • actions_do() : actions.inc
  • actions_function_lookup() : actions.inc
  • actions_get_all_actions() : actions.inc
  • actions_list() : actions.inc
  • actions_load() : actions.inc
  • actions_save() : actions.inc
  • actions_synchronize() : actions.inc
  • aggregator_admin_overview() : aggregator.admin.inc
  • aggregator_admin_refresh_feed() : aggregator.admin.inc
  • aggregator_admin_remove_feed() : aggregator.admin.inc
  • aggregator_admin_remove_feed_submit() : aggregator.admin.inc
  • aggregator_admin_settings() : aggregator.admin.inc
  • aggregator_block() : aggregator.module
  • aggregator_categorize_items() : aggregator.pages.inc
  • aggregator_categorize_items_submit() : aggregator.pages.inc
  • aggregator_categorize_items_validate() : aggregator.pages.inc
  • aggregator_category_load() : aggregator.module
  • aggregator_cron() : aggregator.module
  • aggregator_element_data() : aggregator.module
  • aggregator_element_end() : aggregator.module
  • aggregator_element_start() : aggregator.module
  • aggregator_feed_items_load() : aggregator.pages.inc
  • aggregator_feed_load() : aggregator.module
  • aggregator_filter_xss() : aggregator.module
  • aggregator_form_category() : aggregator.admin.inc
  • aggregator_form_category_submit() : aggregator.admin.inc
  • aggregator_form_category_validate() : aggregator.admin.inc
  • aggregator_form_feed() : aggregator.admin.inc
  • aggregator_form_feed_submit() : aggregator.admin.inc
  • aggregator_form_feed_validate() : aggregator.admin.inc
  • aggregator_help() : aggregator.module
  • aggregator_init() : aggregator.module
  • aggregator_install() : aggregator.install
  • aggregator_menu() : aggregator.module
  • aggregator_page_categories() : aggregator.pages.inc
  • aggregator_page_category() : aggregator.pages.inc
  • aggregator_page_last() : aggregator.pages.inc
  • aggregator_page_opml() : aggregator.pages.inc
  • aggregator_page_rss() : aggregator.pages.inc
  • aggregator_page_source() : aggregator.pages.inc
  • aggregator_page_sources() : aggregator.pages.inc
  • aggregator_parse_feed() : aggregator.module
  • aggregator_parse_w3cdtf() : aggregator.module
  • aggregator_perm() : aggregator.module
  • aggregator_refresh() : aggregator.module
  • aggregator_remove() : aggregator.module
  • aggregator_save_category() : aggregator.module
  • aggregator_save_feed() : aggregator.module
  • aggregator_save_item() : aggregator.module
  • aggregator_schema() : aggregator.install
  • aggregator_theme() : aggregator.module
  • aggregator_uninstall() : aggregator.install
  • aggregator_view() : aggregator.admin.inc
  • arg() : path.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- b -

  • base_path() : common.inc
  • batch_example_batch_1() : batch_example.module
  • batch_example_batch_2() : batch_example.module
  • batch_example_finished() : batch_example.module
  • batch_example_menu() : batch_example.module
  • batch_example_multistep_form() : batch_example.module
  • batch_example_multistep_form_submit() : batch_example.module
  • batch_example_op_1() : batch_example.module
  • batch_example_op_2() : batch_example.module
  • batch_example_page() : batch_example.module
  • batch_example_simple_form() : batch_example.module
  • batch_example_simple_form_submit() : batch_example.module
  • batch_get() : form.inc
  • batch_process() : form.inc
  • batch_set() : form.inc
  • batch_test_update_1() : batch_example.install
  • block_add_block_form() : block.admin.inc
  • block_add_block_form_submit() : block.admin.inc
  • block_add_block_form_validate() : block.admin.inc
  • block_admin_configure() : block.admin.inc
  • block_admin_configure_submit() : block.admin.inc
  • block_admin_configure_validate() : block.admin.inc
  • block_admin_display() : block.admin.inc
  • block_admin_display_form() : block.admin.inc
  • block_admin_display_form_submit() : block.admin.inc
  • block_block() : block.module
  • block_box_delete() : block.admin.inc
  • block_box_delete_submit() : block.admin.inc
  • block_box_form() : block.module
  • block_box_get() : block.module
  • block_box_save() : block.module
  • BLOCK_CACHE_GLOBAL : block.module
  • BLOCK_CACHE_PER_PAGE : block.module
  • BLOCK_CACHE_PER_ROLE : block.module
  • BLOCK_CACHE_PER_USER : block.module
  • block_example_block() : block_example.module
  • block_example_contents() : block_example.module
  • block_help() : block.module
  • block_list() : block.module
  • block_menu() : block.module
  • BLOCK_NO_CACHE : block.module
  • block_perm() : block.module
  • BLOCK_REGION_NONE : block.module
  • block_schema() : block.install
  • block_theme() : block.module
  • block_user() : block.module
  • blog_access() : blog.module
  • blog_block() : blog.module
  • blog_feed_last() : blog.pages.inc
  • blog_feed_user() : blog.pages.inc
  • blog_form() : blog.module
  • blog_help() : blog.module
  • blog_link() : blog.module
  • blog_menu() : blog.module
  • blog_node_info() : blog.module
  • blog_page_last() : blog.pages.inc
  • blog_page_user() : blog.pages.inc
  • blog_perm() : blog.module
  • blog_user() : blog.module
  • blog_view() : blog.module
  • blogap_mti_publish_post() : blogapi.module
  • blogapi_admin_settings() : blogapi.module
  • blogapi_blogger_delete_post() : blogapi.module
  • blogapi_blogger_edit_post() : blogapi.module
  • blogapi_blogger_get_post() : blogapi.module
  • blogapi_blogger_get_recent_posts() : blogapi.module
  • blogapi_blogger_get_user_info() : blogapi.module
  • blogapi_blogger_get_users_blogs() : blogapi.module
  • blogapi_blogger_new_post() : blogapi.module
  • blogapi_blogger_title() : blogapi.module
  • blogapi_error() : blogapi.module
  • blogapi_help() : blogapi.module
  • blogapi_init() : blogapi.module
  • blogapi_menu() : blogapi.module
  • blogapi_metaweblog_edit_post() : blogapi.module
  • blogapi_metaweblog_get_category_list() : blogapi.module
  • blogapi_metaweblog_get_post() : blogapi.module
  • blogapi_metaweblog_get_recent_posts() : blogapi.module
  • blogapi_metaweblog_new_media_object() : blogapi.module
  • blogapi_metaweblog_new_post() : blogapi.module
  • blogapi_mt_get_category_list() : blogapi.module
  • blogapi_mt_get_post_categories() : blogapi.module
  • blogapi_mt_get_recent_post_titles() : blogapi.module
  • blogapi_mt_set_post_categories() : blogapi.module
  • blogapi_mt_supported_text_filters() : blogapi.module
  • blogapi_perm() : blogapi.module
  • blogapi_rsd() : blogapi.module
  • blogapi_update_6000() : blogapi.install
  • blogapi_validate_user() : blogapi.module
  • blogapi_xmlrpc() : blogapi.module
  • book_admin_edit() : book.admin.inc
  • book_admin_edit_submit() : book.admin.inc
  • book_admin_overview() : book.admin.inc
  • book_admin_settings() : book.admin.inc
  • book_admin_settings_validate() : book.admin.inc
  • book_block() : book.module
  • book_build_active_trail() : book.module
  • book_children() : book.module
  • book_export() : book.pages.inc
  • book_export_html() : book.pages.inc
  • book_export_traverse() : book.module
  • book_form_alter() : book.module
  • book_form_node_delete_confirm_alter() : book.module
  • book_form_update() : book.pages.inc
  • book_get_books() : book.module
  • book_get_flat_menu() : book.module
  • book_help() : book.module
  • book_init() : book.module
  • book_install() : book.install
  • book_link() : book.module
  • book_link_load() : book.module
  • book_menu() : book.module
  • book_menu_name() : book.module
  • book_menu_subtree_data() : book.module
  • book_next() : book.module
  • book_node_export() : book.module
  • book_node_type() : book.module
  • book_nodeapi() : book.module
  • book_outline() : book.pages.inc
  • book_outline_form() : book.pages.inc
  • book_outline_form_submit() : book.pages.inc
  • book_perm() : book.module
  • book_prev() : book.module
  • book_remove_button_submit() : book.pages.inc
  • book_remove_form() : book.pages.inc
  • book_remove_form_submit() : book.pages.inc
  • book_render() : book.pages.inc
  • book_schema() : book.install
  • book_theme() : book.module
  • book_toc() : book.module
  • book_type_is_allowed() : book.module
  • book_uninstall() : book.install
  • book_update_6000() : book.install
  • book_update_bid() : book.module
  • bootstrap_hooks() : bootstrap.inc
  • bootstrap_invoke_all() : bootstrap.inc
  • break : index.php , update.php
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- c -

  • CACHE_AGGRESSIVE : bootstrap.inc
  • cache_clear_all() : cache-install.inc , cache.inc
  • CACHE_DISABLED : bootstrap.inc
  • cache_get() : cache-install.inc , cache.inc
  • CACHE_NORMAL : bootstrap.inc
  • CACHE_PERMANENT : bootstrap.inc
  • cache_set() : cache-install.inc , cache.inc
  • CACHE_TEMPORARY : bootstrap.inc
  • chameleon_comment() : chameleon.theme
  • chameleon_help() : chameleon.theme
  • chameleon_node() : chameleon.theme
  • chameleon_page() : chameleon.theme
  • chameleon_theme() : chameleon.theme
  • check_file() : common.inc
  • check_markup() : filter.module
  • check_plain() : bootstrap.inc
  • check_url() : common.inc
  • color_form_alter() : color.module
  • color_get_info() : color.module
  • color_get_palette() : color.module
  • color_help() : color.module
  • color_requirements() : color.install
  • color_scheme_form() : color.module
  • color_scheme_form_submit() : color.module
  • color_theme() : color.module
  • comment_access() : comment.module
  • comment_action_info() : comment.module
  • comment_admin() : comment.admin.inc
  • comment_admin_overview() : comment.admin.inc
  • comment_admin_overview_submit() : comment.admin.inc
  • comment_admin_overview_validate() : comment.admin.inc
  • COMMENT_ANONYMOUS_MAY_CONTACT : comment.module
  • COMMENT_ANONYMOUS_MAYNOT_CONTACT : comment.module
  • COMMENT_ANONYMOUS_MUST_CONTACT : comment.module
  • comment_block() : comment.module
  • comment_confirm_delete() : comment.admin.inc
  • comment_confirm_delete_submit() : comment.admin.inc
  • comment_controls() : comment.module
  • COMMENT_CONTROLS_ABOVE : comment.module
  • COMMENT_CONTROLS_ABOVE_BELOW : comment.module
  • COMMENT_CONTROLS_BELOW : comment.module
  • COMMENT_CONTROLS_HIDDEN : comment.module
  • comment_controls_submit() : comment.module
  • comment_delete() : comment.admin.inc
  • comment_edit() : comment.pages.inc
  • comment_enable() : comment.install
  • comment_form() : comment.module
  • comment_form_add_preview() : comment.module
  • comment_form_alter() : comment.module
  • COMMENT_FORM_BELOW : comment.module
  • comment_form_box() : comment.module
  • COMMENT_FORM_SEPARATE_PAGE : comment.module
  • comment_form_submit() : comment.module
  • comment_form_validate() : comment.module
  • comment_get_recent() : comment.module
  • comment_help() : comment.module
  • comment_hook_info() : comment.module
  • comment_invoke_comment() : comment.module
  • comment_link() : comment.module
  • comment_links() : comment.module
  • comment_menu() : comment.module
  • COMMENT_MODE_FLAT_COLLAPSED : comment.module
  • COMMENT_MODE_FLAT_EXPANDED : comment.module
  • COMMENT_MODE_THREADED_COLLAPSED : comment.module
  • COMMENT_MODE_THREADED_EXPANDED : comment.module
  • comment_multiple_delete_confirm() : comment.admin.inc
  • comment_multiple_delete_confirm_submit() : comment.admin.inc
  • comment_new_page_count() : comment.module
  • COMMENT_NODE_DISABLED : comment.module
  • COMMENT_NODE_READ_ONLY : comment.module
  • COMMENT_NODE_READ_WRITE : comment.module
  • comment_node_type() : comment.module
  • comment_node_url() : comment.module
  • comment_nodeapi() : comment.module
  • COMMENT_NOT_PUBLISHED : comment.module
  • comment_num_all() : comment.module
  • comment_num_new() : comment.module
  • comment_num_replies() : comment.module
  • comment_operations() : comment.module
  • COMMENT_ORDER_NEWEST_FIRST : comment.module
  • COMMENT_ORDER_OLDEST_FIRST : comment.module
  • comment_perm() : comment.module
  • COMMENT_PREVIEW_OPTIONAL : comment.module
  • COMMENT_PREVIEW_REQUIRED : comment.module
  • COMMENT_PUBLISHED : comment.module
  • comment_render() : comment.module
  • comment_reply() : comment.pages.inc
  • comment_save() : comment.module
  • comment_schema() : comment.install
  • comment_theme() : comment.module
  • comment_unpublish_action() : comment.module
  • comment_unpublish_by_keyword_action() : comment.module
  • comment_unpublish_by_keyword_action_form() : comment.module
  • comment_unpublish_by_keyword_action_submit() : comment.module
  • comment_update_1() : comment.install
  • comment_update_6001() : comment.install
  • comment_update_6002() : comment.install
  • comment_update_6003() : comment.install
  • comment_user() : comment.module
  • comment_validate() : comment.module
  • conf_init() : bootstrap.inc
  • conf_path() : bootstrap.inc
  • confirm_form() : system.module
  • contact_admin_categories() : contact.admin.inc
  • contact_admin_delete() : contact.admin.inc
  • contact_admin_delete_submit() : contact.admin.inc
  • contact_admin_edit() : contact.admin.inc
  • contact_admin_edit_submit() : contact.admin.inc
  • contact_admin_edit_validate() : contact.admin.inc
  • contact_admin_settings() : contact.admin.inc
  • contact_help() : contact.module
  • contact_install() : contact.install
  • contact_load() : contact.module
  • contact_mail() : contact.module
  • contact_mail_page() : contact.pages.inc
  • contact_mail_page_submit() : contact.pages.inc
  • contact_mail_page_validate() : contact.pages.inc
  • contact_mail_user() : contact.pages.inc
  • contact_mail_user_submit() : contact.pages.inc
  • contact_menu() : contact.module
  • contact_perm() : contact.module
  • contact_schema() : contact.install
  • contact_site_page() : contact.pages.inc
  • contact_uninstall() : contact.install
  • contact_user() : contact.module
  • contact_user_page() : contact.pages.inc
  • content : block.tpl.php
  • custom_url_rewrite_inbound() : core.php
  • custom_url_rewrite_outbound() : core.php
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- d -

  • date_validate() : form.inc
  • db_add_column() : update.php
  • db_add_field() : database.pgsql.inc , database.mysql-common.inc
  • db_add_index() : database.mysql-common.inc , database.pgsql.inc
  • db_add_primary_key() : database.pgsql.inc , database.mysql-common.inc
  • db_add_unique_key() : database.mysql-common.inc , database.pgsql.inc
  • db_affected_rows() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_change_column() : update.php
  • db_change_field() : database.pgsql.inc , database.mysql-common.inc
  • db_check_setup() : database.pgsql.inc
  • db_column_exists() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_connect() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_create_table() : database.inc
  • db_create_table_sql() : database.mysql-common.inc , database.pgsql.inc
  • db_decode_blob() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_distinct_field() : database.pgsql.inc , database.mysql.inc , database.mysqli.inc
  • db_drop_field() : database.mysql-common.inc , database.pgsql.inc
  • db_drop_index() : database.mysql-common.inc , database.pgsql.inc
  • db_drop_primary_key() : database.mysql-common.inc , database.pgsql.inc
  • db_drop_table() : database.mysql-common.inc , database.pgsql.inc
  • db_drop_unique_key() : database.mysql-common.inc , database.pgsql.inc
  • db_encode_blob() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • DB_ERROR : database.inc
  • db_error() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_escape_string() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_escape_table() : database.inc
  • db_fetch_array() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_fetch_object() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_field_names() : database.inc
  • db_field_set_default() : database.mysql-common.inc , database.pgsql.inc
  • db_field_set_no_default() : database.pgsql.inc , database.mysql-common.inc
  • db_is_active() : database.inc
  • db_last_insert_id() : database.mysql-common.inc , database.pgsql.inc
  • db_lock_table() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_placeholders() : database.inc
  • db_prefix_tables() : database.inc
  • db_query() : database.mysql-common.inc , database.pgsql.inc
  • db_query_range() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • DB_QUERY_REGEXP : database.inc
  • db_query_temporary() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_rename_table() : database.mysql-common.inc , database.pgsql.inc
  • db_result() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_rewrite_sql() : database.inc
  • db_set_active() : database.inc
  • db_status_report() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_table_exists() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_type_map() : database.mysql-common.inc , database.pgsql.inc
  • db_type_placeholder() : database.inc
  • db_unlock_tables() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_version() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • dblog_admin_settings() : dblog.admin.inc
  • dblog_build_filter_query() : dblog.admin.inc
  • dblog_cron() : dblog.module
  • dblog_event() : dblog.admin.inc
  • dblog_filter_form() : dblog.admin.inc
  • dblog_filter_form_submit() : dblog.admin.inc
  • dblog_filter_form_validate() : dblog.admin.inc
  • dblog_filters() : dblog.admin.inc
  • dblog_help() : dblog.module
  • dblog_init() : dblog.module
  • dblog_install() : dblog.install
  • dblog_menu() : dblog.module
  • dblog_overview() : dblog.admin.inc
  • dblog_schema() : dblog.install
  • dblog_theme() : dblog.module
  • dblog_top() : dblog.admin.inc
  • dblog_uninstall() : dblog.install
  • dblog_user() : dblog.module
  • dblog_watchdog() : dblog.module
  • decode_entities() : unicode.inc
  • default_form_alter() : default.profile
  • default_profile_details() : default.profile
  • default_profile_modules() : default.profile
  • default_profile_task_list() : default.profile
  • default_profile_tasks() : default.profile
  • delta : block.tpl.php
  • do_search() : search.module
  • drupal_access_denied() : common.inc
  • drupal_add_css() : common.inc
  • drupal_add_feed() : common.inc
  • drupal_add_js() : common.inc
  • drupal_add_link() : common.inc
  • drupal_add_tabledrag() : common.inc
  • drupal_alter() : common.inc
  • DRUPAL_ANONYMOUS_RID : bootstrap.inc
  • drupal_anonymous_user() : bootstrap.inc
  • drupal_attributes() : common.inc
  • DRUPAL_AUTHENTICATED_RID : bootstrap.inc
  • drupal_bootstrap() : bootstrap.inc
  • DRUPAL_BOOTSTRAP_ACCESS : bootstrap.inc
  • DRUPAL_BOOTSTRAP_CONFIGURATION : bootstrap.inc
  • DRUPAL_BOOTSTRAP_DATABASE : bootstrap.inc
  • DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE : bootstrap.inc
  • DRUPAL_BOOTSTRAP_FULL : bootstrap.inc
  • DRUPAL_BOOTSTRAP_LANGUAGE : bootstrap.inc
  • DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE : bootstrap.inc
  • DRUPAL_BOOTSTRAP_PATH : bootstrap.inc
  • DRUPAL_BOOTSTRAP_SESSION : bootstrap.inc
  • drupal_build_css_cache() : common.inc
  • drupal_build_js_cache() : common.inc
  • drupal_check_module() : install.inc
  • drupal_check_profile() : install.inc
  • drupal_clear_css_cache() : common.inc
  • drupal_clear_js_cache() : common.inc
  • drupal_clear_path_cache() : common.inc
  • drupal_clone() : common.inc
  • drupal_common_theme() : common.inc
  • drupal_convert_to_utf8() : unicode.inc
  • DRUPAL_CORE_COMPATIBILITY : system.module
  • drupal_cron_cleanup() : common.inc
  • drupal_cron_run() : common.inc
  • drupal_detect_baseurl() : install.inc
  • drupal_detect_database_types() : install.inc
  • drupal_discover_template() : theme.inc
  • drupal_error_handler() : common.inc
  • drupal_eval() : common.inc
  • drupal_execute() : form.inc
  • drupal_explode_tags() : common.inc
  • drupal_find_theme_functions() : theme.inc
  • drupal_find_theme_templates() : theme.inc
  • drupal_flush_all_caches() : common.inc
  • drupal_get_breadcrumb() : common.inc
  • drupal_get_content() : common.inc
  • drupal_get_css() : common.inc
  • drupal_get_destination() : common.inc
  • drupal_get_feeds() : common.inc
  • drupal_get_filename() : bootstrap.inc
  • drupal_get_form() : form.inc
  • drupal_get_headers() : common.inc
  • drupal_get_html_head() : common.inc
  • drupal_get_install_files() : install.inc
  • drupal_get_installed_schema_version() : install.inc
  • drupal_get_js() : common.inc
  • drupal_get_messages() : bootstrap.inc
  • drupal_get_normal_path() : path.inc
  • drupal_get_path() : common.inc
  • drupal_get_path_alias() : path.inc
  • drupal_get_private_key() : common.inc
  • drupal_get_schema() : common.inc
  • drupal_get_schema_unprocessed() : common.inc
  • drupal_get_schema_versions() : install.inc
  • drupal_get_title() : path.inc
  • drupal_get_token() : common.inc
  • drupal_goto() : common.inc
  • drupal_help_arg() : menu.inc
  • drupal_html_to_text() : mail.inc
  • drupal_http_request() : common.inc
  • drupal_implode_tags() : common.inc
  • drupal_init_language() : bootstrap.inc
  • drupal_init_path() : path.inc
  • drupal_install_fix_file() : install.inc
  • drupal_install_mkdir() : install.inc
  • drupal_install_modules() : install.inc
  • drupal_install_profile_name() : install.inc
  • drupal_install_schema() : common.inc
  • drupal_install_system() : install.inc
  • drupal_is_denied() : bootstrap.inc
  • drupal_is_front_page() : path.inc
  • drupal_json() : common.inc
  • drupal_load() : bootstrap.inc
  • drupal_load_stylesheet() : common.inc
  • drupal_load_updates() : install.inc
  • drupal_lookup_path() : path.inc
  • drupal_mail() : mail.inc
  • drupal_mail_send() : mail.inc
  • drupal_maintenance_theme() : bootstrap.inc
  • drupal_map_assoc() : common.inc
  • drupal_match_path() : path.inc
  • DRUPAL_MAXIMUM_TEMP_FILE_AGE : system.module
  • DRUPAL_MINIMUM_MYSQL : system.module
  • DRUPAL_MINIMUM_PGSQL : system.module
  • DRUPAL_MINIMUM_PHP : system.module
  • DRUPAL_MINIMUM_PHP_MEMORY_LIMIT : system.module
  • drupal_not_found() : common.inc
  • drupal_page_cache_header() : bootstrap.inc
  • drupal_page_footer() : common.inc
  • drupal_page_header() : bootstrap.inc
  • drupal_parse_info_file() : common.inc
  • drupal_prepare_form() : form.inc
  • drupal_process_form() : form.inc
  • drupal_query_string_encode() : common.inc
  • drupal_rebuild_form() : form.inc
  • drupal_rebuild_theme_registry() : theme.inc
  • drupal_redirect_form() : form.inc
  • drupal_render() : common.inc
  • drupal_render_form() : form.inc
  • drupal_required_modules() : module.inc
  • drupal_requirements_severity() : install.inc
  • drupal_retrieve_form() : form.inc
  • drupal_rewrite_settings() : install.inc
  • drupal_schema_fields_sql() : common.inc
  • drupal_set_breadcrumb() : common.inc
  • drupal_set_content() : common.inc
  • drupal_set_header() : common.inc
  • drupal_set_html_head() : common.inc
  • drupal_set_installed_schema_version() : install.inc
  • drupal_set_message() : bootstrap.inc
  • drupal_set_title() : path.inc
  • drupal_site_offline() : common.inc
  • drupal_strlen() : unicode.inc
  • drupal_strtolower() : unicode.inc
  • drupal_strtoupper() : unicode.inc
  • drupal_substr() : unicode.inc
  • drupal_system_listing() : common.inc
  • drupal_test_mysql() : install.mysql.inc
  • drupal_test_mysqli() : install.mysqli.inc
  • drupal_test_pgsql() : install.pgsql.inc
  • drupal_to_js() : common.inc
  • drupal_truncate_bytes() : unicode.inc
  • drupal_ucfirst() : unicode.inc
  • drupal_uninstall_module() : install.inc
  • drupal_uninstall_schema() : common.inc
  • drupal_unpack() : bootstrap.inc
  • drupal_unset_globals() : bootstrap.inc
  • drupal_urlencode() : common.inc
  • drupal_valid_token() : common.inc
  • drupal_validate_form() : form.inc
  • drupal_validate_utf8() : bootstrap.inc
  • drupal_verify_install_file() : install.inc
  • drupal_verify_profile() : install.inc
  • drupal_wrap_mail() : mail.inc
  • drupal_write_record() : common.inc
  • drupal_xml_parser_create() : unicode.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- e -

  • element_child() : common.inc
  • element_children() : common.inc
  • element_properties() : common.inc
  • element_property() : common.inc
  • element_sort() : common.inc
  • EMAIL_MAX_LENGTH : user.module
  • endif : block-admin-display-form.tpl.php , book-navigation.tpl.php , forum-submitted.tpl.php , forum-topic-navigation.tpl.php , forums.tpl.php , maintenance-page.tpl.php , aggregator-item.tpl.php , page.tpl.php
  • example_element_demo_form() : example_element.module
  • example_element_elements() : example_element.module
  • example_element_menu() : example_element.module
  • example_element_phonenumber_expand() : example_element.module
  • example_element_phonenumber_validate() : example_element.module
  • example_element_theme() : example_element.module
  • example_form() : example.profile
  • example_form_alter() : example.profile
  • example_form_submit() : example.profile
  • example_profile_details() : example.profile
  • example_profile_modules() : example.profile
  • example_profile_task_list() : example.profile
  • example_profile_tasks() : example.profile
  • exit : update.php
  • expand_checkboxes() : form.inc
  • expand_date() : form.inc
  • expand_hidden_array() : multipage_form_example.module
  • expand_password_confirm() : form.inc
  • expand_radios() : form.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- f -

  • file_check_directory() : file.inc
  • file_check_location() : file.inc
  • file_check_path() : file.inc
  • file_copy() : file.inc
  • FILE_CREATE_DIRECTORY : file.inc
  • file_create_filename() : file.inc
  • file_create_path() : file.inc
  • file_create_url() : file.inc
  • file_delete() : file.inc
  • file_destination() : file.inc
  • file_directory_path() : file.inc
  • file_directory_temp() : file.inc
  • file_download() : file.inc
  • FILE_DOWNLOADS_PRIVATE : file.inc
  • FILE_DOWNLOADS_PUBLIC : file.inc
  • FILE_EXECUTABLE : install.inc
  • FILE_EXIST : install.inc
  • FILE_EXISTS_ERROR : file.inc
  • FILE_EXISTS_RENAME : file.inc
  • FILE_EXISTS_REPLACE : file.inc
  • FILE_MODIFY_PERMISSIONS : file.inc
  • file_move() : file.inc
  • file_munge_filename() : file.inc
  • FILE_NOT_EXECUTABLE : install.inc
  • FILE_NOT_EXIST : install.inc
  • FILE_NOT_READABLE : install.inc
  • FILE_NOT_WRITABLE : install.inc
  • FILE_READABLE : install.inc
  • file_save_data() : file.inc
  • file_save_upload() : file.inc
  • file_scan_directory() : file.inc
  • file_set_status() : file.inc
  • file_space_used() : file.inc
  • FILE_STATUS_PERMANENT : file.inc
  • FILE_STATUS_TEMPORARY : file.inc
  • file_transfer() : file.inc
  • file_unmunge_filename() : file.inc
  • file_upload_max_size() : file.inc
  • file_validate_extensions() : file.inc
  • file_validate_image_resolution() : file.inc
  • file_validate_is_image() : file.inc
  • file_validate_name_length() : file.inc
  • file_validate_size() : file.inc
  • FILE_WRITABLE : install.inc
  • fileupload_access() : fileupload.module
  • fileupload_delete() : fileupload.module
  • fileupload_file_download() : fileupload.module
  • fileupload_form() : fileupload.module
  • fileupload_help() : fileupload.module
  • fileupload_insert() : fileupload.module
  • fileupload_load() : fileupload.module
  • fileupload_menu() : fileupload.module
  • fileupload_node_info() : fileupload.module
  • fileupload_perm() : fileupload.module
  • fileupload_submit() : fileupload.module
  • fileupload_update() : fileupload.module
  • fileupload_validate() : fileupload.module
  • fileupload_view() : fileupload.module
  • filter_access() : filter.module
  • filter_admin_configure() : filter.admin.inc
  • filter_admin_configure_page() : filter.admin.inc
  • filter_admin_configure_submit() : filter.admin.inc
  • filter_admin_delete() : filter.admin.inc
  • filter_admin_delete_submit() : filter.admin.inc
  • filter_admin_format_form() : filter.admin.inc
  • filter_admin_format_form_submit() : filter.admin.inc
  • filter_admin_format_form_validate() : filter.admin.inc
  • filter_admin_format_page() : filter.admin.inc
  • filter_admin_format_title() : filter.module
  • filter_admin_order() : filter.admin.inc
  • filter_admin_order_page() : filter.admin.inc
  • filter_admin_order_submit() : filter.admin.inc
  • filter_admin_overview() : filter.admin.inc
  • filter_admin_overview_submit() : filter.admin.inc
  • filter_cron() : filter.module
  • filter_example_filter() : filter_example.module
  • filter_example_filter_tips() : filter_example.module
  • filter_filter() : filter.module
  • filter_filter_tips() : filter.module
  • filter_form() : filter.module
  • filter_form_validate() : filter.module
  • filter_format_allowcache() : filter.module
  • FILTER_FORMAT_DEFAULT : filter.module
  • filter_format_load() : filter.module
  • filter_formats() : filter.module
  • filter_help() : filter.module
  • FILTER_HTML_ESCAPE : filter.module
  • FILTER_HTML_STRIP : filter.module
  • filter_list_all() : filter.module
  • filter_list_format() : filter.module
  • filter_menu() : filter.module
  • filter_perm() : filter.module
  • filter_resolve_format() : filter.module
  • filter_schema() : filter.install
  • filter_theme() : filter.module
  • filter_tips_long() : filter.pages.inc
  • filter_xss() : filter.module
  • filter_xss_admin() : filter.module
  • filter_xss_bad_protocol() : filter.module
  • fix_gpc_magic() : common.inc
  • flood_is_allowed() : common.inc
  • flood_register_event() : common.inc
  • form_builder() : form.inc
  • form_clean_id() : form.inc
  • form_error() : form.inc
  • form_execute_handlers() : form.inc
  • form_expand_ahah() : form.inc
  • form_get_cache() : form.inc
  • form_get_error() : form.inc
  • form_get_errors() : form.inc
  • form_get_options() : form.inc
  • form_options_flatten() : form.inc
  • form_select_options() : form.inc
  • form_set_cache() : form.inc
  • form_set_error() : form.inc
  • form_set_value() : form.inc
  • form_type_checkbox_value() : form.inc
  • form_type_checkboxes_value() : form.inc
  • form_type_image_button_value() : form.inc
  • form_type_password_confirm_value() : form.inc
  • form_type_select_value() : form.inc
  • form_type_textfield_value() : form.inc
  • form_type_token_value() : form.inc
  • format_date() : common.inc
  • format_interval() : common.inc
  • format_plural() : common.inc
  • format_rss_channel() : common.inc
  • format_rss_item() : common.inc
  • format_size() : common.inc
  • format_xml_elements() : common.inc
  • forum_access() : forum.module
  • forum_admin_settings() : forum.admin.inc
  • forum_block() : forum.module
  • forum_confirm_delete() : forum.admin.inc
  • forum_confirm_delete_submit() : forum.admin.inc
  • forum_enable() : forum.install
  • forum_form() : forum.module
  • forum_form_alter() : forum.module
  • forum_form_container() : forum.admin.inc
  • forum_form_forum() : forum.admin.inc
  • forum_form_main() : forum.admin.inc
  • forum_form_submit() : forum.admin.inc
  • forum_get_forums() : forum.module
  • forum_get_topics() : forum.module
  • forum_help() : forum.module
  • forum_init() : forum.module
  • forum_install() : forum.install
  • forum_link_alter() : forum.module
  • forum_load() : forum.module
  • forum_menu() : forum.module
  • forum_node_info() : forum.module
  • forum_nodeapi() : forum.module
  • forum_overview() : forum.admin.inc
  • forum_page() : forum.pages.inc
  • forum_perm() : forum.module
  • forum_schema() : forum.install
  • forum_taxonomy() : forum.module
  • forum_term_load() : forum.module
  • forum_theme() : forum.module
  • forum_uninstall() : forum.install
  • forum_update_6000() : forum.install
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- g -

  • get_t() : bootstrap.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- h -

  • help_help() : help.module
  • help_links_as_list() : help.admin.inc
  • help_main() : help.admin.inc
  • help_menu() : help.module
  • help_page() : help.admin.inc
  • hook_access() : node.php
  • hook_block() : core.php
  • hook_boot() : core.php
  • hook_comment() : core.php
  • hook_cron() : core.php
  • hook_db_rewrite_sql() : core.php
  • hook_delete() : node.php
  • hook_disable() : install.php
  • hook_elements() : core.php
  • hook_enable() : install.php
  • hook_exit() : core.php
  • hook_file_download() : core.php
  • hook_filter() : core.php
  • hook_filter_tips() : core.php
  • hook_footer() : core.php
  • hook_form() : node.php
  • hook_form_alter() : core.php
  • hook_forms() : core.php
  • hook_help() : core.php
  • hook_init() : core.php
  • hook_insert() : node.php
  • hook_install() : install.php
  • hook_link() : core.php
  • hook_link_alter() : core.php
  • hook_load() : node.php
  • hook_mail() : core.php
  • hook_mail_alter() : core.php
  • hook_menu() : core.php
  • hook_menu_alter() : core.php
  • hook_menu_link_alter() : core.php
  • hook_node_access_records() : core.php
  • hook_node_grants() : core.php
  • hook_node_info() : node.php
  • hook_node_operations() : core.php
  • hook_node_type() : node.php
  • hook_nodeapi() : core.php
  • hook_perm() : core.php
  • hook_ping() : core.php
  • hook_prepare() : node.php
  • hook_profile_alter() : core.php
  • hook_requirements() : install.php
  • hook_schema() : install.php
  • hook_search() : core.php
  • hook_search_preprocess() : core.php
  • hook_submit() : node.php
  • hook_taxonomy() : core.php
  • hook_theme() : core.php
  • hook_translated_menu_link_alter() : core.php
  • hook_uninstall() : install.php
  • hook_update() : node.php
  • hook_update_index() : core.php
  • hook_update_N() : install.php
  • hook_user() : core.php
  • hook_user_operations() : core.php
  • hook_validate() : node.php
  • hook_view() : node.php
  • hook_watchdog() : core.php
  • hook_xmlrpc() : core.php
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- i -

  • image_crop() : image.inc
  • image_gd_check_settings() : image.gd.inc
  • image_gd_close() : image.gd.inc
  • image_gd_crop() : image.gd.inc
  • image_gd_info() : image.gd.inc
  • image_gd_open() : image.gd.inc
  • image_gd_resize() : image.gd.inc
  • image_gd_rotate() : image.gd.inc
  • image_gd_settings() : image.gd.inc
  • image_gd_settings_validate() : image.gd.inc
  • image_get_available_toolkits() : image.inc
  • image_get_info() : image.inc
  • image_get_toolkit() : image.inc
  • image_resize() : image.inc
  • image_rotate() : image.inc
  • image_scale() : image.inc
  • image_scale_and_crop() : image.inc
  • image_toolkit_invoke() : image.inc
  • init_theme() : theme.inc
  • install_already_done_error() : install.php
  • install_change_settings() : install.php
  • install_check_requirements() : install.php
  • install_configure_form() : install.php
  • install_configure_form_submit() : install.php
  • install_configure_form_validate() : install.php
  • install_find_locales() : install.php
  • install_find_profiles() : install.php
  • install_goto() : install.inc
  • install_main() : install.php
  • install_no_profile_error() : install.php
  • install_reserved_tasks() : install.php
  • install_select_locale() : install.php
  • install_select_locale_form() : install.php
  • install_select_profile() : install.php
  • install_select_profile_form() : install.php
  • install_settings_form() : install.php
  • install_settings_form_submit() : install.php
  • install_settings_form_validate() : install.php
  • install_task_list() : install.php
  • install_tasks() : install.php
  • install_verify_drupal() : install.php
  • install_verify_settings() : install.php
  • int2vancode() : comment.module
  • ip_address() : bootstrap.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- p -

  • page_example_baz() : page_example.module
  • page_example_foo() : page_example.module
  • page_example_help() : page_example.module
  • page_example_menu() : page_example.module
  • page_example_perm() : page_example.module
  • page_get_cache() : bootstrap.inc
  • page_set_cache() : common.inc
  • pager_get_querystring() : pager.inc
  • pager_load_array() : pager.inc
  • pager_query() : pager.inc
  • parse_size() : common.inc
  • password_confirm_validate() : form.inc
  • path_admin_delete() : path.module
  • path_admin_delete_confirm() : path.admin.inc
  • path_admin_delete_confirm_submit() : path.admin.inc
  • path_admin_edit() : path.admin.inc
  • path_admin_filter_form() : path.admin.inc
  • path_admin_filter_form_submit_filter() : path.admin.inc
  • path_admin_filter_form_submit_reset() : path.admin.inc
  • path_admin_filter_get_keys() : path.admin.inc
  • path_admin_form() : path.admin.inc
  • path_admin_form_submit() : path.admin.inc
  • path_admin_form_validate() : path.admin.inc
  • path_admin_overview() : path.admin.inc
  • path_form_alter() : path.module
  • path_help() : path.module
  • path_load() : path.module
  • path_menu() : path.module
  • path_nodeapi() : path.module
  • path_perm() : path.module
  • path_set_alias() : path.module
  • path_to_theme() : theme.inc
  • pgsql_is_available() : install.pgsql.inc
  • php_disable() : php.install
  • php_filter() : php.module
  • php_filter_tips() : php.module
  • php_help() : php.module
  • php_install() : php.install
  • phptemplate_body_class() : template.php
  • phptemplate_breadcrumb() : template.php
  • phptemplate_comment_submitted() : template.php
  • phptemplate_comment_wrapper() : template.php
  • phptemplate_get_ie_styles() : template.php
  • phptemplate_init() : phptemplate.engine
  • phptemplate_menu_local_tasks() : template.php
  • phptemplate_node_submitted() : template.php
  • phptemplate_preprocess_page() : template.php
  • phptemplate_theme() : phptemplate.engine
  • ping_cron() : ping.module
  • ping_help() : ping.module
  • ping_ping() : ping.module
  • poll_access() : poll.module
  • poll_block() : poll.module
  • poll_cancel() : poll.module
  • poll_cancel_form() : poll.module
  • poll_choice_js() : poll.module
  • poll_cron() : poll.module
  • poll_delete() : poll.module
  • poll_form() : poll.module
  • poll_help() : poll.module
  • poll_init() : poll.module
  • poll_insert() : poll.module
  • poll_install() : poll.install
  • poll_load() : poll.module
  • poll_menu() : poll.module
  • poll_more_choices_submit() : poll.module
  • poll_node_form_submit() : poll.module
  • poll_node_info() : poll.module
  • poll_page() : poll.pages.inc
  • poll_perm() : poll.module
  • poll_results() : poll.pages.inc
  • poll_schema() : poll.install
  • poll_teaser() : poll.module
  • poll_theme() : poll.module
  • poll_uninstall() : poll.install
  • poll_update() : poll.module
  • poll_user() : poll.module
  • poll_validate() : poll.module
  • poll_view() : poll.module
  • poll_view_results() : poll.module
  • poll_view_voting() : poll.module
  • poll_view_voting_validate() : poll.module
  • poll_vote() : poll.module
  • poll_votes() : poll.pages.inc
  • PREG_CLASS_CJK : search.module
  • PREG_CLASS_NUMBERS : search.module
  • PREG_CLASS_PUNCTUATION : search.module
  • PREG_CLASS_SEARCH_EXCLUDE : search.module
  • process_weight() : form.inc
  • profile_admin_overview() : profile.admin.inc
  • profile_admin_overview_submit() : profile.admin.inc
  • profile_admin_settings_autocomplete() : profile.admin.inc
  • profile_autocomplete() : profile.pages.inc
  • profile_block() : profile.module
  • profile_browse() : profile.pages.inc
  • profile_categories() : profile.module
  • profile_category_access() : profile.module
  • profile_field_delete() : profile.admin.inc
  • profile_field_delete_submit() : profile.admin.inc
  • profile_field_form() : profile.admin.inc
  • profile_field_form_submit() : profile.admin.inc
  • profile_field_form_validate() : profile.admin.inc
  • profile_form_profile() : profile.module
  • profile_help() : profile.module
  • PROFILE_HIDDEN : profile.module
  • profile_install() : profile.install
  • profile_load_profile() : profile.module
  • profile_menu() : profile.module
  • PROFILE_PRIVATE : profile.module
  • PROFILE_PUBLIC : profile.module
  • PROFILE_PUBLIC_LISTINGS : profile.module
  • profile_save_profile() : profile.module
  • profile_schema() : profile.install
  • profile_theme() : profile.module
  • profile_uninstall() : profile.install
  • profile_user() : profile.module
  • profile_validate_profile() : profile.module
  • profile_view_field() : profile.module
  • profile_view_profile() : profile.module
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- r -

  • referer_uri() : bootstrap.inc
  • request_uri() : bootstrap.inc
  • REQUIREMENT_ERROR : install.inc
  • REQUIREMENT_INFO : install.inc
  • REQUIREMENT_OK : install.inc
  • REQUIREMENT_WARNING : install.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- s -

  • SAVED_DELETED : common.inc
  • SAVED_NEW : common.inc
  • SAVED_UPDATED : common.inc
  • SCHEMA_INSTALLED : install.inc
  • SCHEMA_UNINSTALLED : install.inc
  • search_admin_settings() : search.admin.inc
  • search_admin_settings_validate() : search.admin.inc
  • search_block() : search.module
  • search_box() : search.module
  • search_box_form_submit() : search.module
  • search_comment() : search.module
  • search_cron() : search.module
  • search_data() : search.module
  • search_dirty() : search.module
  • search_excerpt() : search.module
  • search_expand_cjk() : search.module
  • search_form() : search.module
  • search_form_submit() : search.pages.inc
  • search_form_validate() : search.pages.inc
  • search_forms() : search.module
  • search_get_keys() : search.module
  • search_help() : search.module
  • search_index() : search.module
  • search_index_split() : search.module
  • search_install() : search.install
  • search_invoke_preprocess() : search.module
  • search_menu() : search.module
  • search_nodeapi() : search.module
  • search_parse_query() : search.module
  • search_perm() : search.module
  • search_query_extract() : search.module
  • search_query_insert() : search.module
  • search_schema() : search.install
  • search_simplify() : search.module
  • search_theme() : search.module
  • search_touch_node() : search.module
  • search_uninstall() : search.install
  • search_update_totals() : search.module
  • search_view() : search.pages.inc
  • search_wipe() : search.module
  • search_wipe_confirm() : search.admin.inc
  • search_wipe_confirm_submit() : search.admin.inc
  • sess_close() : session.inc
  • sess_count() : session.inc
  • sess_destroy_sid() : session.inc
  • sess_destroy_uid() : session.inc
  • sess_gc() : session.inc
  • sess_open() : session.inc
  • sess_read() : session.inc
  • sess_regenerate() : session.inc
  • sess_write() : session.inc
  • session_save_session() : session.inc
  • st() : install.inc
  • statistics_access_log() : statistics.admin.inc
  • statistics_access_logging_settings() : statistics.admin.inc
  • statistics_block() : statistics.module
  • statistics_cron() : statistics.module
  • statistics_exit() : statistics.module
  • statistics_get() : statistics.module
  • statistics_help() : statistics.module
  • statistics_install() : statistics.install
  • statistics_link() : statistics.module
  • statistics_menu() : statistics.module
  • statistics_node_tracker() : statistics.pages.inc
  • statistics_nodeapi() : statistics.module
  • statistics_perm() : statistics.module
  • statistics_recent_hits() : statistics.admin.inc
  • statistics_schema() : statistics.install
  • statistics_title_list() : statistics.module
  • statistics_top_pages() : statistics.admin.inc
  • statistics_top_referrers() : statistics.admin.inc
  • statistics_top_visitors() : statistics.admin.inc
  • statistics_uninstall() : statistics.install
  • statistics_update_1000() : statistics.install
  • statistics_user() : statistics.module
  • statistics_user_tracker() : statistics.pages.inc
  • subject : block.tpl.php
  • system_action_delete_orphans_post() : system.module
  • system_action_info() : system.module
  • system_actions_configure() : system.module
  • system_actions_configure_submit() : system.module
  • system_actions_configure_validate() : system.module
  • system_actions_delete_form() : system.module
  • system_actions_delete_form_submit() : system.module
  • system_actions_manage() : system.module
  • system_actions_manage_form() : system.module
  • system_actions_manage_form_submit() : system.module
  • system_actions_remove_orphans() : system.module
  • system_admin_by_module() : system.admin.inc
  • system_admin_compact_mode() : system.module
  • system_admin_compact_page() : system.admin.inc
  • system_admin_menu_block() : system.module
  • system_admin_menu_block_page() : system.admin.inc
  • system_admin_theme_settings() : system.admin.inc
  • system_admin_theme_submit() : system.module
  • system_batch_page() : system.admin.inc
  • system_block() : system.module
  • system_check_directory() : system.module
  • system_check_http_request() : system.module
  • system_clean_url_settings() : system.admin.inc
  • system_clear_cache_submit() : system.admin.inc
  • system_cron() : system.module
  • system_date_time_lookup() : system.admin.inc
  • system_date_time_settings() : system.admin.inc
  • system_date_time_settings_submit() : system.admin.inc
  • system_default_region() : system.module
  • system_elements() : system.module
  • system_error_reporting_settings() : system.admin.inc
  • system_file_system_settings() : system.admin.inc
  • system_find_base_theme() : system.module
  • system_get_files_database() : system.module
  • system_get_module_admin_tasks() : system.module
  • system_goto_action() : system.module
  • system_goto_action_form() : system.module
  • system_goto_action_submit() : system.module
  • system_help() : system.module
  • system_hook_info() : system.module
  • system_image_toolkit_settings() : system.admin.inc
  • system_init() : system.module
  • system_initialize_theme_blocks() : system.module
  • system_install() : system.install
  • system_logging_overview() : system.admin.inc
  • system_mail() : system.module
  • system_main_admin_page() : system.admin.inc
  • system_menu() : system.module
  • system_message_action() : system.module
  • system_message_action_form() : system.module
  • system_message_action_submit() : system.module
  • system_module_build_dependencies() : system.admin.inc
  • system_modules() : system.admin.inc
  • system_modules_confirm_form() : system.admin.inc
  • system_modules_disable() : system.admin.inc
  • system_modules_submit() : system.admin.inc
  • system_modules_uninstall() : system.admin.inc
  • system_modules_uninstall_confirm_form() : system.admin.inc
  • system_modules_uninstall_submit() : system.admin.inc
  • system_modules_uninstall_validate() : system.admin.inc
  • system_node_type() : system.module
  • system_performance_settings() : system.admin.inc
  • system_perm() : system.module
  • system_php() : system.admin.inc
  • system_region_list() : system.module
  • system_requirements() : system.install
  • system_rss_feeds_settings() : system.admin.inc
  • system_run_cron() : system.admin.inc
  • system_schema() : system.install
  • system_send_email_action() : system.module
  • system_send_email_action_form() : system.module
  • system_send_email_action_submit() : system.module
  • system_send_email_action_validate() : system.module
  • system_settings_form() : system.module
  • system_settings_form_submit() : system.module
  • system_settings_overview() : system.admin.inc
  • system_site_information_settings() : system.admin.inc
  • system_site_information_settings_validate() : system.admin.inc
  • system_site_maintenance_settings() : system.admin.inc
  • system_sort_modules_by_info_name() : system.admin.inc
  • system_sql() : system.admin.inc
  • system_status() : system.admin.inc
  • system_theme() : system.module
  • system_theme_data() : system.module
  • system_theme_default() : system.module
  • system_theme_select_form() : system.module
  • system_theme_settings() : system.admin.inc
  • system_theme_settings_submit() : system.admin.inc
  • system_themes_form() : system.admin.inc
  • system_themes_form_submit() : system.admin.inc
  • system_update_1022() : system.install
  • system_update_6000() : system.install
  • system_update_6001() : system.install
  • system_update_6002() : system.install
  • system_update_6003() : system.install
  • system_update_6004() : system.install
  • system_update_6005() : system.install
  • system_update_6006() : system.install
  • system_update_6007() : system.install
  • system_update_6008() : system.install
  • system_update_6009() : system.install
  • system_update_6010() : system.install
  • system_update_6011() : system.install
  • system_update_6012() : system.install
  • system_update_6013() : system.install
  • system_update_6014() : system.install
  • system_update_6015() : system.install
  • system_update_6016() : system.install
  • system_update_6017() : system.install
  • system_update_6018() : system.install
  • system_update_6019() : system.install
  • system_update_6020() : system.install
  • system_update_6021() : system.install
  • system_update_6022() : system.install
  • system_update_6023() : system.install
  • system_update_6024() : system.install
  • system_update_6025() : system.install
  • system_update_6026() : system.install
  • system_update_6027() : system.install
  • system_update_6028() : system.install
  • system_update_6029() : system.install
  • system_update_6030() : system.install
  • system_update_6031() : system.install
  • system_update_6032() : system.install
  • system_update_6033() : system.install
  • system_update_6034() : system.install
  • system_update_6035() : system.install
  • system_update_6036() : system.install
  • system_update_6037() : system.install
  • system_update_6038() : system.install
  • system_update_6039() : system.install
  • system_update_6040() : system.install
  • system_update_6041() : system.install
  • system_update_6042() : system.install
  • system_update_6043() : system.install
  • system_update_6044() : system.install
  • system_update_6045() : system.install
  • system_update_6046() : system.install
  • system_update_6047() : system.install
  • system_update_last_removed() : system.install
  • system_user() : system.module
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- t -

  • t() : common.inc
  • tablesort_cell() : tablesort.inc
  • tablesort_get_order() : tablesort.inc
  • tablesort_get_querystring() : tablesort.inc
  • tablesort_get_sort() : tablesort.inc
  • tablesort_header() : tablesort.inc
  • tablesort_init() : tablesort.inc
  • tablesort_sql() : tablesort.inc
  • taxonomy_add_term_page() : taxonomy.admin.inc
  • taxonomy_admin_term_edit() : taxonomy.admin.inc
  • taxonomy_admin_vocabulary_edit() : taxonomy.admin.inc
  • taxonomy_autocomplete() : taxonomy.pages.inc
  • taxonomy_check_vocabulary_hierarchy() : taxonomy.module
  • taxonomy_del_term() : taxonomy.module
  • taxonomy_del_vocabulary() : taxonomy.module
  • taxonomy_form() : taxonomy.module
  • taxonomy_form_all() : taxonomy.module
  • taxonomy_form_alter() : taxonomy.module
  • taxonomy_form_term() : taxonomy.admin.inc
  • taxonomy_form_term_submit() : taxonomy.admin.inc
  • taxonomy_form_term_validate() : taxonomy.admin.inc
  • taxonomy_form_vocabulary() : taxonomy.admin.inc
  • taxonomy_form_vocabulary_submit() : taxonomy.admin.inc
  • taxonomy_get_children() : taxonomy.module
  • taxonomy_get_parents() : taxonomy.module
  • taxonomy_get_parents_all() : taxonomy.module
  • taxonomy_get_related() : taxonomy.module
  • taxonomy_get_synonym_root() : taxonomy.module
  • taxonomy_get_synonyms() : taxonomy.module
  • taxonomy_get_term() : taxonomy.module
  • taxonomy_get_term_by_name() : taxonomy.module
  • taxonomy_get_tree() : taxonomy.module
  • taxonomy_get_vocabularies() : taxonomy.module
  • taxonomy_help() : taxonomy.module
  • taxonomy_hook_info() : taxonomy.module
  • taxonomy_implode_tags() : taxonomy.module
  • taxonomy_link() : taxonomy.module
  • taxonomy_menu() : taxonomy.module
  • taxonomy_node_delete() : taxonomy.module
  • taxonomy_node_delete_revision() : taxonomy.module
  • taxonomy_node_get_terms() : taxonomy.module
  • taxonomy_node_get_terms_by_vocabulary() : taxonomy.module
  • taxonomy_node_save() : taxonomy.module
  • taxonomy_node_type() : taxonomy.module
  • taxonomy_node_update_index() : taxonomy.module
  • taxonomy_node_validate() : taxonomy.module
  • taxonomy_nodeapi() : taxonomy.module
  • taxonomy_overview_terms() : taxonomy.admin.inc
  • taxonomy_overview_terms_submit() : taxonomy.admin.inc
  • taxonomy_overview_vocabularies() : taxonomy.admin.inc
  • taxonomy_overview_vocabularies_submit() : taxonomy.admin.inc
  • taxonomy_perm() : taxonomy.module
  • taxonomy_preview_terms() : taxonomy.module
  • taxonomy_render_nodes() : taxonomy.module
  • taxonomy_rss_item() : taxonomy.module
  • taxonomy_save_term() : taxonomy.module
  • taxonomy_save_vocabulary() : taxonomy.module
  • taxonomy_schema() : taxonomy.install
  • taxonomy_select_nodes() : taxonomy.module
  • taxonomy_term_confirm_delete() : taxonomy.admin.inc
  • taxonomy_term_confirm_delete_submit() : taxonomy.admin.inc
  • taxonomy_term_confirm_parents() : taxonomy.admin.inc
  • taxonomy_term_count_nodes() : taxonomy.module
  • taxonomy_term_page() : taxonomy.pages.inc
  • taxonomy_term_path() : taxonomy.module
  • taxonomy_terms_parse_string() : taxonomy.module
  • taxonomy_theme() : taxonomy.module
  • taxonomy_vocabulary_confirm_delete() : taxonomy.admin.inc
  • taxonomy_vocabulary_confirm_delete_submit() : taxonomy.admin.inc
  • taxonomy_vocabulary_confirm_reset_alphabetical() : taxonomy.admin.inc
  • taxonomy_vocabulary_confirm_reset_alphabetical_submit() : taxonomy.admin.inc
  • taxonomy_vocabulary_load() : taxonomy.module
  • template_preprocess() : theme.inc
  • template_preprocess_aggregator_feed_source() : aggregator.pages.inc
  • template_preprocess_aggregator_item() : aggregator.pages.inc
  • template_preprocess_aggregator_summary_item() : aggregator.pages.inc
  • template_preprocess_aggregator_summary_items() : aggregator.pages.inc
  • template_preprocess_aggregator_wrapper() : aggregator.pages.inc
  • template_preprocess_block() : theme.inc
  • template_preprocess_block_admin_display_form() : block.admin.inc
  • template_preprocess_book_export_html() : book.module
  • template_preprocess_book_navigation() : book.module
  • template_preprocess_book_node_export_html() : book.module
  • template_preprocess_comment() : comment.module
  • template_preprocess_comment_folded() : comment.module
  • template_preprocess_comment_wrapper() : comment.module
  • template_preprocess_forum_icon() : forum.module
  • template_preprocess_forum_list() : forum.module
  • template_preprocess_forum_submitted() : forum.module
  • template_preprocess_forum_topic_list() : forum.module
  • template_preprocess_forum_topic_navigation() : forum.module
  • template_preprocess_forums() : forum.module
  • template_preprocess_maintenance_page() : theme.maintenance.inc
  • template_preprocess_node() : theme.inc
  • template_preprocess_page() : theme.inc
  • template_preprocess_poll_bar() : poll.module
  • template_preprocess_poll_results() : poll.module
  • template_preprocess_poll_vote() : poll.module
  • template_preprocess_profile_block() : profile.module
  • template_preprocess_profile_listing() : profile.module
  • template_preprocess_profile_wrapper() : profile.module
  • template_preprocess_search_block_form() : search.module
  • template_preprocess_search_result() : search.pages.inc
  • template_preprocess_search_results() : search.pages.inc
  • template_preprocess_search_theme_form() : search.module
  • template_preprocess_user_picture() : user.module
  • template_preprocess_user_profile() : user.pages.inc
  • template_preprocess_user_profile_category() : user.pages.inc
  • template_preprocess_user_profile_item() : user.pages.inc
  • theme() : theme.inc
  • theme_admin_block() : system.admin.inc
  • theme_admin_block_content() : system.admin.inc
  • theme_admin_page() : system.admin.inc
  • theme_aggregator_block_item() : aggregator.module
  • theme_aggregator_categorize_items() : aggregator.pages.inc
  • theme_aggregator_page_opml() : aggregator.pages.inc
  • theme_aggregator_page_rss() : aggregator.pages.inc
  • theme_blocks() : theme.inc
  • theme_book_admin_table() : book.admin.inc
  • theme_book_title_link() : book.module
  • theme_box() : theme.inc
  • theme_breadcrumb() : theme.inc
  • theme_button() : form.inc
  • theme_checkbox() : form.inc
  • theme_checkboxes() : form.inc
  • theme_closure() : theme.inc
  • theme_color_scheme_form() : color.module
  • theme_comment_admin_overview() : comment.admin.inc
  • theme_comment_block() : comment.module
  • theme_comment_controls() : comment.module
  • theme_comment_flat_collapsed() : comment.module
  • theme_comment_flat_expanded() : comment.module
  • theme_comment_post_forbidden() : comment.module
  • theme_comment_submitted() : comment.module
  • theme_comment_thread_collapsed() : comment.module
  • theme_comment_thread_expanded() : comment.module
  • theme_comment_view() : comment.module
  • theme_date() : form.inc
  • theme_dblog_filters() : dblog.module
  • theme_feed_icon() : theme.inc
  • theme_fieldset() : form.inc
  • theme_file() : form.inc
  • theme_filter_admin_order() : filter.admin.inc
  • theme_filter_admin_overview() : filter.admin.inc
  • theme_filter_tips() : filter.pages.inc
  • theme_filter_tips_more_info() : filter.module
  • theme_form() : form.inc
  • theme_form_element() : form.inc
  • theme_get_registry() : theme.inc
  • theme_get_setting() : theme.inc
  • theme_get_settings() : theme.inc
  • theme_help() : theme.inc
  • theme_hidden() : form.inc
  • theme_hidden_array() : multipage_form_example.module
  • theme_image() : theme.inc
  • theme_image_button() : form.inc
  • theme_indentation() : theme.inc
  • theme_install_page() : theme.maintenance.inc
  • theme_item() : form.inc
  • theme_item_list() : theme.inc
  • theme_links() : theme.inc
  • theme_locale_languages_overview_form() : locale.inc
  • theme_mark() : theme.inc
  • theme_markup() : form.inc
  • theme_menu_item() : menu.inc
  • theme_menu_item_link() : menu.inc
  • theme_menu_local_task() : menu.inc
  • theme_menu_local_tasks() : menu.inc
  • theme_menu_overview_form() : menu.admin.inc
  • theme_menu_tree() : menu.inc
  • theme_more_help_link() : theme.inc
  • theme_more_link() : theme.inc
  • theme_multipage_form_example() : multipage_form_example.module
  • theme_multipage_form_example_node_form() : multipage_form_example.module
  • theme_node_add_list() : node.pages.inc
  • theme_node_admin_nodes() : node.admin.inc
  • theme_node_example_order_info() : node_example.module
  • theme_node_filter_form() : node.admin.inc
  • theme_node_filters() : node.admin.inc
  • theme_node_form() : node.pages.inc
  • theme_node_list() : node.module
  • theme_node_log_message() : node.module
  • theme_node_preview() : node.pages.inc
  • theme_node_search_admin() : node.module
  • theme_node_submitted() : node.module
  • theme_nodeapi_example_rating() : nodeapi_example.module
  • theme_pager() : pager.inc
  • theme_pager_first() : pager.inc
  • theme_pager_last() : pager.inc
  • theme_pager_link() : pager.inc
  • theme_pager_next() : pager.inc
  • theme_pager_previous() : pager.inc
  • theme_password() : form.inc
  • theme_password_confirm() : form.inc
  • theme_phonenumber() : example_element.module
  • theme_placeholder() : theme.inc
  • theme_poll_choices() : poll.module
  • theme_profile_admin_overview() : profile.admin.inc
  • theme_progress_bar() : theme.inc
  • theme_radio() : form.inc
  • theme_radios() : form.inc
  • theme_render_template() : theme.inc
  • theme_select() : form.inc
  • theme_status_messages() : theme.inc
  • theme_status_report() : system.admin.inc
  • theme_submenu() : theme.inc
  • theme_submit() : form.inc
  • theme_system_admin_by_module() : system.admin.inc
  • theme_system_modules() : system.admin.inc
  • theme_system_modules_uninstall() : system.admin.inc
  • theme_system_powered_by() : system.module
  • theme_system_theme_select_form() : system.admin.inc
  • theme_system_themes_form() : system.admin.inc
  • theme_table() : theme.inc
  • theme_table_select_header_cell() : theme.inc
  • theme_tablesort_indicator() : theme.inc
  • theme_task_list() : theme.maintenance.inc
  • theme_taxonomy_overview_terms() : taxonomy.admin.inc
  • theme_taxonomy_overview_vocabularies() : taxonomy.admin.inc
  • theme_taxonomy_term_page() : taxonomy.pages.inc
  • theme_taxonomy_term_select() : taxonomy.module
  • theme_textarea() : form.inc
  • theme_textfield() : form.inc
  • theme_token() : form.inc
  • theme_trigger_display() : trigger.admin.inc
  • theme_update_page() : theme.maintenance.inc
  • theme_update_report() : update.report.inc
  • theme_update_version() : update.report.inc
  • theme_upload_attachments() : upload.module
  • theme_upload_form_current() : upload.module
  • theme_upload_form_new() : upload.module
  • theme_user_admin_account() : user.admin.inc
  • theme_user_admin_new_role() : user.admin.inc
  • theme_user_admin_perm() : user.admin.inc
  • theme_user_filter_form() : user.admin.inc
  • theme_user_filters() : user.admin.inc
  • theme_user_list() : user.module
  • theme_user_signature() : user.module
  • theme_username() : theme.inc
  • theme_xml_icon() : theme.inc
  • throttle_admin_settings() : throttle.admin.inc
  • throttle_admin_settings_validate() : throttle.admin.inc
  • throttle_exit() : throttle.module
  • throttle_help() : throttle.module
  • throttle_menu() : throttle.module
  • throttle_status() : throttle.module
  • timer_read() : bootstrap.inc
  • timer_start() : bootstrap.inc
  • timer_stop() : bootstrap.inc
  • tracker_help() : tracker.module
  • tracker_menu() : tracker.module
  • tracker_page() : tracker.pages.inc
  • TRANSLATION_ENABLED : translation.module
  • translation_form_alter() : translation.module
  • translation_help() : translation.module
  • translation_link() : translation.module
  • translation_menu() : translation.module
  • translation_node_get_translations() : translation.module
  • translation_node_overview() : translation.pages.inc
  • translation_nodeapi() : translation.module
  • translation_path_get_translations() : translation.module
  • translation_perm() : translation.module
  • translation_remove_from_set() : translation.module
  • translation_supported_type() : translation.module
  • translation_translation_link_alter() : translation.module
  • trigger_access_check() : trigger.module
  • trigger_actions_delete() : trigger.module
  • trigger_assign() : trigger.admin.inc
  • trigger_assign_form() : trigger.admin.inc
  • trigger_assign_form_submit() : trigger.admin.inc
  • trigger_assign_form_validate() : trigger.admin.inc
  • trigger_comment() : trigger.module
  • trigger_cron() : trigger.module
  • trigger_forms() : trigger.module
  • trigger_help() : trigger.module
  • trigger_install() : trigger.install
  • trigger_menu() : trigger.module
  • trigger_nodeapi() : trigger.module
  • trigger_options() : trigger.module
  • trigger_schema() : trigger.install
  • trigger_taxonomy() : trigger.module
  • trigger_theme() : trigger.module
  • trigger_unassign() : trigger.admin.inc
  • trigger_unassign_submit() : trigger.admin.inc
  • trigger_uninstall() : trigger.install
  • trigger_user() : trigger.module
  • truncate_utf8() : unicode.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- u -

  • unicode_check() : unicode.inc
  • UNICODE_ERROR : unicode.inc
  • UNICODE_MULTIBYTE : unicode.inc
  • unicode_requirements() : unicode.inc
  • UNICODE_SINGLEBYTE : unicode.inc
  • update_access_denied_page() : update.php
  • update_batch() : update.php
  • update_calculate_project_data() : update.compare.inc
  • update_check_incompatibility() : update.php
  • update_check_requirements() : update.php
  • update_create_batch_table() : update.php
  • update_cron() : update.module
  • UPDATE_CURRENT : update.module
  • UPDATE_DEFAULT_URL : update.module
  • update_do_one() : update.php
  • update_finished() : update.php
  • update_fix_compatibility() : update.php
  • update_fix_d6_requirements() : update.php
  • update_flush_caches() : update.module
  • update_form_alter() : update.module
  • update_get_available() : update.module
  • update_get_project_name() : update.compare.inc
  • update_get_projects() : update.compare.inc
  • update_help() : update.module
  • update_info_page() : update.php
  • update_install() : update.install
  • update_invalidate_cache() : update.module
  • update_mail() : update.module
  • update_manual_status() : update.fetch.inc
  • update_menu() : update.module
  • UPDATE_NOT_CHECKED : update.module
  • UPDATE_NOT_CURRENT : update.module
  • UPDATE_NOT_SECURE : update.module
  • UPDATE_NOT_SUPPORTED : update.module
  • update_process_project_info() : update.compare.inc
  • update_project_cache() : update.compare.inc
  • update_refresh() : update.module
  • update_requirements() : update.module
  • update_results_page() : update.php
  • UPDATE_REVOKED : update.module
  • update_schema() : update.install
  • update_script_selection_form() : update.php
  • update_selection_page() : update.php
  • update_settings() : update.settings.inc
  • update_settings_submit() : update.settings.inc
  • update_settings_validate() : update.settings.inc
  • update_sql() : database.inc
  • update_status() : update.report.inc
  • update_task_list() : update.php
  • update_theme() : update.module
  • update_uninstall() : update.install
  • UPDATE_UNKNOWN : update.module
  • update_update_6000() : update.install
  • upload_admin_settings() : upload.admin.inc
  • upload_admin_settings_validate() : upload.admin.inc
  • upload_delete() : upload.module
  • upload_delete_revision() : upload.module
  • upload_file_download() : upload.module
  • upload_form_alter() : upload.module
  • upload_help() : upload.module
  • upload_install() : upload.install
  • upload_js() : upload.module
  • upload_link() : upload.module
  • upload_load() : upload.module
  • upload_menu() : upload.module
  • upload_menu_alter() : upload.module
  • upload_node_form_submit() : upload.module
  • upload_nodeapi() : upload.module
  • upload_perm() : upload.module
  • upload_save() : upload.module
  • upload_schema() : upload.install
  • upload_space_used() : upload.module
  • upload_theme() : upload.module
  • upload_total_space_used() : upload.module
  • upload_uninstall() : upload.install
  • url() : common.inc
  • user_access() : user.module
  • user_action_info() : user.module
  • user_admin() : user.admin.inc
  • user_admin_access() : user.admin.inc
  • user_admin_access_add() : user.admin.inc
  • user_admin_access_check() : user.admin.inc
  • user_admin_access_check_submit() : user.admin.inc
  • user_admin_access_check_validate() : user.admin.inc
  • user_admin_access_delete_confirm() : user.admin.inc
  • user_admin_access_delete_confirm_submit() : user.admin.inc
  • user_admin_access_edit() : user.admin.inc
  • user_admin_access_form() : user.admin.inc
  • user_admin_account() : user.admin.inc
  • user_admin_account_submit() : user.admin.inc
  • user_admin_account_validate() : user.admin.inc
  • user_admin_check_host() : user.admin.inc
  • user_admin_check_mail() : user.admin.inc
  • user_admin_check_user() : user.admin.inc
  • user_admin_perm() : user.admin.inc
  • user_admin_perm_submit() : user.admin.inc
  • user_admin_role() : user.admin.inc
  • user_admin_role_submit() : user.admin.inc
  • user_admin_role_validate() : user.admin.inc
  • user_admin_settings() : user.admin.inc
  • user_authenticate() : user.module
  • user_authenticate_finalize() : user.module
  • user_autocomplete() : user.pages.inc
  • user_block() : user.module
  • user_block_ip_action() : user.module
  • user_block_user_action() : user.module
  • user_build_content() : user.module
  • user_build_filter_query() : user.module
  • user_category_load() : user.module
  • user_comment() : user.module
  • user_confirm_delete() : user.pages.inc
  • user_confirm_delete_submit() : user.pages.inc
  • user_current_load() : user.module
  • user_current_to_arg() : user.module
  • user_delete() : user.module
  • user_edit() : user.pages.inc
  • user_edit_access() : user.module
  • user_edit_delete_submit() : user.pages.inc
  • user_edit_form() : user.module
  • user_edit_submit() : user.pages.inc
  • user_edit_validate() : user.pages.inc
  • user_elements() : user.module
  • user_external_load() : user.module
  • user_external_login() : user.module
  • user_external_login_register() : user.module
  • user_fields() : user.module
  • user_file_download() : user.module
  • user_filter_form() : user.admin.inc
  • user_filter_form_submit() : user.admin.inc
  • user_filters() : user.module
  • user_forms() : user.module
  • user_get_authmaps() : user.module
  • user_help() : user.module
  • user_hook_info() : user.module
  • user_init() : user.module
  • user_is_anonymous() : user.module
  • user_is_blocked() : user.module
  • user_is_logged_in() : user.module
  • user_load() : user.module
  • user_load_self() : user.module
  • user_login() : user.module
  • user_login_authenticate_validate() : user.module
  • user_login_block() : user.module
  • user_login_default_validators() : user.module
  • user_login_final_validate() : user.module
  • user_login_name_validate() : user.module
  • user_login_submit() : user.module
  • user_logout() : user.pages.inc
  • user_mail() : user.module
  • user_mail_tokens() : user.module
  • user_menu() : user.module
  • user_module_invoke() : user.module
  • user_multiple_delete_confirm() : user.module
  • user_multiple_delete_confirm_submit() : user.module
  • user_multiple_role_edit() : user.module
  • user_page() : user.pages.inc
  • user_page_title() : user.module
  • user_pass() : user.pages.inc
  • user_pass_rehash() : user.module
  • user_pass_reset() : user.pages.inc
  • user_pass_reset_url() : user.module
  • user_pass_submit() : user.pages.inc
  • user_pass_validate() : user.pages.inc
  • user_password() : user.module
  • user_perm() : user.module
  • user_preferred_language() : user.module
  • user_profile_form() : user.pages.inc
  • user_profile_form_submit() : user.pages.inc
  • user_profile_form_validate() : user.pages.inc
  • user_register() : user.module
  • user_register_access() : user.module
  • user_register_submit() : user.module
  • user_register_validate() : user.module
  • user_roles() : user.module
  • user_save() : user.module
  • user_schema() : user.install
  • user_search() : user.module
  • user_set_authmaps() : user.module
  • user_theme() : user.module
  • user_user() : user.module
  • user_user_operations() : user.module
  • user_user_operations_block() : user.module
  • user_user_operations_unblock() : user.module
  • user_validate_mail() : user.module
  • user_validate_name() : user.module
  • user_validate_picture() : user.module
  • user_view() : user.pages.inc
  • user_view_access() : user.module
  • USERNAME_MAX_LENGTH : user.module
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- v -

  • valid_email_address() : common.inc
  • valid_url() : common.inc
  • vancode2int() : comment.module
  • variable_del() : bootstrap.inc
  • variable_get() : bootstrap.inc
  • variable_init() : bootstrap.inc
  • variable_set() : bootstrap.inc
  • VERSION : system.module
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- w -

  • watchdog() : bootstrap.inc
  • WATCHDOG_ALERT : bootstrap.inc
  • WATCHDOG_CRITICAL : bootstrap.inc
  • WATCHDOG_DEBUG : bootstrap.inc
  • WATCHDOG_EMERG : bootstrap.inc
  • WATCHDOG_ERROR : bootstrap.inc
  • WATCHDOG_INFO : bootstrap.inc
  • WATCHDOG_NOTICE : bootstrap.inc
  • watchdog_severity_levels() : common.inc
  • WATCHDOG_WARNING : bootstrap.inc
  • weight_value() : form.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

Here is a list of all file members with links to the files they belong to:

- x -

  • xmlrpc() : common.inc
  • xmlrpc_base64() : xmlrpc.inc
  • xmlrpc_base64_get_xml() : xmlrpc.inc
  • xmlrpc_date() : xmlrpc.inc
  • xmlrpc_date_get_xml() : xmlrpc.inc
  • xmlrpc_errno() : xmlrpc.inc
  • xmlrpc_error() : xmlrpc.inc
  • xmlrpc_error_get_xml() : xmlrpc.inc
  • xmlrpc_error_msg() : xmlrpc.inc
  • xmlrpc_example_arrayOfStructsTest() : xmlrpc_example.module
  • xmlrpc_example_countTheEntities() : xmlrpc_example.module
  • xmlrpc_example_easyStructTest() : xmlrpc_example.module
  • xmlrpc_example_echoStructTest() : xmlrpc_example.module
  • xmlrpc_example_manyTypesTest() : xmlrpc_example.module
  • xmlrpc_example_moderateSizeArrayCheck() : xmlrpc_example.module
  • xmlrpc_example_nestedStructTest() : xmlrpc_example.module
  • xmlrpc_example_simpleStructReturnTest() : xmlrpc_example.module
  • xmlrpc_example_xmlrpc() : xmlrpc_example.module
  • xmlrpc_message() : xmlrpc.inc
  • xmlrpc_message_cdata() : xmlrpc.inc
  • xmlrpc_message_get() : xmlrpc.inc
  • xmlrpc_message_parse() : xmlrpc.inc
  • xmlrpc_message_set() : xmlrpc.inc
  • xmlrpc_message_tag_close() : xmlrpc.inc
  • xmlrpc_message_tag_open() : xmlrpc.inc
  • xmlrpc_request() : xmlrpc.inc
  • xmlrpc_server() : xmlrpcs.inc
  • xmlrpc_server_call() : xmlrpcs.inc
  • xmlrpc_server_error() : xmlrpcs.inc
  • xmlrpc_server_get() : xmlrpcs.inc
  • xmlrpc_server_get_capabilities() : xmlrpcs.inc
  • xmlrpc_server_list_methods() : xmlrpcs.inc
  • xmlrpc_server_method_help() : xmlrpcs.inc
  • xmlrpc_server_method_signature() : xmlrpcs.inc
  • xmlrpc_server_multicall() : xmlrpcs.inc
  • xmlrpc_server_output() : xmlrpcs.inc
  • xmlrpc_server_set() : xmlrpcs.inc
  • xmlrpc_value() : xmlrpc.inc
  • xmlrpc_value_calculate_type() : xmlrpc.inc
  • xmlrpc_value_get_xml() : xmlrpc.inc
  • xrds_parse() : xrds.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/globals.php Source File

docs

globals.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: globals.php,v 1.3 2008/01/26 03:25:29 drumm Exp $
00003
00016 global $timers;
00017
00023 global $base_url;
00024
00030 global $base_path;
00031
00037 global $base_root;
00038
00042 global $db_url;
00043
00047 global $db_prefix;
00048
00055 global $cookie_domain;
00056
00060 global $conf;
00061
00065 global $installed_profile;
00066
00071 global $update_free_access;
00072
00076 global $user;
00077
00099 global $language;
00100
00107 global $update_mode;
00108
00112 global $profile;
00113
00119 global $db_type;
00120
00126 global $active_db;
00127
00131 global $queries;
00132
00136 global $last_result;
00137
00143 global $install_locale;
00144
00148 global $pager_page_array;
00149
00154 global $pager_total;
00155
00160 global $pager_total_items;
00161
00165 global $theme;
00166
00172 global $custom_theme;
00173
00179 global $theme_key;
00180
00186 global $theme_info;
00187
00192 global $base_theme_info;
00193
00197 global $theme_engine;
00198
00202 global $theme_path;
00203
00208 global $multibyte;
00209
00215 global $item;
00216
00222 global $element;
00223
00229 global $tag;
00230
00236 global $items;
00237
00244 global $channel;
00245
00249 global $image;
00250
00254 global $nid;
00255
00259 global $forum_topic_list_header;
00260
00264 global $menu_admin;
00265
00269 global $xrds_services;
00270
00274 global $xrds_open_elements;
00275
00279 global $xrds_current_service;
00280
00284 global $recent_activity;
00285
00289 global $id;
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • b
  • c
  • d
  • e
  • f
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w

- b -

  • BLOCK_CACHE_GLOBAL : block.module
  • BLOCK_CACHE_PER_PAGE : block.module
  • BLOCK_CACHE_PER_ROLE : block.module
  • BLOCK_CACHE_PER_USER : block.module
  • BLOCK_NO_CACHE : block.module
  • BLOCK_REGION_NONE : block.module

- c -

  • CACHE_AGGRESSIVE : bootstrap.inc
  • CACHE_DISABLED : bootstrap.inc
  • CACHE_NORMAL : bootstrap.inc
  • CACHE_PERMANENT : bootstrap.inc
  • CACHE_TEMPORARY : bootstrap.inc
  • COMMENT_ANONYMOUS_MAY_CONTACT : comment.module
  • COMMENT_ANONYMOUS_MAYNOT_CONTACT : comment.module
  • COMMENT_ANONYMOUS_MUST_CONTACT : comment.module
  • COMMENT_CONTROLS_ABOVE : comment.module
  • COMMENT_CONTROLS_ABOVE_BELOW : comment.module
  • COMMENT_CONTROLS_BELOW : comment.module
  • COMMENT_CONTROLS_HIDDEN : comment.module
  • COMMENT_FORM_BELOW : comment.module
  • COMMENT_FORM_SEPARATE_PAGE : comment.module
  • COMMENT_MODE_FLAT_COLLAPSED : comment.module
  • COMMENT_MODE_FLAT_EXPANDED : comment.module
  • COMMENT_MODE_THREADED_COLLAPSED : comment.module
  • COMMENT_MODE_THREADED_EXPANDED : comment.module
  • COMMENT_NODE_DISABLED : comment.module
  • COMMENT_NODE_READ_ONLY : comment.module
  • COMMENT_NODE_READ_WRITE : comment.module
  • COMMENT_NOT_PUBLISHED : comment.module
  • COMMENT_ORDER_NEWEST_FIRST : comment.module
  • COMMENT_ORDER_OLDEST_FIRST : comment.module
  • COMMENT_PREVIEW_OPTIONAL : comment.module
  • COMMENT_PREVIEW_REQUIRED : comment.module
  • COMMENT_PUBLISHED : comment.module

- d -

  • DB_ERROR : database.inc
  • DB_QUERY_REGEXP : database.inc
  • DRUPAL_ANONYMOUS_RID : bootstrap.inc
  • DRUPAL_AUTHENTICATED_RID : bootstrap.inc
  • DRUPAL_BOOTSTRAP_ACCESS : bootstrap.inc
  • DRUPAL_BOOTSTRAP_CONFIGURATION : bootstrap.inc
  • DRUPAL_BOOTSTRAP_DATABASE : bootstrap.inc
  • DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE : bootstrap.inc
  • DRUPAL_BOOTSTRAP_FULL : bootstrap.inc
  • DRUPAL_BOOTSTRAP_LANGUAGE : bootstrap.inc
  • DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE : bootstrap.inc
  • DRUPAL_BOOTSTRAP_PATH : bootstrap.inc
  • DRUPAL_BOOTSTRAP_SESSION : bootstrap.inc
  • DRUPAL_CORE_COMPATIBILITY : system.module
  • DRUPAL_MAXIMUM_TEMP_FILE_AGE : system.module
  • DRUPAL_MINIMUM_MYSQL : system.module
  • DRUPAL_MINIMUM_PGSQL : system.module
  • DRUPAL_MINIMUM_PHP : system.module
  • DRUPAL_MINIMUM_PHP_MEMORY_LIMIT : system.module

- e -

  • EMAIL_MAX_LENGTH : user.module

- f -

  • FILE_CREATE_DIRECTORY : file.inc
  • FILE_DOWNLOADS_PRIVATE : file.inc
  • FILE_DOWNLOADS_PUBLIC : file.inc
  • FILE_EXECUTABLE : install.inc
  • FILE_EXIST : install.inc
  • FILE_EXISTS_ERROR : file.inc
  • FILE_EXISTS_RENAME : file.inc
  • FILE_EXISTS_REPLACE : file.inc
  • FILE_MODIFY_PERMISSIONS : file.inc
  • FILE_NOT_EXECUTABLE : install.inc
  • FILE_NOT_EXIST : install.inc
  • FILE_NOT_READABLE : install.inc
  • FILE_NOT_WRITABLE : install.inc
  • FILE_READABLE : install.inc
  • FILE_STATUS_PERMANENT : file.inc
  • FILE_STATUS_TEMPORARY : file.inc
  • FILE_WRITABLE : install.inc
  • FILTER_FORMAT_DEFAULT : filter.module
  • FILTER_HTML_ESCAPE : filter.module
  • FILTER_HTML_STRIP : filter.module

- l -

  • LANGUAGE_LTR : locale.module
  • LANGUAGE_NEGOTIATION_DOMAIN : bootstrap.inc
  • LANGUAGE_NEGOTIATION_NONE : bootstrap.inc
  • LANGUAGE_NEGOTIATION_PATH : bootstrap.inc
  • LANGUAGE_NEGOTIATION_PATH_DEFAULT : bootstrap.inc
  • LANGUAGE_RTL : locale.module
  • LOCALE_IMPORT_KEEP : locale.inc
  • LOCALE_IMPORT_OVERWRITE : locale.inc
  • LOCALE_JS_STRING : locale.inc

- m -

  • MAINTENANCE_MODE : install.php , update.php
  • MARK_NEW : theme.inc
  • MARK_READ : theme.inc
  • MARK_UPDATED : theme.inc
  • MENU_ACCESS_DENIED : menu.inc
  • MENU_CALLBACK : menu.inc
  • MENU_CREATED_BY_ADMIN : menu.inc
  • MENU_DEFAULT_LOCAL_TASK : menu.inc
  • MENU_FOUND : menu.inc
  • MENU_IS_LOCAL_TASK : menu.inc
  • MENU_IS_ROOT : menu.inc
  • MENU_LINKS_TO_PARENT : menu.inc
  • MENU_LOCAL_TASK : menu.inc
  • MENU_MAX_DEPTH : menu.inc
  • MENU_MAX_MENU_NAME_LENGTH_UI : menu.module
  • MENU_MAX_PARTS : menu.inc
  • MENU_MODIFIED_BY_ADMIN : menu.inc
  • MENU_NORMAL_ITEM : menu.inc
  • MENU_NOT_FOUND : menu.inc
  • MENU_SITE_OFFLINE : menu.inc
  • MENU_SUGGESTED_ITEM : menu.inc
  • MENU_VISIBLE_IN_BREADCRUMB : menu.inc
  • MENU_VISIBLE_IN_TREE : menu.inc

- n -

  • NODE_BUILD_NORMAL : node.module
  • NODE_BUILD_PREVIEW : node.module
  • NODE_BUILD_PRINT : node.module
  • NODE_BUILD_RSS : node.module
  • NODE_BUILD_SEARCH_INDEX : node.module
  • NODE_BUILD_SEARCH_RESULT : node.module
  • NODE_NEW_LIMIT : node.module

- o -

  • OPENID_DH_DEFAULT_GEN : openid.inc
  • OPENID_DH_DEFAULT_MOD : openid.inc
  • OPENID_NS_1_0 : openid.inc
  • OPENID_NS_1_1 : openid.inc
  • OPENID_NS_2_0 : openid.inc
  • OPENID_RAND_SOURCE : openid.inc
  • OPENID_SHA1_BLOCKSIZE : openid.inc

- p -

  • PREG_CLASS_CJK : search.module
  • PREG_CLASS_NUMBERS : search.module
  • PREG_CLASS_PUNCTUATION : search.module
  • PREG_CLASS_SEARCH_EXCLUDE : search.module
  • PROFILE_HIDDEN : profile.module
  • PROFILE_PRIVATE : profile.module
  • PROFILE_PUBLIC : profile.module
  • PROFILE_PUBLIC_LISTINGS : profile.module

- r -

  • REQUIREMENT_ERROR : install.inc
  • REQUIREMENT_INFO : install.inc
  • REQUIREMENT_OK : install.inc
  • REQUIREMENT_WARNING : install.inc

- s -

  • SAVED_DELETED : common.inc
  • SAVED_NEW : common.inc
  • SAVED_UPDATED : common.inc
  • SCHEMA_INSTALLED : install.inc
  • SCHEMA_UNINSTALLED : install.inc

- t -

  • TRANSLATION_ENABLED : translation.module

- u -

  • UNICODE_ERROR : unicode.inc
  • UNICODE_MULTIBYTE : unicode.inc
  • UNICODE_SINGLEBYTE : unicode.inc
  • UPDATE_CURRENT : update.module
  • UPDATE_DEFAULT_URL : update.module
  • UPDATE_NOT_CHECKED : update.module
  • UPDATE_NOT_CURRENT : update.module
  • UPDATE_NOT_SECURE : update.module
  • UPDATE_NOT_SUPPORTED : update.module
  • UPDATE_REVOKED : update.module
  • UPDATE_UNKNOWN : update.module
  • USERNAME_MAX_LENGTH : user.module

- v -

  • VERSION : system.module

- w -

  • WATCHDOG_ALERT : bootstrap.inc
  • WATCHDOG_CRITICAL : bootstrap.inc
  • WATCHDOG_DEBUG : bootstrap.inc
  • WATCHDOG_EMERG : bootstrap.inc
  • WATCHDOG_ERROR : bootstrap.inc
  • WATCHDOG_INFO : bootstrap.inc
  • WATCHDOG_NOTICE : bootstrap.inc
  • WATCHDOG_WARNING : bootstrap.inc
Generated on Tue Feb 12 15:31:03 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- _ -

  • _aggregator_category_title() : aggregator.module
  • _aggregator_has_categories() : aggregator.module
  • _aggregator_items() : aggregator.module
  • _aggregator_page_list() : aggregator.pages.inc
  • _batch_current_set() : batch.inc
  • _batch_do() : batch.inc
  • _batch_finished() : batch.inc
  • _batch_next_set() : batch.inc
  • _batch_page() : batch.inc
  • _batch_process() : batch.inc
  • _batch_progress_page_js() : batch.inc
  • _batch_progress_page_nojs() : batch.inc
  • _batch_shutdown() : batch.inc
  • _batch_start() : batch.inc
  • _block_compare() : block.admin.inc
  • _block_get_cache_id() : block.module
  • _block_rehash() : block.module
  • _block_themes_access() : block.module
  • _blogapi_get_node_types() : blogapi.module
  • _blogapi_get_post() : blogapi.module
  • _blogapi_mt_extra() : blogapi.module
  • _blogapi_validate_blogid() : blogapi.module
  • _book_add_form_elements() : book.module
  • _book_admin_compare() : book.admin.inc
  • _book_admin_sort_tree() : book.admin.inc
  • _book_admin_table() : book.admin.inc
  • _book_admin_table_tree() : book.admin.inc
  • _book_flatten_menu() : book.module
  • _book_install_type_create() : book.install
  • _book_link_defaults() : book.module
  • _book_outline_access() : book.module
  • _book_outline_remove_access() : book.module
  • _book_parent_depth_limit() : book.module
  • _book_parent_select() : book.module
  • _book_toc_recurse() : book.module
  • _book_update_outline() : book.module
  • _color_blend() : color.module
  • _color_gd() : color.module
  • _color_hsl2rgb() : color.module
  • _color_hue2rgb() : color.module
  • _color_pack() : color.module
  • _color_page_alter() : color.module
  • _color_render_images() : color.module
  • _color_rewrite_stylesheet() : color.module
  • _color_rgb2hsl() : color.module
  • _color_save_stylesheet() : color.module
  • _color_shift() : color.module
  • _color_unpack() : color.module
  • _comment_delete_thread() : comment.admin.inc
  • _comment_form_submit() : comment.module
  • _comment_get_display_setting() : comment.module
  • _comment_get_modes() : comment.module
  • _comment_get_orders() : comment.module
  • _comment_load() : comment.module
  • _comment_per_page() : comment.module
  • _comment_update_node_statistics() : comment.module
  • _contact_user_tab_access() : contact.module
  • _db_create_field_sql() : database.mysql-common.inc , database.pgsql.inc
  • _db_create_index_sql() : database.pgsql.inc
  • _db_create_key_sql() : database.mysql-common.inc , database.pgsql.inc
  • _db_create_keys() : database.pgsql.inc
  • _db_create_keys_sql() : database.mysql-common.inc
  • _db_error_page() : database.inc
  • _db_process_field() : database.mysql-common.inc , database.pgsql.inc
  • _db_query() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • _db_query_callback() : database.inc
  • _db_rewrite_sql() : database.inc
  • _dblog_format_message() : dblog.admin.inc
  • _dblog_get_message_types() : dblog.module
  • _decode_entities() : unicode.inc
  • _drupal_bootstrap() : bootstrap.inc
  • _drupal_bootstrap_full() : common.inc
  • _drupal_build_css_path() : common.inc
  • _drupal_flush_css_js() : common.inc
  • _drupal_html_to_mail_urls() : mail.inc
  • _drupal_html_to_text_clean() : mail.inc
  • _drupal_html_to_text_pad() : mail.inc
  • _drupal_initialize_schema() : common.inc
  • _drupal_install_module() : install.inc
  • _drupal_load_stylesheet() : common.inc
  • _drupal_maintenance_theme() : theme.maintenance.inc
  • _drupal_wrap_mail_line() : mail.inc
  • _element_info() : form.inc
  • _filter_autop() : filter.module
  • _filter_html() : filter.module
  • _filter_html_settings() : filter.module
  • _filter_htmlcorrector() : filter.module
  • _filter_list_cmp() : filter.module
  • _filter_tips() : filter.module
  • _filter_url() : filter.module
  • _filter_url_parse_full_links() : filter.module
  • _filter_url_parse_partial_links() : filter.module
  • _filter_url_settings() : filter.module
  • _filter_url_trim() : filter.module
  • _filter_xss_attributes() : filter.module
  • _filter_xss_split() : filter.module
  • _fix_gpc_magic() : common.inc
  • _fix_gpc_magic_files() : common.inc
  • _form_builder_handle_input_element() : form.inc
  • _form_builder_ie_cleanup() : form.inc
  • _form_button_was_clicked() : form.inc
  • _form_set_class() : form.inc
  • _form_set_value() : form.inc
  • _form_validate() : form.inc
  • _forum_get_topic_order() : forum.module
  • _forum_get_topic_order_sql() : forum.module
  • _forum_new() : forum.module
  • _forum_parent_select() : forum.admin.inc
  • _forum_topics_unread() : forum.module
  • _forum_user_last_visit() : forum.module
  • _init_theme() : theme.inc
  • _install_locale_initial_batch_finished() : install.php
  • _install_locale_remaining_batch_finished() : install.php
  • _install_module_batch() : install.php
  • _install_profile_batch_finished() : install.php
  • _install_settings_form_validate() : install.php
  • _locale_batch_build() : locale.inc
  • _locale_batch_import() : locale.inc
  • _locale_batch_language_finished() : locale.inc
  • _locale_batch_system_finished() : locale.inc
  • _locale_export_get_strings() : locale.inc
  • _locale_export_po() : locale.inc
  • _locale_export_po_generate() : locale.inc
  • _locale_export_remove_plural() : locale.inc
  • _locale_export_string() : locale.inc
  • _locale_export_wrap() : locale.inc
  • _locale_get_predefined_list() : locale.inc
  • _locale_import_append_plural() : locale.inc
  • _locale_import_message() : locale.inc
  • _locale_import_one_string() : locale.inc
  • _locale_import_one_string_db() : locale.inc
  • _locale_import_parse_arithmetic() : locale.inc
  • _locale_import_parse_header() : locale.inc
  • _locale_import_parse_plural_forms() : locale.inc
  • _locale_import_parse_quoted() : locale.inc
  • _locale_import_po() : locale.inc
  • _locale_import_read_po() : locale.inc
  • _locale_import_shorten_comments() : locale.inc
  • _locale_import_tokenize_formula() : locale.inc
  • _locale_invalidate_js() : locale.inc
  • _locale_languages_common_controls() : locale.inc
  • _locale_parse_js_file() : locale.inc
  • _locale_prepare_predefined_list() : locale.inc
  • _locale_rebuild_js() : locale.inc
  • _locale_translate_language_list() : locale.inc
  • _locale_translate_seek() : locale.inc
  • _locale_translate_seek_query() : locale.inc
  • _menu_check_access() : menu.inc
  • _menu_clear_page_cache() : menu.inc
  • _menu_delete_item() : menu.inc
  • _menu_find_router_path() : menu.inc
  • _menu_item_localize() : menu.inc
  • _menu_link_build() : menu.inc
  • _menu_link_map_translate() : menu.inc
  • _menu_link_move_children() : menu.inc
  • _menu_link_parents_set() : menu.inc
  • _menu_link_translate() : menu.inc
  • _menu_load_objects() : menu.inc
  • _menu_navigation_links_rebuild() : menu.inc
  • _menu_overview_tree_form() : menu.admin.inc
  • _menu_parent_depth_limit() : menu.module
  • _menu_parents_recurse() : menu.module
  • _menu_router_build() : menu.inc
  • _menu_set_expanded_menus() : menu.inc
  • _menu_site_is_offline() : menu.inc
  • _menu_translate() : menu.inc
  • _menu_tree_check_access() : menu.inc
  • _menu_tree_data() : menu.inc
  • _menu_update_parental_status() : menu.inc
  • _mime_header_decode() : unicode.inc
  • _module_build_dependencies() : module.inc
  • _node_access_join_sql() : node.module
  • _node_access_rebuild_batch_finished() : node.module
  • _node_access_rebuild_batch_operation() : node.module
  • _node_access_where_sql() : node.module
  • _node_add_access() : node.module
  • _node_index_node() : node.module
  • _node_mass_update_batch_finished() : node.admin.inc
  • _node_mass_update_batch_process() : node.admin.inc
  • _node_mass_update_helper() : node.admin.inc
  • _node_revision_access() : node.module
  • _node_save_revision() : node.module
  • _node_type_set_defaults() : node.module
  • _node_types_build() : node.module
  • _openid_create_message() : openid.inc
  • _openid_dh_base64_to_long() : openid.inc
  • _openid_dh_binary_to_long() : openid.inc
  • _openid_dh_long_to_base64() : openid.inc
  • _openid_dh_long_to_binary() : openid.inc
  • _openid_dh_rand() : openid.inc
  • _openid_dh_xorsecret() : openid.inc
  • _openid_encode_message() : openid.inc
  • _openid_get_bytes() : openid.inc
  • _openid_get_params() : openid.inc
  • _openid_hmac() : openid.inc
  • _openid_is_xri() : openid.inc
  • _openid_link_href() : openid.inc
  • _openid_meta_httpequiv() : openid.inc
  • _openid_nonce() : openid.inc
  • _openid_normalize() : openid.inc
  • _openid_normalize_url() : openid.inc
  • _openid_normalize_xri() : openid.inc
  • _openid_parse_message() : openid.inc
  • _openid_response() : openid.inc
  • _openid_sha1() : openid.inc
  • _openid_signature() : openid.inc
  • _ping_notify() : ping.module
  • _poll_choice_form() : poll.module
  • _poll_menu_access() : poll.module
  • _profile_field_serialize() : profile.module
  • _profile_field_types() : profile.module
  • _profile_form_explanation() : profile.module
  • _profile_get_fields() : profile.module
  • _profile_update_user_fields() : profile.module
  • _search_excerpt_replace() : search.module
  • _search_index_truncate() : search.module
  • _search_menu() : search.module
  • _search_parse_query() : search.module
  • _statistics_format_item() : statistics.module
  • _statistics_link() : statistics.module
  • _system_is_incompatible() : system.admin.inc
  • _system_sort_requirements() : system.module
  • _system_sql() : system.admin.inc
  • _system_theme_data() : system.module
  • _system_themes_access() : system.module
  • _system_zonelist() : system.module
  • _taxonomy_get_tid_from_term() : taxonomy.module
  • _taxonomy_term_children() : taxonomy.module
  • _taxonomy_term_select() : taxonomy.module
  • _theme_build_registry() : theme.inc
  • _theme_load_offline_registry() : theme.maintenance.inc
  • _theme_load_registry() : theme.inc
  • _theme_process_registry() : theme.inc
  • _theme_save_registry() : theme.inc
  • _theme_set_registry() : theme.inc
  • _theme_table_cell() : theme.inc
  • _translation_tab_access() : translation.module
  • _trigger_get_hook_actions() : trigger.admin.inc
  • _trigger_get_hook_aids() : trigger.module
  • _trigger_normalize_comment_context() : trigger.module
  • _trigger_normalize_node_context() : trigger.module
  • _trigger_normalize_user_context() : trigger.module
  • _unicode_caseflip() : unicode.inc
  • _unicode_check() : unicode.inc
  • _update_build_fetch_url() : update.fetch.inc
  • _update_cron_notify() : update.fetch.inc
  • _update_message_text() : update.module
  • _update_no_data() : update.module
  • _update_process_info_list() : update.compare.inc
  • _update_project_status_sort() : update.module
  • _update_refresh() : update.fetch.inc
  • _update_remove_update_status_variables() : update.install
  • _update_requirement_check() : update.module
  • _upload_file_limits() : upload.module
  • _upload_form() : upload.module
  • _user_categories() : user.module
  • _user_edit_submit() : user.module
  • _user_edit_validate() : user.module
  • _user_forms() : user.module
  • _user_mail_notify() : user.module
  • _user_mail_text() : user.module
  • _user_password_dynamic_validation() : user.module
  • _user_sort() : user.module
  • _xmlrpc() : xmlrpc.inc
  • _xrds_cdata() : xrds.inc
  • _xrds_element_end() : xrds.inc
  • _xrds_element_start() : xrds.inc
  • _xrds_strip_namespace() : xrds.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- l -

  • l() : common.inc
  • language_default() : bootstrap.inc
  • language_from_browser() : language.inc
  • language_initialize() : language.inc
  • language_list() : bootstrap.inc
  • language_url_rewrite() : language.inc
  • list_themes() : theme.inc
  • locale() : locale.module
  • locale_add_language() : locale.inc
  • locale_batch_by_component() : locale.inc
  • locale_batch_by_language() : locale.inc
  • locale_block() : locale.module
  • locale_form_alter() : locale.module
  • locale_get_plural() : locale.module
  • locale_help() : locale.module
  • locale_inc_callback() : locale.module
  • locale_install() : locale.install
  • locale_language_list() : locale.module
  • locale_language_name() : locale.module
  • locale_languages_add_screen() : locale.inc
  • locale_languages_configure_form() : locale.inc
  • locale_languages_configure_form_submit() : locale.inc
  • locale_languages_custom_form() : locale.inc
  • locale_languages_delete_form() : locale.inc
  • locale_languages_delete_form_submit() : locale.inc
  • locale_languages_edit_form() : locale.inc
  • locale_languages_edit_form_submit() : locale.inc
  • locale_languages_edit_form_validate() : locale.inc
  • locale_languages_overview_form() : locale.inc
  • locale_languages_overview_form_submit() : locale.inc
  • locale_languages_predefined_form() : locale.inc
  • locale_languages_predefined_form_submit() : locale.inc
  • locale_languages_predefined_form_validate() : locale.inc
  • locale_locale() : locale.module
  • locale_menu() : locale.module
  • locale_perm() : locale.module
  • locale_schema() : locale.install
  • locale_system_update() : locale.module
  • locale_theme() : locale.module
  • locale_translate_delete() : locale.inc
  • locale_translate_edit_form() : locale.inc
  • locale_translate_edit_form_submit() : locale.inc
  • locale_translate_export_po_form() : locale.inc
  • locale_translate_export_po_form_submit() : locale.inc
  • locale_translate_export_pot_form() : locale.inc
  • locale_translate_export_screen() : locale.inc
  • locale_translate_import_form() : locale.inc
  • locale_translate_import_form_submit() : locale.inc
  • locale_translate_overview_screen() : locale.inc
  • locale_translate_seek_form() : locale.inc
  • locale_translate_seek_screen() : locale.inc
  • locale_uninstall() : locale.install
  • locale_update_6000() : locale.install
  • locale_update_6001() : locale.install
  • locale_update_6002() : locale.install
  • locale_update_6003() : locale.install
  • locale_update_6004() : locale.install
  • locale_update_6005() : locale.install
  • locale_update_js_files() : locale.module
  • locale_user() : locale.module
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- m -

  • map_month() : form.inc
  • menu_block() : menu.module
  • menu_cache_clear() : menu.inc
  • menu_cache_clear_all() : menu.inc
  • menu_configure() : menu.admin.inc
  • menu_custom_delete_submit() : menu.admin.inc
  • menu_delete_menu_confirm() : menu.admin.inc
  • menu_delete_menu_confirm_submit() : menu.admin.inc
  • menu_delete_menu_page() : menu.admin.inc
  • menu_edit_item() : menu.admin.inc
  • menu_edit_item_submit() : menu.admin.inc
  • menu_edit_item_validate() : menu.admin.inc
  • menu_edit_menu() : menu.admin.inc
  • menu_edit_menu_submit() : menu.admin.inc
  • menu_edit_menu_validate() : menu.admin.inc
  • menu_enable() : menu.module
  • menu_execute_active_handler() : menu.inc
  • menu_form_alter() : menu.module
  • menu_get_active_breadcrumb() : menu.inc
  • menu_get_active_help() : menu.inc
  • menu_get_active_menu_name() : menu.inc
  • menu_get_active_title() : menu.inc
  • menu_get_active_trail() : menu.inc
  • menu_get_ancestors() : menu.inc
  • menu_get_item() : menu.inc
  • menu_get_menus() : menu.module
  • menu_get_names() : menu.inc
  • menu_get_object() : menu.inc
  • menu_help() : menu.module
  • menu_install() : menu.install
  • menu_item_delete_form() : menu.admin.inc
  • menu_item_delete_form_submit() : menu.admin.inc
  • menu_item_delete_page() : menu.admin.inc
  • menu_item_delete_submit() : menu.admin.inc
  • menu_link_children_relative_depth() : menu.inc
  • menu_link_delete() : menu.inc
  • menu_link_load() : menu.inc
  • menu_link_maintain() : menu.inc
  • menu_link_save() : menu.inc
  • menu_list_system_menus() : menu.inc
  • menu_load() : menu.module
  • menu_local_tasks() : menu.inc
  • menu_menu() : menu.module
  • menu_navigation_links() : menu.inc
  • menu_node_form_submit() : menu.module
  • menu_nodeapi() : menu.module
  • menu_overview_form() : menu.admin.inc
  • menu_overview_form_submit() : menu.admin.inc
  • menu_overview_page() : menu.admin.inc
  • menu_overview_title() : menu.module
  • menu_parent_options() : menu.module
  • menu_path_is_external() : menu.inc
  • menu_perm() : menu.module
  • menu_primary_links() : menu.inc
  • menu_primary_local_tasks() : menu.inc
  • menu_rebuild() : menu.inc
  • menu_reset_item() : menu.module
  • menu_reset_item_confirm() : menu.admin.inc
  • menu_reset_item_confirm_submit() : menu.admin.inc
  • menu_router_build() : menu.inc
  • menu_schema() : menu.install
  • menu_secondary_links() : menu.inc
  • menu_secondary_local_tasks() : menu.inc
  • menu_set_active_item() : menu.inc
  • menu_set_active_menu_name() : menu.inc
  • menu_set_active_trail() : menu.inc
  • menu_set_item() : menu.inc
  • menu_tab_root_path() : menu.inc
  • menu_tail_to_arg() : menu.inc
  • menu_theme() : menu.module
  • menu_tree() : menu.inc
  • menu_tree_all_data() : menu.inc
  • menu_tree_check_access() : menu.inc
  • menu_tree_collect_node_links() : menu.inc
  • menu_tree_data() : menu.inc
  • menu_tree_output() : menu.inc
  • menu_tree_page_data() : menu.inc
  • menu_uninstall() : menu.install
  • menu_unserialize() : menu.inc
  • menu_valid_path() : menu.inc
  • mime_header_decode() : unicode.inc
  • mime_header_encode() : unicode.inc
  • module_disable() : module.inc
  • module_enable() : module.inc
  • module_exists() : module.inc
  • module_hook() : module.inc
  • module_implements() : module.inc
  • module_invoke() : module.inc
  • module_invoke_all() : module.inc
  • module_iterate() : module.inc
  • module_list() : module.inc
  • module_load_all() : module.inc
  • module_load_all_includes() : module.inc
  • module_load_include() : module.inc
  • module_load_install() : module.inc
  • module_rebuild_cache() : module.inc
  • multipage_form_example_access() : multipage_form_example.module
  • multipage_form_example_custom_submit() : multipage_form_example.module
  • multipage_form_example_custom_validate() : multipage_form_example.module
  • multipage_form_example_delete() : multipage_form_example.module
  • multipage_form_example_elements() : multipage_form_example.module
  • multipage_form_example_form() : multipage_form_example.module
  • multipage_form_example_form_alter() : multipage_form_example.module
  • multipage_form_example_help() : multipage_form_example.module
  • multipage_form_example_load() : multipage_form_example.module
  • multipage_form_example_menu() : multipage_form_example.module
  • multipage_form_example_node_info() : multipage_form_example.module
  • multipage_form_example_pre_render() : multipage_form_example.module
  • multipage_form_example_view() : multipage_form_example.module
  • multipage_form_restore_attributes() : multipage_form_example.module
  • multipage_form_set_attribute() : multipage_form_example.module
  • multipage_form_set_element_visibility() : multipage_form_example.module
  • mysql_is_available() : install.mysql.inc
  • mysqli_is_available() : install.mysqli.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- n -

  • node_access() : node.module
  • node_access_acquire_grants() : node.module
  • node_access_example_form_alter() : node_access_example.module
  • node_access_example_install() : node_access_example.install
  • node_access_example_node_access_records() : node_access_example.module
  • node_access_example_node_grants() : node_access_example.module
  • node_access_example_nodeapi() : node_access_example.module
  • node_access_example_perm() : node_access_example.module
  • node_access_example_schema() : node_access_example.install
  • node_access_example_uninstall() : node_access_example.install
  • node_access_grants() : node.module
  • node_access_needs_rebuild() : node.module
  • node_access_rebuild() : node.module
  • node_access_view_all_nodes() : node.module
  • node_access_write_grants() : node.module
  • node_action_info() : node.module
  • node_add() : node.pages.inc
  • node_add_page() : node.pages.inc
  • node_admin_content() : node.admin.inc
  • node_admin_nodes() : node.admin.inc
  • node_admin_nodes_submit() : node.admin.inc
  • node_admin_nodes_validate() : node.admin.inc
  • node_assign_owner_action() : node.module
  • node_assign_owner_action_form() : node.module
  • node_assign_owner_action_submit() : node.module
  • node_assign_owner_action_validate() : node.module
  • node_block() : node.module
  • node_body_field() : node.pages.inc
  • node_build_content() : node.module
  • node_build_filter_query() : node.admin.inc
  • node_comment_mode() : node.module
  • node_configure() : node.admin.inc
  • node_configure_rebuild_confirm() : node.admin.inc
  • node_configure_rebuild_confirm_submit() : node.admin.inc
  • node_configure_validate() : node.admin.inc
  • node_content_access() : node.module
  • node_content_form() : node.module
  • node_cron() : node.module
  • node_db_rewrite_sql() : node.module
  • node_delete() : node.module
  • node_delete_confirm() : node.pages.inc
  • node_delete_confirm_submit() : node.pages.inc
  • node_example_access() : node_example.module
  • node_example_delete() : node_example.module
  • node_example_form() : node_example.module
  • node_example_insert() : node_example.module
  • node_example_install() : node_example.install
  • node_example_load() : node_example.module
  • node_example_node_info() : node_example.module
  • node_example_nodeapi() : node_example.module
  • node_example_perm() : node_example.module
  • node_example_schema() : node_example.install
  • node_example_theme() : node_example.module
  • node_example_uninstall() : node_example.install
  • node_example_update() : node_example.module
  • node_example_validate() : node_example.module
  • node_example_view() : node_example.module
  • node_feed() : node.module
  • node_filter_form() : node.admin.inc
  • node_filter_form_submit() : node.admin.inc
  • node_filters() : node.admin.inc
  • node_form() : node.pages.inc
  • node_form_alter() : node.module
  • node_form_build_preview() : node.pages.inc
  • node_form_delete_submit() : node.pages.inc
  • node_form_submit() : node.pages.inc
  • node_form_submit_build_node() : node.pages.inc
  • node_form_validate() : node.pages.inc
  • node_forms() : node.module
  • node_get_types() : node.module
  • node_help() : node.module
  • node_hook() : node.module
  • node_hook_info() : node.module
  • node_init() : node.module
  • node_invoke() : node.module
  • node_invoke_nodeapi() : node.module
  • node_last_changed() : node.module
  • node_last_viewed() : node.module
  • node_link() : node.module
  • node_load() : node.module
  • node_make_sticky_action() : node.module
  • node_make_unsticky_action() : node.module
  • node_mark() : node.module
  • node_mass_update() : node.admin.inc
  • node_menu() : node.module
  • node_multiple_delete_confirm() : node.admin.inc
  • node_multiple_delete_confirm_submit() : node.admin.inc
  • node_node_operations() : node.admin.inc
  • node_node_type() : content_types.inc
  • node_object_prepare() : node.pages.inc
  • node_overview_types() : content_types.inc
  • node_page_default() : node.module
  • node_page_edit() : node.pages.inc
  • node_page_title() : node.module
  • node_page_view() : node.module
  • node_perm() : node.module
  • node_prepare() : node.module
  • node_preview() : node.pages.inc
  • node_promote_action() : node.module
  • node_publish_action() : node.module
  • node_revision_delete_confirm() : node.pages.inc
  • node_revision_delete_confirm_submit() : node.pages.inc
  • node_revision_list() : node.module
  • node_revision_overview() : node.pages.inc
  • node_revision_revert_confirm() : node.pages.inc
  • node_revision_revert_confirm_submit() : node.pages.inc
  • node_save() : node.module
  • node_save_action() : node.module
  • node_schema() : node.install
  • node_search() : node.module
  • node_search_validate() : node.module
  • node_show() : node.module
  • node_submit() : node.module
  • node_tag_new() : node.module
  • node_teaser() : node.module
  • node_teaser_include_verify() : node.module
  • node_teaser_js() : node.module
  • node_theme() : node.module
  • node_title_list() : node.module
  • node_type_delete() : node.module
  • node_type_delete_confirm() : content_types.inc
  • node_type_delete_confirm_submit() : content_types.inc
  • node_type_form() : content_types.inc
  • node_type_form_submit() : content_types.inc
  • node_type_form_validate() : content_types.inc
  • node_type_reset() : content_types.inc
  • node_type_save() : node.module
  • node_type_update_nodes() : node.module
  • node_types_rebuild() : node.module
  • node_unpromote_action() : node.module
  • node_unpublish_action() : node.module
  • node_unpublish_by_keyword_action() : node.module
  • node_unpublish_by_keyword_action_form() : node.module
  • node_unpublish_by_keyword_action_submit() : node.module
  • node_update_index() : node.module
  • node_user() : node.module
  • node_validate() : node.module
  • node_view() : node.module
  • nodeapi_example_form_alter() : nodeapi_example.module
  • nodeapi_example_install() : nodeapi_example.install
  • nodeapi_example_nodeapi() : nodeapi_example.module
  • nodeapi_example_schema() : nodeapi_example.install
  • nodeapi_example_theme() : nodeapi_example.module
  • nodeapi_example_uninstall() : nodeapi_example.install
  • nodeapi_example_update_1() : nodeapi_example.install
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- o -

  • openid_association() : openid.module
  • openid_association_request() : openid.module
  • openid_authentication() : openid.module
  • openid_authentication_page() : openid.pages.inc
  • openid_authentication_request() : openid.module
  • openid_begin() : openid.module
  • openid_complete() : openid.module
  • openid_discovery() : openid.module
  • openid_form_alter() : openid.module
  • openid_help() : openid.module
  • openid_install() : openid.install
  • openid_login_validate() : openid.module
  • openid_menu() : openid.module
  • openid_redirect() : openid.inc
  • openid_redirect_form() : openid.inc
  • openid_redirect_http() : openid.inc
  • openid_schema() : openid.install
  • openid_uninstall() : openid.install
  • openid_user() : openid.module
  • openid_user_add() : openid.pages.inc
  • openid_user_add_validate() : openid.pages.inc
  • openid_user_delete() : openid.pages.inc
  • openid_user_identities() : openid.pages.inc
  • openid_verify_assertion() : openid.module
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- a -

  • actions_actions_map() : actions.inc
  • actions_delete() : actions.inc
  • actions_do() : actions.inc
  • actions_function_lookup() : actions.inc
  • actions_get_all_actions() : actions.inc
  • actions_list() : actions.inc
  • actions_load() : actions.inc
  • actions_save() : actions.inc
  • actions_synchronize() : actions.inc
  • aggregator_admin_overview() : aggregator.admin.inc
  • aggregator_admin_refresh_feed() : aggregator.admin.inc
  • aggregator_admin_remove_feed() : aggregator.admin.inc
  • aggregator_admin_remove_feed_submit() : aggregator.admin.inc
  • aggregator_admin_settings() : aggregator.admin.inc
  • aggregator_block() : aggregator.module
  • aggregator_categorize_items() : aggregator.pages.inc
  • aggregator_categorize_items_submit() : aggregator.pages.inc
  • aggregator_categorize_items_validate() : aggregator.pages.inc
  • aggregator_category_load() : aggregator.module
  • aggregator_cron() : aggregator.module
  • aggregator_element_data() : aggregator.module
  • aggregator_element_end() : aggregator.module
  • aggregator_element_start() : aggregator.module
  • aggregator_feed_items_load() : aggregator.pages.inc
  • aggregator_feed_load() : aggregator.module
  • aggregator_filter_xss() : aggregator.module
  • aggregator_form_category() : aggregator.admin.inc
  • aggregator_form_category_submit() : aggregator.admin.inc
  • aggregator_form_category_validate() : aggregator.admin.inc
  • aggregator_form_feed() : aggregator.admin.inc
  • aggregator_form_feed_submit() : aggregator.admin.inc
  • aggregator_form_feed_validate() : aggregator.admin.inc
  • aggregator_help() : aggregator.module
  • aggregator_init() : aggregator.module
  • aggregator_install() : aggregator.install
  • aggregator_menu() : aggregator.module
  • aggregator_page_categories() : aggregator.pages.inc
  • aggregator_page_category() : aggregator.pages.inc
  • aggregator_page_last() : aggregator.pages.inc
  • aggregator_page_opml() : aggregator.pages.inc
  • aggregator_page_rss() : aggregator.pages.inc
  • aggregator_page_source() : aggregator.pages.inc
  • aggregator_page_sources() : aggregator.pages.inc
  • aggregator_parse_feed() : aggregator.module
  • aggregator_parse_w3cdtf() : aggregator.module
  • aggregator_perm() : aggregator.module
  • aggregator_refresh() : aggregator.module
  • aggregator_remove() : aggregator.module
  • aggregator_save_category() : aggregator.module
  • aggregator_save_feed() : aggregator.module
  • aggregator_save_item() : aggregator.module
  • aggregator_schema() : aggregator.install
  • aggregator_theme() : aggregator.module
  • aggregator_uninstall() : aggregator.install
  • aggregator_view() : aggregator.admin.inc
  • arg() : path.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- b -

  • base_path() : common.inc
  • batch_example_batch_1() : batch_example.module
  • batch_example_batch_2() : batch_example.module
  • batch_example_finished() : batch_example.module
  • batch_example_menu() : batch_example.module
  • batch_example_multistep_form() : batch_example.module
  • batch_example_multistep_form_submit() : batch_example.module
  • batch_example_op_1() : batch_example.module
  • batch_example_op_2() : batch_example.module
  • batch_example_page() : batch_example.module
  • batch_example_simple_form() : batch_example.module
  • batch_example_simple_form_submit() : batch_example.module
  • batch_get() : form.inc
  • batch_process() : form.inc
  • batch_set() : form.inc
  • batch_test_update_1() : batch_example.install
  • block_add_block_form() : block.admin.inc
  • block_add_block_form_submit() : block.admin.inc
  • block_add_block_form_validate() : block.admin.inc
  • block_admin_configure() : block.admin.inc
  • block_admin_configure_submit() : block.admin.inc
  • block_admin_configure_validate() : block.admin.inc
  • block_admin_display() : block.admin.inc
  • block_admin_display_form() : block.admin.inc
  • block_admin_display_form_submit() : block.admin.inc
  • block_block() : block.module
  • block_box_delete() : block.admin.inc
  • block_box_delete_submit() : block.admin.inc
  • block_box_form() : block.module
  • block_box_get() : block.module
  • block_box_save() : block.module
  • block_example_block() : block_example.module
  • block_example_contents() : block_example.module
  • block_help() : block.module
  • block_list() : block.module
  • block_menu() : block.module
  • block_perm() : block.module
  • block_schema() : block.install
  • block_theme() : block.module
  • block_user() : block.module
  • blog_access() : blog.module
  • blog_block() : blog.module
  • blog_feed_last() : blog.pages.inc
  • blog_feed_user() : blog.pages.inc
  • blog_form() : blog.module
  • blog_help() : blog.module
  • blog_link() : blog.module
  • blog_menu() : blog.module
  • blog_node_info() : blog.module
  • blog_page_last() : blog.pages.inc
  • blog_page_user() : blog.pages.inc
  • blog_perm() : blog.module
  • blog_user() : blog.module
  • blog_view() : blog.module
  • blogap_mti_publish_post() : blogapi.module
  • blogapi_admin_settings() : blogapi.module
  • blogapi_blogger_delete_post() : blogapi.module
  • blogapi_blogger_edit_post() : blogapi.module
  • blogapi_blogger_get_post() : blogapi.module
  • blogapi_blogger_get_recent_posts() : blogapi.module
  • blogapi_blogger_get_user_info() : blogapi.module
  • blogapi_blogger_get_users_blogs() : blogapi.module
  • blogapi_blogger_new_post() : blogapi.module
  • blogapi_blogger_title() : blogapi.module
  • blogapi_error() : blogapi.module
  • blogapi_help() : blogapi.module
  • blogapi_init() : blogapi.module
  • blogapi_menu() : blogapi.module
  • blogapi_metaweblog_edit_post() : blogapi.module
  • blogapi_metaweblog_get_category_list() : blogapi.module
  • blogapi_metaweblog_get_post() : blogapi.module
  • blogapi_metaweblog_get_recent_posts() : blogapi.module
  • blogapi_metaweblog_new_media_object() : blogapi.module
  • blogapi_metaweblog_new_post() : blogapi.module
  • blogapi_mt_get_category_list() : blogapi.module
  • blogapi_mt_get_post_categories() : blogapi.module
  • blogapi_mt_get_recent_post_titles() : blogapi.module
  • blogapi_mt_set_post_categories() : blogapi.module
  • blogapi_mt_supported_text_filters() : blogapi.module
  • blogapi_perm() : blogapi.module
  • blogapi_rsd() : blogapi.module
  • blogapi_update_6000() : blogapi.install
  • blogapi_validate_user() : blogapi.module
  • blogapi_xmlrpc() : blogapi.module
  • book_admin_edit() : book.admin.inc
  • book_admin_edit_submit() : book.admin.inc
  • book_admin_overview() : book.admin.inc
  • book_admin_settings() : book.admin.inc
  • book_admin_settings_validate() : book.admin.inc
  • book_block() : book.module
  • book_build_active_trail() : book.module
  • book_children() : book.module
  • book_export() : book.pages.inc
  • book_export_html() : book.pages.inc
  • book_export_traverse() : book.module
  • book_form_alter() : book.module
  • book_form_node_delete_confirm_alter() : book.module
  • book_form_update() : book.pages.inc
  • book_get_books() : book.module
  • book_get_flat_menu() : book.module
  • book_help() : book.module
  • book_init() : book.module
  • book_install() : book.install
  • book_link() : book.module
  • book_link_load() : book.module
  • book_menu() : book.module
  • book_menu_name() : book.module
  • book_menu_subtree_data() : book.module
  • book_next() : book.module
  • book_node_export() : book.module
  • book_node_type() : book.module
  • book_nodeapi() : book.module
  • book_outline() : book.pages.inc
  • book_outline_form() : book.pages.inc
  • book_outline_form_submit() : book.pages.inc
  • book_perm() : book.module
  • book_prev() : book.module
  • book_remove_button_submit() : book.pages.inc
  • book_remove_form() : book.pages.inc
  • book_remove_form_submit() : book.pages.inc
  • book_render() : book.pages.inc
  • book_schema() : book.install
  • book_theme() : book.module
  • book_toc() : book.module
  • book_type_is_allowed() : book.module
  • book_uninstall() : book.install
  • book_update_6000() : book.install
  • book_update_bid() : book.module
  • bootstrap_hooks() : bootstrap.inc
  • bootstrap_invoke_all() : bootstrap.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- c -

  • cache_clear_all() : cache-install.inc , cache.inc
  • cache_get() : cache.inc , cache-install.inc
  • cache_set() : cache-install.inc , cache.inc
  • chameleon_comment() : chameleon.theme
  • chameleon_help() : chameleon.theme
  • chameleon_node() : chameleon.theme
  • chameleon_page() : chameleon.theme
  • chameleon_theme() : chameleon.theme
  • check_file() : common.inc
  • check_markup() : filter.module
  • check_plain() : bootstrap.inc
  • check_url() : common.inc
  • color_form_alter() : color.module
  • color_get_info() : color.module
  • color_get_palette() : color.module
  • color_help() : color.module
  • color_requirements() : color.install
  • color_scheme_form() : color.module
  • color_scheme_form_submit() : color.module
  • color_theme() : color.module
  • comment_access() : comment.module
  • comment_action_info() : comment.module
  • comment_admin() : comment.admin.inc
  • comment_admin_overview() : comment.admin.inc
  • comment_admin_overview_submit() : comment.admin.inc
  • comment_admin_overview_validate() : comment.admin.inc
  • comment_block() : comment.module
  • comment_confirm_delete() : comment.admin.inc
  • comment_confirm_delete_submit() : comment.admin.inc
  • comment_controls() : comment.module
  • comment_controls_submit() : comment.module
  • comment_delete() : comment.admin.inc
  • comment_edit() : comment.pages.inc
  • comment_enable() : comment.install
  • comment_form() : comment.module
  • comment_form_add_preview() : comment.module
  • comment_form_alter() : comment.module
  • comment_form_box() : comment.module
  • comment_form_submit() : comment.module
  • comment_form_validate() : comment.module
  • comment_get_recent() : comment.module
  • comment_help() : comment.module
  • comment_hook_info() : comment.module
  • comment_invoke_comment() : comment.module
  • comment_link() : comment.module
  • comment_links() : comment.module
  • comment_menu() : comment.module
  • comment_multiple_delete_confirm() : comment.admin.inc
  • comment_multiple_delete_confirm_submit() : comment.admin.inc
  • comment_new_page_count() : comment.module
  • comment_node_type() : comment.module
  • comment_node_url() : comment.module
  • comment_nodeapi() : comment.module
  • comment_num_all() : comment.module
  • comment_num_new() : comment.module
  • comment_num_replies() : comment.module
  • comment_operations() : comment.module
  • comment_perm() : comment.module
  • comment_render() : comment.module
  • comment_reply() : comment.pages.inc
  • comment_save() : comment.module
  • comment_schema() : comment.install
  • comment_theme() : comment.module
  • comment_unpublish_action() : comment.module
  • comment_unpublish_by_keyword_action() : comment.module
  • comment_unpublish_by_keyword_action_form() : comment.module
  • comment_unpublish_by_keyword_action_submit() : comment.module
  • comment_update_1() : comment.install
  • comment_update_6001() : comment.install
  • comment_update_6002() : comment.install
  • comment_update_6003() : comment.install
  • comment_user() : comment.module
  • comment_validate() : comment.module
  • conf_init() : bootstrap.inc
  • conf_path() : bootstrap.inc
  • confirm_form() : system.module
  • contact_admin_categories() : contact.admin.inc
  • contact_admin_delete() : contact.admin.inc
  • contact_admin_delete_submit() : contact.admin.inc
  • contact_admin_edit() : contact.admin.inc
  • contact_admin_edit_submit() : contact.admin.inc
  • contact_admin_edit_validate() : contact.admin.inc
  • contact_admin_settings() : contact.admin.inc
  • contact_help() : contact.module
  • contact_install() : contact.install
  • contact_load() : contact.module
  • contact_mail() : contact.module
  • contact_mail_page() : contact.pages.inc
  • contact_mail_page_submit() : contact.pages.inc
  • contact_mail_page_validate() : contact.pages.inc
  • contact_mail_user() : contact.pages.inc
  • contact_mail_user_submit() : contact.pages.inc
  • contact_menu() : contact.module
  • contact_perm() : contact.module
  • contact_schema() : contact.install
  • contact_site_page() : contact.pages.inc
  • contact_uninstall() : contact.install
  • contact_user() : contact.module
  • contact_user_page() : contact.pages.inc
  • custom_url_rewrite_inbound() : core.php
  • custom_url_rewrite_outbound() : core.php
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- d -

  • date_validate() : form.inc
  • db_add_column() : update.php
  • db_add_field() : database.pgsql.inc , database.mysql-common.inc
  • db_add_index() : database.mysql-common.inc , database.pgsql.inc
  • db_add_primary_key() : database.pgsql.inc , database.mysql-common.inc
  • db_add_unique_key() : database.mysql-common.inc , database.pgsql.inc
  • db_affected_rows() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_change_column() : update.php
  • db_change_field() : database.pgsql.inc , database.mysql-common.inc
  • db_check_setup() : database.pgsql.inc
  • db_column_exists() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_connect() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_create_table() : database.inc
  • db_create_table_sql() : database.mysql-common.inc , database.pgsql.inc
  • db_decode_blob() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_distinct_field() : database.pgsql.inc , database.mysql.inc , database.mysqli.inc
  • db_drop_field() : database.mysql-common.inc , database.pgsql.inc
  • db_drop_index() : database.mysql-common.inc , database.pgsql.inc
  • db_drop_primary_key() : database.mysql-common.inc , database.pgsql.inc
  • db_drop_table() : database.mysql-common.inc , database.pgsql.inc
  • db_drop_unique_key() : database.mysql-common.inc , database.pgsql.inc
  • db_encode_blob() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_error() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_escape_string() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_escape_table() : database.inc
  • db_fetch_array() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_fetch_object() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_field_names() : database.inc
  • db_field_set_default() : database.mysql-common.inc , database.pgsql.inc
  • db_field_set_no_default() : database.mysql-common.inc , database.pgsql.inc
  • db_is_active() : database.inc
  • db_last_insert_id() : database.mysql-common.inc , database.pgsql.inc
  • db_lock_table() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_placeholders() : database.inc
  • db_prefix_tables() : database.inc
  • db_query() : database.mysql-common.inc , database.pgsql.inc
  • db_query_range() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_query_temporary() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_rename_table() : database.mysql-common.inc , database.pgsql.inc
  • db_result() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_rewrite_sql() : database.inc
  • db_set_active() : database.inc
  • db_status_report() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_table_exists() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_type_map() : database.mysql-common.inc , database.pgsql.inc
  • db_type_placeholder() : database.inc
  • db_unlock_tables() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • db_version() : database.mysql.inc , database.mysqli.inc , database.pgsql.inc
  • dblog_admin_settings() : dblog.admin.inc
  • dblog_build_filter_query() : dblog.admin.inc
  • dblog_cron() : dblog.module
  • dblog_event() : dblog.admin.inc
  • dblog_filter_form() : dblog.admin.inc
  • dblog_filter_form_submit() : dblog.admin.inc
  • dblog_filter_form_validate() : dblog.admin.inc
  • dblog_filters() : dblog.admin.inc
  • dblog_help() : dblog.module
  • dblog_init() : dblog.module
  • dblog_install() : dblog.install
  • dblog_menu() : dblog.module
  • dblog_overview() : dblog.admin.inc
  • dblog_schema() : dblog.install
  • dblog_theme() : dblog.module
  • dblog_top() : dblog.admin.inc
  • dblog_uninstall() : dblog.install
  • dblog_user() : dblog.module
  • dblog_watchdog() : dblog.module
  • decode_entities() : unicode.inc
  • default_form_alter() : default.profile
  • default_profile_details() : default.profile
  • default_profile_modules() : default.profile
  • default_profile_task_list() : default.profile
  • default_profile_tasks() : default.profile
  • do_search() : search.module
  • drupal_access_denied() : common.inc
  • drupal_add_css() : common.inc
  • drupal_add_feed() : common.inc
  • drupal_add_js() : common.inc
  • drupal_add_link() : common.inc
  • drupal_add_tabledrag() : common.inc
  • drupal_alter() : common.inc
  • drupal_anonymous_user() : bootstrap.inc
  • drupal_attributes() : common.inc
  • drupal_bootstrap() : bootstrap.inc
  • drupal_build_css_cache() : common.inc
  • drupal_build_js_cache() : common.inc
  • drupal_check_module() : install.inc
  • drupal_check_profile() : install.inc
  • drupal_clear_css_cache() : common.inc
  • drupal_clear_js_cache() : common.inc
  • drupal_clear_path_cache() : common.inc
  • drupal_clone() : common.inc
  • drupal_common_theme() : common.inc
  • drupal_convert_to_utf8() : unicode.inc
  • drupal_cron_cleanup() : common.inc
  • drupal_cron_run() : common.inc
  • drupal_detect_baseurl() : install.inc
  • drupal_detect_database_types() : install.inc
  • drupal_discover_template() : theme.inc
  • drupal_error_handler() : common.inc
  • drupal_eval() : common.inc
  • drupal_execute() : form.inc
  • drupal_explode_tags() : common.inc
  • drupal_find_theme_functions() : theme.inc
  • drupal_find_theme_templates() : theme.inc
  • drupal_flush_all_caches() : common.inc
  • drupal_get_breadcrumb() : common.inc
  • drupal_get_content() : common.inc
  • drupal_get_css() : common.inc
  • drupal_get_destination() : common.inc
  • drupal_get_feeds() : common.inc
  • drupal_get_filename() : bootstrap.inc
  • drupal_get_form() : form.inc
  • drupal_get_headers() : common.inc
  • drupal_get_html_head() : common.inc
  • drupal_get_install_files() : install.inc
  • drupal_get_installed_schema_version() : install.inc
  • drupal_get_js() : common.inc
  • drupal_get_messages() : bootstrap.inc
  • drupal_get_normal_path() : path.inc
  • drupal_get_path() : common.inc
  • drupal_get_path_alias() : path.inc
  • drupal_get_private_key() : common.inc
  • drupal_get_schema() : common.inc
  • drupal_get_schema_unprocessed() : common.inc
  • drupal_get_schema_versions() : install.inc
  • drupal_get_title() : path.inc
  • drupal_get_token() : common.inc
  • drupal_goto() : common.inc
  • drupal_help_arg() : menu.inc
  • drupal_html_to_text() : mail.inc
  • drupal_http_request() : common.inc
  • drupal_implode_tags() : common.inc
  • drupal_init_language() : bootstrap.inc
  • drupal_init_path() : path.inc
  • drupal_install_fix_file() : install.inc
  • drupal_install_mkdir() : install.inc
  • drupal_install_modules() : install.inc
  • drupal_install_profile_name() : install.inc
  • drupal_install_schema() : common.inc
  • drupal_install_system() : install.inc
  • drupal_is_denied() : bootstrap.inc
  • drupal_is_front_page() : path.inc
  • drupal_json() : common.inc
  • drupal_load() : bootstrap.inc
  • drupal_load_stylesheet() : common.inc
  • drupal_load_updates() : install.inc
  • drupal_lookup_path() : path.inc
  • drupal_mail() : mail.inc
  • drupal_mail_send() : mail.inc
  • drupal_maintenance_theme() : bootstrap.inc
  • drupal_map_assoc() : common.inc
  • drupal_match_path() : path.inc
  • drupal_not_found() : common.inc
  • drupal_page_cache_header() : bootstrap.inc
  • drupal_page_footer() : common.inc
  • drupal_page_header() : bootstrap.inc
  • drupal_parse_info_file() : common.inc
  • drupal_prepare_form() : form.inc
  • drupal_process_form() : form.inc
  • drupal_query_string_encode() : common.inc
  • drupal_rebuild_form() : form.inc
  • drupal_rebuild_theme_registry() : theme.inc
  • drupal_redirect_form() : form.inc
  • drupal_render() : common.inc
  • drupal_render_form() : form.inc
  • drupal_required_modules() : module.inc
  • drupal_requirements_severity() : install.inc
  • drupal_retrieve_form() : form.inc
  • drupal_rewrite_settings() : install.inc
  • drupal_schema_fields_sql() : common.inc
  • drupal_set_breadcrumb() : common.inc
  • drupal_set_content() : common.inc
  • drupal_set_header() : common.inc
  • drupal_set_html_head() : common.inc
  • drupal_set_installed_schema_version() : install.inc
  • drupal_set_message() : bootstrap.inc
  • drupal_set_title() : path.inc
  • drupal_site_offline() : common.inc
  • drupal_strlen() : unicode.inc
  • drupal_strtolower() : unicode.inc
  • drupal_strtoupper() : unicode.inc
  • drupal_substr() : unicode.inc
  • drupal_system_listing() : common.inc
  • drupal_test_mysql() : install.mysql.inc
  • drupal_test_mysqli() : install.mysqli.inc
  • drupal_test_pgsql() : install.pgsql.inc
  • drupal_to_js() : common.inc
  • drupal_truncate_bytes() : unicode.inc
  • drupal_ucfirst() : unicode.inc
  • drupal_uninstall_module() : install.inc
  • drupal_uninstall_schema() : common.inc
  • drupal_unpack() : bootstrap.inc
  • drupal_unset_globals() : bootstrap.inc
  • drupal_urlencode() : common.inc
  • drupal_valid_token() : common.inc
  • drupal_validate_form() : form.inc
  • drupal_validate_utf8() : bootstrap.inc
  • drupal_verify_install_file() : install.inc
  • drupal_verify_profile() : install.inc
  • drupal_wrap_mail() : mail.inc
  • drupal_write_record() : common.inc
  • drupal_xml_parser_create() : unicode.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- e -

  • element_child() : common.inc
  • element_children() : common.inc
  • element_properties() : common.inc
  • element_property() : common.inc
  • element_sort() : common.inc
  • example_element_demo_form() : example_element.module
  • example_element_elements() : example_element.module
  • example_element_menu() : example_element.module
  • example_element_phonenumber_expand() : example_element.module
  • example_element_phonenumber_validate() : example_element.module
  • example_element_theme() : example_element.module
  • example_form() : example.profile
  • example_form_alter() : example.profile
  • example_form_submit() : example.profile
  • example_profile_details() : example.profile
  • example_profile_modules() : example.profile
  • example_profile_task_list() : example.profile
  • example_profile_tasks() : example.profile
  • expand_checkboxes() : form.inc
  • expand_date() : form.inc
  • expand_hidden_array() : multipage_form_example.module
  • expand_password_confirm() : form.inc
  • expand_radios() : form.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- f -

  • file_check_directory() : file.inc
  • file_check_location() : file.inc
  • file_check_path() : file.inc
  • file_copy() : file.inc
  • file_create_filename() : file.inc
  • file_create_path() : file.inc
  • file_create_url() : file.inc
  • file_delete() : file.inc
  • file_destination() : file.inc
  • file_directory_path() : file.inc
  • file_directory_temp() : file.inc
  • file_download() : file.inc
  • file_move() : file.inc
  • file_munge_filename() : file.inc
  • file_save_data() : file.inc
  • file_save_upload() : file.inc
  • file_scan_directory() : file.inc
  • file_set_status() : file.inc
  • file_space_used() : file.inc
  • file_transfer() : file.inc
  • file_unmunge_filename() : file.inc
  • file_upload_max_size() : file.inc
  • file_validate_extensions() : file.inc
  • file_validate_image_resolution() : file.inc
  • file_validate_is_image() : file.inc
  • file_validate_name_length() : file.inc
  • file_validate_size() : file.inc
  • fileupload_access() : fileupload.module
  • fileupload_delete() : fileupload.module
  • fileupload_file_download() : fileupload.module
  • fileupload_form() : fileupload.module
  • fileupload_help() : fileupload.module
  • fileupload_insert() : fileupload.module
  • fileupload_load() : fileupload.module
  • fileupload_menu() : fileupload.module
  • fileupload_node_info() : fileupload.module
  • fileupload_perm() : fileupload.module
  • fileupload_submit() : fileupload.module
  • fileupload_update() : fileupload.module
  • fileupload_validate() : fileupload.module
  • fileupload_view() : fileupload.module
  • filter_access() : filter.module
  • filter_admin_configure() : filter.admin.inc
  • filter_admin_configure_page() : filter.admin.inc
  • filter_admin_configure_submit() : filter.admin.inc
  • filter_admin_delete() : filter.admin.inc
  • filter_admin_delete_submit() : filter.admin.inc
  • filter_admin_format_form() : filter.admin.inc
  • filter_admin_format_form_submit() : filter.admin.inc
  • filter_admin_format_form_validate() : filter.admin.inc
  • filter_admin_format_page() : filter.admin.inc
  • filter_admin_format_title() : filter.module
  • filter_admin_order() : filter.admin.inc
  • filter_admin_order_page() : filter.admin.inc
  • filter_admin_order_submit() : filter.admin.inc
  • filter_admin_overview() : filter.admin.inc
  • filter_admin_overview_submit() : filter.admin.inc
  • filter_cron() : filter.module
  • filter_example_filter() : filter_example.module
  • filter_example_filter_tips() : filter_example.module
  • filter_filter() : filter.module
  • filter_filter_tips() : filter.module
  • filter_form() : filter.module
  • filter_form_validate() : filter.module
  • filter_format_allowcache() : filter.module
  • filter_format_load() : filter.module
  • filter_formats() : filter.module
  • filter_help() : filter.module
  • filter_list_all() : filter.module
  • filter_list_format() : filter.module
  • filter_menu() : filter.module
  • filter_perm() : filter.module
  • filter_resolve_format() : filter.module
  • filter_schema() : filter.install
  • filter_theme() : filter.module
  • filter_tips_long() : filter.pages.inc
  • filter_xss() : filter.module
  • filter_xss_admin() : filter.module
  • filter_xss_bad_protocol() : filter.module
  • fix_gpc_magic() : common.inc
  • flood_is_allowed() : common.inc
  • flood_register_event() : common.inc
  • form_builder() : form.inc
  • form_clean_id() : form.inc
  • form_error() : form.inc
  • form_execute_handlers() : form.inc
  • form_expand_ahah() : form.inc
  • form_get_cache() : form.inc
  • form_get_error() : form.inc
  • form_get_errors() : form.inc
  • form_get_options() : form.inc
  • form_options_flatten() : form.inc
  • form_select_options() : form.inc
  • form_set_cache() : form.inc
  • form_set_error() : form.inc
  • form_set_value() : form.inc
  • form_type_checkbox_value() : form.inc
  • form_type_checkboxes_value() : form.inc
  • form_type_image_button_value() : form.inc
  • form_type_password_confirm_value() : form.inc
  • form_type_select_value() : form.inc
  • form_type_textfield_value() : form.inc
  • form_type_token_value() : form.inc
  • format_date() : common.inc
  • format_interval() : common.inc
  • format_plural() : common.inc
  • format_rss_channel() : common.inc
  • format_rss_item() : common.inc
  • format_size() : common.inc
  • format_xml_elements() : common.inc
  • forum_access() : forum.module
  • forum_admin_settings() : forum.admin.inc
  • forum_block() : forum.module
  • forum_confirm_delete() : forum.admin.inc
  • forum_confirm_delete_submit() : forum.admin.inc
  • forum_enable() : forum.install
  • forum_form() : forum.module
  • forum_form_alter() : forum.module
  • forum_form_container() : forum.admin.inc
  • forum_form_forum() : forum.admin.inc
  • forum_form_main() : forum.admin.inc
  • forum_form_submit() : forum.admin.inc
  • forum_get_forums() : forum.module
  • forum_get_topics() : forum.module
  • forum_help() : forum.module
  • forum_init() : forum.module
  • forum_install() : forum.install
  • forum_link_alter() : forum.module
  • forum_load() : forum.module
  • forum_menu() : forum.module
  • forum_node_info() : forum.module
  • forum_nodeapi() : forum.module
  • forum_overview() : forum.admin.inc
  • forum_page() : forum.pages.inc
  • forum_perm() : forum.module
  • forum_schema() : forum.install
  • forum_taxonomy() : forum.module
  • forum_term_load() : forum.module
  • forum_theme() : forum.module
  • forum_uninstall() : forum.install
  • forum_update_6000() : forum.install
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- g -

  • get_t() : bootstrap.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- h -

  • help_help() : help.module
  • help_links_as_list() : help.admin.inc
  • help_main() : help.admin.inc
  • help_menu() : help.module
  • help_page() : help.admin.inc
  • hook_access() : node.php
  • hook_block() : core.php
  • hook_boot() : core.php
  • hook_comment() : core.php
  • hook_cron() : core.php
  • hook_db_rewrite_sql() : core.php
  • hook_delete() : node.php
  • hook_disable() : install.php
  • hook_elements() : core.php
  • hook_enable() : install.php
  • hook_exit() : core.php
  • hook_file_download() : core.php
  • hook_filter() : core.php
  • hook_filter_tips() : core.php
  • hook_footer() : core.php
  • hook_form() : node.php
  • hook_form_alter() : core.php
  • hook_forms() : core.php
  • hook_help() : core.php
  • hook_init() : core.php
  • hook_insert() : node.php
  • hook_install() : install.php
  • hook_link() : core.php
  • hook_link_alter() : core.php
  • hook_load() : node.php
  • hook_mail() : core.php
  • hook_mail_alter() : core.php
  • hook_menu() : core.php
  • hook_menu_alter() : core.php
  • hook_menu_link_alter() : core.php
  • hook_node_access_records() : core.php
  • hook_node_grants() : core.php
  • hook_node_info() : node.php
  • hook_node_operations() : core.php
  • hook_node_type() : node.php
  • hook_nodeapi() : core.php
  • hook_perm() : core.php
  • hook_ping() : core.php
  • hook_prepare() : node.php
  • hook_profile_alter() : core.php
  • hook_requirements() : install.php
  • hook_schema() : install.php
  • hook_search() : core.php
  • hook_search_preprocess() : core.php
  • hook_submit() : node.php
  • hook_taxonomy() : core.php
  • hook_theme() : core.php
  • hook_translated_menu_link_alter() : core.php
  • hook_uninstall() : install.php
  • hook_update() : node.php
  • hook_update_index() : core.php
  • hook_update_N() : install.php
  • hook_user() : core.php
  • hook_user_operations() : core.php
  • hook_validate() : node.php
  • hook_view() : node.php
  • hook_watchdog() : core.php
  • hook_xmlrpc() : core.php
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- i -

  • image_crop() : image.inc
  • image_gd_check_settings() : image.gd.inc
  • image_gd_close() : image.gd.inc
  • image_gd_crop() : image.gd.inc
  • image_gd_info() : image.gd.inc
  • image_gd_open() : image.gd.inc
  • image_gd_resize() : image.gd.inc
  • image_gd_rotate() : image.gd.inc
  • image_gd_settings() : image.gd.inc
  • image_gd_settings_validate() : image.gd.inc
  • image_get_available_toolkits() : image.inc
  • image_get_info() : image.inc
  • image_get_toolkit() : image.inc
  • image_resize() : image.inc
  • image_rotate() : image.inc
  • image_scale() : image.inc
  • image_scale_and_crop() : image.inc
  • image_toolkit_invoke() : image.inc
  • init_theme() : theme.inc
  • install_already_done_error() : install.php
  • install_change_settings() : install.php
  • install_check_requirements() : install.php
  • install_configure_form() : install.php
  • install_configure_form_submit() : install.php
  • install_configure_form_validate() : install.php
  • install_find_locales() : install.php
  • install_find_profiles() : install.php
  • install_goto() : install.inc
  • install_main() : install.php
  • install_no_profile_error() : install.php
  • install_reserved_tasks() : install.php
  • install_select_locale() : install.php
  • install_select_locale_form() : install.php
  • install_select_profile() : install.php
  • install_select_profile_form() : install.php
  • install_settings_form() : install.php
  • install_settings_form_submit() : install.php
  • install_settings_form_validate() : install.php
  • install_task_list() : install.php
  • install_tasks() : install.php
  • install_verify_drupal() : install.php
  • install_verify_settings() : install.php
  • int2vancode() : comment.module
  • ip_address() : bootstrap.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- p -

  • page_example_baz() : page_example.module
  • page_example_foo() : page_example.module
  • page_example_help() : page_example.module
  • page_example_menu() : page_example.module
  • page_example_perm() : page_example.module
  • page_get_cache() : bootstrap.inc
  • page_set_cache() : common.inc
  • pager_get_querystring() : pager.inc
  • pager_load_array() : pager.inc
  • pager_query() : pager.inc
  • parse_size() : common.inc
  • password_confirm_validate() : form.inc
  • path_admin_delete() : path.module
  • path_admin_delete_confirm() : path.admin.inc
  • path_admin_delete_confirm_submit() : path.admin.inc
  • path_admin_edit() : path.admin.inc
  • path_admin_filter_form() : path.admin.inc
  • path_admin_filter_form_submit_filter() : path.admin.inc
  • path_admin_filter_form_submit_reset() : path.admin.inc
  • path_admin_filter_get_keys() : path.admin.inc
  • path_admin_form() : path.admin.inc
  • path_admin_form_submit() : path.admin.inc
  • path_admin_form_validate() : path.admin.inc
  • path_admin_overview() : path.admin.inc
  • path_form_alter() : path.module
  • path_help() : path.module
  • path_load() : path.module
  • path_menu() : path.module
  • path_nodeapi() : path.module
  • path_perm() : path.module
  • path_set_alias() : path.module
  • path_to_theme() : theme.inc
  • pgsql_is_available() : install.pgsql.inc
  • php_disable() : php.install
  • php_filter() : php.module
  • php_filter_tips() : php.module
  • php_help() : php.module
  • php_install() : php.install
  • phptemplate_body_class() : template.php
  • phptemplate_breadcrumb() : template.php
  • phptemplate_comment_submitted() : template.php
  • phptemplate_comment_wrapper() : template.php
  • phptemplate_get_ie_styles() : template.php
  • phptemplate_init() : phptemplate.engine
  • phptemplate_menu_local_tasks() : template.php
  • phptemplate_node_submitted() : template.php
  • phptemplate_preprocess_page() : template.php
  • phptemplate_theme() : phptemplate.engine
  • ping_cron() : ping.module
  • ping_help() : ping.module
  • ping_ping() : ping.module
  • poll_access() : poll.module
  • poll_block() : poll.module
  • poll_cancel() : poll.module
  • poll_cancel_form() : poll.module
  • poll_choice_js() : poll.module
  • poll_cron() : poll.module
  • poll_delete() : poll.module
  • poll_form() : poll.module
  • poll_help() : poll.module
  • poll_init() : poll.module
  • poll_insert() : poll.module
  • poll_install() : poll.install
  • poll_load() : poll.module
  • poll_menu() : poll.module
  • poll_more_choices_submit() : poll.module
  • poll_node_form_submit() : poll.module
  • poll_node_info() : poll.module
  • poll_page() : poll.pages.inc
  • poll_perm() : poll.module
  • poll_results() : poll.pages.inc
  • poll_schema() : poll.install
  • poll_teaser() : poll.module
  • poll_theme() : poll.module
  • poll_uninstall() : poll.install
  • poll_update() : poll.module
  • poll_user() : poll.module
  • poll_validate() : poll.module
  • poll_view() : poll.module
  • poll_view_results() : poll.module
  • poll_view_voting() : poll.module
  • poll_view_voting_validate() : poll.module
  • poll_vote() : poll.module
  • poll_votes() : poll.pages.inc
  • process_weight() : form.inc
  • profile_admin_overview() : profile.admin.inc
  • profile_admin_overview_submit() : profile.admin.inc
  • profile_admin_settings_autocomplete() : profile.admin.inc
  • profile_autocomplete() : profile.pages.inc
  • profile_block() : profile.module
  • profile_browse() : profile.pages.inc
  • profile_categories() : profile.module
  • profile_category_access() : profile.module
  • profile_field_delete() : profile.admin.inc
  • profile_field_delete_submit() : profile.admin.inc
  • profile_field_form() : profile.admin.inc
  • profile_field_form_submit() : profile.admin.inc
  • profile_field_form_validate() : profile.admin.inc
  • profile_form_profile() : profile.module
  • profile_help() : profile.module
  • profile_install() : profile.install
  • profile_load_profile() : profile.module
  • profile_menu() : profile.module
  • profile_save_profile() : profile.module
  • profile_schema() : profile.install
  • profile_theme() : profile.module
  • profile_uninstall() : profile.install
  • profile_user() : profile.module
  • profile_validate_profile() : profile.module
  • profile_view_field() : profile.module
  • profile_view_profile() : profile.module
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- r -

  • referer_uri() : bootstrap.inc
  • request_uri() : bootstrap.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- s -

  • search_admin_settings() : search.admin.inc
  • search_admin_settings_validate() : search.admin.inc
  • search_block() : search.module
  • search_box() : search.module
  • search_box_form_submit() : search.module
  • search_comment() : search.module
  • search_cron() : search.module
  • search_data() : search.module
  • search_dirty() : search.module
  • search_excerpt() : search.module
  • search_expand_cjk() : search.module
  • search_form() : search.module
  • search_form_submit() : search.pages.inc
  • search_form_validate() : search.pages.inc
  • search_forms() : search.module
  • search_get_keys() : search.module
  • search_help() : search.module
  • search_index() : search.module
  • search_index_split() : search.module
  • search_install() : search.install
  • search_invoke_preprocess() : search.module
  • search_menu() : search.module
  • search_nodeapi() : search.module
  • search_parse_query() : search.module
  • search_perm() : search.module
  • search_query_extract() : search.module
  • search_query_insert() : search.module
  • search_schema() : search.install
  • search_simplify() : search.module
  • search_theme() : search.module
  • search_touch_node() : search.module
  • search_uninstall() : search.install
  • search_update_totals() : search.module
  • search_view() : search.pages.inc
  • search_wipe() : search.module
  • search_wipe_confirm() : search.admin.inc
  • search_wipe_confirm_submit() : search.admin.inc
  • sess_close() : session.inc
  • sess_count() : session.inc
  • sess_destroy_sid() : session.inc
  • sess_destroy_uid() : session.inc
  • sess_gc() : session.inc
  • sess_open() : session.inc
  • sess_read() : session.inc
  • sess_regenerate() : session.inc
  • sess_write() : session.inc
  • session_save_session() : session.inc
  • st() : install.inc
  • statistics_access_log() : statistics.admin.inc
  • statistics_access_logging_settings() : statistics.admin.inc
  • statistics_block() : statistics.module
  • statistics_cron() : statistics.module
  • statistics_exit() : statistics.module
  • statistics_get() : statistics.module
  • statistics_help() : statistics.module
  • statistics_install() : statistics.install
  • statistics_link() : statistics.module
  • statistics_menu() : statistics.module
  • statistics_node_tracker() : statistics.pages.inc
  • statistics_nodeapi() : statistics.module
  • statistics_perm() : statistics.module
  • statistics_recent_hits() : statistics.admin.inc
  • statistics_schema() : statistics.install
  • statistics_title_list() : statistics.module
  • statistics_top_pages() : statistics.admin.inc
  • statistics_top_referrers() : statistics.admin.inc
  • statistics_top_visitors() : statistics.admin.inc
  • statistics_uninstall() : statistics.install
  • statistics_update_1000() : statistics.install
  • statistics_user() : statistics.module
  • statistics_user_tracker() : statistics.pages.inc
  • system_action_delete_orphans_post() : system.module
  • system_action_info() : system.module
  • system_actions_configure() : system.module
  • system_actions_configure_submit() : system.module
  • system_actions_configure_validate() : system.module
  • system_actions_delete_form() : system.module
  • system_actions_delete_form_submit() : system.module
  • system_actions_manage() : system.module
  • system_actions_manage_form() : system.module
  • system_actions_manage_form_submit() : system.module
  • system_actions_remove_orphans() : system.module
  • system_admin_by_module() : system.admin.inc
  • system_admin_compact_mode() : system.module
  • system_admin_compact_page() : system.admin.inc
  • system_admin_menu_block() : system.module
  • system_admin_menu_block_page() : system.admin.inc
  • system_admin_theme_settings() : system.admin.inc
  • system_admin_theme_submit() : system.module
  • system_batch_page() : system.admin.inc
  • system_block() : system.module
  • system_check_directory() : system.module
  • system_check_http_request() : system.module
  • system_clean_url_settings() : system.admin.inc
  • system_clear_cache_submit() : system.admin.inc
  • system_cron() : system.module
  • system_date_time_lookup() : system.admin.inc
  • system_date_time_settings() : system.admin.inc
  • system_date_time_settings_submit() : system.admin.inc
  • system_default_region() : system.module
  • system_elements() : system.module
  • system_error_reporting_settings() : system.admin.inc
  • system_file_system_settings() : system.admin.inc
  • system_find_base_theme() : system.module
  • system_get_files_database() : system.module
  • system_get_module_admin_tasks() : system.module
  • system_goto_action() : system.module
  • system_goto_action_form() : system.module
  • system_goto_action_submit() : system.module
  • system_help() : system.module
  • system_hook_info() : system.module
  • system_image_toolkit_settings() : system.admin.inc
  • system_init() : system.module
  • system_initialize_theme_blocks() : system.module
  • system_install() : system.install
  • system_logging_overview() : system.admin.inc
  • system_mail() : system.module
  • system_main_admin_page() : system.admin.inc
  • system_menu() : system.module
  • system_message_action() : system.module
  • system_message_action_form() : system.module
  • system_message_action_submit() : system.module
  • system_module_build_dependencies() : system.admin.inc
  • system_modules() : system.admin.inc
  • system_modules_confirm_form() : system.admin.inc
  • system_modules_disable() : system.admin.inc
  • system_modules_submit() : system.admin.inc
  • system_modules_uninstall() : system.admin.inc
  • system_modules_uninstall_confirm_form() : system.admin.inc
  • system_modules_uninstall_submit() : system.admin.inc
  • system_modules_uninstall_validate() : system.admin.inc
  • system_node_type() : system.module
  • system_performance_settings() : system.admin.inc
  • system_perm() : system.module
  • system_php() : system.admin.inc
  • system_region_list() : system.module
  • system_requirements() : system.install
  • system_rss_feeds_settings() : system.admin.inc
  • system_run_cron() : system.admin.inc
  • system_schema() : system.install
  • system_send_email_action() : system.module
  • system_send_email_action_form() : system.module
  • system_send_email_action_submit() : system.module
  • system_send_email_action_validate() : system.module
  • system_settings_form() : system.module
  • system_settings_form_submit() : system.module
  • system_settings_overview() : system.admin.inc
  • system_site_information_settings() : system.admin.inc
  • system_site_information_settings_validate() : system.admin.inc
  • system_site_maintenance_settings() : system.admin.inc
  • system_sort_modules_by_info_name() : system.admin.inc
  • system_sql() : system.admin.inc
  • system_status() : system.admin.inc
  • system_theme() : system.module
  • system_theme_data() : system.module
  • system_theme_default() : system.module
  • system_theme_select_form() : system.module
  • system_theme_settings() : system.admin.inc
  • system_theme_settings_submit() : system.admin.inc
  • system_themes_form() : system.admin.inc
  • system_themes_form_submit() : system.admin.inc
  • system_update_1022() : system.install
  • system_update_6000() : system.install
  • system_update_6001() : system.install
  • system_update_6002() : system.install
  • system_update_6003() : system.install
  • system_update_6004() : system.install
  • system_update_6005() : system.install
  • system_update_6006() : system.install
  • system_update_6007() : system.install
  • system_update_6008() : system.install
  • system_update_6009() : system.install
  • system_update_6010() : system.install
  • system_update_6011() : system.install
  • system_update_6012() : system.install
  • system_update_6013() : system.install
  • system_update_6014() : system.install
  • system_update_6015() : system.install
  • system_update_6016() : system.install
  • system_update_6017() : system.install
  • system_update_6018() : system.install
  • system_update_6019() : system.install
  • system_update_6020() : system.install
  • system_update_6021() : system.install
  • system_update_6022() : system.install
  • system_update_6023() : system.install
  • system_update_6024() : system.install
  • system_update_6025() : system.install
  • system_update_6026() : system.install
  • system_update_6027() : system.install
  • system_update_6028() : system.install
  • system_update_6029() : system.install
  • system_update_6030() : system.install
  • system_update_6031() : system.install
  • system_update_6032() : system.install
  • system_update_6033() : system.install
  • system_update_6034() : system.install
  • system_update_6035() : system.install
  • system_update_6036() : system.install
  • system_update_6037() : system.install
  • system_update_6038() : system.install
  • system_update_6039() : system.install
  • system_update_6040() : system.install
  • system_update_6041() : system.install
  • system_update_6042() : system.install
  • system_update_6043() : system.install
  • system_update_6044() : system.install
  • system_update_6045() : system.install
  • system_update_6046() : system.install
  • system_update_6047() : system.install
  • system_update_last_removed() : system.install
  • system_user() : system.module
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- t -

  • t() : common.inc
  • tablesort_cell() : tablesort.inc
  • tablesort_get_order() : tablesort.inc
  • tablesort_get_querystring() : tablesort.inc
  • tablesort_get_sort() : tablesort.inc
  • tablesort_header() : tablesort.inc
  • tablesort_init() : tablesort.inc
  • tablesort_sql() : tablesort.inc
  • taxonomy_add_term_page() : taxonomy.admin.inc
  • taxonomy_admin_term_edit() : taxonomy.admin.inc
  • taxonomy_admin_vocabulary_edit() : taxonomy.admin.inc
  • taxonomy_autocomplete() : taxonomy.pages.inc
  • taxonomy_check_vocabulary_hierarchy() : taxonomy.module
  • taxonomy_del_term() : taxonomy.module
  • taxonomy_del_vocabulary() : taxonomy.module
  • taxonomy_form() : taxonomy.module
  • taxonomy_form_all() : taxonomy.module
  • taxonomy_form_alter() : taxonomy.module
  • taxonomy_form_term() : taxonomy.admin.inc
  • taxonomy_form_term_submit() : taxonomy.admin.inc
  • taxonomy_form_term_validate() : taxonomy.admin.inc
  • taxonomy_form_vocabulary() : taxonomy.admin.inc
  • taxonomy_form_vocabulary_submit() : taxonomy.admin.inc
  • taxonomy_get_children() : taxonomy.module
  • taxonomy_get_parents() : taxonomy.module
  • taxonomy_get_parents_all() : taxonomy.module
  • taxonomy_get_related() : taxonomy.module
  • taxonomy_get_synonym_root() : taxonomy.module
  • taxonomy_get_synonyms() : taxonomy.module
  • taxonomy_get_term() : taxonomy.module
  • taxonomy_get_term_by_name() : taxonomy.module
  • taxonomy_get_tree() : taxonomy.module
  • taxonomy_get_vocabularies() : taxonomy.module
  • taxonomy_help() : taxonomy.module
  • taxonomy_hook_info() : taxonomy.module
  • taxonomy_implode_tags() : taxonomy.module
  • taxonomy_link() : taxonomy.module
  • taxonomy_menu() : taxonomy.module
  • taxonomy_node_delete() : taxonomy.module
  • taxonomy_node_delete_revision() : taxonomy.module
  • taxonomy_node_get_terms() : taxonomy.module
  • taxonomy_node_get_terms_by_vocabulary() : taxonomy.module
  • taxonomy_node_save() : taxonomy.module
  • taxonomy_node_type() : taxonomy.module
  • taxonomy_node_update_index() : taxonomy.module
  • taxonomy_node_validate() : taxonomy.module
  • taxonomy_nodeapi() : taxonomy.module
  • taxonomy_overview_terms() : taxonomy.admin.inc
  • taxonomy_overview_terms_submit() : taxonomy.admin.inc
  • taxonomy_overview_vocabularies() : taxonomy.admin.inc
  • taxonomy_overview_vocabularies_submit() : taxonomy.admin.inc
  • taxonomy_perm() : taxonomy.module
  • taxonomy_preview_terms() : taxonomy.module
  • taxonomy_render_nodes() : taxonomy.module
  • taxonomy_rss_item() : taxonomy.module
  • taxonomy_save_term() : taxonomy.module
  • taxonomy_save_vocabulary() : taxonomy.module
  • taxonomy_schema() : taxonomy.install
  • taxonomy_select_nodes() : taxonomy.module
  • taxonomy_term_confirm_delete() : taxonomy.admin.inc
  • taxonomy_term_confirm_delete_submit() : taxonomy.admin.inc
  • taxonomy_term_confirm_parents() : taxonomy.admin.inc
  • taxonomy_term_count_nodes() : taxonomy.module
  • taxonomy_term_page() : taxonomy.pages.inc
  • taxonomy_term_path() : taxonomy.module
  • taxonomy_terms_parse_string() : taxonomy.module
  • taxonomy_theme() : taxonomy.module
  • taxonomy_vocabulary_confirm_delete() : taxonomy.admin.inc
  • taxonomy_vocabulary_confirm_delete_submit() : taxonomy.admin.inc
  • taxonomy_vocabulary_confirm_reset_alphabetical() : taxonomy.admin.inc
  • taxonomy_vocabulary_confirm_reset_alphabetical_submit() : taxonomy.admin.inc
  • taxonomy_vocabulary_load() : taxonomy.module
  • template_preprocess() : theme.inc
  • template_preprocess_aggregator_feed_source() : aggregator.pages.inc
  • template_preprocess_aggregator_item() : aggregator.pages.inc
  • template_preprocess_aggregator_summary_item() : aggregator.pages.inc
  • template_preprocess_aggregator_summary_items() : aggregator.pages.inc
  • template_preprocess_aggregator_wrapper() : aggregator.pages.inc
  • template_preprocess_block() : theme.inc
  • template_preprocess_block_admin_display_form() : block.admin.inc
  • template_preprocess_book_export_html() : book.module
  • template_preprocess_book_navigation() : book.module
  • template_preprocess_book_node_export_html() : book.module
  • template_preprocess_comment() : comment.module
  • template_preprocess_comment_folded() : comment.module
  • template_preprocess_comment_wrapper() : comment.module
  • template_preprocess_forum_icon() : forum.module
  • template_preprocess_forum_list() : forum.module
  • template_preprocess_forum_submitted() : forum.module
  • template_preprocess_forum_topic_list() : forum.module
  • template_preprocess_forum_topic_navigation() : forum.module
  • template_preprocess_forums() : forum.module
  • template_preprocess_maintenance_page() : theme.maintenance.inc
  • template_preprocess_node() : theme.inc
  • template_preprocess_page() : theme.inc
  • template_preprocess_poll_bar() : poll.module
  • template_preprocess_poll_results() : poll.module
  • template_preprocess_poll_vote() : poll.module
  • template_preprocess_profile_block() : profile.module
  • template_preprocess_profile_listing() : profile.module
  • template_preprocess_profile_wrapper() : profile.module
  • template_preprocess_search_block_form() : search.module
  • template_preprocess_search_result() : search.pages.inc
  • template_preprocess_search_results() : search.pages.inc
  • template_preprocess_search_theme_form() : search.module
  • template_preprocess_user_picture() : user.module
  • template_preprocess_user_profile() : user.pages.inc
  • template_preprocess_user_profile_category() : user.pages.inc
  • template_preprocess_user_profile_item() : user.pages.inc
  • theme() : theme.inc
  • theme_admin_block() : system.admin.inc
  • theme_admin_block_content() : system.admin.inc
  • theme_admin_page() : system.admin.inc
  • theme_aggregator_block_item() : aggregator.module
  • theme_aggregator_categorize_items() : aggregator.pages.inc
  • theme_aggregator_page_opml() : aggregator.pages.inc
  • theme_aggregator_page_rss() : aggregator.pages.inc
  • theme_blocks() : theme.inc
  • theme_book_admin_table() : book.admin.inc
  • theme_book_title_link() : book.module
  • theme_box() : theme.inc
  • theme_breadcrumb() : theme.inc
  • theme_button() : form.inc
  • theme_checkbox() : form.inc
  • theme_checkboxes() : form.inc
  • theme_closure() : theme.inc
  • theme_color_scheme_form() : color.module
  • theme_comment_admin_overview() : comment.admin.inc
  • theme_comment_block() : comment.module
  • theme_comment_controls() : comment.module
  • theme_comment_flat_collapsed() : comment.module
  • theme_comment_flat_expanded() : comment.module
  • theme_comment_post_forbidden() : comment.module
  • theme_comment_submitted() : comment.module
  • theme_comment_thread_collapsed() : comment.module
  • theme_comment_thread_expanded() : comment.module
  • theme_comment_view() : comment.module
  • theme_date() : form.inc
  • theme_dblog_filters() : dblog.module
  • theme_feed_icon() : theme.inc
  • theme_fieldset() : form.inc
  • theme_file() : form.inc
  • theme_filter_admin_order() : filter.admin.inc
  • theme_filter_admin_overview() : filter.admin.inc
  • theme_filter_tips() : filter.pages.inc
  • theme_filter_tips_more_info() : filter.module
  • theme_form() : form.inc
  • theme_form_element() : form.inc
  • theme_get_registry() : theme.inc
  • theme_get_setting() : theme.inc
  • theme_get_settings() : theme.inc
  • theme_help() : theme.inc
  • theme_hidden() : form.inc
  • theme_hidden_array() : multipage_form_example.module
  • theme_image() : theme.inc
  • theme_image_button() : form.inc
  • theme_indentation() : theme.inc
  • theme_install_page() : theme.maintenance.inc
  • theme_item() : form.inc
  • theme_item_list() : theme.inc
  • theme_links() : theme.inc
  • theme_locale_languages_overview_form() : locale.inc
  • theme_mark() : theme.inc
  • theme_markup() : form.inc
  • theme_menu_item() : menu.inc
  • theme_menu_item_link() : menu.inc
  • theme_menu_local_task() : menu.inc
  • theme_menu_local_tasks() : menu.inc
  • theme_menu_overview_form() : menu.admin.inc
  • theme_menu_tree() : menu.inc
  • theme_more_help_link() : theme.inc
  • theme_more_link() : theme.inc
  • theme_multipage_form_example() : multipage_form_example.module
  • theme_multipage_form_example_node_form() : multipage_form_example.module
  • theme_node_add_list() : node.pages.inc
  • theme_node_admin_nodes() : node.admin.inc
  • theme_node_example_order_info() : node_example.module
  • theme_node_filter_form() : node.admin.inc
  • theme_node_filters() : node.admin.inc
  • theme_node_form() : node.pages.inc
  • theme_node_list() : node.module
  • theme_node_log_message() : node.module
  • theme_node_preview() : node.pages.inc
  • theme_node_search_admin() : node.module
  • theme_node_submitted() : node.module
  • theme_nodeapi_example_rating() : nodeapi_example.module
  • theme_pager() : pager.inc
  • theme_pager_first() : pager.inc
  • theme_pager_last() : pager.inc
  • theme_pager_link() : pager.inc
  • theme_pager_next() : pager.inc
  • theme_pager_previous() : pager.inc
  • theme_password() : form.inc
  • theme_password_confirm() : form.inc
  • theme_phonenumber() : example_element.module
  • theme_placeholder() : theme.inc
  • theme_poll_choices() : poll.module
  • theme_profile_admin_overview() : profile.admin.inc
  • theme_progress_bar() : theme.inc
  • theme_radio() : form.inc
  • theme_radios() : form.inc
  • theme_render_template() : theme.inc
  • theme_select() : form.inc
  • theme_status_messages() : theme.inc
  • theme_status_report() : system.admin.inc
  • theme_submenu() : theme.inc
  • theme_submit() : form.inc
  • theme_system_admin_by_module() : system.admin.inc
  • theme_system_modules() : system.admin.inc
  • theme_system_modules_uninstall() : system.admin.inc
  • theme_system_powered_by() : system.module
  • theme_system_theme_select_form() : system.admin.inc
  • theme_system_themes_form() : system.admin.inc
  • theme_table() : theme.inc
  • theme_table_select_header_cell() : theme.inc
  • theme_tablesort_indicator() : theme.inc
  • theme_task_list() : theme.maintenance.inc
  • theme_taxonomy_overview_terms() : taxonomy.admin.inc
  • theme_taxonomy_overview_vocabularies() : taxonomy.admin.inc
  • theme_taxonomy_term_page() : taxonomy.pages.inc
  • theme_taxonomy_term_select() : taxonomy.module
  • theme_textarea() : form.inc
  • theme_textfield() : form.inc
  • theme_token() : form.inc
  • theme_trigger_display() : trigger.admin.inc
  • theme_update_page() : theme.maintenance.inc
  • theme_update_report() : update.report.inc
  • theme_update_version() : update.report.inc
  • theme_upload_attachments() : upload.module
  • theme_upload_form_current() : upload.module
  • theme_upload_form_new() : upload.module
  • theme_user_admin_account() : user.admin.inc
  • theme_user_admin_new_role() : user.admin.inc
  • theme_user_admin_perm() : user.admin.inc
  • theme_user_filter_form() : user.admin.inc
  • theme_user_filters() : user.admin.inc
  • theme_user_list() : user.module
  • theme_user_signature() : user.module
  • theme_username() : theme.inc
  • theme_xml_icon() : theme.inc
  • throttle_admin_settings() : throttle.admin.inc
  • throttle_admin_settings_validate() : throttle.admin.inc
  • throttle_exit() : throttle.module
  • throttle_help() : throttle.module
  • throttle_menu() : throttle.module
  • throttle_status() : throttle.module
  • timer_read() : bootstrap.inc
  • timer_start() : bootstrap.inc
  • timer_stop() : bootstrap.inc
  • tracker_help() : tracker.module
  • tracker_menu() : tracker.module
  • tracker_page() : tracker.pages.inc
  • translation_form_alter() : translation.module
  • translation_help() : translation.module
  • translation_link() : translation.module
  • translation_menu() : translation.module
  • translation_node_get_translations() : translation.module
  • translation_node_overview() : translation.pages.inc
  • translation_nodeapi() : translation.module
  • translation_path_get_translations() : translation.module
  • translation_perm() : translation.module
  • translation_remove_from_set() : translation.module
  • translation_supported_type() : translation.module
  • translation_translation_link_alter() : translation.module
  • trigger_access_check() : trigger.module
  • trigger_actions_delete() : trigger.module
  • trigger_assign() : trigger.admin.inc
  • trigger_assign_form() : trigger.admin.inc
  • trigger_assign_form_submit() : trigger.admin.inc
  • trigger_assign_form_validate() : trigger.admin.inc
  • trigger_comment() : trigger.module
  • trigger_cron() : trigger.module
  • trigger_forms() : trigger.module
  • trigger_help() : trigger.module
  • trigger_install() : trigger.install
  • trigger_menu() : trigger.module
  • trigger_nodeapi() : trigger.module
  • trigger_options() : trigger.module
  • trigger_schema() : trigger.install
  • trigger_taxonomy() : trigger.module
  • trigger_theme() : trigger.module
  • trigger_unassign() : trigger.admin.inc
  • trigger_unassign_submit() : trigger.admin.inc
  • trigger_uninstall() : trigger.install
  • trigger_user() : trigger.module
  • truncate_utf8() : unicode.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- u -

  • unicode_check() : unicode.inc
  • unicode_requirements() : unicode.inc
  • update_access_denied_page() : update.php
  • update_batch() : update.php
  • update_calculate_project_data() : update.compare.inc
  • update_check_incompatibility() : update.php
  • update_check_requirements() : update.php
  • update_create_batch_table() : update.php
  • update_cron() : update.module
  • update_do_one() : update.php
  • update_finished() : update.php
  • update_fix_compatibility() : update.php
  • update_fix_d6_requirements() : update.php
  • update_flush_caches() : update.module
  • update_form_alter() : update.module
  • update_get_available() : update.module
  • update_get_project_name() : update.compare.inc
  • update_get_projects() : update.compare.inc
  • update_help() : update.module
  • update_info_page() : update.php
  • update_install() : update.install
  • update_invalidate_cache() : update.module
  • update_mail() : update.module
  • update_manual_status() : update.fetch.inc
  • update_menu() : update.module
  • update_process_project_info() : update.compare.inc
  • update_project_cache() : update.compare.inc
  • update_refresh() : update.module
  • update_requirements() : update.module
  • update_results_page() : update.php
  • update_schema() : update.install
  • update_script_selection_form() : update.php
  • update_selection_page() : update.php
  • update_settings() : update.settings.inc
  • update_settings_submit() : update.settings.inc
  • update_settings_validate() : update.settings.inc
  • update_sql() : database.inc
  • update_status() : update.report.inc
  • update_task_list() : update.php
  • update_theme() : update.module
  • update_uninstall() : update.install
  • update_update_6000() : update.install
  • upload_admin_settings() : upload.admin.inc
  • upload_admin_settings_validate() : upload.admin.inc
  • upload_delete() : upload.module
  • upload_delete_revision() : upload.module
  • upload_file_download() : upload.module
  • upload_form_alter() : upload.module
  • upload_help() : upload.module
  • upload_install() : upload.install
  • upload_js() : upload.module
  • upload_link() : upload.module
  • upload_load() : upload.module
  • upload_menu() : upload.module
  • upload_menu_alter() : upload.module
  • upload_node_form_submit() : upload.module
  • upload_nodeapi() : upload.module
  • upload_perm() : upload.module
  • upload_save() : upload.module
  • upload_schema() : upload.install
  • upload_space_used() : upload.module
  • upload_theme() : upload.module
  • upload_total_space_used() : upload.module
  • upload_uninstall() : upload.install
  • url() : common.inc
  • user_access() : user.module
  • user_action_info() : user.module
  • user_admin() : user.admin.inc
  • user_admin_access() : user.admin.inc
  • user_admin_access_add() : user.admin.inc
  • user_admin_access_check() : user.admin.inc
  • user_admin_access_check_submit() : user.admin.inc
  • user_admin_access_check_validate() : user.admin.inc
  • user_admin_access_delete_confirm() : user.admin.inc
  • user_admin_access_delete_confirm_submit() : user.admin.inc
  • user_admin_access_edit() : user.admin.inc
  • user_admin_access_form() : user.admin.inc
  • user_admin_account() : user.admin.inc
  • user_admin_account_submit() : user.admin.inc
  • user_admin_account_validate() : user.admin.inc
  • user_admin_check_host() : user.admin.inc
  • user_admin_check_mail() : user.admin.inc
  • user_admin_check_user() : user.admin.inc
  • user_admin_perm() : user.admin.inc
  • user_admin_perm_submit() : user.admin.inc
  • user_admin_role() : user.admin.inc
  • user_admin_role_submit() : user.admin.inc
  • user_admin_role_validate() : user.admin.inc
  • user_admin_settings() : user.admin.inc
  • user_authenticate() : user.module
  • user_authenticate_finalize() : user.module
  • user_autocomplete() : user.pages.inc
  • user_block() : user.module
  • user_block_ip_action() : user.module
  • user_block_user_action() : user.module
  • user_build_content() : user.module
  • user_build_filter_query() : user.module
  • user_category_load() : user.module
  • user_comment() : user.module
  • user_confirm_delete() : user.pages.inc
  • user_confirm_delete_submit() : user.pages.inc
  • user_current_load() : user.module
  • user_current_to_arg() : user.module
  • user_delete() : user.module
  • user_edit() : user.pages.inc
  • user_edit_access() : user.module
  • user_edit_delete_submit() : user.pages.inc
  • user_edit_form() : user.module
  • user_edit_submit() : user.pages.inc
  • user_edit_validate() : user.pages.inc
  • user_elements() : user.module
  • user_external_load() : user.module
  • user_external_login() : user.module
  • user_external_login_register() : user.module
  • user_fields() : user.module
  • user_file_download() : user.module
  • user_filter_form() : user.admin.inc
  • user_filter_form_submit() : user.admin.inc
  • user_filters() : user.module
  • user_forms() : user.module
  • user_get_authmaps() : user.module
  • user_help() : user.module
  • user_hook_info() : user.module
  • user_init() : user.module
  • user_is_anonymous() : user.module
  • user_is_blocked() : user.module
  • user_is_logged_in() : user.module
  • user_load() : user.module
  • user_load_self() : user.module
  • user_login() : user.module
  • user_login_authenticate_validate() : user.module
  • user_login_block() : user.module
  • user_login_default_validators() : user.module
  • user_login_final_validate() : user.module
  • user_login_name_validate() : user.module
  • user_login_submit() : user.module
  • user_logout() : user.pages.inc
  • user_mail() : user.module
  • user_mail_tokens() : user.module
  • user_menu() : user.module
  • user_module_invoke() : user.module
  • user_multiple_delete_confirm() : user.module
  • user_multiple_delete_confirm_submit() : user.module
  • user_multiple_role_edit() : user.module
  • user_page() : user.pages.inc
  • user_page_title() : user.module
  • user_pass() : user.pages.inc
  • user_pass_rehash() : user.module
  • user_pass_reset() : user.pages.inc
  • user_pass_reset_url() : user.module
  • user_pass_submit() : user.pages.inc
  • user_pass_validate() : user.pages.inc
  • user_password() : user.module
  • user_perm() : user.module
  • user_preferred_language() : user.module
  • user_profile_form() : user.pages.inc
  • user_profile_form_submit() : user.pages.inc
  • user_profile_form_validate() : user.pages.inc
  • user_register() : user.module
  • user_register_access() : user.module
  • user_register_submit() : user.module
  • user_register_validate() : user.module
  • user_roles() : user.module
  • user_save() : user.module
  • user_schema() : user.install
  • user_search() : user.module
  • user_set_authmaps() : user.module
  • user_theme() : user.module
  • user_user() : user.module
  • user_user_operations() : user.module
  • user_user_operations_block() : user.module
  • user_user_operations_unblock() : user.module
  • user_validate_mail() : user.module
  • user_validate_name() : user.module
  • user_validate_picture() : user.module
  • user_view() : user.pages.inc
  • user_view_access() : user.module
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- v -

  • valid_email_address() : common.inc
  • valid_url() : common.inc
  • vancode2int() : comment.module
  • variable_del() : bootstrap.inc
  • variable_get() : bootstrap.inc
  • variable_init() : bootstrap.inc
  • variable_set() : bootstrap.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- w -

  • watchdog() : bootstrap.inc
  • watchdog_severity_levels() : common.inc
  • weight_value() : form.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • _
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
  • x

- x -

  • xmlrpc() : common.inc
  • xmlrpc_base64() : xmlrpc.inc
  • xmlrpc_base64_get_xml() : xmlrpc.inc
  • xmlrpc_date() : xmlrpc.inc
  • xmlrpc_date_get_xml() : xmlrpc.inc
  • xmlrpc_errno() : xmlrpc.inc
  • xmlrpc_error() : xmlrpc.inc
  • xmlrpc_error_get_xml() : xmlrpc.inc
  • xmlrpc_error_msg() : xmlrpc.inc
  • xmlrpc_example_arrayOfStructsTest() : xmlrpc_example.module
  • xmlrpc_example_countTheEntities() : xmlrpc_example.module
  • xmlrpc_example_easyStructTest() : xmlrpc_example.module
  • xmlrpc_example_echoStructTest() : xmlrpc_example.module
  • xmlrpc_example_manyTypesTest() : xmlrpc_example.module
  • xmlrpc_example_moderateSizeArrayCheck() : xmlrpc_example.module
  • xmlrpc_example_nestedStructTest() : xmlrpc_example.module
  • xmlrpc_example_simpleStructReturnTest() : xmlrpc_example.module
  • xmlrpc_example_xmlrpc() : xmlrpc_example.module
  • xmlrpc_message() : xmlrpc.inc
  • xmlrpc_message_cdata() : xmlrpc.inc
  • xmlrpc_message_get() : xmlrpc.inc
  • xmlrpc_message_parse() : xmlrpc.inc
  • xmlrpc_message_set() : xmlrpc.inc
  • xmlrpc_message_tag_close() : xmlrpc.inc
  • xmlrpc_message_tag_open() : xmlrpc.inc
  • xmlrpc_request() : xmlrpc.inc
  • xmlrpc_server() : xmlrpcs.inc
  • xmlrpc_server_call() : xmlrpcs.inc
  • xmlrpc_server_error() : xmlrpcs.inc
  • xmlrpc_server_get() : xmlrpcs.inc
  • xmlrpc_server_get_capabilities() : xmlrpcs.inc
  • xmlrpc_server_list_methods() : xmlrpcs.inc
  • xmlrpc_server_method_help() : xmlrpcs.inc
  • xmlrpc_server_method_signature() : xmlrpcs.inc
  • xmlrpc_server_multicall() : xmlrpcs.inc
  • xmlrpc_server_output() : xmlrpcs.inc
  • xmlrpc_server_set() : xmlrpcs.inc
  • xmlrpc_value() : xmlrpc.inc
  • xmlrpc_value_calculate_type() : xmlrpc.inc
  • xmlrpc_value_get_xml() : xmlrpc.inc
  • xrds_parse() : xrds.inc
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Class Members

  • File List
  • File Members
  • All
  • Functions
  • Variables
  • Enumerations
  • $
  • _
  • b
  • c
  • d
  • e
  • l
  • m
  • n
  • s

- $ -

  • $active_db : globals.php
  • $attributes : user-profile-item.tpl.php
  • $base_path : globals.php
  • $base_root : globals.php
  • $base_theme_info : globals.php
  • $base_url : globals.php , book-export-html.tpl.php
  • $body_classes : maintenance-page.tpl.php , page.tpl.php
  • $channel : globals.php
  • $children : book-node-export-html.tpl.php
  • $conf : globals.php
  • $content : profile-wrapper.tpl.php , aggregator-wrapper.tpl.php , book-node-export-html.tpl.php , comment-wrapper.tpl.php
  • $cookie_domain : globals.php
  • $custom_theme : globals.php
  • $db_prefix : globals.php
  • $db_type : globals.php
  • $db_url : globals.php
  • $depth : book-node-export-html.tpl.php
  • $element : globals.php
  • $exp : openid.inc
  • $feed_age : aggregator-summary-item.tpl.php
  • $feed_title : aggregator-item.tpl.php , aggregator-summary-item.tpl.php
  • $feed_url : aggregator-item.tpl.php , aggregator-summary-item.tpl.php
  • $forum_id : forum-list.tpl.php
  • $forum_topic_list_header : globals.php
  • $forums : forums.tpl.php
  • $head : book-export-html.tpl.php , maintenance-page.tpl.php , page.tpl.php
  • $head_title : maintenance-page.tpl.php , page.tpl.php
  • $header : forum-topic-list.tpl.php , maintenance-page.tpl.php , page.tpl.php
  • $id : globals.php
  • $image : globals.php
  • $install_locale : globals.php
  • $installed_profile : globals.php
  • $item : globals.php
  • $items : globals.php
  • $language : globals.php
  • $last_checked : aggregator-feed-source.tpl.php
  • $last_result : globals.php
  • $links : poll-results-block.tpl.php
  • $logo : maintenance-page.tpl.php , page.tpl.php
  • $menu_admin : globals.php
  • $messages : update.php
  • $module_list : update.php
  • $multibyte : globals.php
  • $name : profile-listing.tpl.php
  • $new : comment-folded.tpl.php
  • $nid : globals.php
  • $op : update.php
  • $output : update.php
  • $pager : search-results.tpl.php , aggregator-wrapper.tpl.php
  • $pager_page_array : globals.php
  • $pager_total : globals.php
  • $pager_total_items : globals.php
  • $percentage : poll-bar-block.tpl.php , poll-bar.tpl.php
  • $picture : profile-block.tpl.php , user-picture.tpl.php , profile-listing.tpl.php
  • $profile : globals.php
  • $queries : globals.php
  • $recent_activity : globals.php
  • $result : openid.inc
  • $results : poll-results.tpl.php
  • $return : index.php
  • $row : block-admin-display-form.tpl.php
  • $scripts : maintenance-page.tpl.php , page.tpl.php
  • $search_form : search-block-form.tpl.php , search-theme-form.tpl.php
  • $search_results : search-results.tpl.php
  • $site_fields : maintenance-page.tpl.php , page.tpl.php
  • $site_name : maintenance-page.tpl.php , page.tpl.php
  • $site_title : maintenance-page.tpl.php , page.tpl.php
  • $source_description : aggregator-feed-source.tpl.php
  • $source_icon : aggregator-feed-source.tpl.php
  • $source_image : aggregator-feed-source.tpl.php
  • $source_url : aggregator-feed-source.tpl.php , aggregator-summary-items.tpl.php
  • $square : openid.inc
  • $status : comment.tpl.php
  • $styles : maintenance-page.tpl.php , page.tpl.php
  • $summary_list : aggregator-summary-items.tpl.php
  • $tag : globals.php
  • $theme : globals.php
  • $theme_engine : globals.php
  • $theme_info : globals.php
  • $theme_key : globals.php
  • $theme_path : globals.php
  • $timers : globals.php
  • $title : book-export-html.tpl.php , search-result.tpl.php , user-profile-item.tpl.php , poll-bar.tpl.php , book-node-export-html.tpl.php , poll-bar-block.tpl.php , aggregator-summary-items.tpl.php
  • $topic_id : forum-topic-list.tpl.php
  • $topics : forums.tpl.php
  • $type : search-results.tpl.php
  • $update_free_access : globals.php
  • $update_mode : globals.php
  • $url : search-result.tpl.php
  • $user : globals.php
  • $user_profile : user-profile.tpl.php
  • $value : user-profile-item.tpl.php
  • $xrds_current_service : xrds.inc , globals.php
  • $xrds_open_elements : globals.php , xrds.inc
  • $xrds_services : globals.php , xrds.inc

- _ -

  • __pad0__ : forum-submitted.tpl.php , update.php
  • __pad1__ : update.php
  • __pad2__ : update.php
  • __pad3__ : update.php

- b -

  • break : index.php , update.php

- c -

  • content : block.tpl.php

- d -

  • delta : block.tpl.php

- e -

  • endif : aggregator-item.tpl.php , block-admin-display-form.tpl.php , forum-submitted.tpl.php , maintenance-page.tpl.php , forums.tpl.php , forum-topic-navigation.tpl.php , page.tpl.php , book-navigation.tpl.php
  • exit : update.php

- l -

  • language : book-export-html.tpl.php
  • link : forum-list.tpl.php

- m -

  • MENU_ACCESS_DENIED : index.php
  • MENU_SITE_OFFLINE : index.php
  • module : block.tpl.php

- n -

  • name : forum-list.tpl.php
  • nid : node.tpl.php , book-node-export-html.tpl.php

- s -

  • subject : block.tpl.php
Generated on Tue Feb 12 15:31:02 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Graph Legend

Graph Legend

This page explains how to interpret the graphs that are generated by doxygen.

Consider the following example:

/*! Invisible class because of truncation */
class Invisible { };

/*! Truncated class, inheritance relation is hidden */
class Truncated : public Invisible { };

/* Class not documented with doxygen comments */
class Undocumented { };

/*! Class that is inherited using public inheritance */
class PublicBase : public Truncated { };

/*! A template class */
template<class T> class Templ { };

/*! Class that is inherited using protected inheritance */
class ProtectedBase { };

/*! Class that is inherited using private inheritance */
class PrivateBase { };

/*! Class that is used by the Inherited class */
class Used { };

/*! Super class that inherits a number of other classes */
class Inherited : public PublicBase,
                  protected ProtectedBase,
                  private PrivateBase,
                  public Undocumented,
                  public Templ<int>
{
  private:
    Used *m_usedClass;
};
If the MAX_DOT_GRAPH_HEIGHT tag in the configuration file is set to 240 this will result in the following graph:

The boxes in the above graph have the following meaning:

  • A filled gray box represents the struct or class for which the graph is generated.
  • A box with a black border denotes a documented struct or class.
  • A box with a grey border denotes an undocumented struct or class.
  • A box with a red border denotes a documented struct or class forwhich not all inheritance/containment relations are shown. A graph is truncated if it does not fit within the specified boundaries.
The arrows have the following meaning:
  • A dark blue arrow is used to visualize a public inheritance relation between two classes.
  • A dark green arrow is used for protected inheritance.
  • A dark red arrow is used for private inheritance.
  • A purple dashed arrow is used if a class is contained or used by another class. The arrow is labeled with the variable(s) through which the pointed class or struct is accessible.
  • A yellow dashed arrow denotes a relation between a template instance and the template class it was instantiated from. The arrow is labeled with the template parameters of the instance.
Generated on Tue Feb 12 15:30:52 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/help/help.admin.inc Source File

modules » help

help.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: help.admin.inc,v 1.5 2007/11/25 11:11:17 goba Exp $
00003
00012 function help_main() {
00013   // Add CSS
00014   drupal_add_css(drupal_get_path('module', 'help') .'/help.css', 'module', 'all', FALSE);
00015   $output = '<h2>'. t('Help topics') .'</h2><p>'. t('Help is available on the following items:') .'</p>'. help_links_as_list();
00016   return $output;
00017 }
00018
00022 function help_page($name) {
00023   $output = '';
00024   if (module_hook($name, 'help')) {
00025     $module = drupal_parse_info_file(drupal_get_path('module', $name) .'/'. $name .'.info');
00026     drupal_set_title($module['name']);
00027
00028     $temp = module_invoke($name, 'help', "admin/help#$name", drupal_help_arg());
00029     if (empty($temp)) {
00030       $output .= t("No help is available for module %module.", array('%module' => $module['name']));
00031     }
00032     else {
00033       $output .= $temp;
00034     }
00035
00036     // Only print list of administration pages if the module in question has
00037     // any such pages associated to it.
00038     $admin_tasks = system_get_module_admin_tasks($name);
00039     if (!empty($admin_tasks)) {
00040       ksort($admin_tasks);
00041       $output .= theme('item_list', $admin_tasks, t('@module administration pages', array('@module' => $module['name'])));
00042     }
00043
00044   }
00045   return $output;
00046 }
00047
00048 function help_links_as_list() {
00049   $empty_arg = drupal_help_arg();
00050   $module_info = module_rebuild_cache();
00051
00052   $modules = array();
00053   foreach (module_implements('help', TRUE) as $module) {
00054     if (module_invoke($module, 'help', "admin/help#$module", $empty_arg)) {
00055       $modules[$module] = $module_info[$module]->info['name'];
00056     }
00057   }
00058   asort($modules);
00059
00060   // Output pretty four-column list
00061   $count = count($modules);
00062   $break = ceil($count / 4);
00063   $output = '<div class="clear-block"><div class="help-items"><ul>';
00064   $i = 0;
00065   foreach ($modules as $module => $name) {
00066     $output .= '<li>'. l($name, 'admin/help/'. $module) .'</li>';
00067     if (($i + 1) % $break == 0 && ($i + 1) != $count) {
00068       $output .= '</ul></div><div class="help-items'. ($i + 1 == $break * 3 ? ' help-items-last' : '') .'"><ul>';
00069     }
00070     $i++;
00071   }
00072   $output .= '</ul></div></div>';
00073
00074   return $output;
00075 }
00076
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/help/help.module Source File

modules » help

help.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: help.module,v 1.78 2007/12/14 18:08:46 goba Exp $
00003
00012 function help_menu() {
00013   $items['admin/help'] = array(
00014     'title' => 'Help',
00015     'page callback' => 'help_main',
00016     'access arguments' => array('access administration pages'),
00017     'weight' => 9,
00018     'file' => 'help.admin.inc',
00019   );
00020
00021   foreach (module_implements('help', TRUE) as $module) {
00022     $items['admin/help/'. $module] = array(
00023       'title' => $module,
00024       'page callback' => 'help_page',
00025       'page arguments' => array(2),
00026       'type' => MENU_CALLBACK,
00027       'file' => 'help.admin.inc',
00028     );
00029   }
00030
00031   return $items;
00032 }
00033
00037 function help_help($path, $arg) {
00038   switch ($path) {
00039     case 'admin/help':
00040       $output = '<p>'. t('This guide provides context sensitive help on the use and configuration of <a href="@drupal">Drupal</a> and its modules, and is a supplement to the more extensive online <a href="@handbook">Drupal handbook</a>. The online handbook may contain more up-to-date information, is annotated with helpful user-contributed comments, and serves as the definitive reference point for all Drupal documentation.', array('@drupal' => 'http://drupal.org', '@handbook' => 'http://drupal.org/handbook')) .'</p>';
00041       return $output;
00042     case 'admin/help#help':
00043       $output = '<p>'. t('The help module provides context sensitive help on the use and configuration of <a href="@drupal">Drupal</a> and its modules, and is a supplement to the more extensive online <a href="@handbook">Drupal handbook</a>. The online handbook may contain more up-to-date information, is annotated with helpful user-contributed comments, and serves as the definitive reference point for all Drupal documentation.', array('@drupal' => 'http://drupal.org', '@handbook' => 'http://drupal.org/handbook')) .'</p>';
00044       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@help">Help module</a>.', array('@help' => 'http://drupal.org/handbook/modules/help/')) .'</p>';
00045       return $output;
00046   }
00047 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/image.gd.inc Source File

includes

image.gd.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: image.gd.inc,v 1.4 2008/01/15 10:17:42 goba Exp $
00003
00017 function image_gd_info() {
00018   return array('name' => 'gd', 'title' => t('GD2 image manipulation toolkit'));
00019 }
00020
00024 function image_gd_settings() {
00025   if (image_gd_check_settings()) {
00026     $form = array();
00027     $form['status'] = array(
00028       '#value' => t('The GD toolkit is installed and working properly.')
00029     );
00030
00031     $form['image_jpeg_quality'] = array(
00032       '#type' => 'textfield',
00033       '#title' => t('JPEG quality'),
00034       '#description' => t('Define the image quality for JPEG manipulations. Ranges from 0 to 100. Higher values mean better image quality but bigger files.'),
00035       '#size' => 10,
00036       '#maxlength' => 3,
00037       '#default_value' => variable_get('image_jpeg_quality', 75),
00038       '#field_suffix' => t('%'),
00039     );
00040     $form['#element_validate'] = array('image_gd_settings_validate');
00041
00042     return $form;
00043   }
00044   else {
00045     form_set_error('image_toolkit', t('The GD image toolkit requires that the GD module for PHP be installed and configured properly. For more information see <a href="@url">PHP\'s image documentation</a>.', array('@url' => 'http://php.net/image')));
00046     return FALSE;
00047   }
00048 }
00049
00053 function image_gd_settings_validate($form, &$form_state) {
00054   // Validate image quality range.
00055   $value = $form_state['values']['image_jpeg_quality'];
00056   if (!is_numeric($value) || $value < 0 || $value > 100) {
00057     form_set_error('image_jpeg_quality', t('JPEG quality must be a number between 0 and 100.'));
00058   }
00059 }
00060
00067 function image_gd_check_settings() {
00068   if ($check = get_extension_funcs('gd')) {
00069     if (in_array('imagegd2', $check)) {
00070       // GD2 support is available.
00071       return TRUE;
00072     }
00073   }
00074   return FALSE;
00075 }
00076
00080 function image_gd_resize($source, $destination, $width, $height) {
00081   if (!file_exists($source)) {
00082     return FALSE;
00083   }
00084
00085   $info = image_get_info($source);
00086   if (!$info) {
00087     return FALSE;
00088   }
00089
00090   $im = image_gd_open($source, $info['extension']);
00091   if (!$im) {
00092     return FALSE;
00093   }
00094
00095   $res = imagecreatetruecolor($width, $height);
00096   if ($info['extension'] == 'png') {
00097     $transparency = imagecolorallocatealpha($res, 0, 0, 0, 127);
00098     imagealphablending($res, FALSE);
00099     imagefilledrectangle($res, 0, 0, $width, $height, $transparency);
00100     imagealphablending($res, TRUE);
00101     imagesavealpha($res, TRUE);
00102   }
00103   elseif ($info['extension'] == 'gif') {
00104     // If we have a specific transparent color.
00105     $transparency_index = imagecolortransparent($im);
00106     if ($transparency_index >= 0) {
00107       // Get the original image's transparent color's RGB values.
00108       $transparent_color = imagecolorsforindex($im, $transparency_index);
00109       // Allocate the same color in the new image resource.
00110       $transparency_index = imagecolorallocate($res, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']);
00111       // Completely fill the background of the new image with allocated color.
00112       imagefill($res, 0, 0, $transparency_index);
00113       // Set the background color for new image to transparent.
00114       imagecolortransparent($res, $transparency_index);
00115       // Find number of colors in the images palette.
00116       $number_colors = imagecolorstotal($im);
00117       // Convert from true color to palette to fix transparency issues.
00118       imagetruecolortopalette($res, TRUE, $number_colors);
00119     }
00120   }
00121   imagecopyresampled($res, $im, 0, 0, 0, 0, $width, $height, $info['width'], $info['height']);
00122   $result = image_gd_close($res, $destination, $info['extension']);
00123
00124   imagedestroy($res);
00125   imagedestroy($im);
00126
00127   return $result;
00128 }
00129
00133 function image_gd_rotate($source, $destination, $degrees, $background = 0x000000) {
00134   if (!function_exists('imageRotate')) {
00135     return FALSE;
00136   }
00137
00138   $info = image_get_info($source);
00139   if (!$info) {
00140     return FALSE;
00141   }
00142
00143   $im = image_gd_open($source, $info['extension']);
00144   if (!$im) {
00145     return FALSE;
00146   }
00147
00148   $res = imageRotate($im, $degrees, $background);
00149   $result = image_gd_close($res, $destination, $info['extension']);
00150
00151   return $result;
00152 }
00153
00157 function image_gd_crop($source, $destination, $x, $y, $width, $height) {
00158   $info = image_get_info($source);
00159   if (!$info) {
00160     return FALSE;
00161   }
00162
00163   $im = image_gd_open($source, $info['extension']);
00164   $res = imageCreateTrueColor($width, $height);
00165   imageCopy($res, $im, 0, 0, $x, $y, $width, $height);
00166   $result = image_gd_close($res, $destination, $info['extension']);
00167
00168   imageDestroy($res);
00169   imageDestroy($im);
00170
00171   return $result;
00172 }
00173
00184 function image_gd_open($file, $extension) {
00185   $extension = str_replace('jpg', 'jpeg', $extension);
00186   $open_func = 'imageCreateFrom'. $extension;
00187   if (!function_exists($open_func)) {
00188     return FALSE;
00189   }
00190   return $open_func($file);
00191 }
00192
00205 function image_gd_close($res, $destination, $extension) {
00206   $extension = str_replace('jpg', 'jpeg', $extension);
00207   $close_func = 'image'. $extension;
00208   if (!function_exists($close_func)) {
00209     return FALSE;
00210   }
00211   if ($extension == 'jpeg') {
00212     return $close_func($res, $destination, variable_get('image_jpeg_quality', 75));
00213   }
00214   else {
00215     return $close_func($res, $destination);
00216   }
00217 }
00218
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/image.inc Source File

includes

image.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: image.inc,v 1.24 2008/01/28 16:05:17 goba Exp $
00003
00039 function image_get_available_toolkits() {
00040   $toolkits = file_scan_directory('includes', 'image\..*\.inc$');
00041
00042   $output = array();
00043   foreach ($toolkits as $file => $toolkit) {
00044     include_once "./$file";
00045     $function = str_replace('.', '_', $toolkit->name) .'_info';
00046     if (function_exists($function)) {
00047       $info = $function();
00048       $output[$info['name']] = $info['title'];
00049     }
00050   }
00051
00052   return $output;
00053 }
00054
00061 function image_get_toolkit() {
00062   static $toolkit;
00063
00064   if (!$toolkit) {
00065     $toolkit = variable_get('image_toolkit', 'gd');
00066     $toolkit_file = './includes/image.'. $toolkit .'.inc';
00067     if (isset($toolkit) && file_exists($toolkit_file)) {
00068       include_once $toolkit_file;
00069     }
00070     elseif (!image_gd_check_settings()) {
00071       $toolkit = FALSE;
00072     }
00073   }
00074
00075   return $toolkit;
00076 }
00077
00088 function image_toolkit_invoke($method, $params = array()) {
00089   if ($toolkit = image_get_toolkit()) {
00090     $function = 'image_'. $toolkit .'_'. $method;
00091     if (function_exists($function)) {
00092       return call_user_func_array($function, $params);
00093     }
00094     else {
00095       watchdog('php', 'The selected image handling toolkit %toolkit can not correctly process %function.', array('%toolkit' => $toolkit, '%function' => $function), WATCHDOG_ERROR);
00096       return FALSE;
00097     }
00098   }
00099 }
00100
00101
00116 function image_get_info($file) {
00117   if (!is_file($file)) {
00118     return FALSE;
00119   }
00120
00121   $details = FALSE;
00122   $data = @getimagesize($file);
00123   $file_size = @filesize($file);
00124
00125   if (isset($data) && is_array($data)) {
00126     $extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png');
00127     $extension = array_key_exists($data[2], $extensions) ?  $extensions[$data[2]] : '';
00128     $details = array('width'     => $data[0],
00129                      'height'    => $data[1],
00130                      'extension' => $extension,
00131                      'file_size' => $file_size,
00132                      'mime_type' => $data['mime']);
00133   }
00134
00135   return $details;
00136 }
00137
00157 function image_scale_and_crop($source, $destination, $width, $height) {
00158   $info = image_get_info($source);
00159
00160   $scale = max($width / $info['width'], $height / $info['height']);
00161   $x = round(($info['width'] * $scale - $width) / 2);
00162   $y = round(($info['height'] * $scale - $height) / 2);
00163
00164   if (image_toolkit_invoke('resize', array($source, $destination, $info['width'] * $scale, $info['height'] * $scale))) {
00165     return image_toolkit_invoke('crop', array($destination, $destination, $x, $y, $width, $height));
00166   }
00167   return FALSE;
00168 }
00169
00187 function image_scale($source, $destination, $width, $height) {
00188   $info = image_get_info($source);
00189
00190   // Don't scale up.
00191   if ($width >= $info['width'] && $height >= $info['height']) {
00192     return FALSE;
00193   }
00194
00195   $aspect = $info['height'] / $info['width'];
00196   if ($aspect < $height / $width) {
00197     $width = (int)min($width, $info['width']);
00198     $height = (int)round($width * $aspect);
00199   }
00200   else {
00201     $height = (int)min($height, $info['height']);
00202     $width = (int)round($height / $aspect);
00203   }
00204
00205   return image_toolkit_invoke('resize', array($source, $destination, $width, $height));
00206 }
00207
00222 function image_resize($source, $destination, $width, $height) {
00223   return image_toolkit_invoke('resize', array($source, $destination, $width, $height));
00224 }
00225
00242 function image_rotate($source, $destination, $degrees, $background = 0x000000) {
00243   return image_toolkit_invoke('rotate', array($source, $destination, $degrees, $background));
00244 }
00245
00264 function image_crop($source, $destination, $x, $y, $width, $height) {
00265   return image_toolkit_invoke('crop', array($source, $destination, $x, $y, $width, $height));
00266 }
00267
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: index.php Source File

index.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: index.php,v 1.94 2007/12/26 08:46:48 dries Exp $
00003
00015 require_once './includes/bootstrap.inc';
00016 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
00017
00018 $return = menu_execute_active_handler();
00019
00020 // Menu status constants are integers; page content is a string.
00021 if (is_int($return)) {
00022   switch ($return) {
00023     case MENU_NOT_FOUND:
00024       drupal_not_found();
00025       break;
00026     case MENU_ACCESS_DENIED:
00027       drupal_access_denied();
00028       break;
00029     case MENU_SITE_OFFLINE:
00030       drupal_site_offline();
00031       break;
00032   }
00033 }
00034 elseif (isset($return)) {
00035   // Print any value (including an empty string) except NULL or undefined:
00036   print theme('page', $return);
00037 }
00038
00039 drupal_page_footer();
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/install.inc Source File

includes

install.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: install.inc,v 1.56.2.2 2008/02/11 15:10:26 goba Exp $
00003
00004 define('SCHEMA_UNINSTALLED', -1);
00005 define('SCHEMA_INSTALLED', 0);
00006
00007 define('REQUIREMENT_INFO', -1);
00008 define('REQUIREMENT_OK', 0);
00009 define('REQUIREMENT_WARNING', 1);
00010 define('REQUIREMENT_ERROR', 2);
00011
00012 define('FILE_EXIST',          1);
00013 define('FILE_READABLE',       2);
00014 define('FILE_WRITABLE',       4);
00015 define('FILE_EXECUTABLE',     8);
00016 define('FILE_NOT_EXIST',      16);
00017 define('FILE_NOT_READABLE',   32);
00018 define('FILE_NOT_WRITABLE',   64);
00019 define('FILE_NOT_EXECUTABLE', 128);
00020
00024 function drupal_load_updates() {
00025   foreach (drupal_get_installed_schema_version(NULL, FALSE, TRUE) as $module => $schema_version) {
00026     if ($schema_version > -1) {
00027       module_load_install($module);
00028     }
00029   }
00030 }
00031
00041 function drupal_get_schema_versions($module) {
00042   $updates = array();
00043   $functions = get_defined_functions();
00044   foreach ($functions['user'] as $function) {
00045     if (strpos($function, $module .'_update_') === 0) {
00046       $version = substr($function, strlen($module .'_update_'));
00047       if (is_numeric($version)) {
00048         $updates[] = $version;
00049       }
00050     }
00051   }
00052   if (count($updates) == 0) {
00053     return FALSE;
00054   }
00055   return $updates;
00056 }
00057
00071 function drupal_get_installed_schema_version($module, $reset = FALSE, $array = FALSE) {
00072   static $versions = array();
00073
00074   if ($reset) {
00075     $versions = array();
00076   }
00077
00078   if (!$versions) {
00079     $versions = array();
00080     $result = db_query("SELECT name, schema_version FROM {system} WHERE type = '%s'", 'module');
00081     while ($row = db_fetch_object($result)) {
00082       $versions[$row->name] = $row->schema_version;
00083     }
00084   }
00085
00086   return $array ? $versions : $versions[$module];
00087 }
00088
00097 function drupal_set_installed_schema_version($module, $version) {
00098   db_query("UPDATE {system} SET schema_version = %d WHERE name = '%s'", $version, $module);
00099 }
00100
00107 function drupal_install_profile_name() {
00108   global $profile;
00109   static $name = NULL;
00110
00111   if (!isset($name)) {
00112     // Load profile details.
00113     $function = $profile .'_profile_details';
00114     if (function_exists($function)) {
00115       $details = $function();
00116     }
00117     $name = isset($details['name']) ? $details['name'] : 'Drupal';
00118   }
00119
00120   return $name;
00121 }
00122
00133 function drupal_detect_baseurl($file = 'install.php') {
00134   global $profile;
00135   $proto = $_SERVER['HTTPS'] ? 'https://' : 'http://';
00136   $host = $_SERVER['SERVER_NAME'];
00137   $port = ($_SERVER['SERVER_PORT'] == 80 ? '' : ':'. $_SERVER['SERVER_PORT']);
00138   $uri = preg_replace("/\?.*/", '', $_SERVER['REQUEST_URI']);
00139   $dir = str_replace("/$file", '', $uri);
00140
00141   return "$proto$host$port$dir";
00142 }
00143
00151 function drupal_detect_database_types() {
00152   $databases = array();
00153
00154   foreach (array('mysql', 'mysqli', 'pgsql') as $type) {
00155     if (file_exists('./includes/install.'. $type .'.inc')) {
00156       include_once './includes/install.'. $type .'.inc';
00157       $function = $type .'_is_available';
00158       if ($function()) {
00159         $databases[$type] = $type;
00160       }
00161     }
00162   }
00163
00164   return $databases;
00165 }
00166
00174 function drupal_rewrite_settings($settings = array(), $prefix = '') {
00175   $default_settings = './sites/default/default.settings.php';
00176   $settings_file = './'. conf_path(FALSE, TRUE) .'/'. $prefix .'settings.php';
00177
00178   // Build list of setting names and insert the values into the global namespace.
00179   $keys = array();
00180   foreach ($settings as $setting => $data) {
00181     $GLOBALS[$setting] = $data['value'];
00182     $keys[] = $setting;
00183   }
00184
00185   $buffer = NULL;
00186   $first = TRUE;
00187   if ($fp = fopen($default_settings, 'r')) {
00188     // Step line by line through settings.php.
00189     while (!feof($fp)) {
00190       $line = fgets($fp);
00191       if ($first && substr($line, 0, 5) != '<?php') {
00192         $buffer = "<?php\n\n";
00193       }
00194       $first = FALSE;
00195       // Check for constants.
00196       if (substr($line, 0, 7) == 'define(') {
00197         preg_match('/define\(\s*[\'"]([A-Z_-]+)[\'"]\s*,(.*?)\);/', $line, $variable);
00198         if (in_array($variable[1], $keys)) {
00199           $setting = $settings[$variable[1]];
00200           $buffer .= str_replace($variable[2], " '". $setting['value'] ."'", $line);
00201           unset($settings[$variable[1]]);
00202           unset($settings[$variable[2]]);
00203         }
00204         else {
00205           $buffer .= $line;
00206         }
00207       }
00208       // Check for variables.
00209       elseif (substr($line, 0, 1) == '$') {
00210         preg_match('/\$([^ ]*) /', $line, $variable);
00211         if (in_array($variable[1], $keys)) {
00212           // Write new value to settings.php in the following format:
00213           //    $'setting' = 'value'; // 'comment'
00214           $setting = $settings[$variable[1]];
00215           $buffer .= '$'. $variable[1] ." = '". $setting['value'] ."';". (!empty($setting['comment']) ? ' // '. $setting['comment'] ."\n" : "\n");
00216           unset($settings[$variable[1]]);
00217         }
00218         else {
00219           $buffer .= $line;
00220         }
00221       }
00222       else {
00223         $buffer .= $line;
00224       }
00225     }
00226     fclose($fp);
00227
00228     // Add required settings that were missing from settings.php.
00229     foreach ($settings as $setting => $data) {
00230       if ($data['required']) {
00231         $buffer .= "\$$setting = '". $data['value'] ."';\n";
00232       }
00233     }
00234
00235     $fp = fopen($settings_file, 'w');
00236     if ($fp && fwrite($fp, $buffer) === FALSE) {
00237       drupal_set_message(st('Failed to modify %settings, please verify the file permissions.', array('%settings' => $settings_file)), 'error');
00238     }
00239   }
00240   else {
00241     drupal_set_message(st('Failed to open %settings, please verify the file permissions.', array('%settings' => $default_settings)), 'error');
00242   }
00243 }
00244
00251 function drupal_get_install_files($module_list = array()) {
00252   $installs = array();
00253   foreach ($module_list as $module) {
00254     $installs = array_merge($installs, drupal_system_listing($module .'.install$', 'modules'));
00255   }
00256   return $installs;
00257 }
00258
00269 function drupal_verify_profile($profile, $locale) {
00270   include_once './includes/file.inc';
00271   include_once './includes/common.inc';
00272
00273   $profile_file = "./profiles/$profile/$profile.profile";
00274
00275   if (!isset($profile) || !file_exists($profile_file)) {
00276     install_no_profile_error();
00277   }
00278
00279   require_once($profile_file);
00280
00281   // Get a list of modules required by this profile.
00282   $function = $profile .'_profile_modules';
00283   $module_list = array_merge(drupal_required_modules(), $function(), ($locale != 'en' ? array('locale') : array()));
00284
00285   // Get a list of modules that exist in Drupal's assorted subdirectories.
00286   $present_modules = array();
00287   foreach (drupal_system_listing('\.module$', 'modules', 'name', 0) as $present_module) {
00288     $present_modules[] = $present_module->name;
00289   }
00290
00291   // Verify that all of the profile's required modules are present.
00292   $missing_modules = array_diff($module_list, $present_modules);
00293   if (count($missing_modules)) {
00294     foreach ($missing_modules as $module) {
00295       drupal_set_message(st('The %module module is required but was not found. Please move it into the <em>modules</em> subdirectory.', array('%module' => $module)), 'error');
00296     }
00297   }
00298   else {
00299     return $module_list;
00300   }
00301 }
00302
00310 function drupal_install_modules($module_list = array()) {
00311   $files = module_rebuild_cache();
00312   $module_list = array_flip(array_values($module_list));
00313   do {
00314     $moved = FALSE;
00315     foreach ($module_list as $module => $weight) {
00316       $file = $files[$module];
00317       if (isset($file->info['dependencies']) && is_array($file->info['dependencies'])) {
00318         foreach ($file->info['dependencies'] as $dependency) {
00319           if (isset($module_list[$dependency]) && $module_list[$module] < $module_list[$dependency] +1) {
00320             $module_list[$module] = $module_list[$dependency] +1;
00321             $moved = TRUE;
00322           }
00323         }
00324       }
00325     }
00326   } while ($moved);
00327   asort($module_list);
00328   $module_list = array_keys($module_list);
00329   array_filter($module_list, '_drupal_install_module');
00330   module_enable($module_list);
00331 }
00332
00340 function _drupal_install_module($module) {
00341   if (drupal_get_installed_schema_version($module, TRUE) == SCHEMA_UNINSTALLED) {
00342     module_load_install($module);
00343     module_invoke($module, 'install');
00344     $versions = drupal_get_schema_versions($module);
00345     drupal_set_installed_schema_version($module, $versions ? max($versions) : SCHEMA_INSTALLED);
00346     return TRUE;
00347   }
00348 }
00349
00356 function drupal_install_system() {
00357   $system_path = dirname(drupal_get_filename('module', 'system', NULL));
00358   require_once './'. $system_path .'/system.install';
00359   module_invoke('system', 'install');
00360   $system_versions = drupal_get_schema_versions('system');
00361   $system_version = $system_versions ? max($system_versions) : SCHEMA_INSTALLED;
00362   db_query("INSERT INTO {system} (filename, name, type, owner, status, throttle, bootstrap, schema_version) VALUES('%s', '%s', '%s', '%s', %d, %d, %d, %d)", $system_path .'/system.module', 'system', 'module', '', 1, 0, 0, $system_version);
00363   // Now that we've installed things properly, bootstrap the full Drupal environment
00364   drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
00365   module_rebuild_cache();
00366 }
00367
00368
00375 function drupal_uninstall_module($module) {
00376   // First, retrieve all the module's menu paths from db.
00377   drupal_load('module', $module);
00378   $paths = module_invoke($module, 'menu');
00379
00380   // Uninstall the module(s).
00381   module_load_install($module);
00382   module_invoke($module, 'uninstall');
00383
00384   // Now remove the menu links for all paths declared by this module.
00385   if (!empty($paths)) {
00386     $paths = array_keys($paths);
00387     // Clean out the names of load functions.
00388     foreach ($paths as $index => $path) {
00389       $parts = explode('/', $path, MENU_MAX_PARTS);
00390       foreach ($parts as $k => $part) {
00391         if (preg_match('/^%[a-z_]*$/', $part)) {
00392           $parts[$k] = '%';
00393         }
00394       }
00395       $paths[$index] = implode('/', $parts);
00396     }
00397     $placeholders = implode(', ', array_fill(0, count($paths), "'%s'"));
00398
00399     $result = db_query('SELECT * FROM {menu_links} WHERE router_path IN ('. $placeholders .') AND external = 0 ORDER BY depth DESC', $paths);
00400     // Remove all such items. Starting from those with the greatest depth will
00401     // minimize the amount of re-parenting done by menu_link_delete().
00402     while ($item = db_fetch_array($result)) {
00403       _menu_delete_item($item, TRUE);
00404     }
00405   }
00406
00407   drupal_set_installed_schema_version($module, SCHEMA_UNINSTALLED);
00408 }
00409
00422 function drupal_verify_install_file($file, $mask = NULL, $type = 'file') {
00423   $return = TRUE;
00424   // Check for files that shouldn't be there.
00425   if (isset($mask) && ($mask & FILE_NOT_EXIST) && file_exists($file)) {
00426     return FALSE;
00427   }
00428   // Verify that the file is the type of file it is supposed to be.
00429   if (isset($type) && file_exists($file)) {
00430     $check = 'is_'. $type;
00431     if (!function_exists($check) || !$check($file)) {
00432       $return = FALSE;
00433     }
00434   }
00435
00436   // Verify file permissions.
00437   if (isset($mask)) {
00438     $masks = array(FILE_EXIST, FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
00439     foreach ($masks as $current_mask) {
00440       if ($mask & $current_mask) {
00441         switch ($current_mask) {
00442           case FILE_EXIST:
00443             if (!file_exists($file)) {
00444               if ($type == 'dir') {
00445                 drupal_install_mkdir($file, $mask);
00446               }
00447               if (!file_exists($file)) {
00448                 $return = FALSE;
00449               }
00450             }
00451             break;
00452           case FILE_READABLE:
00453             if (!is_readable($file) && !drupal_install_fix_file($file, $mask)) {
00454               $return = FALSE;
00455             }
00456             break;
00457           case FILE_WRITABLE:
00458             if (!is_writable($file) && !drupal_install_fix_file($file, $mask)) {
00459               $return = FALSE;
00460             }
00461             break;
00462           case FILE_EXECUTABLE:
00463             if (!is_executable($file) && !drupal_install_fix_file($file, $mask)) {
00464               $return = FALSE;
00465             }
00466             break;
00467           case FILE_NOT_READABLE:
00468             if (is_readable($file) && !drupal_install_fix_file($file, $mask)) {
00469               $return = FALSE;
00470             }
00471             break;
00472           case FILE_NOT_WRITABLE:
00473             if (is_writable($file) && !drupal_install_fix_file($file, $mask)) {
00474               $return = FALSE;
00475             }
00476             break;
00477           case FILE_NOT_EXECUTABLE:
00478             if (is_executable($file) && !drupal_install_fix_file($file, $mask)) {
00479               $return = FALSE;
00480             }
00481             break;
00482         }
00483       }
00484     }
00485   }
00486   return $return;
00487 }
00488
00502 function drupal_install_mkdir($file, $mask, $message = TRUE) {
00503   $mod = 0;
00504   $masks = array(FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
00505   foreach ($masks as $m) {
00506     if ($mask & $m) {
00507       switch ($m) {
00508         case FILE_READABLE:
00509           $mod += 444;
00510           break;
00511         case FILE_WRITABLE:
00512           $mod += 222;
00513           break;
00514         case FILE_EXECUTABLE:
00515           $mod += 111;
00516           break;
00517       }
00518     }
00519   }
00520
00521   if (@mkdir($file, intval("0$mod", 8))) {
00522     return TRUE;
00523   }
00524   else {
00525     return FALSE;
00526   }
00527 }
00528
00551 function drupal_install_fix_file($file, $mask, $message = TRUE) {
00552   $mod = fileperms($file) & 0777;
00553   $masks = array(FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE);
00554
00555   // FILE_READABLE, FILE_WRITABLE, and FILE_EXECUTABLE permission strings
00556   // can theoretically be 0400, 0200, and 0100 respectively, but to be safe
00557   // we set all three access types in case the administrator intends to
00558   // change the owner of settings.php after installation.
00559   foreach ($masks as $m) {
00560     if ($mask & $m) {
00561       switch ($m) {
00562         case FILE_READABLE:
00563           if (!is_readable($file)) {
00564             $mod |= 0444;
00565           }
00566           break;
00567         case FILE_WRITABLE:
00568           if (!is_writable($file)) {
00569             $mod |= 0222;
00570           }
00571           break;
00572         case FILE_EXECUTABLE:
00573           if (!is_executable($file)) {
00574             $mod |= 0111;
00575           }
00576           break;
00577         case FILE_NOT_READABLE:
00578           if (is_readable($file)) {
00579             $mod &= ~0444;
00580           }
00581           break;
00582         case FILE_NOT_WRITABLE:
00583           if (is_writable($file)) {
00584             $mod &= ~0222;
00585           }
00586           break;
00587         case FILE_NOT_EXECUTABLE:
00588           if (is_executable($file)) {
00589             $mod &= ~0111;
00590           }
00591           break;
00592       }
00593     }
00594   }
00595
00596   // chmod() will work if the web server is running as owner of the file.
00597   // If PHP safe_mode is enabled the currently executing script must also
00598   // have the same owner.
00599   if (@chmod($file, $mod)) {
00600     return TRUE;
00601   }
00602   else {
00603     return FALSE;
00604   }
00605 }
00606
00607
00615 function install_goto($path) {
00616   global $base_url;
00617   header('Location: '. $base_url .'/'. $path);
00618   header('Cache-Control: no-cache'); // Not a permanent redirect.
00619   exit();
00620 }
00621
00627 function st($string, $args = array()) {
00628   static $locale_strings = NULL;
00629   global $profile, $install_locale;
00630
00631   if (!isset($locale_strings)) {
00632     $locale_strings = array();
00633     $filename = './profiles/'. $profile .'/translations/'. $install_locale .'.po';
00634     if (file_exists($filename)) {
00635       require_once './includes/locale.inc';
00636       $file = (object) array('filepath' => $filename);
00637       _locale_import_read_po('mem-store', $file);
00638       $locale_strings = _locale_import_one_string('mem-report');
00639     }
00640   }
00641
00642   require_once './includes/theme.inc';
00643   // Transform arguments before inserting them
00644   foreach ($args as $key => $value) {
00645     switch ($key[0]) {
00646       // Escaped only
00647       case '@':
00648         $args[$key] = check_plain($value);
00649         break;
00650       // Escaped and placeholder
00651       case '%':
00652       default:
00653         $args[$key] = '<em>'. check_plain($value) .'</em>';
00654         break;
00655       // Pass-through
00656       case '!':
00657     }
00658   }
00659   return strtr((!empty($locale_strings[$string]) ? $locale_strings[$string] : $string), $args);
00660 }
00661
00668 function drupal_check_profile($profile) {
00669   include_once './includes/file.inc';
00670
00671   $profile_file = "./profiles/$profile/$profile.profile";
00672
00673   if (!isset($profile) || !file_exists($profile_file)) {
00674     install_no_profile_error();
00675   }
00676
00677   require_once($profile_file);
00678
00679   // Get a list of modules required by this profile.
00680   $function = $profile .'_profile_modules';
00681   $module_list = array_unique(array_merge(drupal_required_modules(), $function()));
00682
00683   // Get a list of all .install files.
00684   $installs = drupal_get_install_files($module_list);
00685
00686   // Collect requirement testing results
00687   $requirements = array();
00688   foreach ($installs as $install) {
00689     require_once $install->filename;
00690     if (module_hook($install->name, 'requirements')) {
00691       $requirements = array_merge($requirements, module_invoke($install->name, 'requirements', 'install'));
00692     }
00693   }
00694   return $requirements;
00695 }
00696
00700 function drupal_requirements_severity(&$requirements) {
00701   $severity = REQUIREMENT_OK;
00702   foreach ($requirements as $requirement) {
00703     if (isset($requirement['severity'])) {
00704       $severity = max($severity, $requirement['severity']);
00705     }
00706   }
00707   return $severity;
00708 }
00709
00713 function drupal_check_module($module) {
00714   // Include install file
00715   $install = drupal_get_install_files(array($module));
00716   if (isset($install[$module])) {
00717     require_once $install[$module]->filename;
00718
00719     // Check requirements
00720     $requirements = module_invoke($module, 'requirements', 'install');
00721     if (is_array($requirements) && drupal_requirements_severity($requirements) == REQUIREMENT_ERROR) {
00722       // Print any error messages
00723       foreach ($requirements as $requirement) {
00724         if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
00725           $message = $requirement['description'];
00726           if (isset($requirement['value']) && $requirement['value']) {
00727             $message .= ' ('. t('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) .')';
00728           }
00729           drupal_set_message($message, 'error');
00730         }
00731       }
00732       return FALSE;
00733     }
00734   }
00735   return TRUE;
00736 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/install.mysql.inc Source File

includes

install.mysql.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: install.mysql.inc,v 1.9 2008/01/23 09:59:29 goba Exp $
00003
00004 // MySQL specific install functions
00005
00012 function mysql_is_available() {
00013   return function_exists('mysql_connect');
00014 }
00015
00022 function drupal_test_mysql($url, &$success) {
00023   if (!mysql_is_available()) {
00024     drupal_set_message(st('PHP MySQL support not enabled.'), 'error');
00025     return FALSE;
00026   }
00027
00028   $url = parse_url($url);
00029
00030   // Decode url-encoded information in the db connection string.
00031   $url['user'] = urldecode($url['user']);
00032   $url['pass'] = isset($url['pass']) ? urldecode($url['pass']) : '';
00033   $url['host'] = urldecode($url['host']);
00034   $url['path'] = urldecode($url['path']);
00035
00036   // Allow for non-standard MySQL port.
00037   if (isset($url['port'])) {
00038     $url['host'] = $url['host'] .':'. $url['port'];
00039   }
00040
00041   // Test connecting to the database.
00042   $connection = @mysql_connect($url['host'], $url['user'], $url['pass'], TRUE, 2);
00043   if (!$connection) {
00044     drupal_set_message(st('Failed to connect to your MySQL database server. MySQL reports the following message: %error.<ul><li>Are you sure you have the correct username and password?</li><li>Are you sure that you have typed the correct database hostname?</li><li>Are you sure that the database server is running?</li></ul>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.', array('%error' => mysql_error())), 'error');
00045     return FALSE;
00046   }
00047
00048   // Test selecting the database.
00049   if (!mysql_select_db(substr($url['path'], 1))) {
00050     drupal_set_message(st('Failed to select your database on your MySQL database server, which means the connection username and password are valid, but there is a problem accessing your data. MySQL reports the following message: %error.<ul><li>Are you sure you have the correct database name?</li><li>Are you sure the database exists?</li><li>Are you sure the username has permission to access the database?</li></ul>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.', array('%error' => mysql_error())), 'error');
00051     return FALSE;
00052   }
00053
00054   $success = array('CONNECT');
00055
00056   // Test CREATE.
00057   $query = 'CREATE TABLE drupal_install_test (id int NULL)';
00058   $result = mysql_query($query);
00059   if ($error = mysql_error()) {
00060     drupal_set_message(st('Failed to create a test table on your MySQL database server with the command %query. MySQL reports the following message: %error.<ul><li>Are you sure the configured username has the necessary MySQL permissions to create tables in the database?</li></ul>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.', array('%query' => $query, '%error' => $error)), 'error');
00061     return FALSE;
00062   }
00063   $err = FALSE;
00064   $success[] = 'SELECT';
00065   $success[] = 'CREATE';
00066
00067   // Test INSERT.
00068   $query = 'INSERT INTO drupal_install_test (id) VALUES (1)';
00069   $result = mysql_query($query);
00070   if ($error = mysql_error()) {
00071     drupal_set_message(st('Failed to insert a value into a test table on your MySQL database server. We tried inserting a value with the command %query and MySQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error');
00072     $err = TRUE;
00073   }
00074   else {
00075     $success[] = 'INSERT';
00076   }
00077
00078   // Test UPDATE.
00079   $query = 'UPDATE drupal_install_test SET id = 2';
00080   $result = mysql_query($query);
00081   if ($error = mysql_error()) {
00082     drupal_set_message(st('Failed to update a value in a test table on your MySQL database server. We tried updating a value with the command %query and MySQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error');
00083     $err = TRUE;
00084   }
00085   else {
00086     $success[] = 'UPDATE';
00087   }
00088
00089   // Test DELETE.
00090   $query = 'DELETE FROM drupal_install_test';
00091   $result = mysql_query($query);
00092   if ($error = mysql_error()) {
00093     drupal_set_message(st('Failed to delete a value from a test table on your MySQL database server. We tried deleting a value with the command %query and MySQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error');
00094     $err = TRUE;
00095   }
00096   else {
00097     $success[] = 'DELETE';
00098   }
00099
00100   // Test DROP.
00101   $query = 'DROP TABLE drupal_install_test';
00102   $result = mysql_query($query);
00103   if ($error = mysql_error()) {
00104     drupal_set_message(st('Failed to drop a test table from your MySQL database server. We tried dropping a table with the command %query and MySQL reported the following error %error.', array('%query' => $query, '%error' => $error)), 'error');
00105     $err = TRUE;
00106   }
00107   else {
00108     $success[] = 'DROP';
00109   }
00110
00111   if ($err) {
00112     return FALSE;
00113   }
00114
00115   mysql_close($connection);
00116   return TRUE;
00117 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/install.mysqli.inc Source File

includes

install.mysqli.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: install.mysqli.inc,v 1.12 2008/01/23 09:59:29 goba Exp $
00003
00004 // MySQLi specific install functions
00005
00012 function mysqli_is_available() {
00013   return function_exists('mysqli_connect');
00014 }
00015
00022 function drupal_test_mysqli($url, &$success) {
00023   if (!mysqli_is_available()) {
00024     drupal_set_message(st('PHP MySQLi support not enabled.'), 'error');
00025     return FALSE;
00026   }
00027
00028   $url = parse_url($url);
00029
00030   // Decode url-encoded information in the db connection string.
00031   $url['user'] = urldecode($url['user']);
00032   $url['pass'] = isset($url['pass']) ? urldecode($url['pass']) : '';
00033   $url['host'] = urldecode($url['host']);
00034   $url['path'] = urldecode($url['path']);
00035
00036   $connection = mysqli_init();
00037   @mysqli_real_connect($connection, $url['host'], $url['user'], $url['pass'], substr($url['path'], 1), $url['port'], NULL, MYSQLI_CLIENT_FOUND_ROWS);
00038   if (mysqli_connect_errno() >= 2000 || mysqli_connect_errno() == 1045) {
00039     drupal_set_message(st('Failed to connect to your MySQL database server. MySQL reports the following message: %error.<ul><li>Are you sure you have the correct username and password?</li><li>Are you sure that you have typed the correct database hostname?</li><li>Are you sure that the database server is running?</li></ul>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.', array('%error' => mysqli_connect_error())), 'error');
00040     return FALSE;
00041   }
00042
00043   // Test selecting the database.
00044   if (mysqli_connect_errno() > 0) {
00045     drupal_set_message(st('Failed to select your database on your MySQL database server, which means the connection username and password are valid, but there is a problem accessing your data. MySQL reports the following message: %error.<ul><li>Are you sure you have the correct database name?</li><li>Are you sure the database exists?</li><li>Are you sure the username has permission to access the database?</li></ul>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.', array('%error' => mysqli_connect_error())), 'error');
00046     return FALSE;
00047   }
00048
00049   $success = array('CONNECT');
00050
00051   // Test CREATE.
00052   $query = 'CREATE TABLE drupal_install_test (id int NULL)';
00053   $result = mysqli_query($connection, $query);
00054   if ($error = mysqli_error($connection)) {
00055     drupal_set_message(st('Failed to create a test table on your MySQL database server with the command %query. MySQL reports the following message: %error.<ul><li>Are you sure the configured username has the necessary MySQL permissions to create tables in the database?</li></ul>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.', array('%query' => $query, '%error' => $error)), 'error');
00056     return FALSE;
00057   }
00058   $err = FALSE;
00059   $success[] = 'SELECT';
00060   $success[] = 'CREATE';
00061
00062   // Test INSERT.
00063   $query = 'INSERT INTO drupal_install_test (id) VALUES (1)';
00064   $result = mysqli_query($connection, $query);
00065   if ($error = mysqli_error($connection)) {
00066     drupal_set_message(st('Failed to insert a value into a test table on your MySQL database server. We tried inserting a value with the command %query and MySQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error');
00067     $err = TRUE;
00068   }
00069   else {
00070     $success[] = 'INSERT';
00071   }
00072
00073   // Test UPDATE.
00074   $query = 'UPDATE drupal_install_test SET id = 2';
00075   $result = mysqli_query($connection, $query);
00076   if ($error = mysqli_error($connection)) {
00077     drupal_set_message(st('Failed to update a value in a test table on your MySQL database server. We tried updating a value with the command %query and MySQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error');
00078     $err = TRUE;
00079   }
00080   else {
00081     $success[] = 'UPDATE';
00082   }
00083
00084   // Test DELETE.
00085   $query = 'DELETE FROM drupal_install_test';
00086   $result = mysqli_query($connection, $query);
00087   if ($error = mysqli_error($connection)) {
00088     drupal_set_message(st('Failed to delete a value from a test table on your MySQL database server. We tried deleting a value with the command %query and MySQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error');
00089     $err = TRUE;
00090   }
00091   else {
00092     $success[] = 'DELETE';
00093   }
00094
00095   // Test DROP.
00096   $query = 'DROP TABLE drupal_install_test';
00097   $result = mysqli_query($connection, $query);
00098   if ($error = mysqli_error($connection)) {
00099     drupal_set_message(st('Failed to drop a test table from your MySQL database server. We tried dropping a table with the command %query and MySQL reported the following error %error.', array('%query' => $query, '%error' => $error)), 'error');
00100     $err = TRUE;
00101   }
00102   else {
00103     $success[] = 'DROP';
00104   }
00105
00106   if ($err) {
00107     return FALSE;
00108   }
00109
00110   mysqli_close($connection);
00111   return TRUE;
00112 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/install.pgsql.inc Source File

includes

install.pgsql.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: install.pgsql.inc,v 1.6 2007/10/22 15:22:39 dries Exp $
00003
00004 // PostgreSQL specific install functions
00005
00012 function pgsql_is_available() {
00013   return function_exists('pg_connect');
00014 }
00015
00022 function drupal_test_pgsql($url, &$success) {
00023   if (!pgsql_is_available()) {
00024     drupal_set_message(st('PHP PostgreSQL support not enabled.'), 'error');
00025     return FALSE;
00026   }
00027
00028   $url = parse_url($url);
00029   $conn_string = '';
00030
00031   // Decode url-encoded information in the db connection string
00032   if (isset($url['user'])) {
00033     $conn_string .= ' user='. urldecode($url['user']);
00034   }
00035   if (isset($url['pass'])) {
00036     $conn_string .= ' password='. urldecode($url['pass']);
00037   }
00038   if (isset($url['host'])) {
00039     $conn_string .= ' host='. urldecode($url['host']);
00040   }
00041   if (isset($url['path'])) {
00042     $conn_string .= ' dbname='. substr(urldecode($url['path']), 1);
00043   }
00044   if (isset($url['port'])) {
00045     $conn_string .= ' port='. urldecode($url['port']);
00046   }
00047
00048   // Test connecting to the database.
00049   $connection = @pg_connect($conn_string);
00050   if (!$connection) {
00051     drupal_set_message(st('Failed to connect to your PostgreSQL database server. PostgreSQL reports the following message: %error.<ul><li>Are you sure you have the correct username and password?</li><li>Are you sure that you have typed the correct database hostname?</li><li>Are you sure that the database server is running?</li><li>Are you sure you typed the correct database name?</li></ul>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.', array('%error' => 'Connection failed. See log file for failure reason')), 'error');
00052     return FALSE;
00053   }
00054
00055   $success = array('CONNECT');
00056
00057   // Test CREATE.
00058   $query = 'CREATE TABLE drupal_install_test (id integer NOT NULL)';
00059   $result = pg_query($connection, $query);
00060   if ($error = pg_result_error($result)) {
00061     drupal_set_message(st('Failed to create a test table on your PostgreSQL database server with the command %query. PostgreSQL reports the following message: %error.<ul><li>Are you sure the configured username has the necessary PostgreSQL permissions to create tables in the database?</li></ul>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.', array('%query' => $query, '%error' => $error)), 'error');
00062     return FALSE;
00063   }
00064   $err = FALSE;
00065   $success[] = 'SELECT';
00066   $success[] = 'CREATE';
00067
00068   // Test INSERT.
00069   $query = 'INSERT INTO drupal_install_test (id) VALUES (1)';
00070   $result = pg_query($connection, $query);
00071   if ($error = pg_result_error($result)) {
00072     drupal_set_message(st('Failed to insert a value into a test table on your PostgreSQL database server. We tried inserting a value with the command %query and PostgreSQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error');
00073     $err = TRUE;
00074   }
00075   else {
00076     $success[] = 'INSERT';
00077   }
00078
00079   // Test UPDATE.
00080   $query = 'UPDATE drupal_install_test SET id = 2';
00081   $result = pg_query($connection, $query);
00082   if ($error = pg_result_error($result)) {
00083     drupal_set_message(st('Failed to update a value in a test table on your PostgreSQL database server. We tried updating a value with the command %query and PostgreSQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error');
00084     $err = TRUE;
00085   }
00086   else {
00087     $success[] = 'UPDATE';
00088   }
00089
00090   // Test LOCK.
00091   $query = 'BEGIN; LOCK drupal_install_test IN SHARE ROW EXCLUSIVE MODE';
00092   $result = pg_query($connection, $query);
00093   if ($error = pg_result_error($result)) {
00094     drupal_set_message(st('Failed to lock a test table on your PostgreSQL database server. We tried locking a table with the command %query and PostgreSQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error');
00095     $err = TRUE;
00096   }
00097   else {
00098     $success[] = 'LOCK';
00099   }
00100
00101   // Test UNLOCK, which is done automatically upon transaction end in PostgreSQL
00102   $query = 'COMMIT';
00103   $result = pg_query($connection, $query);
00104   if ($error = pg_result_error()) {
00105     drupal_set_message(st('Failed to unlock a test table on your PostgreSQL database server. We tried unlocking a table with the command %query and PostgreSQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error');
00106     $err = TRUE;
00107   }
00108   else {
00109     $success[] = 'UNLOCK';
00110   }
00111
00112   // Test DELETE.
00113   $query = 'DELETE FROM drupal_install_test';
00114   $result = pg_query($connection, $query);
00115   if ($error = pg_result_error()) {
00116     drupal_set_message(st('Failed to delete a value from a test table on your PostgreSQL database server. We tried deleting a value with the command %query and PostgreSQL reported the following error: %error.', array('%query' => $query, '%error' => $error)), 'error');
00117     $err = TRUE;
00118   }
00119   else {
00120     $success[] = 'DELETE';
00121   }
00122
00123   // Test DROP.
00124   $query = 'DROP TABLE drupal_install_test';
00125   $result = pg_query($connection, $query);
00126   if ($error = pg_result_error()) {
00127     drupal_set_message(st('Failed to drop a test table from your PostgreSQL database server. We tried dropping a table with the command %query and PostgreSQL reported the following error %error.', array('%query' => $query, '%error' => $error)), 'error');
00128     $err = TRUE;
00129   }
00130   else {
00131     $success[] = 'DROP';
00132   }
00133
00134   if ($err) {
00135     return FALSE;
00136   }
00137
00138   pg_close($connection);
00139   return TRUE;
00140 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: install.php Source File

install.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: install.php,v 1.113.2.2 2008/02/08 22:00:45 goba Exp $
00003
00004 require_once './includes/install.inc';
00005
00006 define('MAINTENANCE_MODE', 'install');
00007
00019 function install_main() {
00020   require_once './includes/bootstrap.inc';
00021   drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
00022
00023   // This must go after drupal_bootstrap(), which unsets globals!
00024   global $profile, $install_locale, $conf;
00025
00026   require_once './modules/system/system.install';
00027   require_once './includes/file.inc';
00028
00029   // Ensure correct page headers are sent (e.g. caching)
00030   drupal_page_header();
00031
00032   // Set up $language, so t() caller functions will still work.
00033   drupal_init_language();
00034
00035   // Load module basics (needed for hook invokes).
00036   include_once './includes/module.inc';
00037   $module_list['system']['filename'] = 'modules/system/system.module';
00038   $module_list['filter']['filename'] = 'modules/filter/filter.module';
00039   module_list(TRUE, FALSE, FALSE, $module_list);
00040   drupal_load('module', 'system');
00041   drupal_load('module', 'filter');
00042
00043   // Set up theme system for the maintenance page.
00044   drupal_maintenance_theme();
00045
00046   // Check existing settings.php.
00047   $verify = install_verify_settings();
00048
00049   if ($verify) {
00050     // Since we have a database connection, we use the normal cache system.
00051     // This is important, as the installer calls into the Drupal system for
00052     // the clean URL checks, so we should maintain the cache properly.
00053     require_once './includes/cache.inc';
00054     $conf['cache_inc'] = './includes/cache.inc';
00055
00056     // Establish a connection to the database.
00057     require_once './includes/database.inc';
00058     db_set_active();
00059
00060     // Check if Drupal is installed.
00061     $task = install_verify_drupal();
00062     if ($task == 'done') {
00063       install_already_done_error();
00064     }
00065   }
00066   else {
00067     // Since no persistent storage is available yet, and functions that check
00068     // for cached data will fail, we temporarily replace the normal cache
00069     // system with a stubbed-out version that short-circuits the actual
00070     // caching process and avoids any errors.
00071     require_once './includes/cache-install.inc';
00072     $conf['cache_inc'] = './includes/cache-install.inc';
00073
00074     $task = NULL;
00075   }
00076
00077   // Decide which profile to use.
00078   if (!empty($_GET['profile'])) {
00079     $profile = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['profile']);
00080   }
00081   elseif ($profile = install_select_profile()) {
00082     install_goto("install.php?profile=$profile");
00083   }
00084   else {
00085     install_no_profile_error();
00086   }
00087
00088   // Load the profile.
00089   require_once "./profiles/$profile/$profile.profile";
00090
00091   // Locale selection
00092   if (!empty($_GET['locale'])) {
00093     $install_locale = preg_replace('/[^a-zA-Z_0-9]/', '', $_GET['locale']);
00094   }
00095   elseif (($install_locale = install_select_locale($profile)) !== FALSE) {
00096     install_goto("install.php?profile=$profile&locale=$install_locale");
00097   }
00098
00099   // Tasks come after the database is set up
00100   if (!$task) {
00101     // Check the installation requirements for Drupal and this profile.
00102     install_check_requirements($profile, $verify);
00103
00104     // Verify existence of all required modules.
00105     $modules = drupal_verify_profile($profile, $install_locale);
00106
00107     // If any error messages are set now, it means a requirement problem.
00108     $messages = drupal_set_message();
00109     if (!empty($messages['error'])) {
00110       install_task_list('requirements');
00111       drupal_set_title(st('Requirements problem'));
00112       print theme('install_page', '');
00113       exit;
00114     }
00115
00116     // Change the settings.php information if verification failed earlier.
00117     // Note: will trigger a redirect if database credentials change.
00118     if (!$verify) {
00119       install_change_settings($profile, $install_locale);
00120     }
00121
00122     // Install system.module.
00123     drupal_install_system();
00124     // Save the list of other modules to install for the 'profile-install'
00125     // task. variable_set() can be used now that system.module is installed
00126     // and drupal is bootstrapped.
00127     variable_set('install_profile_modules', array_diff($modules, array('system')));
00128   }
00129
00130   // The database is set up, turn to further tasks.
00131   install_tasks($profile, $task);
00132 }
00133
00137 function install_verify_drupal() {
00138   // Read the variable manually using the @ so we don't trigger an error if it fails.
00139   $result = @db_query("SELECT value FROM {variable} WHERE name = '%s'", 'install_task');
00140   if ($result) {
00141     return unserialize(db_result($result));
00142   }
00143 }
00144
00148 function install_verify_settings() {
00149   global $db_prefix, $db_type, $db_url;
00150
00151   // Verify existing settings (if any).
00152   if (!empty($db_url)) {
00153     // We need this because we want to run form_get_errors.
00154     include_once './includes/form.inc';
00155
00156     $url = parse_url(is_array($db_url) ? $db_url['default'] : $db_url);
00157     $db_user = urldecode($url['user']);
00158     $db_pass = isset($url['pass']) ? urldecode($url['pass']) : NULL;
00159     $db_host = urldecode($url['host']);
00160     $db_port = isset($url['port']) ? urldecode($url['port']) : '';
00161     $db_path = ltrim(urldecode($url['path']), '/');
00162     $settings_file = './'. conf_path(FALSE, TRUE) .'/settings.php';
00163
00164     $form_state = array();
00165     _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pass, $db_host, $db_port, $db_path, $settings_file, $form_state);
00166     if (!form_get_errors()) {
00167       return TRUE;
00168     }
00169   }
00170   return FALSE;
00171 }
00172
00176 function install_change_settings($profile = 'default', $install_locale = '') {
00177   global $db_url, $db_type, $db_prefix;
00178
00179   $url = parse_url(is_array($db_url) ? $db_url['default'] : $db_url);
00180   $db_user = isset($url['user']) ? urldecode($url['user']) : '';
00181   $db_pass = isset($url['pass']) ? urldecode($url['pass']) : '';
00182   $db_host = isset($url['host']) ? urldecode($url['host']) : '';
00183   $db_port = isset($url['port']) ? urldecode($url['port']) : '';
00184   $db_path = ltrim(urldecode($url['path']), '/');
00185   $conf_path = './'. conf_path(FALSE, TRUE);
00186   $settings_file = $conf_path .'/settings.php';
00187
00188   // We always need this because we want to run form_get_errors.
00189   include_once './includes/form.inc';
00190   install_task_list('database');
00191
00192   if ($db_url == 'mysql://username:password@localhost/databasename') {
00193     $db_user = $db_pass = $db_path = '';
00194   }
00195   elseif (!empty($db_url)) {
00196     // Do not install over a configured settings.php.
00197     install_already_done_error();
00198   }
00199
00200   $output = drupal_get_form('install_settings_form', $profile, $install_locale, $settings_file, $db_url, $db_type, $db_prefix, $db_user, $db_pass, $db_host, $db_port, $db_path);
00201   drupal_set_title(st('Database configuration'));
00202   print theme('install_page', $output);
00203   exit;
00204 }
00205
00206
00210 function install_settings_form(&$form_state, $profile, $install_locale, $settings_file, $db_url, $db_type, $db_prefix, $db_user, $db_pass, $db_host, $db_port, $db_path) {
00211   if (empty($db_host)) {
00212     $db_host = 'localhost';
00213   }
00214   $db_types = drupal_detect_database_types();
00215
00216   // If both 'mysql' and 'mysqli' are available, we disable 'mysql':
00217   if (isset($db_types['mysqli'])) {
00218     unset($db_types['mysql']);
00219   }
00220
00221   if (count($db_types) == 0) {
00222     $form['no_db_types'] = array(
00223       '#value' => st('Your web server does not appear to support any common database types. Check with your hosting provider to see if they offer any databases that <a href="@drupal-databases">Drupal supports</a>.', array('@drupal-databases' => 'http://drupal.org/node/270#database')),
00224     );
00225   }
00226   else {
00227     $form['basic_options'] = array(
00228       '#type' => 'fieldset',
00229       '#title' => st('Basic options'),
00230       '#description' => '<p>'. st('To set up your @drupal database, enter the following information.', array('@drupal' => drupal_install_profile_name())) .'</p>',
00231     );
00232
00233     if (count($db_types) > 1) {
00234       $form['basic_options']['db_type'] = array(
00235         '#type' => 'radios',
00236         '#title' => st('Database type'),
00237         '#required' => TRUE,
00238         '#options' => $db_types,
00239         '#default_value' => ($db_type ? $db_type : current($db_types)),
00240         '#description' => st('The type of database your @drupal data will be stored in.', array('@drupal' => drupal_install_profile_name())),
00241       );
00242       $db_path_description = st('The name of the database your @drupal data will be stored in. It must exist on your server before @drupal can be installed.', array('@drupal' => drupal_install_profile_name()));
00243     }
00244     else {
00245       if (count($db_types) == 1) {
00246         $db_types = array_values($db_types);
00247         $form['basic_options']['db_type'] = array(
00248           '#type' => 'hidden',
00249           '#value' => $db_types[0],
00250         );
00251         $db_path_description = st('The name of the %db_type database your @drupal data will be stored in. It must exist on your server before @drupal can be installed.', array('%db_type' => $db_types[0], '@drupal' => drupal_install_profile_name()));
00252       }
00253     }
00254
00255     // Database name
00256     $form['basic_options']['db_path'] = array(
00257       '#type' => 'textfield',
00258       '#title' => st('Database name'),
00259       '#default_value' => $db_path,
00260       '#size' => 45,
00261       '#maxlength' => 45,
00262       '#required' => TRUE,
00263       '#description' => $db_path_description
00264     );
00265
00266     // Database username
00267     $form['basic_options']['db_user'] = array(
00268       '#type' => 'textfield',
00269       '#title' => st('Database username'),
00270       '#default_value' => $db_user,
00271       '#size' => 45,
00272       '#maxlength' => 45,
00273       '#required' => TRUE,
00274     );
00275
00276     // Database username
00277     $form['basic_options']['db_pass'] = array(
00278       '#type' => 'password',
00279       '#title' => st('Database password'),
00280       '#default_value' => $db_pass,
00281       '#size' => 45,
00282       '#maxlength' => 45,
00283     );
00284
00285     $form['advanced_options'] = array(
00286       '#type' => 'fieldset',
00287       '#title' => st('Advanced options'),
00288       '#collapsible' => TRUE,
00289       '#collapsed' => TRUE,
00290       '#description' => st("These options are only necessary for some sites. If you're not sure what you should enter here, leave the default settings or check with your hosting provider.")
00291     );
00292
00293     // Database host
00294     $form['advanced_options']['db_host'] = array(
00295       '#type' => 'textfield',
00296       '#title' => st('Database host'),
00297       '#default_value' => $db_host,
00298       '#size' => 45,
00299       '#maxlength' => 45,
00300       '#required' => TRUE,
00301       '#description' => st('If your database is located on a different server, change this.'),
00302     );
00303
00304     // Database port
00305     $form['advanced_options']['db_port'] = array(
00306       '#type' => 'textfield',
00307       '#title' => st('Database port'),
00308       '#default_value' => $db_port,
00309       '#size' => 45,
00310       '#maxlength' => 45,
00311       '#description' => st('If your database server is listening to a non-standard port, enter its number.'),
00312     );
00313
00314     // Table prefix
00315     $prefix = ($profile == 'default') ? 'drupal_' : $profile .'_';
00316     $form['advanced_options']['db_prefix'] = array(
00317       '#type' => 'textfield',
00318       '#title' => st('Table prefix'),
00319       '#default_value' => $db_prefix,
00320       '#size' => 45,
00321       '#maxlength' => 45,
00322       '#description' => st('If more than one application will be sharing this database, enter a table prefix such as %prefix for your @drupal site here.', array('@drupal' => drupal_install_profile_name(), '%prefix' => $prefix)),
00323     );
00324
00325     $form['save'] = array(
00326       '#type' => 'submit',
00327       '#value' => st('Save and continue'),
00328     );
00329
00330     $form['errors'] = array();
00331     $form['settings_file'] = array('#type' => 'value', '#value' => $settings_file);
00332     $form['_db_url'] = array('#type' => 'value');
00333     $form['#action'] = "install.php?profile=$profile". ($install_locale ? "&locale=$install_locale" : '');
00334     $form['#redirect'] = FALSE;
00335   }
00336   return $form;
00337 }
00338
00342 function install_settings_form_validate($form, &$form_state) {
00343   global $db_url;
00344   _install_settings_form_validate($form_state['values']['db_prefix'], $form_state['values']['db_type'], $form_state['values']['db_user'], $form_state['values']['db_pass'], $form_state['values']['db_host'], $form_state['values']['db_port'], $form_state['values']['db_path'], $form_state['values']['settings_file'], $form_state, $form);
00345 }
00346
00350 function _install_settings_form_validate($db_prefix, $db_type, $db_user, $db_pass, $db_host, $db_port, $db_path, $settings_file, &$form_state, $form = NULL) {
00351   global $db_url;
00352
00353   // Verify the table prefix
00354   if (!empty($db_prefix) && is_string($db_prefix) && !preg_match('/^[A-Za-z0-9_.]+$/', $db_prefix)) {
00355     form_set_error('db_prefix', st('The database table prefix you have entered, %db_prefix, is invalid. The table prefix can only contain alphanumeric characters, periods, or underscores.', array('%db_prefix' => $db_prefix)), 'error');
00356   }
00357
00358   if (!empty($db_port) && !is_numeric($db_port)) {
00359     form_set_error('db_port', st('Database port must be a number.'));
00360   }
00361
00362   // Check database type
00363   if (!isset($form)) {
00364     $_db_url = is_array($db_url) ? $db_url['default'] : $db_url;
00365     $db_type = substr($_db_url, 0, strpos($_db_url, '://'));
00366   }
00367   $databases = drupal_detect_database_types();
00368   if (!in_array($db_type, $databases)) {
00369     form_set_error('db_type', st("In your %settings_file file you have configured @drupal to use a %db_type server, however your PHP installation currently does not support this database type.", array('%settings_file' => $settings_file, '@drupal' => drupal_install_profile_name(), '%db_type' => $db_type)));
00370   }
00371   else {
00372     // Verify
00373     $db_url = $db_type .'://'. urlencode($db_user) . ($db_pass ? ':'. urlencode($db_pass) : '') .'@'. ($db_host ? urlencode($db_host) : 'localhost') . ($db_port ? ":$db_port" : '') .'/'. urlencode($db_path);
00374     if (isset($form)) {
00375       form_set_value($form['_db_url'], $db_url, $form_state);
00376     }
00377     $success = array();
00378
00379     $function = 'drupal_test_'. $db_type;
00380     if (!$function($db_url, $success)) {
00381       if (isset($success['CONNECT'])) {
00382         form_set_error('db_type', st('In order for Drupal to work, and to continue with the installation process, you must resolve all permission issues reported above. We were able to verify that we have permission for the following commands: %commands. For more help with configuring your database server, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what any of this means you should probably contact your hosting provider.', array('%commands' => implode($success, ', '))));
00383       }
00384       else {
00385         form_set_error('db_type', '');
00386       }
00387     }
00388   }
00389 }
00390
00394 function install_settings_form_submit($form, &$form_state) {
00395   global $profile, $install_locale;
00396
00397   // Update global settings array and save
00398   $settings['db_url'] = array(
00399     'value'    => $form_state['values']['_db_url'],
00400     'required' => TRUE,
00401   );
00402   $settings['db_prefix'] = array(
00403     'value'    => $form_state['values']['db_prefix'],
00404     'required' => TRUE,
00405   );
00406   drupal_rewrite_settings($settings);
00407
00408   // Continue to install profile step
00409   install_goto("install.php?profile=$profile". ($install_locale ? "&locale=$install_locale" : ''));
00410 }
00411
00415 function install_find_profiles() {
00416   return file_scan_directory('./profiles', '\.profile$', array('.', '..', 'CVS'), 0, TRUE, 'name', 0);
00417 }
00418
00425 function install_select_profile() {
00426   include_once './includes/form.inc';
00427
00428   $profiles = install_find_profiles();
00429   // Don't need to choose profile if only one available.
00430   if (sizeof($profiles) == 1) {
00431     $profile = array_pop($profiles);
00432     require_once $profile->filename;
00433     return $profile->name;
00434   }
00435   elseif (sizeof($profiles) > 1) {
00436     foreach ($profiles as $profile) {
00437       if (!empty($_POST['profile']) && ($_POST['profile'] == $profile->name)) {
00438         return $profile->name;
00439       }
00440     }
00441
00442     install_task_list('profile-select');
00443
00444     drupal_set_title(st('Select an installation profile'));
00445     print theme('install_page', drupal_get_form('install_select_profile_form', $profiles));
00446     exit;
00447   }
00448 }
00449
00453 function install_select_profile_form(&$form_state, $profiles) {
00454   foreach ($profiles as $profile) {
00455     include_once($profile->filename);
00456     // Load profile details.
00457     $function = $profile->name .'_profile_details';
00458     if (function_exists($function)) {
00459       $details = $function();
00460     }
00461     // If set, used defined name. Otherwise use file name.
00462     $name = isset($details['name']) ? $details['name'] : $profile->name;
00463     $form['profile'][$name] = array(
00464       '#type' => 'radio',
00465       '#value' => 'default',
00466       '#return_value' => $profile->name,
00467       '#title' => $name,
00468       '#description' => isset($details['description']) ? $details['description'] : '',
00469       '#parents' => array('profile'),
00470     );
00471   }
00472   $form['submit'] =  array(
00473     '#type' => 'submit',
00474     '#value' => st('Save and continue'),
00475   );
00476   return $form;
00477 }
00478
00482 function install_find_locales($profilename) {
00483   $locales = file_scan_directory('./profiles/'. $profilename .'/translations', '\.po$', array('.', '..', 'CVS'), 0, FALSE);
00484   array_unshift($locales, (object) array('name' => 'en'));
00485   return $locales;
00486 }
00487
00494 function install_select_locale($profilename) {
00495   include_once './includes/file.inc';
00496   include_once './includes/form.inc';
00497
00498   // Find all available locales.
00499   $locales = install_find_locales($profilename);
00500
00501   // If only the built-in (English) language is available,
00502   // and we are using the default profile, inform the user
00503   // that the installer can be localized. Otherwise we assume
00504   // the user know what he is doing.
00505   if (count($locales) == 1) {
00506     if ($profilename == 'default') {
00507       install_task_list('locale-select');
00508       drupal_set_title(st('Choose language'));
00509       if (!empty($_GET['localize'])) {
00510         $output = '<p>'. st('With the addition of an appropriate translation package, this installer is capable of proceeding in another language of your choice. To install and use Drupal in a language other than English:') .'</p>';
00511         $output .= '<ul><li>'. st('Determine if <a href="@translations" target="_blank">a translation of this Drupal version</a> is available in your language of choice. A translation is provided via a translation package; each translation package enables the display of a specific version of Drupal in a specific language. Not all languages are available for every version of Drupal.', array('@translations' => 'http://drupal.org/project/translations')) .'</li>';
00512         $output .= '<li>'. st('If an alternative translation package of your choice is available, download and extract its contents to your Drupal root directory.') .'</li>';
00513         $output .= '<li>'. st('Return to choose language using the second link below and select your desired language from the displayed list. Reloading the page allows the list to automatically adjust to the presence of new translation packages.') .'</li>';
00514         $output .= '</ul><p>'. st('Alternatively, to install and use Drupal in English, or to defer the selection of an alternative language until after installation, select the first link below.') .'</p>';
00515         $output .= '<p>'. st('How should the installation continue?') .'</p>';
00516         $output .= '<ul><li><a href="install.php?profile='. $profilename .'&amp;locale=en">'. st('Continue installation in English') .'</a></li><li><a href="install.php?profile='. $profilename .'">'. st('Return to choose a language') .'</a></li></ul>';
00517       }
00518       else {
00519         $output = '<ul><li><a href="install.php?profile='. $profilename .'&amp;locale=en">'. st('Install Drupal in English') .'</a></li><li><a href="install.php?profile='. $profilename .'&amp;localize=true">'. st('Learn how to install Drupal in other languages') .'</a></li></ul>';
00520       }
00521       print theme('install_page', $output);
00522       exit;
00523     }
00524     // One language, but not the default profile, assume
00525     // the user knows what he is doing.
00526     return FALSE;
00527   }
00528   else {
00529     // Allow profile to pre-select the language, skipping the selection.
00530     $function = $profilename .'_profile_details';
00531     if (function_exists($function)) {
00532       $details = $function();
00533       if (isset($details['language'])) {
00534         foreach ($locales as $locale) {
00535           if ($details['language'] == $locale->name) {
00536             return $locale->name;
00537           }
00538         }
00539       }
00540     }
00541
00542     foreach ($locales as $locale) {
00543       if ($_POST['locale'] == $locale->name) {
00544         return $locale->name;
00545       }
00546     }
00547
00548     install_task_list('locale-select');
00549
00550     drupal_set_title(st('Choose language'));
00551     print theme('install_page', drupal_get_form('install_select_locale_form', $locales));
00552     exit;
00553   }
00554 }
00555
00559 function install_select_locale_form(&$form_state, $locales) {
00560   include_once './includes/locale.inc';
00561   $languages = _locale_get_predefined_list();
00562   foreach ($locales as $locale) {
00563     // Try to use verbose locale name
00564     $name = $locale->name;
00565     if (isset($languages[$name])) {
00566       $name = $languages[$name][0] . (isset($languages[$name][1]) ? ' '. st('(@language)', array('@language' => $languages[$name][1])) : '');
00567     }
00568     $form['locale'][$locale->name] = array(
00569       '#type' => 'radio',
00570       '#return_value' => $locale->name,
00571       '#default_value' => ($locale->name == 'en' ? TRUE : FALSE),
00572       '#title' => $name . ($locale->name == 'en' ? ' '. st('(built-in)') : ''),
00573       '#parents' => array('locale')
00574     );
00575   }
00576   $form['submit'] =  array(
00577     '#type' => 'submit',
00578     '#value' => st('Select language'),
00579   );
00580   return $form;
00581 }
00582
00586 function install_no_profile_error() {
00587   install_task_list('profile-select');
00588   drupal_set_title(st('No profiles available'));
00589   print theme('install_page', '<p>'. st('We were unable to find any installer profiles. Installer profiles tell us what modules to enable and what schema to install in the database. A profile is necessary to continue with the installation process.') .'</p>');
00590   exit;
00591 }
00592
00593
00597 function install_already_done_error() {
00598   global $base_url;
00599
00600   drupal_set_title(st('Drupal already installed'));
00601   print theme('install_page', st('<ul><li>To start over, you must empty your existing database.</li><li>To install to a different database, edit the appropriate <em>settings.php</em> file in the <em>sites</em> folder.</li><li>To upgrade an existing installation, proceed to the <a href="@base-url/update.php">update script</a>.</li><li>View your <a href="@base-url">existing site</a>.</li></ul>', array('@base-url' => $base_url)));
00602   exit;
00603 }
00604
00608 function install_tasks($profile, $task) {
00609   global $base_url, $install_locale;
00610
00611   // Bootstrap newly installed Drupal, while preserving existing messages.
00612   $messages = isset($_SESSION['messages']) ? $_SESSION['messages'] : '';
00613   drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
00614   $_SESSION['messages'] = $messages;
00615
00616   // URL used to direct page requests.
00617   $url = $base_url .'/install.php?locale='. $install_locale .'&profile='. $profile;
00618
00619   // Build a page for final tasks.
00620   if (empty($task)) {
00621     variable_set('install_task', 'profile-install');
00622     $task = 'profile-install';
00623   }
00624
00625   // We are using a list of if constructs here to allow for
00626   // passing from one task to the other in the same request.
00627
00628   // Install profile modules.
00629   if ($task == 'profile-install') {
00630     $modules = variable_get('install_profile_modules', array());
00631     $files = module_rebuild_cache();
00632     variable_del('install_profile_modules');
00633     $operations = array();
00634     foreach ($modules as $module) {
00635       $operations[] = array('_install_module_batch', array($module, $files[$module]->info['name']));
00636     }
00637     $batch = array(
00638       'operations' => $operations,
00639       'finished' => '_install_profile_batch_finished',
00640       'title' => st('Installing @drupal', array('@drupal' => drupal_install_profile_name())),
00641       'error_message' => st('The installation has encountered an error.'),
00642     );
00643     // Start a batch, switch to 'profile-install-batch' task. We need to
00644     // set the variable here, because batch_process() redirects.
00645     variable_set('install_task', 'profile-install-batch');
00646     batch_set($batch);
00647     batch_process($url, $url);
00648   }
00649   // We are running a batch install of the profile's modules.
00650   // This might run in multiple HTTP requests, constantly redirecting
00651   // to the same address, until the batch finished callback is invoked
00652   // and the task advances to 'locale-initial-import'.
00653   if ($task == 'profile-install-batch') {
00654     include_once 'includes/batch.inc';
00655     $output = _batch_page();
00656   }
00657
00658   // Import interface translations for the enabled modules.
00659   if ($task == 'locale-initial-import') {
00660     if (!empty($install_locale) && ($install_locale != 'en')) {
00661       include_once 'includes/locale.inc';
00662       // Enable installation language as default site language.
00663       locale_add_language($install_locale, NULL, NULL, NULL, NULL, NULL, 1, TRUE);
00664       // Collect files to import for this language.
00665       $batch = locale_batch_by_language($install_locale, '_install_locale_initial_batch_finished');
00666       if (!empty($batch)) {
00667         // Remember components we cover in this batch set.
00668         variable_set('install_locale_batch_components', $batch['#components']);
00669         // Start a batch, switch to 'locale-batch' task. We need to
00670         // set the variable here, because batch_process() redirects.
00671         variable_set('install_task', 'locale-initial-batch');
00672         batch_set($batch);
00673         batch_process($url, $url);
00674       }
00675     }
00676     // Found nothing to import or not foreign language, go to next task.
00677     $task = 'configure';
00678   }
00679   if ($task == 'locale-initial-batch') {
00680     include_once 'includes/batch.inc';
00681     include_once 'includes/locale.inc';
00682     $output = _batch_page();
00683   }
00684
00685   if ($task == 'configure') {
00686     if (variable_get('site_name', FALSE) || variable_get('site_mail', FALSE)) {
00687       // Site already configured: This should never happen, means re-running
00688       // the installer, possibly by an attacker after the 'install_task' variable
00689       // got accidentally blown somewhere. Stop it now.
00690       install_already_done_error();
00691     }
00692     $form = drupal_get_form('install_configure_form', $url);
00693
00694     if (!variable_get('site_name', FALSE) && !variable_get('site_mail', FALSE)) {
00695       // Not submitted yet: Prepare to display the form.
00696       $output = $form;
00697       drupal_set_title(st('Configure site'));
00698
00699       // Warn about settings.php permissions risk
00700       $settings_dir = './'. conf_path();
00701       $settings_file = $settings_dir .'/settings.php';
00702       if (!drupal_verify_install_file($settings_file, FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE) || !drupal_verify_install_file($settings_dir, FILE_NOT_WRITABLE, 'dir')) {
00703         drupal_set_message(st('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, please consult the <a href="@handbook_url">on-line handbook</a>.', array('%dir' => $settings_dir, '%file' => $settings_file, '@handbook_url' => 'http://drupal.org/getting-started')), 'error');
00704       }
00705       else {
00706         drupal_set_message(st('All necessary changes to %dir and %file have been made. They have been set to read-only for security.', array('%dir' => $settings_dir, '%file' => $settings_file)));
00707       }
00708
00709       // Add JavaScript validation.
00710       _user_password_dynamic_validation();
00711       drupal_add_js(drupal_get_path('module', 'system') .'/system.js', 'module');
00712       // We add these strings as settings because JavaScript translation does not
00713       // work on install time.
00714       drupal_add_js(array('copyFieldValue' => array('edit-site-mail' => array('edit-account-mail')), 'cleanURL' => array('success' => st('Your server has been successfully tested to support this feature.'), 'failure' => st('Your system configuration does not currently support this feature. The <a href="http://drupal.org/node/15365">handbook page on Clean URLs</a> has additional troubleshooting information.'), 'testing' => st('Testing clean URLs...'))), 'setting');
00715       drupal_add_js('
00716 // Global Killswitch
00717 if (Drupal.jsEnabled) {
00718   $(document).ready(function() {
00719     Drupal.cleanURLsInstallCheck();
00720     Drupal.setDefaultTimezone();
00721   });
00722 }', 'inline');
00723       // Build menu to allow clean URL check.
00724       menu_rebuild();
00725     }
00726
00727     else {
00728       $task = 'profile';
00729     }
00730   }
00731
00732   // If found an unknown task or the 'profile' task, which is
00733   // reserved for profiles, hand over the control to the profile,
00734   // so it can run any number of custom tasks it defines.
00735   if (!in_array($task, install_reserved_tasks())) {
00736     $function = $profile .'_profile_tasks';
00737     if (function_exists($function)) {
00738       // The profile needs to run more code, maybe even more tasks.
00739       // $task is sent through as a reference and may be changed!
00740       $output = $function($task, $url);
00741     }
00742
00743     // If the profile doesn't move on to a new task we assume
00744     // that it is done.
00745     if ($task == 'profile') {
00746       $task = 'profile-finished';
00747     }
00748   }
00749
00750   // Profile custom tasks are done, so let the installer regain
00751   // control and proceed with importing the remaining translations.
00752   if ($task == 'profile-finished') {
00753     if (!empty($install_locale) && ($install_locale != 'en')) {
00754       include_once 'includes/locale.inc';
00755       // Collect files to import for this language. Skip components
00756       // already covered in the initial batch set.
00757       $batch = locale_batch_by_language($install_locale, '_install_locale_remaining_batch_finished', variable_get('install_locale_batch_components', array()));
00758       // Remove temporary variable.
00759       variable_del('install_locale_batch_components');
00760       if (!empty($batch)) {
00761         // Start a batch, switch to 'locale-remaining-batch' task. We need to
00762         // set the variable here, because batch_process() redirects.
00763         variable_set('install_task', 'locale-remaining-batch');
00764         batch_set($batch);
00765         batch_process($url, $url);
00766       }
00767     }
00768     // Found nothing to import or not foreign language, go to next task.
00769     $task = 'finished';
00770   }
00771   if ($task == 'locale-remaining-batch') {
00772     include_once 'includes/batch.inc';
00773     include_once 'includes/locale.inc';
00774     $output = _batch_page();
00775   }
00776
00777   // Display a 'finished' page to user.
00778   if ($task == 'finished') {
00779     drupal_set_title(st('@drupal installation complete', array('@drupal' => drupal_install_profile_name())));
00780     $messages = drupal_set_message();
00781     $output = '<p>'. st('Congratulations, @drupal has been successfully installed.', array('@drupal' => drupal_install_profile_name())) .'</p>';
00782     $output .= '<p>'. (isset($messages['error']) ? st('Please review the messages above before continuing on to <a href="@url">your new site</a>.', array('@url' => url(''))) : st('You may now visit <a href="@url">your new site</a>.', array('@url' => url('')))) .'</p>';
00783     $task = 'done';
00784   }
00785
00786   // The end of the install process. Remember profile used.
00787   if ($task == 'done') {
00788     // Rebuild menu to get content type links registered by the profile,
00789     // and possibly any other menu items created through the tasks.
00790     menu_rebuild();
00791
00792     // Register actions declared by any modules.
00793     actions_synchronize();
00794
00795     // Randomize query-strings on css/js files, to hide the fact that
00796     // this is a new install, not upgraded yet.
00797     _drupal_flush_css_js();
00798
00799     variable_set('install_profile', $profile);
00800   }
00801
00802   // Set task for user, and remember the task in the database.
00803   install_task_list($task);
00804   variable_set('install_task', $task);
00805
00806   // Output page, if some output was required. Otherwise it is possible
00807   // that we are printing a JSON page and theme output should not be there.
00808   if (isset($output)) {
00809     print theme('maintenance_page', $output);
00810   }
00811 }
00812
00816 function _install_module_batch($module, $module_name, &$context) {
00817   _drupal_install_module($module);
00818   // We enable the installed module right away, so that the module will be
00819   // loaded by drupal_bootstrap in subsequent batch requests, and other
00820   // modules possibly depending on it can safely perform their installation
00821   // steps.
00822   module_enable(array($module));
00823   $context['results'][] = $module;
00824   $context['message'] = 'Installed '. $module_name .' module.';
00825 }
00826
00832 function _install_profile_batch_finished($success, $results) {
00833   variable_set('install_task', 'locale-initial-import');
00834 }
00835
00841 function _install_locale_initial_batch_finished($success, $results) {
00842   variable_set('install_task', 'configure');
00843 }
00844
00850 function _install_locale_remaining_batch_finished($success, $results) {
00851   variable_set('install_task', 'finished');
00852 }
00853
00857 function install_reserved_tasks() {
00858   return array('configure', 'profile-install', 'profile-install-batch', 'locale-initial-import', 'locale-initial-batch', 'profile-finished', 'locale-remaining-batch', 'finished', 'done');
00859 }
00860
00864 function install_check_requirements($profile, $verify) {
00865
00866   // If Drupal is not set up already, we need to create a settings file.
00867   if (!$verify) {
00868     $writable = FALSE;
00869     $conf_path = './'. conf_path(FALSE, TRUE);
00870     $settings_file = $conf_path .'/settings.php';
00871     $file = $conf_path;
00872     // Verify that the directory exists.
00873     if (drupal_verify_install_file($conf_path, FILE_EXIST, 'dir')) {
00874       // Check to see if a settings.php already exists.
00875       if (drupal_verify_install_file($settings_file, FILE_EXIST)) {
00876         // If it does, make sure it is writable.
00877         $writable = drupal_verify_install_file($settings_file, FILE_READABLE|FILE_WRITABLE);
00878         $file = $settings_file;
00879       }
00880       else {
00881         // If not, make sure the directory is.
00882         $writable = drupal_verify_install_file($conf_path, FILE_READABLE|FILE_WRITABLE, 'dir');
00883       }
00884     }
00885
00886     if (!$writable) {
00887       drupal_set_message(st('The @drupal installer requires write permissions to %file during the installation process. If you are unsure how to grant file permissions, please consult the <a href="@handbook_url">on-line handbook</a>.', array('@drupal' => drupal_install_profile_name(), '%file' => $file, '@handbook_url' => 'http://drupal.org/server-permissions')), 'error');
00888     }
00889   }
00890
00891   // Check the other requirements.
00892   $requirements = drupal_check_profile($profile);
00893   $severity = drupal_requirements_severity($requirements);
00894
00895   // If there are issues, report them.
00896   if ($severity == REQUIREMENT_ERROR) {
00897
00898     foreach ($requirements as $requirement) {
00899       if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
00900         $message = $requirement['description'];
00901         if (isset($requirement['value']) && $requirement['value']) {
00902           $message .= ' ('. st('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) .')';
00903         }
00904         drupal_set_message($message, 'error');
00905       }
00906     }
00907   }
00908   if ($severity == REQUIREMENT_WARNING) {
00909
00910     foreach ($requirements as $requirement) {
00911       if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_WARNING) {
00912         $message = $requirement['description'];
00913         if (isset($requirement['value']) && $requirement['value']) {
00914           $message .= ' ('. st('Currently using !item !version', array('!item' => $requirement['title'], '!version' => $requirement['value'])) .')';
00915         }
00916         drupal_set_message($message, 'warning');
00917       }
00918     }
00919   }
00920 }
00921
00925 function install_task_list($active = NULL) {
00926   // Default list of tasks.
00927   $tasks = array(
00928     'profile-select'        => st('Choose profile'),
00929     'locale-select'         => st('Choose language'),
00930     'requirements'          => st('Verify requirements'),
00931     'database'              => st('Set up database'),
00932     'profile-install-batch' => st('Install profile'),
00933     'locale-initial-batch'  => st('Set up translations'),
00934     'configure'             => st('Configure site'),
00935   );
00936
00937   $profiles = install_find_profiles();
00938   $profile = isset($_GET['profile']) && isset($profiles[$_GET['profile']]) ? $_GET['profile'] : '.';
00939   $locales = install_find_locales($profile);
00940
00941   // If we have only one profile, remove 'Choose profile'
00942   // and rename 'Install profile'.
00943   if (count($profiles) == 1) {
00944     unset($tasks['profile-select']);
00945     $tasks['profile-install-batch'] = st('Install site');
00946   }
00947
00948   // Add tasks defined by the profile.
00949   if ($profile) {
00950     $function = $profile .'_profile_task_list';
00951     if (function_exists($function)) {
00952       $result = $function();
00953       if (is_array($result)) {
00954         $tasks += $result;
00955       }
00956     }
00957   }
00958
00959   if (count($locales) < 2 || empty($_GET['locale']) || $_GET['locale'] == 'en') {
00960     // If not required, remove translation import from the task list.
00961     unset($tasks['locale-initial-batch']);
00962   }
00963   else {
00964     // If required, add remaining translations import task.
00965     $tasks += array('locale-remaining-batch' => st('Finish translations'));
00966   }
00967
00968   // Add finished step as the last task.
00969   $tasks += array(
00970     'finished'     => st('Finished')
00971   );
00972
00973   // Let the theming function know that 'finished' and 'done'
00974   // include everything, so every step is completed.
00975   if (in_array($active, array('finished', 'done'))) {
00976     $active = NULL;
00977   }
00978   drupal_set_content('left', theme_task_list($tasks, $active));
00979 }
00980
00984 function install_configure_form(&$form_state, $url) {
00985
00986   $form['intro'] = array(
00987     '#value' => st('To configure your website, please provide the following information.'),
00988     '#weight' => -10,
00989   );
00990   $form['site_information'] = array(
00991     '#type' => 'fieldset',
00992     '#title' => st('Site information'),
00993     '#collapsible' => FALSE,
00994   );
00995   $form['site_information']['site_name'] = array(
00996     '#type' => 'textfield',
00997     '#title' => st('Site name'),
00998     '#required' => TRUE,
00999     '#weight' => -20,
01000   );
01001   $form['site_information']['site_mail'] = array(
01002     '#type' => 'textfield',
01003     '#title' => st('Site e-mail address'),
01004     '#default_value' => ini_get('sendmail_from'),
01005     '#description' => st("The <em>From</em> address in automated e-mails sent during registration and new password requests, and other notifications. (Use an address ending in your site's domain to help prevent this e-mail being flagged as spam.)"),
01006     '#required' => TRUE,
01007     '#weight' => -15,
01008   );
01009   $form['admin_account'] = array(
01010     '#type' => 'fieldset',
01011     '#title' => st('Administrator account'),
01012     '#collapsible' => FALSE,
01013   );
01014   $form['admin_account']['account']['#tree'] = TRUE;
01015   $form['admin_account']['markup'] = array(
01016     '#value' => '<p class="description">'. st('The administrator account has complete access to the site; it will automatically be granted all permissions and can perform any administrative activity. This will be the only account that can perform certain activities, so keep its credentials safe.') .'</p>',
01017     '#weight' => -10,
01018   );
01019
01020   $form['admin_account']['account']['name'] = array('#type' => 'textfield',
01021     '#title' => st('Username'),
01022     '#maxlength' => USERNAME_MAX_LENGTH,
01023     '#description' => st('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.'),
01024     '#required' => TRUE,
01025     '#weight' => -10,
01026   );
01027
01028   $form['admin_account']['account']['mail'] = array('#type' => 'textfield',
01029     '#title' => st('E-mail address'),
01030     '#maxlength' => EMAIL_MAX_LENGTH,
01031     '#description' => st('All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'),
01032     '#required' => TRUE,
01033     '#weight' => -5,
01034   );
01035   $form['admin_account']['account']['pass'] = array(
01036     '#type' => 'password_confirm',
01037     '#required' => TRUE,
01038     '#size' => 25,
01039     '#weight' => 0,
01040   );
01041
01042   $form['server_settings'] = array(
01043     '#type' => 'fieldset',
01044     '#title' => st('Server settings'),
01045     '#collapsible' => FALSE,
01046   );
01047   $form['server_settings']['date_default_timezone'] = array(
01048     '#type' => 'select',
01049     '#title' => st('Default time zone'),
01050     '#default_value' => 0,
01051     '#options' => _system_zonelist(),
01052     '#description' => st('By default, dates in this site will be displayed in the chosen time zone.'),
01053     '#weight' => 5,
01054   );
01055
01056   $form['server_settings']['clean_url'] = array(
01057     '#type' => 'radios',
01058     '#title' => st('Clean URLs'),
01059     '#default_value' => 0,
01060     '#options' => array(0 => st('Disabled'), 1 => st('Enabled')),
01061     '#description' => st('This option makes Drupal emit "clean" URLs (i.e. without <code>?q=</code> in the URL).'),
01062     '#disabled' => TRUE,
01063     '#prefix' => '<div id="clean-url" class="install">',
01064     '#suffix' => '</div>',
01065     '#weight' => 10,
01066   );
01067
01068   $form['server_settings']['update_status_module'] = array(
01069     '#type' => 'checkboxes',
01070     '#title' => st('Update notifications'),
01071     '#options' => array(1 => st('Check for updates automatically')),
01072     '#default_value' => array(1),
01073     '#description' => st('With this option enabled, Drupal will notify you when new releases are available. This will significantly enhance your site\'s security and is <strong>highly recommended</strong>. This requires your site to periodically send anonymous information on its installed components to <a href="@drupal">drupal.org</a>. For more information please see the <a href="@update">update notification information</a>.', array('@drupal' => 'http://drupal.org', '@update' => 'http://drupal.org/handbook/modules/update')),
01074     '#weight' => 15,
01075   );
01076
01077   $form['submit'] = array(
01078     '#type' => 'submit',
01079     '#value' => st('Save and continue'),
01080     '#weight' => 15,
01081   );
01082   $form['#action'] = $url;
01083   $form['#redirect'] = FALSE;
01084
01085   // Allow the profile to alter this form. $form_state isn't available
01086   // here, but to conform to the hook_form_alter() signature, we pass
01087   // an empty array.
01088   $hook_form_alter = $_GET['profile'] .'_form_alter';
01089   if (function_exists($hook_form_alter)) {
01090     $hook_form_alter($form, array(), 'install_configure');
01091   }
01092   return $form;
01093 }
01094
01098 function install_configure_form_validate($form, &$form_state) {
01099   if ($error = user_validate_name($form_state['values']['account']['name'])) {
01100     form_error($form['admin_account']['account']['name'], $error);
01101   }
01102   if ($error = user_validate_mail($form_state['values']['account']['mail'])) {
01103     form_error($form['admin_account']['account']['mail'], $error);
01104   }
01105   if ($error = user_validate_mail($form_state['values']['site_mail'])) {
01106     form_error($form['site_information']['site_mail'], $error);
01107   }
01108 }
01109
01113 function install_configure_form_submit($form, &$form_state) {
01114   global $user;
01115
01116   variable_set('site_name', $form_state['values']['site_name']);
01117   variable_set('site_mail', $form_state['values']['site_mail']);
01118   variable_set('date_default_timezone', $form_state['values']['date_default_timezone']);
01119
01120   // Enable update.module if this option was selected.
01121   if ($form_state['values']['update_status_module'][1]) {
01122     drupal_install_modules(array('update'));
01123   }
01124
01125   // Turn this off temporarily so that we can pass a password through.
01126   variable_set('user_email_verification', FALSE);
01127   $form_state['old_values'] = $form_state['values'];
01128   $form_state['values'] = $form_state['values']['account'];
01129
01130   // We precreated user 1 with placeholder values. Let's save the real values.
01131   $account = user_load(1);
01132   $merge_data = array('init' => $form_state['values']['mail'], 'roles' => array(), 'status' => 1);
01133   user_save($account, array_merge($form_state['values'], $merge_data));
01134   // Log in the first user.
01135   user_authenticate($form_state['values']);
01136   $form_state['values'] = $form_state['old_values'];
01137   unset($form_state['old_values']);
01138   variable_set('user_email_verification', TRUE);
01139
01140   if (isset($form_state['values']['clean_url'])) {
01141     variable_set('clean_url', $form_state['values']['clean_url']);
01142   }
01143   // The user is now logged in, but has no session ID yet, which
01144   // would be required later in the request, so remember it.
01145   $user->sid = session_id();
01146
01147   // Record when this install ran.
01148   variable_set('install_time', time());
01149 }
01150
01151 // Start the installer.
01152 install_main();
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


JavaScript Startup Guide

Content

  1. Three difficulties in learning JavaScript for Drupal
    1. Lack of documentation
    2. Object Orientated Programming (OOP)
    3. Many APIs: who does what?
      1. JavaScript
      2. Document Object Model (DOM)
      3. jQuery
      4. Drupal JavaScript
      5. Drupal Form API
  2. Examples
    1. Drupal.jsEnabled
    2. Conclusion
  3. Drupal JavaScript API
    1. Drupal.behaviors

Three difficulties in learning JavaScript for Drupal

There are three main difficulties that an inexperienced developer faces when trying to understand JavaScript as used in Drupal:

  1. The lack of documentation,
  2. The OOP style of programming,
  3. The confusion between all the different elements and API involved.
Each element is detailled below.

1- Lack of documentation

First and foremost, the lack of documentation has made Drupal's JavaScript code difficultly accessible to the inexperienced developer. This document is an attempt at filling a little a huge gap.

Also, this site (api.drupal.org) uses the api.module to automatically extract the documentation from the source code in order to present it here. Unfortunately, the API parser works only on PHP code. A parser for JavaScript code is needed. If you are good at this kind of stuff, your help will be appreciated.

Lastly, some .js files in Drupal core and in contrib modules could do with a bit more in-code documentation. Patches are welcome.

2- Object Orientated Programming (OOP)

The second difficulty concerns the programmer who is mostly self-taught, with little or no formal training in programming, and who knows only HTML and PHP as used within Drupal. Other programmers, the professionals, those who have learned other computer languages using OOP (like C, C++, Java, etc.) would already be familiar with OOP.

While PHP does support OOP, the fact is that Drupal does not use OOP. So a programmer who has learned only as much PHP as necessary to program for Drupal may find the OOP in JavaScript confusing.

Indeed, the very first line of JavaScript code in Drupal core, in drupal.js, is an Object declaration:

var Drupal = Drupal || { 'settings': {}, 'behaviors': {}, 'themes': {}, 'locale': {} };

In this code, Drupal is an Object declared to be equal to itself, or, if not yet set, equal to { 'settings': {}, 'behaviors': {}, 'themes': {}, 'locale': {} } which is an Object containing 4 methods (settings, behaviors, themes, and locale) each of which is itself an Object. This line of code is an Object Initializer.

So, if you find yourself unfamiliar with Object Oriented Programming, you need to learn a bit more on the topic in order to understand what follows. See in particular the following:

  • Classes and Objects (PHP 5)
  • Core JavaScript 1.5 Guide:Working with Objects
  • Object-oriented programming (Wikipedia)

3- Many APIs: who does what?

Maybe the major problem in understanding the JavaScript code found within Drupal is because there is not one language (JavaScript), but many different APIs and Specifications involved. Within a .js file, there could be DOM components and Drupal Form API elements tied together with JavaScript, jQuery, some core Drupal JavaScript Objects and functions, as well as the module's own JavaScript code and HTML markup. The real difficulty is understanding what does what. This section is about clarifying a bit this big mess.

JavaScript

For an experienced PHP devoloper, reading the Core JavaScript 1.5 Guide can be both easy and frustrating.

The JavaScript language is easy to understand because it is very similar to PHP. There are some important and obvious differences, like the operator used for concatenation: php uses the dot (full stop), while JavaScript, as should be obvious by reading any js code, uses the + sign. Other than that, JavaScript and PHP are both dynamically typed language (i.e. without strong typing like in C++), and share many language structures. As noted above, Javascript code makes heavy use of OOP. It is still recommended to have at least a quick read through the available documentation.

The frustrating part is that reading the documentation does not seem to answer any of the questions that prompted us to read it in the first place. The fact is, for a php developer, JavaScript is easy to understand. What we have a problem with is not it, but the other elements involved in js code.

Document Object Model (DOM)

JavaScript uses the DOM to manipulate elements in the web page. This Document Object is the reason why JavaScript programming in inherently Object Oriented. In short, the object in question is your browser window, the top element of which is the <html> tag. The HTML DOM will create the object called document which you will find in many js code.

Rather than repeating what has been better said elsewhere, here is a list of important resources about the DOM specifications and its relationship with JavaScript. It is recommended that you become fairly familiar with at least the general content of the following documents:

  • The official DOM documentation at the W3C:
    • Document Object Model (DOM): the DOM homepage.
    • Document Object Model (DOM) Technical Reports: the list of DOM specifications.
    • Document Object Model (DOM) Level 1 Specification: chapter one deals with the basic DOM specs for any document. Chapter two covers more specifically a HTML document.
    • Document Object Model Level 2: 6 documents in total. See in particular the DOM Level 2 HTML Specification and the DOM Level 2 Events Specification. In them, you will find the specs for many methods that you would have encountered in most js code.
  • DOM and Javascript:
    • DOM: the DOM section at mozilla.org. They write: The Document Object Model (DOM) is an API for HTML and XML documents. It provides a structural representation of the document, enabling you to modify its content and visual presentation. Essentially, it connects web pages to scripts or programming languages. The DOM is what connects the js code to your HTML page.
    • The DOM and JavaScript: a simple introduction to help differenciate both topics.
    • Gecko DOM Reference: this document is important. It covers all the different properties and methods of the document Object, as used in Gecko browsers, and other complient browsers (i.e. almost any browser!).

jQuery

jQuery enhances JavaScript and the DOM by adding new methods to the document object. Understanding the jQuery documentation assumes that you have a fair grasp of both Object Oriented Programming and the DOM. Do not proceed further if you are still unclear about either.

Here are some useful links:

  • jQuery documentation. See links in the API Reference section for specific topics.

When reading example code is the Tutorials section, it help to try figuring out which parts of the code are JavaScript constructs, which are DOM specs implementations, and which are jQuery extensions.

Drupal JavaScript

Building up on all the previous elements, core Drupal js files create a Drupal Object with a few methods that modules can use, like Drupal.behaviors, Drupal.settings, etc. Those will be covered in more details below.

Drupal Form API

More often than not, JavaScript is used within Drupal to enhance the forms' User Interface.

In order to make the most of Drupal js, we can use some FORM API attributes, like #ahah. Details to come.

Examples

As we have seen, js code is a mix of different APIs and Specifications. We are now going to provide some examples to show how tightly integrated those different parts are.

Drupal.jsEnabled

if (Drupal.jsEnabled) {
   // Global Killswitch on the <html> element
   document.documentElement.className = 'js';
   // 'js enabled' cookie
   document.cookie = 'has_js=1; path=/';
   // Attach all behaviors.
   $(document).ready(Drupal.attachBehaviors);
}

In this block of code we have:

  • JavaScript language:
    • you can recognize a simple if() {} structure control, the semi-column ";" at the end of lines, etc.
    • What is different compared to PHP is the dot (.) used in Objects where PHP would use ->, as in a node object (e.g. $node->nid).
  • Comments, much like in PHP.
  • DOM elements:
    • The document is a Javascript implementation of the Document interface as defined in the core DOM Level 1 specifications: The Document interface is the first interface defined in the DOM1 Core, and document is a host object implementing the Document interface.
    • documentElement is a core DOM attribute: This is a convenience attribute that allows direct access to the child node that is the root element of the document. For HTML documents, this is the element with the tagName "HTML".
    • className is the class attribute of the element: This attribute has been renamed due to conflicts with the "class" keyword exposed by many languages.. What the line document.documentElement.className = 'js'; does, is add the class 'js' to the element <html>, so that in effect we have <html class="js" > .
    • cookie is yet another DOM attribute.
  • jQuery:
    • $(document) is a jQuery selector. In this case, it selects the whole document. As explained in the tutorial: $ is an alias for the jQuery "class", therefore $() constructs a new jQuery object.
    • ready() is a jQuery event function.
  • Drupal:
    • Drupal is the object we discussed above
    • jsEnabled is the present function. If we manage to use JavaScript to add the class "js" to the html element, then we know the browser has JavaScript enabled :).
    • attachBehaviors: in PHP, we would have <?php module_invoke_all('Behaviors');?>. attachBehaviors is a method of the Object Drupal which calls all the Behavior functions declared by modules.

Conclusion

If you have some difficulty understanding some js code, your first task is to figure out what API is defining the part you don't understand. Is is a DOM complient method? A jQuery method? a Drupal one? Is it the Object Oriented Programming style? Or the way jQuery objects are bound together in a long succession of methods?

If you can identify what troubles you, then finding the solution becomes easier, because you know in which documentation to look.

Drupal JavaScript API

This section is to be completed... If you want to give a hand, please do! :)

Drupal.behaviors

Drupal.settings

Drupal.themes

Drupal.locale


Drupal 6: includes/language.inc Source File

includes

language.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: language.inc,v 1.14 2008/01/06 16:46:02 goba Exp $
00003
00012 function language_initialize() {
00013   global $user;
00014
00015   // Configured presentation language mode.
00016   $mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE);
00017   // Get a list of enabled languages.
00018   $languages = language_list('enabled');
00019   $languages = $languages[1];
00020
00021   switch ($mode) {
00022     case LANGUAGE_NEGOTIATION_NONE:
00023       return language_default();
00024
00025     case LANGUAGE_NEGOTIATION_DOMAIN:
00026       foreach ($languages as $language) {
00027         $parts = parse_url($language->domain);
00028         if (!empty($parts['host']) && ($_SERVER['SERVER_NAME'] == $parts['host'])) {
00029           return $language;
00030         }
00031       }
00032       return language_default();
00033
00034     case LANGUAGE_NEGOTIATION_PATH_DEFAULT:
00035     case LANGUAGE_NEGOTIATION_PATH:
00036       // $_GET['q'] might not be available at this time, because
00037       // path initialization runs after the language bootstrap phase.
00038       $args = isset($_GET['q']) ? explode('/', $_GET['q']) : array();
00039       $prefix = array_shift($args);
00040       // Search prefix within enabled languages.
00041       foreach ($languages as $language) {
00042         if (!empty($language->prefix) && $language->prefix == $prefix) {
00043           // Rebuild $GET['q'] with the language removed.
00044           $_GET['q'] = implode('/', $args);
00045           return $language;
00046         }
00047       }
00048       if ($mode == LANGUAGE_NEGOTIATION_PATH_DEFAULT) {
00049         // If we did not found the language by prefix, choose the default.
00050         return language_default();
00051       }
00052       break;
00053   }
00054
00055   // User language.
00056   if ($user->uid && isset($languages[$user->language])) {
00057     return $languages[$user->language];
00058   }
00059
00060   // Browser accept-language parsing.
00061   if ($language = language_from_browser()) {
00062     return $language;
00063   }
00064
00065   // Fall back on the default if everything else fails.
00066   return language_default();
00067 }
00068
00072 function language_from_browser() {
00073   // Specified by the user via the browser's Accept Language setting
00074   // Samples: "hu, en-us;q=0.66, en;q=0.33", "hu,en-us;q=0.5"
00075   $browser_langs = array();
00076
00077   if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
00078     $browser_accept = explode(",", $_SERVER['HTTP_ACCEPT_LANGUAGE']);
00079     for ($i = 0; $i < count($browser_accept); $i++) {
00080       // The language part is either a code or a code with a quality.
00081       // We cannot do anything with a * code, so it is skipped.
00082       // If the quality is missing, it is assumed to be 1 according to the RFC.
00083       if (preg_match("!([a-z-]+)(;q=([0-9\\.]+))?!", trim($browser_accept[$i]), $found)) {
00084         $browser_langs[$found[1]] = (isset($found[3]) ? (float) $found[3] : 1.0);
00085       }
00086     }
00087   }
00088
00089   // Order the codes by quality
00090   arsort($browser_langs);
00091
00092   // Try to find the first preferred language we have
00093   $languages = language_list('enabled');
00094   foreach ($browser_langs as $langcode => $q) {
00095     if (isset($languages['1'][$langcode])) {
00096       return $languages['1'][$langcode];
00097     }
00098   }
00099 }
00100
00105 function language_url_rewrite(&$path, &$options) {
00106   global $language;
00107
00108   // Only modify relative (insite) URLs.
00109   if (!$options['external']) {
00110
00111     // Language can be passed as an option, or we go for current language.
00112     if (!isset($options['language'])) {
00113       $options['language'] = $language;
00114     }
00115
00116     switch (variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE)) {
00117       case LANGUAGE_NEGOTIATION_NONE:
00118         // No language dependent path allowed in this mode.
00119         unset($options['language']);
00120         break;
00121
00122       case LANGUAGE_NEGOTIATION_DOMAIN:
00123         if ($options['language']->domain) {
00124           // Ask for an absolute URL with our modified base_url.
00125           $options['absolute'] = TRUE;
00126           $options['base_url'] = $options['language']->domain;
00127         }
00128         break;
00129
00130       case LANGUAGE_NEGOTIATION_PATH_DEFAULT:
00131         $default = language_default();
00132         if ($options['language']->language == $default->language) {
00133           break;
00134         }
00135         // Intentionally no break here.
00136
00137       case LANGUAGE_NEGOTIATION_PATH:
00138         if (!empty($options['language']->prefix)) {
00139           $options['prefix'] = $options['language']->prefix .'/';
00140         }
00141         break;
00142     }
00143   }
00144 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/locale.inc Source File

includes

locale.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: locale.inc,v 1.174 2008/01/09 21:36:13 goba Exp $
00003
00009 define('LOCALE_JS_STRING', '(?:(?:\'(?:\\\\\'|[^\'])*\'|"(?:\\\\"|[^"])*")(?:\s*\+\s*)?)+');
00010
00015 define('LOCALE_IMPORT_OVERWRITE', 0);
00016
00021 define('LOCALE_IMPORT_KEEP', 1);
00022
00031 function locale_languages_overview_form() {
00032   $languages = language_list('language', TRUE);
00033
00034   $options = array();
00035   $form['weight'] = array('#tree' => TRUE);
00036   foreach ($languages as $langcode => $language) {
00037
00038     $options[$langcode] = '';
00039     if ($language->enabled) {
00040       $enabled[] = $langcode;
00041     }
00042     $form['weight'][$langcode] = array(
00043       '#type' => 'weight',
00044       '#default_value' => $language->weight
00045     );
00046     $form['name'][$langcode] = array('#value' => check_plain($language->name));
00047     $form['native'][$langcode] = array('#value' => check_plain($language->native));
00048     $form['direction'][$langcode] = array('#value' => ($language->direction == LANGUAGE_RTL ? t('Right to left') : t('Left to right')));
00049   }
00050   $form['enabled'] = array('#type' => 'checkboxes',
00051     '#options' => $options,
00052     '#default_value' => $enabled,
00053   );
00054   $form['site_default'] = array('#type' => 'radios',
00055     '#options' => $options,
00056     '#default_value' => language_default('language'),
00057   );
00058   $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
00059   $form['#theme'] = 'locale_languages_overview_form';
00060
00061   return $form;
00062 }
00063
00069 function theme_locale_languages_overview_form($form) {
00070   $default = language_default();
00071   foreach ($form['name'] as $key => $element) {
00072     // Do not take form control structures.
00073     if (is_array($element) && element_child($key)) {
00074       // Disable checkbox for the default language, because it cannot be disabled.
00075       if ($key == $default->language) {
00076         $form['enabled'][$key]['#attributes']['disabled'] = 'disabled';
00077       }
00078       $rows[] = array(
00079         array('data' => drupal_render($form['enabled'][$key]), 'align' => 'center'),
00080         check_plain($key),
00081         '<strong>'. drupal_render($form['name'][$key]) .'</strong>',
00082         drupal_render($form['native'][$key]),
00083         drupal_render($form['direction'][$key]),
00084         drupal_render($form['site_default'][$key]),
00085         drupal_render($form['weight'][$key]),
00086         l(t('edit'), 'admin/settings/language/edit/'. $key) . (($key != 'en' && $key != $default->language) ? ' '. l(t('delete'), 'admin/settings/language/delete/'. $key) : '')
00087       );
00088     }
00089   }
00090   $header = array(array('data' => t('Enabled')), array('data' => t('Code')), array('data' => t('English name')), array('data' => t('Native name')), array('data' => t('Direction')), array('data' => t('Default')), array('data' => t('Weight')), array('data' => t('Operations')));
00091   $output = theme('table', $header, $rows);
00092   $output .= drupal_render($form);
00093
00094   return $output;
00095 }
00096
00100 function locale_languages_overview_form_submit($form, &$form_state) {
00101   $languages = language_list();
00102   $default = language_default();
00103   $enabled_count = 0;
00104   foreach ($languages as $langcode => $language) {
00105     if ($form_state['values']['site_default'] == $langcode || $default->language == $langcode) {
00106       // Automatically enable the default language and the language
00107       // which was default previously (because we will not get the
00108       // value from that disabled checkox).
00109       $form_state['values']['enabled'][$langcode] = 1;
00110     }
00111     if ($form_state['values']['enabled'][$langcode]) {
00112       $enabled_count++;
00113       $language->enabled = 1;
00114     }
00115     else {
00116       $language->enabled = 0;
00117     }
00118     $language->weight = $form_state['values']['weight'][$langcode];
00119     db_query("UPDATE {languages} SET enabled = %d, weight = %d WHERE language = '%s'", $language->enabled, $language->weight, $langcode);
00120     $languages[$langcode] = $language;
00121   }
00122   drupal_set_message(t('Configuration saved.'));
00123   variable_set('language_default', $languages[$form_state['values']['site_default']]);
00124   variable_set('language_count', $enabled_count);
00125
00126   // Changing the language settings impacts the interface.
00127   cache_clear_all('*', 'cache_page', TRUE);
00128
00129   $form_state['redirect'] = 'admin/settings/language';
00130   return;
00131 }
00144 function locale_languages_add_screen() {
00145   $output = drupal_get_form('locale_languages_predefined_form');
00146   $output .= drupal_get_form('locale_languages_custom_form');
00147   return $output;
00148 }
00149
00153 function locale_languages_predefined_form() {
00154   $predefined = _locale_prepare_predefined_list();
00155   $form = array();
00156   $form['language list'] = array('#type' => 'fieldset',
00157     '#title' => t('Predefined language'),
00158     '#collapsible' => TRUE,
00159   );
00160   $form['language list']['langcode'] = array('#type' => 'select',
00161     '#title' => t('Language name'),
00162     '#default_value' => key($predefined),
00163     '#options' => $predefined,
00164     '#description' => t('Select the desired language and click the <em>Add language</em> button. (Use the <em>Custom language</em> options if your desired language does not appear in this list.)'),
00165   );
00166   $form['language list']['submit'] = array('#type' => 'submit', '#value' => t('Add language'));
00167   return $form;
00168 }
00169
00173 function locale_languages_custom_form() {
00174   $form = array();
00175   $form['custom language'] = array('#type' => 'fieldset',
00176     '#title' => t('Custom language'),
00177     '#collapsible' => TRUE,
00178     '#collapsed' => TRUE,
00179   );
00180   _locale_languages_common_controls($form['custom language']);
00181   $form['custom language']['submit'] = array(
00182     '#type' => 'submit',
00183     '#value' => t('Add custom language')
00184   );
00185   // Reuse the validation and submit functions of the predefined language setup form.
00186   $form['#submit'][] = 'locale_languages_predefined_form_submit';
00187   $form['#validate'][] = 'locale_languages_predefined_form_validate';
00188   return $form;
00189 }
00190
00197 function locale_languages_edit_form(&$form_state, $langcode) {
00198   if ($language = db_fetch_object(db_query("SELECT * FROM {languages} WHERE language = '%s'", $langcode))) {
00199     $form = array();
00200     _locale_languages_common_controls($form, $language);
00201     $form['submit'] = array(
00202       '#type' => 'submit',
00203       '#value' => t('Save language')
00204     );
00205     $form['#submit'][] = 'locale_languages_edit_form_submit';
00206     $form['#validate'][] = 'locale_languages_edit_form_validate';
00207     return $form;
00208   }
00209   else {
00210     drupal_not_found();
00211   }
00212 }
00213
00222 function _locale_languages_common_controls(&$form, $language = NULL) {
00223   if (!is_object($language)) {
00224     $language = new stdClass();
00225   }
00226   if (isset($language->language)) {
00227     $form['langcode_view'] = array(
00228       '#type' => 'item',
00229       '#title' => t('Language code'),
00230       '#value' => $language->language
00231     );
00232     $form['langcode'] = array(
00233       '#type' => 'value',
00234       '#value' => $language->language
00235     );
00236   }
00237   else {
00238     $form['langcode'] = array('#type' => 'textfield',
00239       '#title' => t('Language code'),
00240       '#size' => 12,
00241       '#maxlength' => 60,
00242       '#required' => TRUE,
00243       '#default_value' => @$language->language,
00244       '#disabled' => (isset($language->language)),
00245       '#description' => t('<a href="@rfc4646">RFC 4646</a> compliant language identifier. Language codes typically use a country code, and optionally, a script or regional variant name. <em>Examples: "en", "en-US" and "zh-Hant".</em>', array('@rfc4646' => 'http://www.ietf.org/rfc/rfc4646.txt')),
00246     );
00247   }
00248   $form['name'] = array('#type' => 'textfield',
00249     '#title' => t('Language name in English'),
00250     '#maxlength' => 64,
00251     '#default_value' => @$language->name,
00252     '#required' => TRUE,
00253     '#description' => t('Name of the language in English. Will be available for translation in all languages.'),
00254   );
00255   $form['native'] = array('#type' => 'textfield',
00256     '#title' => t('Native language name'),
00257     '#maxlength' => 64,
00258     '#default_value' => @$language->native,
00259     '#required' => TRUE,
00260     '#description' => t('Name of the language in the language being added.'),
00261   );
00262   $form['prefix'] = array('#type' => 'textfield',
00263     '#title' => t('Path prefix'),
00264     '#maxlength' => 64,
00265     '#default_value' => @$language->prefix,
00266     '#description' => t('Language code or other custom string for pattern matching within the path. With language negotiation set to <em>Path prefix only</em> or <em>Path prefix with language fallback</em>, this site is presented in this language when the Path prefix value matches an element in the path. For the default language, this value may be left blank. <strong>Modifying this value will break existing URLs and should be used with caution in a production environment.</strong> <em>Example: Specifying "deutsch" as the path prefix for German results in URLs in the form "www.example.com/deutsch/node".</em>')
00267   );
00268   $form['domain'] = array('#type' => 'textfield',
00269     '#title' => t('Language domain'),
00270     '#maxlength' => 64,
00271     '#default_value' => @$language->domain,
00272     '#description' => t('Language-specific URL, with protocol. With language negotiation set to <em>Domain name only</em>, the site is presented in this language when the URL accessing the site references this domain. For the default language, this value may be left blank. <strong>This value must include a protocol as part of the string.</strong> <em>Example: Specifying "http://example.de" or "http://de.example.com" as language domains for German results in URLs in the forms "http://example.de/node" and "http://de.example.com/node", respectively.</em>'),
00273   );
00274   $form['direction'] = array('#type' => 'radios',
00275     '#title' => t('Direction'),
00276     '#required' => TRUE,
00277     '#description' => t('Direction that text in this language is presented.'),
00278     '#default_value' => @$language->direction,
00279     '#options' => array(LANGUAGE_LTR => t('Left to right'), LANGUAGE_RTL => t('Right to left'))
00280   );
00281   return $form;
00282 }
00283
00287 function locale_languages_predefined_form_validate($form, &$form_state) {
00288   $langcode = $form_state['values']['langcode'];
00289
00290   if ($duplicate = db_result(db_query("SELECT COUNT(*) FROM {languages} WHERE language = '%s'", $langcode)) != 0) {
00291     form_set_error('langcode', t('The language %language (%code) already exists.', array('%language' => $form_state['values']['name'], '%code' => $langcode)));
00292   }
00293
00294   if (!isset($form_state['values']['name'])) {
00295     // Predefined language selection.
00296     $predefined = _locale_get_predefined_list();
00297     if (!isset($predefined[$langcode])) {
00298       form_set_error('langcode', t('Invalid language code.'));
00299     }
00300   }
00301   else {
00302     // Reuse the editing form validation routine if we add a custom language.
00303     locale_languages_edit_form_validate($form, $form_state);
00304   }
00305 }
00306
00310 function locale_languages_predefined_form_submit($form, &$form_state) {
00311   $langcode = $form_state['values']['langcode'];
00312   if (isset($form_state['values']['name'])) {
00313     // Custom language form.
00314     locale_add_language($langcode, $form_state['values']['name'], $form_state['values']['native'], $form_state['values']['direction'], $form_state['values']['domain'], $form_state['values']['prefix']);
00315     drupal_set_message(t('The language %language has been created and can now be used. More information is available on the <a href="@locale-help">help screen</a>.', array('%language' => t($form_state['values']['name']), '@locale-help' => url('admin/help/locale'))));
00316   }
00317   else {
00318     // Predefined language selection.
00319     $predefined = _locale_get_predefined_list();
00320     locale_add_language($langcode);
00321     drupal_set_message(t('The language %language has been created and can now be used. More information is available on the <a href="@locale-help">help screen</a>.', array('%language' => t($predefined[$langcode][0]), '@locale-help' => url('admin/help/locale'))));
00322   }
00323
00324   // See if we have language files to import for the newly added
00325   // language, collect and import them.
00326   if ($batch = locale_batch_by_language($langcode, '_locale_batch_language_finished')) {
00327     batch_set($batch);
00328   }
00329
00330   $form_state['redirect'] = 'admin/settings/language';
00331   return;
00332 }
00333
00337 function locale_languages_edit_form_validate($form, &$form_state) {
00338   if (!empty($form_state['values']['domain']) && !empty($form_state['values']['prefix'])) {
00339     form_set_error('prefix', t('Domain and path prefix values should not be set at the same time.'));
00340   }
00341   if (!empty($form_state['values']['domain']) && $duplicate = db_fetch_object(db_query("SELECT language FROM {languages} WHERE domain = '%s' AND language != '%s'", $form_state['values']['domain'], $form_state['values']['langcode']))) {
00342     form_set_error('domain', t('The domain (%domain) is already tied to a language (%language).', array('%domain' => $form_state['values']['domain'], '%language' => $duplicate->language)));
00343   }
00344   if (empty($form_state['values']['prefix']) && language_default('language') != $form_state['values']['langcode'] && empty($form_state['values']['domain'])) {
00345     form_set_error('prefix', t('Only the default language can have both the domain and prefix empty.'));
00346   }
00347   if (!empty($form_state['values']['prefix']) && $duplicate = db_fetch_object(db_query("SELECT language FROM {languages} WHERE prefix = '%s' AND language != '%s'", $form_state['values']['prefix'], $form_state['values']['langcode']))) {
00348     form_set_error('prefix', t('The prefix (%prefix) is already tied to a language (%language).', array('%prefix' => $form_state['values']['prefix'], '%language' => $duplicate->language)));
00349   }
00350 }
00351
00355 function locale_languages_edit_form_submit($form, &$form_state) {
00356   db_query("UPDATE {languages} SET name = '%s', native = '%s', domain = '%s', prefix = '%s', direction = %d WHERE language = '%s'", $form_state['values']['name'], $form_state['values']['native'], $form_state['values']['domain'], $form_state['values']['prefix'], $form_state['values']['direction'], $form_state['values']['langcode']);
00357   $default = language_default();
00358   if ($default->language == $form_state['values']['langcode']) {
00359     $properties = array('name', 'native', 'direction', 'enabled', 'plurals', 'formula', 'domain', 'prefix', 'weight');
00360     foreach ($properties as $keyname) {
00361       if (isset($form_state['values'][$keyname])) {
00362         $default->$keyname = $form_state['values'][$keyname];
00363       }
00364     }
00365     variable_set('language_default', $default);
00366   }
00367   $form_state['redirect'] = 'admin/settings/language';
00368   return;
00369 }
00382 function locale_languages_delete_form(&$form_state, $langcode) {
00383
00384   // Do not allow deletion of English locale.
00385   if ($langcode == 'en') {
00386     drupal_set_message(t('The English language cannot be deleted.'));
00387     drupal_goto('admin/settings/language');
00388   }
00389
00390   if (language_default('language') == $langcode) {
00391     drupal_set_message(t('The default language cannot be deleted.'));
00392     drupal_goto('admin/settings/language');
00393   }
00394
00395   // For other languages, warn user that data loss is ahead.
00396   $languages = language_list();
00397
00398   if (!isset($languages[$langcode])) {
00399     drupal_not_found();
00400   }
00401   else {
00402     $form['langcode'] = array('#type' => 'value', '#value' => $langcode);
00403     return confirm_form($form, t('Are you sure you want to delete the language %name?', array('%name' => t($languages[$langcode]->name))), 'admin/settings/language', t('Deleting a language will remove all interface translations associated with it, and posts in this language will be set to be language neutral. This action cannot be undone.'), t('Delete'), t('Cancel'));
00404   }
00405 }
00406
00410 function locale_languages_delete_form_submit($form, &$form_state) {
00411   $languages = language_list();
00412   if (isset($languages[$form_state['values']['langcode']])) {
00413     // Remove translations first.
00414     db_query("DELETE FROM {locales_target} WHERE language = '%s'", $form_state['values']['langcode']);
00415     cache_clear_all('locale:'. $form_state['values']['langcode'], 'cache');
00416     // With no translations, this removes existing JavaScript translations file.
00417     _locale_rebuild_js($form_state['values']['langcode']);
00418     // Remove the language.
00419     db_query("DELETE FROM {languages} WHERE language = '%s'", $form_state['values']['langcode']);
00420     db_query("UPDATE {node} SET language = '' WHERE language = '%s'", $form_state['values']['langcode']);
00421     $variables = array('%locale' => $languages[$form_state['values']['langcode']]->name);
00422     drupal_set_message(t('The language %locale has been removed.', $variables));
00423     watchdog('locale', 'The language %locale has been removed.', $variables);
00424   }
00425
00426   // Changing the language settings impacts the interface:
00427   cache_clear_all('*', 'cache_page', TRUE);
00428
00429   $form_state['redirect'] = 'admin/settings/language';
00430   return;
00431 }
00444 function locale_languages_configure_form() {
00445   $form['language_negotiation'] = array(
00446     '#title' => t('Language negotiation'),
00447     '#type' => 'radios',
00448     '#options' => array(
00449       LANGUAGE_NEGOTIATION_NONE => t('None.'),
00450       LANGUAGE_NEGOTIATION_PATH_DEFAULT => t('Path prefix only.'),
00451       LANGUAGE_NEGOTIATION_PATH => t('Path prefix with language fallback.'),
00452       LANGUAGE_NEGOTIATION_DOMAIN => t('Domain name only.')),
00453     '#default_value' => variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE),
00454     '#description' => t("Select the mechanism used to determine your site's presentation language. <strong>Modifying this setting may break all incoming URLs and should be used with caution in a production environment.</strong>")
00455   );
00456   $form['submit'] = array(
00457     '#type' => 'submit',
00458     '#value' => t('Save settings')
00459   );
00460   return $form;
00461 }
00462
00466 function locale_languages_configure_form_submit($form, &$form_state) {
00467   variable_set('language_negotiation', $form_state['values']['language_negotiation']);
00468   drupal_set_message(t('Language negotiation configuration saved.'));
00469   $form_state['redirect'] = 'admin/settings/language';
00470   return;
00471 }
00484 function locale_translate_overview_screen() {
00485   $languages = language_list('language', TRUE);
00486   $groups = module_invoke_all('locale', 'groups');
00487
00488   // Build headers with all groups in order.
00489   $headers = array_merge(array(t('Language')), array_values($groups));
00490
00491   // Collect summaries of all source strings in all groups.
00492   $sums = db_query("SELECT COUNT(*) AS strings, textgroup FROM {locales_source} GROUP BY textgroup");
00493   $groupsums = array();
00494   while ($group = db_fetch_object($sums)) {
00495     $groupsums[$group->textgroup] = $group->strings;
00496   }
00497
00498   // Set up overview table with default values, ensuring common order for values.
00499   $rows = array();
00500   foreach ($languages as $langcode => $language) {
00501     $rows[$langcode] = array('name' => ($langcode == 'en' ? t('English (built-in)') : t($language->name)));
00502     foreach ($groups as $group => $name) {
00503       $rows[$langcode][$group] = ($langcode == 'en' ? t('n/a') : '0/'. (isset($groupsums[$group]) ? $groupsums[$group] : 0) .' (0%)');
00504     }
00505   }
00506
00507   // Languages with at least one record in the locale table.
00508   $translations = db_query("SELECT COUNT(*) AS translation, t.language, s.textgroup FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid GROUP BY textgroup, language");
00509   while ($data = db_fetch_object($translations)) {
00510     $ratio = (!empty($groupsums[$data->textgroup]) && $data->translation > 0) ? round(($data->translation/$groupsums[$data->textgroup])*100., 2) : 0;
00511     $rows[$data->language][$data->textgroup] = $data->translation .'/'. $groupsums[$data->textgroup] ." ($ratio%)";
00512   }
00513
00514   return theme('table', $headers, $rows);
00515 }
00528 function locale_translate_seek_screen() {
00529   $output = _locale_translate_seek();
00530   $output .= drupal_get_form('locale_translate_seek_form');
00531   return $output;
00532 }
00533
00537 function locale_translate_seek_form() {
00538   // Get all languages, except English
00539   $languages = locale_language_list('name', TRUE);
00540   unset($languages['en']);
00541
00542   // Present edit form preserving previous user settings
00543   $query = _locale_translate_seek_query();
00544   $form = array();
00545   $form['search'] = array('#type' => 'fieldset',
00546     '#title' => t('Search'),
00547   );
00548   $form['search']['string'] = array('#type' => 'textfield',
00549     '#title' => t('String contains'),
00550     '#default_value' => @$query['string'],
00551     '#description' => t('Leave blank to show all strings. The search is case sensitive.'),
00552   );
00553   $form['search']['language'] = array(
00554     // Change type of form widget if more the 5 options will
00555     // be present (2 of the options are added below).
00556     '#type' => (count($languages) <= 3 ? 'radios' : 'select'),
00557     '#title' => t('Language'),
00558     '#default_value' => (!empty($query['language']) ? $query['language'] : 'all'),
00559     '#options' => array_merge(array('all' => t('All languages'), 'en' => t('English (provided by Drupal)')), $languages),
00560   );
00561   $form['search']['translation'] = array('#type' => 'radios',
00562     '#title' => t('Search in'),
00563     '#default_value' => (!empty($query['translation']) ? $query['translation'] : 'all'),
00564     '#options' => array('all' => t('Both translated and untranslated strings'), 'translated' => t('Only translated strings'), 'untranslated' => t('Only untranslated strings')),
00565   );
00566   $groups = module_invoke_all('locale', 'groups');
00567   $form['search']['group'] = array('#type' => 'radios',
00568     '#title' => t('Limit search to'),
00569     '#default_value' => (!empty($query['group']) ? $query['group'] : 'all'),
00570     '#options' => array_merge(array('all' => t('All text groups')), $groups),
00571   );
00572
00573   $form['search']['submit'] = array('#type' => 'submit', '#value' => t('Search'));
00574   $form['#redirect'] = FALSE;
00575
00576   return $form;
00577 }
00590 function locale_translate_import_form() {
00591   // Get all languages, except English
00592   $names = locale_language_list('name', TRUE);
00593   unset($names['en']);
00594
00595   if (!count($names)) {
00596     $languages = _locale_prepare_predefined_list();
00597     $default = array_shift(array_keys($languages));
00598   }
00599   else {
00600     $languages = array(
00601       t('Already added languages') => $names,
00602       t('Languages not yet added') => _locale_prepare_predefined_list()
00603     );
00604     $default = array_shift(array_keys($names));
00605   }
00606
00607   $form = array();
00608   $form['import'] = array('#type' => 'fieldset',
00609     '#title' => t('Import translation'),
00610   );
00611   $form['import']['file'] = array('#type' => 'file',
00612     '#title' => t('Language file'),
00613     '#size' => 50,
00614     '#description' => t('A Gettext Portable Object (<em>.po</em>) file.'),
00615   );
00616   $form['import']['langcode'] = array('#type' => 'select',
00617     '#title' => t('Import into'),
00618     '#options' => $languages,
00619     '#default_value' => $default,
00620     '#description' => t('Choose the language you want to add strings into. If you choose a language which is not yet set up, it will be added.'),
00621   );
00622   $form['import']['group'] = array('#type' => 'radios',
00623     '#title' => t('Text group'),
00624     '#default_value' => 'default',
00625     '#options' => module_invoke_all('locale', 'groups'),
00626     '#description' => t('Imported translations will be added to this text group.'),
00627   );
00628   $form['import']['mode'] = array('#type' => 'radios',
00629     '#title' => t('Mode'),
00630     '#default_value' => LOCALE_IMPORT_KEEP,
00631     '#options' => array(
00632       LOCALE_IMPORT_OVERWRITE => t('Strings in the uploaded file replace existing ones, new ones are added'),
00633       LOCALE_IMPORT_KEEP => t('Existing strings are kept, only new strings are added')
00634     ),
00635   );
00636   $form['import']['submit'] = array('#type' => 'submit', '#value' => t('Import'));
00637   $form['#attributes']['enctype'] = 'multipart/form-data';
00638
00639   return $form;
00640 }
00641
00645 function locale_translate_import_form_submit($form, &$form_state) {
00646   // Ensure we have the file uploaded
00647   if ($file = file_save_upload('file')) {
00648
00649     // Add language, if not yet supported
00650     $languages = language_list('language', TRUE);
00651     $langcode = $form_state['values']['langcode'];
00652     if (!isset($languages[$langcode])) {
00653       $predefined = _locale_get_predefined_list();
00654       locale_add_language($langcode);
00655       drupal_set_message(t('The language %language has been created.', array('%language' => t($predefined[$langcode][0]))));
00656     }
00657
00658     // Now import strings into the language
00659     if ($ret = _locale_import_po($file, $langcode, $form_state['values']['mode'], $form_state['values']['group']) == FALSE) {
00660       $variables = array('%filename' => $file->filename);
00661       drupal_set_message(t('The translation import of %filename failed.', $variables), 'error');
00662       watchdog('locale', 'The translation import of %filename failed.', $variables, WATCHDOG_ERROR);
00663     }
00664   }
00665   else {
00666     drupal_set_message(t('File to import not found.'), 'error');
00667     return 'admin/build/translate/import';
00668   }
00669
00670   $form_state['redirect'] = 'admin/build/translate';
00671   return;
00672 }
00685 function locale_translate_export_screen() {
00686   // Get all languages, except English
00687   $names = locale_language_list('name', TRUE);
00688   unset($names['en']);
00689   $output = '';
00690   // Offer translation export if any language is set up.
00691   if (count($names)) {
00692     $output = drupal_get_form('locale_translate_export_po_form', $names);
00693   }
00694   $output .= drupal_get_form('locale_translate_export_pot_form');
00695   return $output;
00696 }
00697
00704 function locale_translate_export_po_form(&$form_state, $names) {
00705   $form['export'] = array('#type' => 'fieldset',
00706     '#title' => t('Export translation'),
00707     '#collapsible' => TRUE,
00708   );
00709   $form['export']['langcode'] = array('#type' => 'select',
00710     '#title' => t('Language name'),
00711     '#options' => $names,
00712     '#description' => t('Select the language to export in Gettext Portable Object (<em>.po</em>) format.'),
00713   );
00714   $form['export']['group'] = array('#type' => 'radios',
00715     '#title' => t('Text group'),
00716     '#default_value' => 'default',
00717     '#options' => module_invoke_all('locale', 'groups'),
00718   );
00719   $form['export']['submit'] = array('#type' => 'submit', '#value' => t('Export'));
00720   return $form;
00721 }
00722
00726 function locale_translate_export_pot_form() {
00727   // Complete template export of the strings
00728   $form['export'] = array('#type' => 'fieldset',
00729     '#title' => t('Export template'),
00730     '#collapsible' => TRUE,
00731     '#description' => t('Generate a Gettext Portable Object Template (<em>.pot</em>) file with all strings from the Drupal locale database.'),
00732   );
00733   $form['export']['group'] = array('#type' => 'radios',
00734     '#title' => t('Text group'),
00735     '#default_value' => 'default',
00736     '#options' => module_invoke_all('locale', 'groups'),
00737   );
00738   $form['export']['submit'] = array('#type' => 'submit', '#value' => t('Export'));
00739   // Reuse PO export submission callback.
00740   $form['#submit'][] = 'locale_translate_export_po_form_submit';
00741   $form['#validate'][] = 'locale_translate_export_po_form_validate';
00742   return $form;
00743 }
00744
00748 function locale_translate_export_po_form_submit($form, &$form_state) {
00749   // If template is required, language code is not given.
00750   $language = NULL;
00751   if (isset($form_state['values']['langcode'])) {
00752     $languages = language_list();
00753     $language = $languages[$form_state['values']['langcode']];
00754   }
00755   _locale_export_po($language, _locale_export_po_generate($language, _locale_export_get_strings($language, $form_state['values']['group'])));
00756 }
00769 function locale_translate_edit_form(&$form_state, $lid) {
00770   // Fetch source string, if possible.
00771   $source = db_fetch_object(db_query('SELECT source, textgroup, location FROM {locales_source} WHERE lid = %d', $lid));
00772   if (!$source) {
00773     drupal_set_message(t('String not found.'), 'error');
00774     drupal_goto('admin/build/translate/search');
00775   }
00776
00777   // Add original text to the top and some values for form altering.
00778   $form = array(
00779     'original' => array(
00780       '#type'  => 'item',
00781       '#title' => t('Original text'),
00782       '#value' => check_plain(wordwrap($source->source, 0)),
00783     ),
00784     'lid' => array(
00785       '#type'  => 'value',
00786       '#value' => $lid
00787     ),
00788     'textgroup' => array(
00789       '#type'  => 'value',
00790       '#value' => $source->textgroup,
00791     ),
00792     'location' => array(
00793       '#type'  => 'value',
00794       '#value' => $source->location
00795     ),
00796   );
00797
00798   // Include default form controls with empty values for all languages.
00799   // This ensures that the languages are always in the same order in forms.
00800   $languages = language_list();
00801   $default = language_default();
00802   // We don't need the default language value, that value is in $source.
00803   $omit = $source->textgroup == 'default' ? 'en' : $default->language;
00804   unset($languages[($omit)]);
00805   $form['translations'] = array('#tree' => TRUE);
00806   // Approximate the number of rows to use in the default textarea.
00807   $rows = min(ceil(str_word_count($source->source) / 12), 10);
00808   foreach ($languages as $langcode => $language) {
00809     $form['translations'][$langcode] = array(
00810       '#type' => 'textarea',
00811       '#title' => t($language->name),
00812       '#rows' => $rows,
00813       '#default_value' => '',
00814     );
00815   }
00816
00817   // Fetch translations and fill in default values in the form.
00818   $result = db_query("SELECT DISTINCT translation, language FROM {locales_target} WHERE lid = %d AND language != '%s'", $lid, $omit);
00819   while ($translation = db_fetch_object($result)) {
00820     $form['translations'][$translation->language]['#default_value'] = $translation->translation;
00821   }
00822
00823   $form['submit'] = array('#type' => 'submit', '#value' => t('Save translations'));
00824   return $form;
00825 }
00826
00831 function locale_translate_edit_form_submit($form, &$form_state) {
00832   $lid = $form_state['values']['lid'];
00833   foreach ($form_state['values']['translations'] as $key => $value) {
00834     $translation = db_result(db_query("SELECT translation FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $key));
00835     if (!empty($value)) {
00836       // Only update or insert if we have a value to use.
00837       if (!empty($translation)) {
00838         db_query("UPDATE {locales_target} SET translation = '%s' WHERE lid = %d AND language = '%s'", $value, $lid, $key);
00839       }
00840       else {
00841         db_query("INSERT INTO {locales_target} (lid, translation, language) VALUES (%d, '%s', '%s')", $lid, $value, $key);
00842       }
00843     }
00844     elseif (!empty($translation)) {
00845       // Empty translation entered: remove existing entry from database.
00846       db_query("DELETE FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $key);
00847     }
00848
00849     // Force JavaScript translation file recreation for this language.
00850     _locale_invalidate_js($key);
00851   }
00852
00853   drupal_set_message(t('The string has been saved.'));
00854
00855   // Clear locale cache.
00856   cache_clear_all('locale:', 'cache', TRUE);
00857
00858   $form_state['redirect'] = 'admin/build/translate/search';
00859   return;
00860 }
00873 function locale_translate_delete($lid) {
00874   db_query('DELETE FROM {locales_source} WHERE lid = %d', $lid);
00875   db_query('DELETE FROM {locales_target} WHERE lid = %d', $lid);
00876   // Force JavaScript translation file recreation for all languages.
00877   _locale_invalidate_js();
00878   cache_clear_all('locale:', 'cache', TRUE);
00879   drupal_set_message(t('The string has been removed.'));
00880   drupal_goto('admin/build/translate/search');
00881 }
00913 function locale_add_language($langcode, $name = NULL, $native = NULL, $direction = LANGUAGE_LTR, $domain = '', $prefix = '', $enabled = TRUE, $default = FALSE) {
00914   // Default prefix on language code.
00915   if (empty($prefix)) {
00916     $prefix = $langcode;
00917   }
00918
00919   // If name was not set, we add a predefined language.
00920   if (!isset($name)) {
00921     $predefined = _locale_get_predefined_list();
00922     $name = $predefined[$langcode][0];
00923     $native = isset($predefined[$langcode][1]) ? $predefined[$langcode][1] : $predefined[$langcode][0];
00924     $direction = isset($predefined[$langcode][2]) ? $predefined[$langcode][2] : LANGUAGE_LTR;
00925   }
00926
00927   db_query("INSERT INTO {languages} (language, name, native, direction, domain, prefix, enabled) VALUES ('%s', '%s', '%s', %d, '%s', '%s', %d)", $langcode, $name, $native, $direction, $domain, $prefix, $enabled);
00928
00929   // Only set it as default if enabled.
00930   if ($enabled && $default) {
00931     variable_set('language_default', (object) array('language' => $langcode, 'name' => $name, 'native' => $native, 'direction' => $direction, 'enabled' => (int) $enabled, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => $prefix, 'weight' => 0, 'javascript' => ''));
00932   }
00933
00934   if ($enabled) {
00935     // Increment enabled language count if we are adding an enabled language.
00936     variable_set('language_count', variable_get('language_count', 1) + 1);
00937   }
00938
00939   // Force JavaScript translation file creation for the newly added language.
00940   _locale_invalidate_js($langcode);
00941
00942   watchdog('locale', 'The %language language (%code) has been created.', array('%language' => $name, '%code' => $langcode));
00943 }
00965 function _locale_import_po($file, $langcode, $mode, $group = NULL) {
00966   // If not in 'safe mode', increase the maximum execution time.
00967   if (!ini_get('safe_mode')) {
00968     set_time_limit(240);
00969   }
00970
00971   // Check if we have the language already in the database.
00972   if (!db_fetch_object(db_query("SELECT language FROM {languages} WHERE language = '%s'", $langcode))) {
00973     drupal_set_message(t('The language selected for import is not supported.'), 'error');
00974     return FALSE;
00975   }
00976
00977   // Get strings from file (returns on failure after a partial import, or on success)
00978   $status = _locale_import_read_po('db-store', $file, $mode, $langcode, $group);
00979   if ($status === FALSE) {
00980     // Error messages are set in _locale_import_read_po().
00981     return FALSE;
00982   }
00983
00984   // Get status information on import process.
00985   list($headerdone, $additions, $updates, $deletes) = _locale_import_one_string('db-report');
00986
00987   if (!$headerdone) {
00988     drupal_set_message(t('The translation file %filename appears to have a missing or malformed header.', array('%filename' => $file->filename)), 'error');
00989   }
00990
00991   // Clear cache and force refresh of JavaScript translations.
00992   _locale_invalidate_js($langcode);
00993   cache_clear_all('locale:', 'cache', TRUE);
00994
00995   // Rebuild the menu, strings may have changed.
00996   menu_rebuild();
00997
00998   drupal_set_message(t('The translation was successfully imported. There are %number newly created translated strings, %update strings were updated and %delete strings were removed.', array('%number' => $additions, '%update' => $updates, '%delete' => $deletes)));
00999   watchdog('locale', 'Imported %file into %locale: %number new strings added, %update updated and %delete removed.', array('%file' => $file->filename, '%locale' => $langcode, '%number' => $additions, '%update' => $updates, '%delete' => $deletes));
01000   return TRUE;
01001 }
01002
01017 function _locale_import_read_po($op, $file, $mode = NULL, $lang = NULL, $group = 'default') {
01018
01019   $fd = fopen($file->filepath, "rb"); // File will get closed by PHP on return
01020   if (!$fd) {
01021     _locale_import_message('The translation import failed, because the file %filename could not be read.', $file);
01022     return FALSE;
01023   }
01024
01025   $context = "COMMENT"; // Parser context: COMMENT, MSGID, MSGID_PLURAL, MSGSTR and MSGSTR_ARR
01026   $current = array();   // Current entry being read
01027   $plural = 0;          // Current plural form
01028   $lineno = 0;          // Current line
01029
01030   while (!feof($fd)) {
01031     $line = fgets($fd, 10*1024); // A line should not be this long
01032     if ($lineno == 0) {
01033       // The first line might come with a UTF-8 BOM, which should be removed.
01034       $line = str_replace("\xEF\xBB\xBF", '', $line);
01035     }
01036     $lineno++;
01037     $line = trim(strtr($line, array("\\\n" => "")));
01038
01039     if (!strncmp("#", $line, 1)) { // A comment
01040       if ($context == "COMMENT") { // Already in comment context: add
01041         $current["#"][] = substr($line, 1);
01042       }
01043       elseif (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) { // End current entry, start a new one
01044         _locale_import_one_string($op, $current, $mode, $lang, $file, $group);
01045         $current = array();
01046         $current["#"][] = substr($line, 1);
01047         $context = "COMMENT";
01048       }
01049       else { // Parse error
01050         _locale_import_message('The translation file %filename contains an error: "msgstr" was expected but not found on line %line.', $file, $lineno);
01051         return FALSE;
01052       }
01053     }
01054     elseif (!strncmp("msgid_plural", $line, 12)) {
01055       if ($context != "MSGID") { // Must be plural form for current entry
01056         _locale_import_message('The translation file %filename contains an error: "msgid_plural" was expected but not found on line %line.', $file, $lineno);
01057         return FALSE;
01058       }
01059       $line = trim(substr($line, 12));
01060       $quoted = _locale_import_parse_quoted($line);
01061       if ($quoted === FALSE) {
01062         _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno);
01063         return FALSE;
01064       }
01065       $current["msgid"] = $current["msgid"] ."\0". $quoted;
01066       $context = "MSGID_PLURAL";
01067     }
01068     elseif (!strncmp("msgid", $line, 5)) {
01069       if ($context == "MSGSTR") {   // End current entry, start a new one
01070         _locale_import_one_string($op, $current, $mode, $lang, $file, $group);
01071         $current = array();
01072       }
01073       elseif ($context == "MSGID") { // Already in this context? Parse error
01074         _locale_import_message('The translation file %filename contains an error: "msgid" is unexpected on line %line.', $file, $lineno);
01075         return FALSE;
01076       }
01077       $line = trim(substr($line, 5));
01078       $quoted = _locale_import_parse_quoted($line);
01079       if ($quoted === FALSE) {
01080         _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno);
01081         return FALSE;
01082       }
01083       $current["msgid"] = $quoted;
01084       $context = "MSGID";
01085     }
01086     elseif (!strncmp("msgstr[", $line, 7)) {
01087       if (($context != "MSGID") && ($context != "MSGID_PLURAL") && ($context != "MSGSTR_ARR")) { // Must come after msgid, msgid_plural, or msgstr[]
01088         _locale_import_message('The translation file %filename contains an error: "msgstr[]" is unexpected on line %line.', $file, $lineno);
01089         return FALSE;
01090       }
01091       if (strpos($line, "]") === FALSE) {
01092         _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno);
01093         return FALSE;
01094       }
01095       $frombracket = strstr($line, "[");
01096       $plural = substr($frombracket, 1, strpos($frombracket, "]") - 1);
01097       $line = trim(strstr($line, " "));
01098       $quoted = _locale_import_parse_quoted($line);
01099       if ($quoted === FALSE) {
01100         _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno);
01101         return FALSE;
01102       }
01103       $current["msgstr"][$plural] = $quoted;
01104       $context = "MSGSTR_ARR";
01105     }
01106     elseif (!strncmp("msgstr", $line, 6)) {
01107       if ($context != "MSGID") {   // Should come just after a msgid block
01108         _locale_import_message('The translation file %filename contains an error: "msgstr" is unexpected on line %line.', $file, $lineno);
01109         return FALSE;
01110       }
01111       $line = trim(substr($line, 6));
01112       $quoted = _locale_import_parse_quoted($line);
01113       if ($quoted === FALSE) {
01114         _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno);
01115         return FALSE;
01116       }
01117       $current["msgstr"] = $quoted;
01118       $context = "MSGSTR";
01119     }
01120     elseif ($line != "") {
01121       $quoted = _locale_import_parse_quoted($line);
01122       if ($quoted === FALSE) {
01123         _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno);
01124         return FALSE;
01125       }
01126       if (($context == "MSGID") || ($context == "MSGID_PLURAL")) {
01127         $current["msgid"] .= $quoted;
01128       }
01129       elseif ($context == "MSGSTR") {
01130         $current["msgstr"] .= $quoted;
01131       }
01132       elseif ($context == "MSGSTR_ARR") {
01133         $current["msgstr"][$plural] .= $quoted;
01134       }
01135       else {
01136         _locale_import_message('The translation file %filename contains an error: there is an unexpected string on line %line.', $file, $lineno);
01137         return FALSE;
01138       }
01139     }
01140   }
01141
01142   // End of PO file, flush last entry
01143   if (($context == "MSGSTR") || ($context == "MSGSTR_ARR")) {
01144     _locale_import_one_string($op, $current, $mode, $lang, $file, $group);
01145   }
01146   elseif ($context != "COMMENT") {
01147     _locale_import_message('The translation file %filename ended unexpectedly at line %line.', $file, $lineno);
01148     return FALSE;
01149   }
01150
01151 }
01152
01163 function _locale_import_message($message, $file, $lineno = NULL) {
01164   $vars = array('%filename' => $file->filename);
01165   if (isset($lineno)) {
01166     $vars['%line'] = $lineno;
01167   }
01168   $t = get_t();
01169   drupal_set_message($t($message, $vars), 'error');
01170 }
01171
01188 function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NULL, $file = NULL, $group = 'default') {
01189   static $report = array(0, 0, 0);
01190   static $headerdone = FALSE;
01191   static $strings = array();
01192
01193   switch ($op) {
01194     // Return stored strings
01195     case 'mem-report':
01196       return $strings;
01197
01198     // Store string in memory (only supports single strings)
01199     case 'mem-store':
01200       $strings[$value['msgid']] = $value['msgstr'];
01201       return;
01202
01203     // Called at end of import to inform the user
01204     case 'db-report':
01205       return array($headerdone, $report[0], $report[1], $report[2]);
01206
01207     // Store the string we got in the database.
01208     case 'db-store':
01209       // We got header information.
01210       if ($value['msgid'] == '') {
01211         $header = _locale_import_parse_header($value['msgstr']);
01212
01213         // Get the plural formula and update in database.
01214         if (isset($header["Plural-Forms"]) && $p = _locale_import_parse_plural_forms($header["Plural-Forms"], $file->filename)) {
01215           list($nplurals, $plural) = $p;
01216           db_query("UPDATE {languages} SET plurals = %d, formula = '%s' WHERE language = '%s'", $nplurals, $plural, $lang);
01217         }
01218         else {
01219           db_query("UPDATE {languages} SET plurals = %d, formula = '%s' WHERE language = '%s'", 0, '', $lang);
01220         }
01221         $headerdone = TRUE;
01222       }
01223
01224       else {
01225         // Some real string to import.
01226         $comments = _locale_import_shorten_comments(empty($value['#']) ? array() : $value['#']);
01227
01228         if (strpos($value['msgid'], "\0")) {
01229           // This string has plural versions.
01230           $english = explode("\0", $value['msgid'], 2);
01231           $entries = array_keys($value['msgstr']);
01232           for ($i = 3; $i <= count($entries); $i++) {
01233             $english[] = $english[1];
01234           }
01235           $translation = array_map('_locale_import_append_plural', $value['msgstr'], $entries);
01236           $english = array_map('_locale_import_append_plural', $english, $entries);
01237           foreach ($translation as $key => $trans) {
01238             if ($key == 0) {
01239               $plid = 0;
01240             }
01241             $plid = _locale_import_one_string_db($report, $lang, $english[$key], $trans, $group, $comments, $mode, $plid, $key);
01242           }
01243         }
01244
01245         else {
01246           // A simple string to import.
01247           $english = $value['msgid'];
01248           $translation = $value['msgstr'];
01249           _locale_import_one_string_db($report, $lang, $english, $translation, $group, $comments, $mode);
01250         }
01251       }
01252   } // end of db-store operation
01253 }
01254
01280 function _locale_import_one_string_db(&$report, $langcode, $source, $translation, $textgroup, $location, $mode, $plid = NULL, $plural = NULL) {
01281   $lid = db_result(db_query("SELECT lid FROM {locales_source} WHERE source = '%s' AND textgroup = '%s'", $source, $textgroup));
01282
01283   if (!empty($translation)) {
01284     if ($lid) {
01285       // We have this source string saved already.
01286       db_query("UPDATE {locales_source} SET location = '%s' WHERE lid = %d", $location, $lid);
01287       $exists = (bool) db_result(db_query("SELECT lid FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $langcode));
01288       if (!$exists) {
01289         // No translation in this language.
01290         db_query("INSERT INTO {locales_target} (lid, language, translation, plid, plural) VALUES (%d, '%s', '%s', %d, %d)", $lid, $langcode, $translation, $plid, $plural);
01291         $report[0]++;
01292       }
01293       else if ($mode == LOCALE_IMPORT_OVERWRITE) {
01294         // Translation exists, only overwrite if instructed.
01295         db_query("UPDATE {locales_target} SET translation = '%s', plid = %d, plural = %d WHERE language = '%s' AND lid = %d", $translation, $plid, $plural, $langcode, $lid);
01296         $report[1]++;
01297       }
01298     }
01299     else {
01300       // No such source string in the database yet.
01301       db_query("INSERT INTO {locales_source} (location, source, textgroup) VALUES ('%s', '%s', '%s')", $location, $source, $textgroup);
01302       $lid = db_result(db_query("SELECT lid FROM {locales_source} WHERE source = '%s' AND textgroup = '%s'", $source, $textgroup));
01303       db_query("INSERT INTO {locales_target} (lid, language, translation, plid, plural) VALUES (%d, '%s', '%s', %d, %d)", $lid, $langcode, $translation, $plid, $plural);
01304       $report[0]++;
01305     }
01306   }
01307   elseif ($mode == LOCALE_IMPORT_OVERWRITE) {
01308     // Empty translation, remove existing if instructed.
01309     db_query("DELETE FROM {locales_target} WHERE language = '%s' AND lid = %d AND plid = %d AND plural = %d", $translation, $langcode, $lid, $plid, $plural);
01310     $report[2]++;
01311   }
01312
01313   return $lid;
01314 }
01315
01324 function _locale_import_parse_header($header) {
01325   $header_parsed = array();
01326   $lines = array_map('trim', explode("\n", $header));
01327   foreach ($lines as $line) {
01328     if ($line) {
01329       list($tag, $contents) = explode(":", $line, 2);
01330       $header_parsed[trim($tag)] = trim($contents);
01331     }
01332   }
01333   return $header_parsed;
01334 }
01335
01347 function _locale_import_parse_plural_forms($pluralforms, $filename) {
01348   // First, delete all whitespace
01349   $pluralforms = strtr($pluralforms, array(" " => "", "\t" => ""));
01350
01351   // Select the parts that define nplurals and plural
01352   $nplurals = strstr($pluralforms, "nplurals=");
01353   if (strpos($nplurals, ";")) {
01354     $nplurals = substr($nplurals, 9, strpos($nplurals, ";") - 9);
01355   }
01356   else {
01357     return FALSE;
01358   }
01359   $plural = strstr($pluralforms, "plural=");
01360   if (strpos($plural, ";")) {
01361     $plural = substr($plural, 7, strpos($plural, ";") - 7);
01362   }
01363   else {
01364     return FALSE;
01365   }
01366
01367   // Get PHP version of the plural formula
01368   $plural = _locale_import_parse_arithmetic($plural);
01369
01370   if ($plural !== FALSE) {
01371     return array($nplurals, $plural);
01372   }
01373   else {
01374     drupal_set_message(t('The translation file %filename contains an error: the plural formula could not be parsed.', array('%filename' => $filename)), 'error');
01375     return FALSE;
01376   }
01377 }
01378
01390 function _locale_import_parse_arithmetic($string) {
01391   // Operator precedence table
01392   $prec = array("(" => -1, ")" => -1, "?" => 1, ":" => 1, "||" => 3, "&&" => 4, "==" => 5, "!=" => 5, "<" => 6, ">" => 6, "<=" => 6, ">=" => 6, "+" => 7, "-" => 7, "*" => 8, "/" => 8, "%" => 8);
01393   // Right associativity
01394   $rasc = array("?" => 1, ":" => 1);
01395
01396   $tokens = _locale_import_tokenize_formula($string);
01397
01398   // Parse by converting into infix notation then back into postfix
01399   $opstk = array();
01400   $elstk = array();
01401
01402   foreach ($tokens as $token) {
01403     $ctok = $token;
01404
01405     // Numbers and the $n variable are simply pushed into $elarr
01406     if (is_numeric($token)) {
01407       $elstk[] = $ctok;
01408     }
01409     elseif ($ctok == "n") {
01410       $elstk[] = '$n';
01411     }
01412     elseif ($ctok == "(") {
01413       $opstk[] = $ctok;
01414     }
01415     elseif ($ctok == ")") {
01416       $topop = array_pop($opstk);
01417       while (isset($topop) && ($topop != "(")) {
01418         $elstk[] = $topop;
01419         $topop = array_pop($opstk);
01420       }
01421     }
01422     elseif (!empty($prec[$ctok])) {
01423       // If it's an operator, then pop from $oparr into $elarr until the
01424       // precedence in $oparr is less than current, then push into $oparr
01425       $topop = array_pop($opstk);
01426       while (isset($topop) && ($prec[$topop] >= $prec[$ctok]) && !(($prec[$topop] == $prec[$ctok]) && !empty($rasc[$topop]) && !empty($rasc[$ctok]))) {
01427         $elstk[] = $topop;
01428         $topop = array_pop($opstk);
01429       }
01430       if ($topop) {
01431         $opstk[] = $topop;   // Return element to top
01432       }
01433       $opstk[] = $ctok;      // Parentheses are not needed
01434     }
01435     else {
01436       return FALSE;
01437     }
01438   }
01439
01440   // Flush operator stack
01441   $topop = array_pop($opstk);
01442   while ($topop != NULL) {
01443     $elstk[] = $topop;
01444     $topop = array_pop($opstk);
01445   }
01446
01447   // Now extract formula from stack
01448   $prevsize = count($elstk) + 1;
01449   while (count($elstk) < $prevsize) {
01450     $prevsize = count($elstk);
01451     for ($i = 2; $i < count($elstk); $i++) {
01452       $op = $elstk[$i];
01453       if (!empty($prec[$op])) {
01454         $f = "";
01455         if ($op == ":") {
01456           $f = $elstk[$i - 2] ."):". $elstk[$i - 1] .")";
01457         }
01458         elseif ($op == "?") {
01459           $f = "(". $elstk[$i - 2] ."?(". $elstk[$i - 1];
01460         }
01461         else {
01462           $f = "(". $elstk[$i - 2] . $op . $elstk[$i - 1] .")";
01463         }
01464         array_splice($elstk, $i - 2, 3, $f);
01465         break;
01466       }
01467     }
01468   }
01469
01470   // If only one element is left, the number of operators is appropriate
01471   if (count($elstk) == 1) {
01472     return $elstk[0];
01473   }
01474   else {
01475     return FALSE;
01476   }
01477 }
01478
01487 function _locale_import_tokenize_formula($formula) {
01488   $formula = str_replace(" ", "", $formula);
01489   $tokens = array();
01490   for ($i = 0; $i < strlen($formula); $i++) {
01491     if (is_numeric($formula[$i])) {
01492       $num = $formula[$i];
01493       $j = $i + 1;
01494       while ($j < strlen($formula) && is_numeric($formula[$j])) {
01495         $num .= $formula[$j];
01496         $j++;
01497       }
01498       $i = $j - 1;
01499       $tokens[] = $num;
01500     }
01501     elseif ($pos = strpos(" =<>!&|", $formula[$i])) { // We won't have a space
01502       $next = $formula[$i + 1];
01503       switch ($pos) {
01504         case 1:
01505         case 2:
01506         case 3:
01507         case 4:
01508           if ($next == '=') {
01509             $tokens[] = $formula[$i] .'=';
01510             $i++;
01511           }
01512           else {
01513             $tokens[] = $formula[$i];
01514           }
01515           break;
01516         case 5:
01517           if ($next == '&') {
01518             $tokens[] = '&&';
01519             $i++;
01520           }
01521           else {
01522             $tokens[] = $formula[$i];
01523           }
01524           break;
01525         case 6:
01526           if ($next == '|') {
01527             $tokens[] = '||';
01528             $i++;
01529           }
01530           else {
01531             $tokens[] = $formula[$i];
01532           }
01533           break;
01534       }
01535     }
01536     else {
01537       $tokens[] = $formula[$i];
01538     }
01539   }
01540   return $tokens;
01541 }
01542
01553 function _locale_import_append_plural($entry, $key) {
01554   // No modifications for 0, 1
01555   if ($key == 0 || $key == 1) {
01556     return $entry;
01557   }
01558
01559   // First remove any possibly false indices, then add new ones
01560   $entry = preg_replace('/(@count)\[[0-9]\]/', '\\1', $entry);
01561   return preg_replace('/(@count)/', "\\1[$key]", $entry);
01562 }
01563
01572 function _locale_import_shorten_comments($comment) {
01573   $comm = '';
01574   while (count($comment)) {
01575     $test = $comm . substr(array_shift($comment), 1) .', ';
01576     if (strlen($comm) < 130) {
01577       $comm = $test;
01578     }
01579     else {
01580       break;
01581     }
01582   }
01583   return substr($comm, 0, -2);
01584 }
01585
01594 function _locale_import_parse_quoted($string) {
01595   if (substr($string, 0, 1) != substr($string, -1, 1)) {
01596     return FALSE;   // Start and end quotes must be the same
01597   }
01598   $quote = substr($string, 0, 1);
01599   $string = substr($string, 1, -1);
01600   if ($quote == '"') {        // Double quotes: strip slashes
01601     return stripcslashes($string);
01602   }
01603   elseif ($quote == "'") {  // Simple quote: return as-is
01604     return $string;
01605   }
01606   else {
01607     return FALSE;             // Unrecognized quote
01608   }
01609 }
01618 function _locale_parse_js_file($filepath) {
01619   global $language;
01620
01621   // Load the JavaScript file.
01622   $file = file_get_contents($filepath);
01623
01624   // Match all calls to Drupal.t() in an array.
01625   // Note: \s also matches newlines with the 's' modifier.
01626   preg_match_all('~[^\w]Drupal\s*\.\s*t\s*\(\s*('. LOCALE_JS_STRING .')\s*[,\)]~s', $file, $t_matches);
01627
01628   // Match all Drupal.formatPlural() calls in another array.
01629   preg_match_all('~[^\w]Drupal\s*\.\s*formatPlural\s*\(\s*.+?\s*,\s*('. LOCALE_JS_STRING .')\s*,\s*((?:(?:\'(?:\\\\\'|[^\'])*@count(?:\\\\\'|[^\'])*\'|"(?:\\\\"|[^"])*@count(?:\\\\"|[^"])*")(?:\s*\+\s*)?)+)\s*[,\)]~s', $file, $plural_matches);
01630
01631   // Loop through all matches and process them.
01632   $all_matches = array_merge($plural_matches[1], $t_matches[1]);
01633   foreach ($all_matches as $key => $string) {
01634     $strings = array($string);
01635
01636     // If there is also a plural version of this string, add it to the strings array.
01637     if (isset($plural_matches[2][$key])) {
01638       $strings[] = $plural_matches[2][$key];
01639     }
01640
01641     foreach ($strings as $key => $string) {
01642       // Remove the quotes and string concatenations from the string.
01643       $string = implode('', preg_split('~(?<!\\\\)[\'"]\s*\+\s*[\'"]~s', substr($string, 1, -1)));
01644
01645       $result = db_query("SELECT lid, location FROM {locales_source} WHERE source = '%s' AND textgroup = 'default'", $string);
01646       if ($source = db_fetch_object($result)) {
01647         // We already have this source string and now have to add the location
01648         // to the location column, if this file is not yet present in there.
01649         $locations = preg_split('~\s*;\s*~', $source->location);
01650
01651         if (!in_array($filepath, $locations)) {
01652           $locations[] = $filepath;
01653           $locations = implode('; ', $locations);
01654
01655           // Save the new locations string to the database.
01656           db_query("UPDATE {locales_source} SET location = '%s' WHERE lid = %d", $locations, $source->lid);
01657         }
01658       }
01659       else {
01660         // We don't have the source string yet, thus we insert it into the database.
01661         db_query("INSERT INTO {locales_source} (location, source, textgroup) VALUES ('%s', '%s', 'default')", $filepath, $string);
01662       }
01663     }
01664   }
01665 }
01666
01683 function _locale_export_get_strings($language = NULL, $group = 'default') {
01684   if (isset($language)) {
01685     $result = db_query("SELECT s.lid, s.source, s.location, t.translation, t.plid, t.plural FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.textgroup = '%s' ORDER BY t.plid, t.plural", $language->language, $group);
01686   }
01687   else {
01688     $result = db_query("SELECT s.lid, s.source, s.location, t.plid, t.plural FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid WHERE s.textgroup = '%s' ORDER BY t.plid, t.plural", $group);
01689   }
01690   $strings = array();
01691   while ($child = db_fetch_object($result)) {
01692     $string = array(
01693       'comment'     => $child->location,
01694       'source'      => $child->source,
01695       'translation' => isset($child->translation) ? $child->translation : ''
01696     );
01697     if ($child->plid) {
01698       // Has a parent lid. Since we process in the order of plids,
01699       // we already have the parent in the array, so we can add the
01700       // lid to the next plural version to it. This builds a linked
01701       // list of plurals.
01702       $string['child'] = TRUE;
01703       $strings[$child->plid]['plural'] = $child->lid;
01704     }
01705     $strings[$child->lid] = $string;
01706   }
01707   return $strings;
01708 }
01709
01723 function _locale_export_po_generate($language = NULL, $strings = array(), $header = NULL) {
01724   global $user;
01725
01726   if (!isset($header)) {
01727     if (isset($language)) {
01728       $header = '# '. $language->name .' translation of '. variable_get('site_name', 'Drupal') ."\n";
01729       $header .= '# Generated by '. $user->name .' <'. $user->mail .">\n";
01730       $header .= "#\n";
01731       $header .= "msgid \"\"\n";
01732       $header .= "msgstr \"\"\n";
01733       $header .= "\"Project-Id-Version: PROJECT VERSION\\n\"\n";
01734       $header .= "\"POT-Creation-Date: ". date("Y-m-d H:iO") ."\\n\"\n";
01735       $header .= "\"PO-Revision-Date: ". date("Y-m-d H:iO") ."\\n\"\n";
01736       $header .= "\"Last-Translator: NAME <EMAIL@ADDRESS>\\n\"\n";
01737       $header .= "\"Language-Team: LANGUAGE <EMAIL@ADDRESS>\\n\"\n";
01738       $header .= "\"MIME-Version: 1.0\\n\"\n";
01739       $header .= "\"Content-Type: text/plain; charset=utf-8\\n\"\n";
01740       $header .= "\"Content-Transfer-Encoding: 8bit\\n\"\n";
01741       if ($language->formula && $language->plurals) {
01742         $header .= "\"Plural-Forms: nplurals=". $language->plurals ."; plural=". strtr($language->formula, array('$' => '')) .";\\n\"\n";
01743       }
01744     }
01745     else {
01746       $header = "# LANGUAGE translation of PROJECT\n";
01747       $header .= "# Copyright (c) YEAR NAME <EMAIL@ADDRESS>\n";
01748       $header .= "#\n";
01749       $header .= "msgid \"\"\n";
01750       $header .= "msgstr \"\"\n";
01751       $header .= "\"Project-Id-Version: PROJECT VERSION\\n\"\n";
01752       $header .= "\"POT-Creation-Date: ". date("Y-m-d H:iO") ."\\n\"\n";
01753       $header .= "\"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\\n\"\n";
01754       $header .= "\"Last-Translator: NAME <EMAIL@ADDRESS>\\n\"\n";
01755       $header .= "\"Language-Team: LANGUAGE <EMAIL@ADDRESS>\\n\"\n";
01756       $header .= "\"MIME-Version: 1.0\\n\"\n";
01757       $header .= "\"Content-Type: text/plain; charset=utf-8\\n\"\n";
01758       $header .= "\"Content-Transfer-Encoding: 8bit\\n\"\n";
01759       $header .= "\"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n\"\n";
01760     }
01761   }
01762
01763   $output = $header ."\n";
01764
01765   foreach ($strings as $lid => $string) {
01766     // Only process non-children, children are output below their parent.
01767     if (!isset($string['child'])) {
01768       if ($string['comment']) {
01769         $output .= '#: '. $string['comment'] ."\n";
01770       }
01771       $output .= 'msgid '. _locale_export_string($string['source']);
01772       if (!empty($string['plural'])) {
01773         $plural = $string['plural'];
01774         $output .= 'msgid_plural '. _locale_export_string($strings[$plural]['source']);
01775         if (isset($language)) {
01776           $translation = $string['translation'];
01777           for ($i = 0; $i < $language->plurals; $i++) {
01778             $output .= 'msgstr['. $i .'] '. _locale_export_string($translation);
01779             if ($plural) {
01780               $translation = _locale_export_remove_plural($strings[$plural]['translation']);
01781               $plural = isset($strings[$plural]['plural']) ? $strings[$plural]['plural'] : 0;
01782             }
01783             else {
01784               $translation = '';
01785             }
01786           }
01787         }
01788         else {
01789           $output .= 'msgstr[0] ""'."\n";
01790           $output .= 'msgstr[1] ""'."\n";
01791         }
01792       }
01793       else {
01794         $output .= 'msgstr '. _locale_export_string($string['translation']);
01795       }
01796       $output .= "\n";
01797     }
01798   }
01799   return $output;
01800 }
01801
01812 function _locale_export_po($language = NULL, $output = NULL) {
01813   // Log the export event.
01814   if (isset($language)) {
01815     $filename = $language->language .'.po';
01816     watchdog('locale', 'Exported %locale translation file: %filename.', array('%locale' => $language->name, '%filename' => $filename));
01817   }
01818   else {
01819     $filename = 'drupal.pot';
01820     watchdog('locale', 'Exported translation file: %filename.', array('%filename' => $filename));
01821   }
01822   // Download the file fo the client.
01823   header("Content-Disposition: attachment; filename=$filename");
01824   header("Content-Type: text/plain; charset=utf-8");
01825   print $output;
01826   die();
01827 }
01828
01832 function _locale_export_string($str) {
01833   $stri = addcslashes($str, "\0..\37\\\"");
01834   $parts = array();
01835
01836   // Cut text into several lines
01837   while ($stri != "") {
01838     $i = strpos($stri, "\\n");
01839     if ($i === FALSE) {
01840       $curstr = $stri;
01841       $stri = "";
01842     }
01843     else {
01844       $curstr = substr($stri, 0, $i + 2);
01845       $stri = substr($stri, $i + 2);
01846     }
01847     $curparts = explode("\n", _locale_export_wrap($curstr, 70));
01848     $parts = array_merge($parts, $curparts);
01849   }
01850
01851   // Multiline string
01852   if (count($parts) > 1) {
01853     return "\"\"\n\"". implode("\"\n\"", $parts) ."\"\n";
01854   }
01855   // Single line string
01856   elseif (count($parts) == 1) {
01857     return "\"$parts[0]\"\n";
01858   }
01859   // No translation
01860   else {
01861     return "\"\"\n";
01862   }
01863 }
01864
01868 function _locale_export_wrap($str, $len) {
01869   $words = explode(' ', $str);
01870   $ret = array();
01871
01872   $cur = "";
01873   $nstr = 1;
01874   while (count($words)) {
01875     $word = array_shift($words);
01876     if ($nstr) {
01877       $cur = $word;
01878       $nstr = 0;
01879     }
01880     elseif (strlen("$cur $word") > $len) {
01881       $ret[] = $cur ." ";
01882       $cur = $word;
01883     }
01884     else {
01885       $cur = "$cur $word";
01886     }
01887   }
01888   $ret[] = $cur;
01889
01890   return implode("\n", $ret);
01891 }
01892
01896 function _locale_export_remove_plural($entry) {
01897   return preg_replace('/(@count)\[[0-9]\]/', '\\1', $entry);
01898 }
01911 function _locale_translate_seek() {
01912   $output = '';
01913
01914   // We have at least one criterion to match
01915   if ($query = _locale_translate_seek_query()) {
01916     $join = "SELECT s.source, s.location, s.lid, s.textgroup, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid ";
01917
01918     $arguments = array();
01919     $limit_language = FALSE;
01920     // Compute LIKE section
01921     switch ($query['translation']) {
01922       case 'translated':
01923         $where = "WHERE (t.translation LIKE '%%%s%%')";
01924         $orderby = "ORDER BY t.translation";
01925         $arguments[] = $query['string'];
01926         break;
01927       case 'untranslated':
01928         $where = "WHERE (s.source LIKE '%%%s%%' AND t.translation IS NULL)";
01929         $orderby = "ORDER BY s.source";
01930         $arguments[] = $query['string'];
01931         break;
01932       case 'all' :
01933       default:
01934         $where = "WHERE (s.source LIKE '%%%s%%' OR t.translation LIKE '%%%s%%')";
01935         $orderby = '';
01936         $arguments[] = $query['string'];
01937         $arguments[] = $query['string'];
01938         break;
01939     }
01940     $grouplimit = '';
01941     if (!empty($query['group']) && $query['group'] != 'all') {
01942       $grouplimit = " AND s.textgroup = '%s'";
01943       $arguments[] = $query['group'];
01944     }
01945
01946     switch ($query['language']) {
01947       // Force search in source strings
01948       case "en":
01949         $sql = $join ." WHERE s.source LIKE '%%%s%%' $grouplimit ORDER BY s.source";
01950         $arguments = array($query['string']); // $where is not used, discard its arguments
01951         if (!empty($grouplimit)) {
01952           $arguments[] = $query['group'];
01953         }
01954         break;
01955       // Search in all languages
01956       case "all":
01957         $sql = "$join $where $grouplimit $orderby";
01958         break;
01959       // Some different language
01960       default:
01961         $sql = "$join AND t.language = '%s' $where $grouplimit $orderby";
01962         array_unshift($arguments, $query['language']);
01963         // Don't show translation flags for other languages, we can't see them with this search.
01964         $limit_language = $query['language'];
01965     }
01966
01967     $result = pager_query($sql, 50, 0, NULL, $arguments);
01968
01969     $groups = module_invoke_all('locale', 'groups');
01970     $header = array(t('Text group'), t('String'), ($limit_language) ? t('Language') : t('Languages'), array('data' => t('Operations'), 'colspan' => '2'));
01971     $arr = array();
01972     while ($locale = db_fetch_object($result)) {
01973       $arr[$locale->lid]['group'] = $groups[$locale->textgroup];
01974       $arr[$locale->lid]['languages'][$locale->language] = $locale->translation;
01975       $arr[$locale->lid]['location'] = $locale->location;
01976       $arr[$locale->lid]['source'] = $locale->source;
01977     }
01978     $rows = array();
01979     foreach ($arr as $lid => $value) {
01980       $rows[] = array(
01981         $value['group'],
01982         array('data' => check_plain(truncate_utf8($value['source'], 150, FALSE, TRUE)) .'<br /><small>'. $value['location'] .'</small>'),
01983         array('data' => _locale_translate_language_list($value['languages'], $limit_language), 'align' => 'center'),
01984         array('data' => l(t('edit'), "admin/build/translate/edit/$lid"), 'class' => 'nowrap'),
01985         array('data' => l(t('delete'), "admin/build/translate/delete/$lid"), 'class' => 'nowrap'),
01986       );
01987     }
01988
01989     if (count($rows)) {
01990       $output .= theme('table', $header, $rows);
01991       if ($pager = theme('pager', NULL, 50)) {
01992         $output .= $pager;
01993       }
01994     }
01995     else {
01996       $output .= t('No strings found for your search.');
01997     }
01998   }
01999
02000   return $output;
02001 }
02002
02006 function _locale_translate_seek_query() {
02007   static $query = NULL;
02008   if (!isset($query)) {
02009     $query = array();
02010     $fields = array('string', 'language', 'translation', 'group');
02011     foreach ($fields as $field) {
02012       if (isset($_REQUEST[$field])) {
02013         $query[$field] = $_REQUEST[$field];
02014       }
02015     }
02016   }
02017   return $query;
02018 }
02019
02033 function _locale_invalidate_js($langcode = NULL) {
02034   $parsed = variable_get('javascript_parsed', array());
02035
02036   if (empty($langcode)) {
02037     // Invalidate all languages.
02038     $languages = language_list();
02039     unset($languages['en']);
02040     foreach ($languages as $lcode => $data) {
02041       $parsed['refresh:'. $lcode] = 'waiting';
02042     }
02043   }
02044   else {
02045     // Invalidate single language.
02046     $parsed['refresh:'. $langcode] = 'waiting';
02047   }
02048
02049   variable_set('javascript_parsed', $parsed);
02050   return $parsed;
02051 }
02052
02059 function _locale_rebuild_js($langcode = NULL) {
02060   if (!isset($langcode)) {
02061     global $language;
02062   }
02063   else {
02064     // Get information about the locale.
02065     $languages = language_list();
02066     $language = $languages[$langcode];
02067   }
02068
02069   // Construct the array for JavaScript translations.
02070   // We sort on plural so that we have all plural forms before singular forms.
02071   $result = db_query("SELECT s.lid, s.source, t.plid, t.plural, t.translation FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.location LIKE '%%.js%%' AND s.textgroup = 'default' ORDER BY t.plural DESC", $language->language);
02072
02073   $translations = $plurals = array();
02074   while ($data = db_fetch_object($result)) {
02075     // Only add this to the translations array when there is actually a translation.
02076     if (!empty($data->translation)) {
02077       if ($data->plural) {
02078         // When the translation is a plural form, first add it to another array and
02079         // wait for the singular (parent) translation.
02080         if (!isset($plurals[$data->plid])) {
02081           $plurals[$data->plid] = array($data->plural => $data->translation);
02082         }
02083         else {
02084           $plurals[$data->plid] += array($data->plural => $data->translation);
02085         }
02086       }
02087       elseif (isset($plurals[$data->lid])) {
02088         // There are plural translations for this translation, so get them from
02089         // the plurals array and add them to the final translations array.
02090         $translations[$data->source] = array($data->plural => $data->translation) + $plurals[$data->lid];
02091         unset($plurals[$data->lid]);
02092       }
02093       else {
02094         // There are no plural forms for this translation, so just add it to
02095         // the translations array.
02096         $translations[$data->source] = $data->translation;
02097       }
02098     }
02099   }
02100
02101   // Construct the JavaScript file, if there are translations.
02102   $data = $status = '';
02103   if (!empty($translations)) {
02104
02105     $data = "Drupal.locale = { ";
02106
02107     if (!empty($language->formula)) {
02108       $data .= "'pluralFormula': function(\$n) { return Number({$language->formula}); }, ";
02109     }
02110
02111     $data .= "'strings': ". drupal_to_js($translations) ." };";
02112     $data_hash = md5($data);
02113   }
02114
02115   // Construct the filepath where JS translation files are stored.
02116   // There is (on purpose) no front end to edit that variable.
02117   $dir = file_create_path(variable_get('locale_js_directory', 'languages'));
02118
02119   // Delete old file, if we have no translations anymore, or a different file to be saved.
02120   if (!empty($language->javascript) && (!$data || $language->javascript != $data_hash)) {
02121     file_delete(file_create_path($dir .'/'. $language->language .'_'. $language->javascript .'.js'));
02122     $language->javascript = '';
02123     $status = 'deleted';
02124   }
02125
02126   // Only create a new file if the content has changed.
02127   if ($data && $language->javascript != $data_hash) {
02128     // Ensure that the directory exists and is writable, if possible.
02129     file_check_directory($dir, TRUE);
02130
02131     // Save the file.
02132     $dest = $dir .'/'. $language->language .'_'. $data_hash .'.js';
02133     if (file_save_data($data, $dest)) {
02134       $language->javascript = $data_hash;
02135       $status = ($status == 'deleted') ? 'updated' : 'created';
02136     }
02137     else {
02138       $language->javascript = '';
02139       $status = 'error';
02140     }
02141   }
02142
02143   // Save the new JavaScript hash (or an empty value if the file
02144   // just got deleted). Act only if some operation was executed.
02145   if ($status) {
02146     db_query("UPDATE {languages} SET javascript = '%s' WHERE language = '%s'", $language->javascript, $language->language);
02147
02148     // Update the default language variable if the default language has been altered.
02149     // This is necessary to keep the variable consistent with the database
02150     // version of the language and to prevent checking against an outdated hash.
02151     $default_langcode = language_default('language');
02152     if ($default_langcode == $language->language) {
02153       $default = db_fetch_object(db_query("SELECT * FROM {languages} WHERE language = '%s'", $default_langcode));
02154       variable_set('language_default', $default);
02155     }
02156   }
02157
02158   // Log the operation and return success flag.
02159   switch ($status) {
02160     case 'updated':
02161       watchdog('locale', 'Updated JavaScript translation file for the language %language.', array('%language' => t($language->name)));
02162       return TRUE;
02163     case 'created':
02164       watchdog('locale', 'Created JavaScript translation file for the language %language.', array('%language' => t($language->name)));
02165       return TRUE;
02166     case 'deleted':
02167       watchdog('locale', 'Removed JavaScript translation file for the language %language, because no translations currently exist for that language.', array('%language' => t($language->name)));
02168       return TRUE;
02169     case 'error':
02170       watchdog('locale', 'An error occurred during creation of the JavaScript translation file for the language %language.', array('%language' => t($language->name)), WATCHDOG_ERROR);
02171       return FALSE;
02172     default:
02173       // No operation needed.
02174       return TRUE;
02175   }
02176 }
02177
02181 function _locale_translate_language_list($translation, $limit_language) {
02182   // Add CSS
02183   drupal_add_css(drupal_get_path('module', 'locale') .'/locale.css', 'module', 'all', FALSE);
02184
02185   $languages = language_list();
02186   unset($languages['en']);
02187   $output = '';
02188   foreach ($languages as $langcode => $language) {
02189     if (!$limit_language || $limit_language == $langcode) {
02190       $output .= (!empty($translation[$langcode])) ? $langcode .' ' : "<em class=\"locale-untranslated\">$langcode</em> ";
02191     }
02192   }
02193
02194   return $output;
02195 }
02208 function _locale_prepare_predefined_list() {
02209   $languages = language_list();
02210   $predefined = _locale_get_predefined_list();
02211   foreach ($predefined as $key => $value) {
02212     if (isset($languages[$key])) {
02213       unset($predefined[$key]);
02214       continue;
02215     }
02216     // Include native name in output, if possible
02217     if (count($value) > 1) {
02218       $tname = t($value[0]);
02219       $predefined[$key] = ($tname == $value[1]) ? $tname : "$tname ($value[1])";
02220     }
02221     else {
02222       $predefined[$key] = t($value[0]);
02223     }
02224   }
02225   asort($predefined);
02226   return $predefined;
02227 }
02228
02234 function _locale_get_predefined_list() {
02235   return array(
02236     "aa" => array("Afar"),
02237     "ab" => array("Abkhazian", "аҧсуа бызшәа"),
02238     "ae" => array("Avestan"),
02239     "af" => array("Afrikaans"),
02240     "ak" => array("Akan"),
02241     "am" => array("Amharic", "አማርኛ"),
02242     "ar" => array("Arabic", /* Left-to-right marker "‭" */ "العربية", LANGUAGE_RTL),
02243     "as" => array("Assamese"),
02244     "av" => array("Avar"),
02245     "ay" => array("Aymara"),
02246     "az" => array("Azerbaijani", "azərbaycan"),
02247     "ba" => array("Bashkir"),
02248     "be" => array("Belarusian", "Беларуская"),
02249     "bg" => array("Bulgarian", "Български"),
02250     "bh" => array("Bihari"),
02251     "bi" => array("Bislama"),
02252     "bm" => array("Bambara", "Bamanankan"),
02253     "bn" => array("Bengali"),
02254     "bo" => array("Tibetan"),
02255     "br" => array("Breton"),
02256     "bs" => array("Bosnian", "Bosanski"),
02257     "ca" => array("Catalan", "Català"),
02258     "ce" => array("Chechen"),
02259     "ch" => array("Chamorro"),
02260     "co" => array("Corsican"),
02261     "cr" => array("Cree"),
02262     "cs" => array("Czech", "Čeština"),
02263     "cu" => array("Old Slavonic"),
02264     "cv" => array("Chuvash"),
02265     "cy" => array("Welsh", "Cymraeg"),
02266     "da" => array("Danish", "Dansk"),
02267     "de" => array("German", "Deutsch"),
02268     "dv" => array("Maldivian"),
02269     "dz" => array("Bhutani"),
02270     "ee" => array("Ewe", "Ɛʋɛ"),
02271     "el" => array("Greek", "Ελληνικά"),
02272     "en" => array("English"),
02273     "eo" => array("Esperanto"),
02274     "es" => array("Spanish", "Español"),
02275     "et" => array("Estonian", "Eesti"),
02276     "eu" => array("Basque", "Euskera"),
02277     "fa" => array("Persian", /* Left-to-right marker "‭" */ "فارسی", LANGUAGE_RTL),
02278     "ff" => array("Fulah", "Fulfulde"),
02279     "fi" => array("Finnish", "Suomi"),
02280     "fj" => array("Fiji"),
02281     "fo" => array("Faeroese"),
02282     "fr" => array("French", "Français"),
02283     "fy" => array("Frisian", "Frysk"),
02284     "ga" => array("Irish", "Gaeilge"),
02285     "gd" => array("Scots Gaelic"),
02286     "gl" => array("Galician", "Galego"),
02287     "gn" => array("Guarani"),
02288     "gu" => array("Gujarati"),
02289     "gv" => array("Manx"),
02290     "ha" => array("Hausa"),
02291     "he" => array("Hebrew", /* Left-to-right marker "‭" */ "עברית", LANGUAGE_RTL),
02292     "hi" => array("Hindi", "हिन्दी"),
02293     "ho" => array("Hiri Motu"),
02294     "hr" => array("Croatian", "Hrvatski"),
02295     "hu" => array("Hungarian", "Magyar"),
02296     "hy" => array("Armenian", "Հայերեն"),
02297     "hz" => array("Herero"),
02298     "ia" => array("Interlingua"),
02299     "id" => array("Indonesian", "Bahasa Indonesia"),
02300     "ie" => array("Interlingue"),
02301     "ig" => array("Igbo"),
02302     "ik" => array("Inupiak"),
02303     "is" => array("Icelandic", "Íslenska"),
02304     "it" => array("Italian", "Italiano"),
02305     "iu" => array("Inuktitut"),
02306     "ja" => array("Japanese", "日本語"),
02307     "jv" => array("Javanese"),
02308     "ka" => array("Georgian"),
02309     "kg" => array("Kongo"),
02310     "ki" => array("Kikuyu"),
02311     "kj" => array("Kwanyama"),
02312     "kk" => array("Kazakh", "Қазақ"),
02313     "kl" => array("Greenlandic"),
02314     "km" => array("Cambodian"),
02315     "kn" => array("Kannada", "ಕನ್ನಡ"),
02316     "ko" => array("Korean", "한국어"),
02317     "kr" => array("Kanuri"),
02318     "ks" => array("Kashmiri"),
02319     "ku" => array("Kurdish", "Kurdî"),
02320     "kv" => array("Komi"),
02321     "kw" => array("Cornish"),
02322     "ky" => array("Kirghiz", "Кыргыз"),
02323     "la" => array("Latin", "Latina"),
02324     "lb" => array("Luxembourgish"),
02325     "lg" => array("Luganda"),
02326     "ln" => array("Lingala"),
02327     "lo" => array("Laothian"),
02328     "lt" => array("Lithuanian", "Lietuvių"),
02329     "lv" => array("Latvian", "Latviešu"),
02330     "mg" => array("Malagasy"),
02331     "mh" => array("Marshallese"),
02332     "mi" => array("Maori"),
02333     "mk" => array("Macedonian", "Македонски"),
02334     "ml" => array("Malayalam", "മലയാളം"),
02335     "mn" => array("Mongolian"),
02336     "mo" => array("Moldavian"),
02337     "mr" => array("Marathi"),
02338     "ms" => array("Malay", "Bahasa Melayu"),
02339     "mt" => array("Maltese", "Malti"),
02340     "my" => array("Burmese"),
02341     "na" => array("Nauru"),
02342     "nd" => array("North Ndebele"),
02343     "ne" => array("Nepali"),
02344     "ng" => array("Ndonga"),
02345     "nl" => array("Dutch", "Nederlands"),
02346     "nb" => array("Norwegian Bokmål", "Bokmål"),
02347     "nn" => array("Norwegian Nynorsk", "Nynorsk"),
02348     "nr" => array("South Ndebele"),
02349     "nv" => array("Navajo"),
02350     "ny" => array("Chichewa"),
02351     "oc" => array("Occitan"),
02352     "om" => array("Oromo"),
02353     "or" => array("Oriya"),
02354     "os" => array("Ossetian"),
02355     "pa" => array("Punjabi"),
02356     "pi" => array("Pali"),
02357     "pl" => array("Polish", "Polski"),
02358     "ps" => array("Pashto", /* Left-to-right marker "‭" */ "پښتو", LANGUAGE_RTL),
02359     "pt" => array("Portuguese, Portugal", "Português"),
02360     "pt-br" => array("Portuguese, Brazil", "Português"),
02361     "qu" => array("Quechua"),
02362     "rm" => array("Rhaeto-Romance"),
02363     "rn" => array("Kirundi"),
02364     "ro" => array("Romanian", "Română"),
02365     "ru" => array("Russian", "Русский"),
02366     "rw" => array("Kinyarwanda"),
02367     "sa" => array("Sanskrit"),
02368     "sc" => array("Sardinian"),
02369     "sd" => array("Sindhi"),
02370     "se" => array("Northern Sami"),
02371     "sg" => array("Sango"),
02372     "sh" => array("Serbo-Croatian"),
02373     "si" => array("Singhalese"),
02374     "sk" => array("Slovak", "Slovenčina"),
02375     "sl" => array("Slovenian", "Slovenščina"),
02376     "sm" => array("Samoan"),
02377     "sn" => array("Shona"),
02378     "so" => array("Somali"),
02379     "sq" => array("Albanian", "Shqip"),
02380     "sr" => array("Serbian", "Српски"),
02381     "ss" => array("Siswati"),
02382     "st" => array("Sesotho"),
02383     "su" => array("Sudanese"),
02384     "sv" => array("Swedish", "Svenska"),
02385     "sw" => array("Swahili", "Kiswahili"),
02386     "ta" => array("Tamil", "தமிழ்"),
02387     "te" => array("Telugu", "తెలుగు"),
02388     "tg" => array("Tajik"),
02389     "th" => array("Thai", "ภาษาไทย"),
02390     "ti" => array("Tigrinya"),
02391     "tk" => array("Turkmen"),
02392     "tl" => array("Tagalog"),
02393     "tn" => array("Setswana"),
02394     "to" => array("Tonga"),
02395     "tr" => array("Turkish", "Türkçe"),
02396     "ts" => array("Tsonga"),
02397     "tt" => array("Tatar", "Tatarça"),
02398     "tw" => array("Twi"),
02399     "ty" => array("Tahitian"),
02400     "ug" => array("Uighur"),
02401     "uk" => array("Ukrainian", "Українська"),
02402     "ur" => array("Urdu", /* Left-to-right marker "‭" */ "اردو", LANGUAGE_RTL),
02403     "uz" => array("Uzbek", "o'zbek"),
02404     "ve" => array("Venda"),
02405     "vi" => array("Vietnamese", "Tiếng Việt"),
02406     "wo" => array("Wolof"),
02407     "xh" => array("Xhosa", "isiXhosa"),
02408     "yi" => array("Yiddish"),
02409     "yo" => array("Yoruba", "Yorùbá"),
02410     "za" => array("Zhuang"),
02411     "zh-hans" => array("Chinese, Simplified", "简体中文"),
02412     "zh-hant" => array("Chinese, Traditional", "繁體中文"),
02413     "zu" => array("Zulu", "isiZulu"),
02414   );
02415 }
02439 function locale_batch_by_language($langcode, $finished = NULL, $skip = array()) {
02440   // Collect all files to import for all enabled modules and themes.
02441   $files = array();
02442   $components = array();
02443   $query = "SELECT name, filename FROM {system} WHERE status = 1";
02444   if (count($skip)) {
02445     $query .= " AND name NOT IN (". db_placeholders($skip, 'varchar') .")";
02446   }
02447   $result = db_query($query, $skip);
02448   while ($component = db_fetch_object($result)) {
02449     // Collect all files for all components, names as $langcode.po or
02450     // with names ending with $langcode.po. This allows for filenames
02451     // like node-module.de.po to let translators use small files and
02452     // be able to import in smaller chunks.
02453     $files = array_merge($files, file_scan_directory(dirname($component->filename) .'/translations', '(^|\.)'. $langcode .'\.po$', array('.', '..', 'CVS'), 0, FALSE));
02454     $components[] = $component->name;
02455   }
02456
02457   return _locale_batch_build($files, $finished, $components);
02458 }
02459
02471 function locale_batch_by_component($components, $finished = '_locale_batch_system_finished') {
02472   $files = array();
02473   $languages = language_list('enabled');
02474   unset($languages[1]['en']);
02475   if (count($languages[1])) {
02476     $language_list = join('|', array_keys($languages[1]));
02477     // Collect all files to import for all $components.
02478     $result = db_query("SELECT name, filename FROM {system} WHERE status = 1");
02479     while ($component = db_fetch_object($result)) {
02480       if (in_array($component->name, $components)) {
02481         // Collect all files for this component in all enabled languages, named
02482         // as $langcode.po or with names ending with $langcode.po. This allows
02483         // for filenames like node-module.de.po to let translators use small
02484         // files and be able to import in smaller chunks.
02485         $files = array_merge($files, file_scan_directory(dirname($component->filename) .'/translations', '(^|\.)('. $language_list .')\.po$', array('.', '..', 'CVS'), 0, FALSE));
02486       }
02487     }
02488     return _locale_batch_build($files, $finished);
02489   }
02490   return FALSE;
02491 }
02492
02505 function _locale_batch_build($files, $finished = NULL, $components = array()) {
02506   $t = get_t();
02507   if (count($files)) {
02508     $operations = array();
02509     foreach ($files as $file) {
02510       // We call _locale_batch_import for every batch operation.
02511       $operations[] = array('_locale_batch_import', array($file->filename));    }
02512       $batch = array(
02513         'operations'    => $operations,
02514         'title'         => $t('Importing interface translations'),
02515         'init_message'  => $t('Starting import'),
02516         'error_message' => $t('Error importing interface translations'),
02517         'file'          => './includes/locale.inc',
02518         // This is not a batch API construct, but data passed along to the
02519         // installer, so we know what did we import already.
02520         '#components'   => $components,
02521       );
02522       if (isset($finished)) {
02523         $batch['finished'] = $finished;
02524       }
02525     return $batch;
02526   }
02527   return FALSE;
02528 }
02529
02538 function _locale_batch_import($filepath, &$context) {
02539   // The filename is either {langcode}.po or {prefix}.{langcode}.po, so
02540   // we can extract the language code to use for the import from the end.
02541   if (preg_match('!(/|\.)([^\./]+)\.po$!', $filepath, $langcode)) {
02542     $file = (object) array('filename' => basename($filepath), 'filepath' => $filepath);
02543     _locale_import_read_po('db-store', $file, LOCALE_IMPORT_KEEP, $langcode[2]);
02544     $context['results'][] = $filepath;
02545   }
02546 }
02547
02552 function _locale_batch_system_finished($success, $results) {
02553   if ($success) {
02554     drupal_set_message(format_plural(count($results), 'One translation file imported for the newly installed modules.', '@count translation files imported for the newly installed modules.'));
02555   }
02556 }
02557
02562 function _locale_batch_language_finished($success, $results) {
02563   if ($success) {
02564     drupal_set_message(format_plural(count($results), 'One translation file imported for the enabled modules.', '@count translation files imported for the enabled modules.'));
02565   }
02566 }
02567
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/locale/locale.install Source File

modules » locale

locale.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: locale.install,v 1.27 2008/01/10 14:35:24 goba Exp $
00003
00007 function locale_install() {
00008   // locales_source.source and locales_target.target are not used as binary
00009   // fields; non-MySQL database servers need to ensure the field type is text
00010   // and that LIKE produces a case-sensitive comparison.
00011
00012   // Create tables.
00013   drupal_install_schema('locale');
00014
00015   db_query("INSERT INTO {languages} (language, name, native, direction, enabled, weight, javascript) VALUES ('en', 'English', 'English', '0', '1', '0', '')");
00016 }
00017
00026 function locale_update_6000() {
00027   $ret = array();
00028
00029   $schema['languages'] = array(
00030     'fields' => array(
00031       'language' => array(
00032         'type' => 'varchar',
00033         'length' => 12,
00034         'not null' => TRUE,
00035         'default' => '',
00036       ),
00037       'name' => array(
00038         'type' => 'varchar',
00039         'length' => 64,
00040         'not null' => TRUE,
00041         'default' => '',
00042       ),
00043       'native' => array(
00044         'type' => 'varchar',
00045         'length' => 64,
00046         'not null' => TRUE,
00047         'default' => '',
00048       ),
00049       'direction' => array(
00050         'type' => 'int',
00051         'not null' => TRUE,
00052         'default' => 0,
00053       ),
00054       'enabled' => array(
00055         'type' => 'int',
00056         'not null' => TRUE,
00057         'default' => 0,
00058       ),
00059       'plurals' => array(
00060         'type' => 'int',
00061         'not null' => TRUE,
00062         'default' => 0,
00063       ),
00064       'formula' => array(
00065         'type' => 'varchar',
00066         'length' => 128,
00067         'not null' => TRUE,
00068         'default' => '',
00069       ),
00070       'domain' => array(
00071         'type' => 'varchar',
00072         'length' => 128,
00073         'not null' => TRUE,
00074         'default' => '',
00075       ),
00076       'prefix' => array(
00077         'type' => 'varchar',
00078         'length' => 128,
00079         'not null' => TRUE,
00080         'default' => '',
00081       ),
00082       'weight' => array(
00083         'type' => 'int',
00084         'not null' => TRUE,
00085         'default' => 0,
00086       ),
00087       'javascript' => array( //Adds a column to store the filename of the JavaScript translation file.
00088         'type' => 'varchar',
00089         'length' => 32,
00090         'not null' => TRUE,
00091         'default' => '',
00092       ),
00093     ),
00094     'primary key' => array('language'),
00095     'indexes' => array(
00096       'list' => array('weight', 'name'),
00097     ),
00098   );
00099
00100   db_create_table($ret, 'languages', $schema['languages']);
00101
00102   // Save the languages
00103   $ret[] = update_sql("INSERT INTO {languages} (language, name, native, direction, enabled, plurals, formula, domain, prefix, weight) SELECT locale, name, name, 0, enabled, plurals, formula, '', locale, 0 FROM {locales_meta}");
00104
00105   // Save the language count in the variable table
00106   $count = db_result(db_query('SELECT COUNT(*) FROM {languages} WHERE enabled = 1'));
00107   variable_set('language_count', $count);
00108
00109   // Save the default language in the variable table
00110   $default = db_fetch_object(db_query('SELECT * FROM {locales_meta} WHERE isdefault = 1'));
00111   variable_set('language_default', (object) array('language' => $default->locale, 'name' => $default->name, 'native' => '', 'direction' => 0, 'enabled' => 1, 'plurals' => $default->plurals, 'formula' => $default->formula, 'domain' => '', 'prefix' => $default->locale, 'weight' => 0));
00112
00113   $ret[] = update_sql("DROP TABLE {locales_meta}");
00114   return $ret;
00115 }
00116
00123 function locale_update_6001() {
00124   $ret = array();
00125   $ret[] = update_sql('UPDATE {locales_target} SET language = locale');
00126   db_drop_field($ret, 'locales_target', 'locale');
00127   return $ret;
00128 }
00129
00133 function locale_update_6002() {
00134   $ret = array();
00135   $ret[] = update_sql("DELETE FROM {locales_target} WHERE translation = ''");
00136   return $ret;
00137 }
00138
00142 function locale_update_6003() {
00143   $ret = array();
00144   $ret[] = update_sql("DELETE FROM {locales_source} WHERE lid NOT IN (SELECT lid FROM {locales_target})");
00145   return $ret;
00146 }
00147
00151 function locale_update_6004() {
00152   $ret = array();
00153   db_add_index($ret, 'locales_target', 'language', array('language'));
00154
00155   switch ($GLOBALS['db_type']) {
00156     case 'pgsql':
00157       db_drop_index($ret, 'locales_source', 'source');
00158       db_add_index($ret, 'locales_source', 'source', array(array('source', 30)));
00159       break;
00160   }
00161
00162   return $ret;
00163 }
00164
00172 function locale_update_6005() {
00173   foreach (node_get_types() as $type => $content_type) {
00174     // Default to NULL, so we can skip dealing with non-existent settings.
00175     $setting = variable_get('language_'. $type, NULL);
00176     if ($type == 'default' && is_numeric($setting)) {
00177       // language_default was overwritten with the content type setting,
00178       // so reset the default language and save the content type setting.
00179       variable_set('language_content_type_default', $setting);
00180       variable_del('language_default');
00181       drupal_set_message('The default language setting has been reset to its default value. Check the '. l('language configuration page', 'admin/settings/language') .' to configure it correctly.');
00182     }
00183     elseif ($type == 'negotiation') {
00184       // language_content_type_negotiation is an integer either if it is
00185       // the negotiation setting or the content type setting.
00186       // The language_negotiation setting is not reset, but
00187       // the user is alerted that this setting possibly was overwritten
00188       variable_set('language_content_type_negotiation', $setting);
00189       drupal_set_message('The language negotiation setting was possibly overwritten by a content type of the same name. Check the '. l('language configuration page', 'admin/settings/language/configure') .' and the '. l('<em>'. $content_type->name ."</em> content type's multilingual support settings", 'admin/content/types/negotiation', array('html' => TRUE)) .' to configure them correctly.');
00190     }
00191     elseif (!is_null($setting)) {
00192       // Change the language setting variable for any other content type.
00193       // Do not worry about language_count, it will be updated below.
00194       variable_set('language_content_type_'. $type, $setting);
00195       variable_del('language_'. $type);
00196     }
00197   }
00198   // Update language count variable that might be overwritten.
00199   $count = db_result(db_query('SELECT COUNT(*) FROM {languages} WHERE enabled = 1'));
00200   variable_set('language_count', $count);
00201   return array();
00202 }
00203
00211 function locale_uninstall() {
00212   // Delete all JavaScript translation files
00213   $files = db_query('SELECT javascript FROM {languages}');
00214   while ($file = db_fetch_object($files)) {
00215     if (!empty($file)) {
00216       file_delete(file_create_path($file->javascript));
00217     }
00218   }
00219
00220   // Remove tables.
00221   drupal_uninstall_schema('locale');
00222 }
00223
00227 function locale_schema() {
00228   $schema['languages'] = array(
00229     'description' => t('List of all available languages in the system.'),
00230     'fields' => array(
00231       'language' => array(
00232         'type' => 'varchar',
00233         'length' => 12,
00234         'not null' => TRUE,
00235         'default' => '',
00236         'description' => t("Language code, e.g. 'de' or 'en-US'."),
00237       ),
00238       'name' => array(
00239         'type' => 'varchar',
00240         'length' => 64,
00241         'not null' => TRUE,
00242         'default' => '',
00243         'description' => t('Language name in English.'),
00244       ),
00245       'native' => array(
00246         'type' => 'varchar',
00247         'length' => 64,
00248         'not null' => TRUE,
00249         'default' => '',
00250         'description' => t('Native language name.'),
00251       ),
00252       'direction' => array(
00253         'type' => 'int',
00254         'not null' => TRUE,
00255         'default' => 0,
00256         'description' => t('Direction of language (Left-to-Right = 0, Right-to-Left = 1).'),
00257       ),
00258       'enabled' => array(
00259         'type' => 'int',
00260         'not null' => TRUE,
00261         'default' => 0,
00262         'description' => t('Enabled flag (1 = Enabled, 0 = Disabled).'),
00263       ),
00264       'plurals' => array(
00265         'type' => 'int',
00266         'not null' => TRUE,
00267         'default' => 0,
00268         'description' => t('Number of plural indexes in this language.'),
00269       ),
00270       'formula' => array(
00271         'type' => 'varchar',
00272         'length' => 128,
00273         'not null' => TRUE,
00274         'default' => '',
00275         'description' => t('Plural formula in PHP code to evaluate to get plural indexes.'),
00276       ),
00277       'domain' => array(
00278         'type' => 'varchar',
00279         'length' => 128,
00280         'not null' => TRUE,
00281         'default' => '',
00282         'description' => t('Domain to use for this language.'),
00283       ),
00284       'prefix' => array(
00285         'type' => 'varchar',
00286         'length' => 128,
00287         'not null' => TRUE,
00288         'default' => '',
00289         'description' => t('Path prefix to use for this language.'),
00290       ),
00291       'weight' => array(
00292         'type' => 'int',
00293         'not null' => TRUE,
00294         'default' => 0,
00295         'description' => t('Weight, used in lists of languages.'),
00296       ),
00297       'javascript' => array(
00298         'type' => 'varchar',
00299         'length' => 32,
00300         'not null' => TRUE,
00301         'default' => '',
00302         'description' => t('Location of JavaScript translation file.'),
00303       ),
00304     ),
00305     'primary key' => array('language'),
00306     'indexes' => array(
00307       'list' => array('weight', 'name'),
00308     ),
00309   );
00310
00311   $schema['locales_source'] = array(
00312     'description' => t('List of English source strings.'),
00313     'fields' => array(
00314       'lid' => array(
00315         'type' => 'serial',
00316         'not null' => TRUE,
00317         'description' => t('Unique identifier of this string.'),
00318       ),
00319       'location' => array(
00320         'type' => 'varchar',
00321         'length' => 255,
00322         'not null' => TRUE,
00323         'default' => '',
00324         'description' => t('Drupal path in case of online discovered translations or file path in case of imported strings.'),
00325       ),
00326       'textgroup' => array(
00327         'type' => 'varchar',
00328         'length' => 255,
00329         'not null' => TRUE,
00330         'default' => 'default',
00331         'description' => t('A module defined group of translations, see hook_locale().'),
00332       ),
00333       'source' => array(
00334         'type' => 'text',
00335         'mysql_type' => 'blob',
00336         'not null' => TRUE,
00337         'description' => t('The original string in English.'),
00338       ),
00339       'version' => array(
00340         'type' => 'varchar',
00341         'length' => 20,
00342         'not null' => TRUE,
00343         'default' => 'none',
00344         'description' => t('Version of Drupal, where the string was last used (for locales optimization).'),
00345       ),
00346     ),
00347     'primary key' => array('lid'),
00348     'indexes' => array(
00349       'source' => array(array('source', 30)),
00350     ),
00351   );
00352
00353   $schema['locales_target'] = array(
00354     'description' => t('Stores translated versions of strings.'),
00355     'fields' => array(
00356       'lid' => array(
00357         'type' => 'int',
00358         'not null' => TRUE,
00359         'default' => 0,
00360         'description' => t('Source string ID. References {locales_source}.lid.'),
00361       ),
00362       'translation' => array(
00363         'type' => 'text',
00364         'mysql_type' => 'blob',
00365         'not null' => TRUE,
00366         'description' => t('Translation string value in this language.'),
00367       ),
00368       'language' => array(
00369         'type' => 'varchar',
00370         'length' => 12,
00371         'not null' => TRUE,
00372         'default' => '',
00373         'description' => t('Language code. References {languages}.language.'),
00374       ),
00375       'plid' => array(
00376         'type' => 'int',
00377         'not null' => TRUE, // This should be NULL for no referenced string, not zero.
00378         'default' => 0,
00379         'description' => t('Parent lid (lid of the previous string in the plural chain) in case of plural strings. References {locales_source}.lid.'),
00380       ),
00381       'plural' => array(
00382         'type' => 'int',
00383         'not null' => TRUE,
00384         'default' => 0,
00385         'description' => t('Plural index number in case of plural strings.'),
00386       ),
00387     ),
00388     'primary key' => array('language', 'lid', 'plural'),
00389     'indexes' => array(
00390       'lid'      => array('lid'),
00391       'plid'     => array('plid'),
00392       'plural'   => array('plural'),
00393     ),
00394   );
00395
00396   return $schema;
00397 }
00398
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/locale/locale.module Source File

modules » locale

locale.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: locale.module,v 1.212 2008/01/28 17:16:34 goba Exp $
00003
00018 define('LANGUAGE_LTR', 0);
00019
00023 define('LANGUAGE_RTL', 1);
00024
00025
00026 // ---------------------------------------------------------------------------------
00027 // Hook implementations
00028
00032 function locale_help($path, $arg) {
00033   switch ($path) {
00034     case 'admin/help#locale':
00035       $output = '<p>'. t('The locale module allows your Drupal site to be presented in languages other than the default English, a defining feature of multi-lingual websites. The locale module works by examining text as it is about to be displayed: when a translation of the text is available in the language to be displayed, the translation is displayed rather than the original text. When a translation is unavailable, the original text is displayed, and then stored for later review by a translator.') .'</p>';
00036       $output .= '<p>'. t('Beyond translation of the Drupal interface, the locale module provides a feature set tailored to the needs of a multi-lingual site. Language negotiation allows your site to automatically change language based on the domain or path used for each request. Users may (optionally) select their preferred language on their <em>My account</em> page, and your site can be configured to honor a web browser\'s preferred language settings. Your site content can be created in (and translated to) any enabled language, and each post may have a language-appropriate alias for each of its translations. The locale module works in concert with the <a href="@content-help">content translation module</a> to manage translated content.', array('@content-help' => url('admin/help/translation'))) .'</p>';
00037       $output .= '<p>'. t('Translations may be provided by:') .'</p>';
00038       $output .= '<ul><li>'. t("translating the original text via the locale module's integrated web interface, or") .'</li>';
00039       $output .= '<li>'. t('importing files from a set of existing translations, known as a translation package. A translation package enables the display of a specific version of Drupal in a specific language, and contain files in the Gettext Portable Object (<em>.po</em>) format. Although not all languages are available for every version of Drupal, translation packages for many languages are available for download from the <a href="@translations">Drupal translation page</a>.', array('@translations' => 'http://drupal.org/project/translations')) .'</li></ul>';
00040       $output .= '<p>'. t('If an existing translation package does not meet your needs, the Gettext Portable Object (<em>.po</em>) files within a package may be modified, or new <em>.po</em> files may be created, using a desktop Gettext editor. The locale module\'s <a href="@import">import</a> feature allows the translated strings from a new or modified <em>.po</em> file to be added to your site. The locale module\'s <a href="@export">export</a> feature generates files from your site\'s translated strings, that can either be shared with others or edited offline by a Gettext translation editor.', array('@import' => url('admin/build/translate/import'), '@export' => url('admin/build/translate/export'))) .'</p>';
00041       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@locale">Locale module</a>.', array('@locale' => 'http://drupal.org/handbook/modules/locale/')) .'</p>';
00042       return $output;
00043     case 'admin/settings/language':
00044       $output = '<p>'. t("This page provides an overview of your site's enabled languages. If multiple languages are available and enabled, the text on your site interface may be translated, registered users may select their preferred language on the <em>My account</em> page, and site authors may indicate a specific language when creating posts. The site's default language is used for anonymous visitors and for users who have not selected a preferred language.") .'</p>';
00045       $output .= '<p>'. t('For each language available on the site, use the <em>edit</em> link to configure language details, including name, an optional language-specific path or domain, and whether the language is natively presented either left-to-right or right-to-left. These languages also appear in the <em>Language</em> selection when creating a post of a content type with multilingual support.') .'</p>';
00046       $output .= '<p>'. t('Use the <a href="@add-language">add language page</a> to enable additional languages (and automatically import files from a translation package, if available), the <a href="@search">translate interface page</a> to locate strings for manual translation, or the <a href="@import">import page</a> to add translations from individual <em>.po</em> files. A number of contributed translation packages containing <em>.po</em> files are available on the <a href="@translations">Drupal.org translations page</a>.', array('@add-language' => url('admin/settings/language/add'), '@search' => url('admin/build/translate/search'), '@import' => url('admin/build/translate/import'), '@translations' => 'http://drupal.org/project/translations')) .'</p>';
00047       return $output;
00048     case 'admin/settings/language/add':
00049       return '<p>'. t('Add all languages to be supported by your site. If your desired language is not available in the <em>Language name</em> drop-down, click <em>Custom language</em> and provide a language code and other details manually. When providing a language code manually, be sure to enter a standardized language code, since this code may be used by browsers to determine an appropriate display language.') .'</p>';
00050     case 'admin/settings/language/configure':
00051       $output = '<p>'. t("Language negotiation settings determine the site's presentation language. Available options include:") .'</p>';
00052       $output .= '<ul><li>'. t('<strong>None.</strong> The default language is used for site presentation, though users may (optionally) select a preferred language on the <em>My Account</em> page. (User language preferences will be used for site e-mails, if available.)') .'</li>';
00053       $output .= '<li>'. t('<strong>Path prefix only.</strong> The presentation language is determined by examining the path for a language code or other custom string that matches the path prefix (if any) specified for each language. If a suitable prefix is not identified, the default language is used. <em>Example: "example.com/de/contact" sets presentation language to German based on the use of "de" within the path.</em>') .'</li>';
00054       $output .= '<li>'. t("<strong>Path prefix with language fallback.</strong> The presentation language is determined by examining the path for a language code or other custom string that matches the path prefix (if any) specified for each language. If a suitable prefix is not identified, the display language is determined by the user's language preferences from the <em>My Account</em> page, or by the browser's language settings. If a presentation language cannot be determined, the default language is used.") .'</t>';
00055       $output .= '<li>'. t('<strong>Domain name only.</strong> The presentation language is determined by examining the domain used to access the site, and comparing it to the language domain (if any) specified for each language. If a match is not identified, the default language is used. <em>Example: "http://de.example.com/contact" sets presentation language to German based on the use of "http://de.example.com" in the domain.</em>') .'</li></ul>';
00056       $output .= '<p>'. t('The path prefix or domain name for a language may be set by editing the <a href="@languages">available languages</a>. In the absence of an appropriate match, the site is displayed in the <a href="@languages">default language</a>.', array('@languages' => url('admin/settings/language'))) .'</p>';
00057       return $output;
00058     case 'admin/build/translate':
00059       $output = '<p>'. t('This page provides an overview of available translatable strings. Drupal displays translatable strings in text groups; modules may define additional text groups containing other translatable strings. Because text groups provide a method of grouping related strings, they are often used to focus translation efforts on specific areas of the Drupal interface.') .'</p>';
00060       $output .= '<p>'. t('Review the <a href="@languages">languages page</a> for more information on adding support for additional languages.', array('@languages' => url('admin/settings/language'))) .'</p>';
00061       return $output;
00062     case 'admin/build/translate/import':
00063       $output = '<p>'. t('This page imports the translated strings contained in an individual Gettext Portable Object (<em>.po</em>) file. Normally distributed as part of a translation package (each translation package may contain several <em>.po</em> files), a <em>.po</em> file may need to be imported after off-line editing in a Gettext translation editor. Importing an individual <em>.po</em> file may be a lengthy process.') .'</p>';
00064       $output .= '<p>'. t('Note that the <em>.po</em> files within a translation package are imported automatically (if available) when new modules or themes are enabled, or as new languages are added. Since this page only allows the import of one <em>.po</em> file at a time, it may be simpler to download and extract a translation package into your Drupal installation directory and <a href="@language-add">add the language</a> (which automatically imports all <em>.po</em> files within the package). Translation packages are available for download on the <a href="@translations">Drupal translation page</a>.', array('@language-add' => url('admin/settings/language/add'), '@translations' => 'http://drupal.org/project/translations')) .'</p>';
00065       return $output;
00066     case 'admin/build/translate/export':
00067       return '<p>'. t('This page exports the translated strings used by your site. An export file may be in Gettext Portable Object (<em>.po</em>) form, which includes both the original string and the translation (used to share translations with others), or in Gettext Portable Object Template (<em>.pot</em>) form, which includes the original strings only (used to create new translations with a Gettext translation editor).') .'</p>';
00068     case 'admin/build/translate/search':
00069       return '<p>'. t('This page allows a translator to search for specific translated and untranslated strings, and is used when creating or editing translations. (Note: For translation tasks involving many strings, it may be more convenient to <a href="@export">export</a> strings for off-line editing in a desktop Gettext translation editor.) Searches may be limited to strings found within a specific text group or in a specific language.', array('@export' => url('admin/build/translate/export'))) .'</p>';
00070     case 'admin/build/block/configure':
00071       if ($arg[4] == 'locale' && $arg[5] == 0) {
00072         return '<p>'. t('This block is only shown if <a href="@languages">at least two languages are enabled</a> and <a href="@configuration">language negotiation</a> is set to something other than <em>None</em>.', array('@languages' => url('admin/settings/language'), '@configuration' => url('admin/settings/language/configure'))) .'</p>';
00073       }
00074       break;
00075   }
00076 }
00077
00084 function locale_menu() {
00085   // Manage languages
00086   $items['admin/settings/language'] = array(
00087     'title' => 'Languages',
00088     'description' => 'Configure languages for content and the user interface.',
00089     'page callback' => 'locale_inc_callback',
00090     'page arguments' => array('drupal_get_form', 'locale_languages_overview_form'),
00091     'access arguments' => array('administer languages'),
00092   );
00093   $items['admin/settings/language/overview'] = array(
00094     'title' => 'List',
00095     'weight' => 0,
00096     'type' => MENU_DEFAULT_LOCAL_TASK,
00097   );
00098   $items['admin/settings/language/add'] = array(
00099     'title' => 'Add language',
00100     'page callback' => 'locale_inc_callback',
00101     'page arguments' => array('locale_languages_add_screen'), // two forms concatenated
00102     'weight' => 5,
00103     'type' => MENU_LOCAL_TASK,
00104   );
00105   $items['admin/settings/language/configure'] = array(
00106     'title' => 'Configure',
00107     'page callback' => 'locale_inc_callback',
00108     'page arguments' => array('drupal_get_form', 'locale_languages_configure_form'),
00109     'weight' => 10,
00110     'type' => MENU_LOCAL_TASK,
00111   );
00112   $items['admin/settings/language/edit/%'] = array(
00113     'title' => 'Edit language',
00114     'page callback' => 'locale_inc_callback',
00115     'page arguments' => array('drupal_get_form', 'locale_languages_edit_form', 4),
00116     'type' => MENU_CALLBACK,
00117   );
00118   $items['admin/settings/language/delete/%'] = array(
00119     'title' => 'Confirm',
00120     'page callback' => 'locale_inc_callback',
00121     'page arguments' => array('drupal_get_form', 'locale_languages_delete_form', 4),
00122     'type' => MENU_CALLBACK,
00123   );
00124
00125   // Translation functionality
00126   $items['admin/build/translate'] = array(
00127     'title' => 'Translate interface',
00128     'description' => 'Translate the built in interface and optionally other text.',
00129     'page callback' => 'locale_inc_callback',
00130     'page arguments' => array('locale_translate_overview_screen'), // not a form, just a table
00131     'access arguments' => array('translate interface'),
00132   );
00133   $items['admin/build/translate/overview'] = array(
00134     'title' => 'Overview',
00135     'weight' => 0,
00136     'type' => MENU_DEFAULT_LOCAL_TASK,
00137   );
00138   $items['admin/build/translate/search'] = array(
00139     'title' => 'Search',
00140     'weight' => 10,
00141     'type' => MENU_LOCAL_TASK,
00142     'page callback' => 'locale_inc_callback',
00143     'page arguments' => array('locale_translate_seek_screen'), // search results and form concatenated
00144   );
00145   $items['admin/build/translate/import'] = array(
00146     'title' => 'Import',
00147     'page callback' => 'locale_inc_callback',
00148     'page arguments' => array('drupal_get_form', 'locale_translate_import_form'),
00149     'weight' => 20,
00150     'type' => MENU_LOCAL_TASK,
00151   );
00152   $items['admin/build/translate/export'] = array(
00153     'title' => 'Export',
00154     'page callback' => 'locale_inc_callback',
00155     'page arguments' => array('locale_translate_export_screen'), // possibly multiple forms concatenated
00156     'weight' => 30,
00157     'type' => MENU_LOCAL_TASK,
00158   );
00159   $items['admin/build/translate/edit/%'] = array(
00160     'title' => 'Edit string',
00161     'page callback' => 'locale_inc_callback',
00162     'page arguments' => array('drupal_get_form', 'locale_translate_edit_form', 4),
00163     'type' => MENU_CALLBACK,
00164   );
00165   $items['admin/build/translate/delete/%'] = array(
00166     'title' => 'Delete string',
00167     'page callback' => 'locale_inc_callback',
00168     'page arguments' => array('locale_translate_delete', 4),  // directly deletes, no confirmation
00169     'type' => MENU_CALLBACK,
00170   );
00171
00172   return $items;
00173 }
00174
00178 function locale_inc_callback() {
00179   $args = func_get_args();
00180   $function = array_shift($args);
00181   include_once './includes/locale.inc';
00182   return call_user_func_array($function, $args);
00183 }
00184
00188 function locale_perm() {
00189   return array('administer languages', 'translate interface');
00190 }
00191
00195 function locale_locale($op = 'groups') {
00196   switch ($op) {
00197     case 'groups':
00198       return array('default' => t('Built-in interface'));
00199   }
00200 }
00201
00205 function locale_user($type, $edit, &$user, $category = NULL) {
00206   global $language;
00207
00208   // If we have more then one language and either creating a user on the
00209   // admin interface or edit the user, show the language selector.
00210   if (variable_get('language_count', 1) > 1 && ($type == 'register' && user_access('administer users') || $type == 'form' && $category == 'account' )) {
00211     $languages = language_list('enabled');
00212     $languages = $languages[1];
00213
00214     // If the user is being created, we set the user language to the page language.
00215     $user_preferred_language = $user ? user_preferred_language($user) : $language;
00216
00217     $names = array();
00218     foreach ($languages as $langcode => $item) {
00219       $name = t($item->name);
00220       $names[$langcode] = $name . ($item->native != $name ? ' ('. $item->native .')' : '');
00221     }
00222     $form['locale'] = array(
00223       '#type' => 'fieldset',
00224       '#title' => t('Language settings'),
00225       '#weight' => 1,
00226     );
00227
00228     // Get language negotiation settings.
00229     $mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE);
00230     $form['locale']['language'] = array(
00231       '#type' => (count($names) <= 5 ? 'radios' : 'select'),
00232       '#title' => t('Language'),
00233       '#default_value' => $user_preferred_language->language,
00234       '#options' => $names,
00235       '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? t("This account's default language for e-mails, and preferred language for site presentation.") : t("This account's default language for e-mails."),
00236     );
00237     return $form;
00238   }
00239 }
00240
00244 function locale_form_alter(&$form, $form_state, $form_id) {
00245   switch ($form_id) {
00246
00247     // Language field for paths
00248     case 'path_admin_form':
00249       $form['language'] = array(
00250         '#type' => 'select',
00251         '#title' => t('Language'),
00252         '#options' => array('' => t('All languages')) + locale_language_list('name'),
00253         '#default_value' => $form['language']['#value'],
00254         '#weight' => -10,
00255         '#description' => t('A path alias set for a specific language will always be used when displaying this page in that language, and takes precedence over path aliases set for <am>All languages</em>.'),
00256       );
00257       break;
00258
00259     // Language setting for content types
00260     case 'node_type_form':
00261       if (isset($form['identity']['type'])) {
00262         $form['workflow']['language_content_type'] = array(
00263           '#type' => 'radios',
00264           '#title' => t('Multilingual support'),
00265           '#default_value' => variable_get('language_content_type_'. $form['#node_type']->type, 0),
00266           '#options' => array(t('Disabled'), t('Enabled')),
00267           '#description' => t('Enable multilingual support for this content type. If enabled, a language selection field will be added to the editing form, allowing you to select from one of the <a href="!languages">enabled languages</a>. If disabled, new posts are saved with the default language. Existing content will not be affected by changing this option.', array('!languages' => url('admin/settings/language'))),
00268         );
00269       }
00270       break;
00271
00272     // Language field for nodes
00273     default:
00274       if (isset($form['#id']) && $form['#id'] == 'node-form') {
00275         if (isset($form['#node']->type) && variable_get('language_content_type_'. $form['#node']->type, 0)) {
00276           $form['language'] = array(
00277             '#type' => 'select',
00278             '#title' => t('Language'),
00279             '#default_value' => (isset($form['#node']->language) ? $form['#node']->language : ''),
00280             '#options' => array('' => t('Language neutral')) + locale_language_list('name'),
00281           );
00282         }
00283         // Node type without language selector: assign the default for new nodes
00284         elseif (!isset($form['#node']->nid)) {
00285           $default = language_default();
00286           $form['language'] = array(
00287             '#type' => 'value',
00288             '#value' => $default->language
00289           );
00290         }
00291       }
00292   }
00293 }
00294
00298 function locale_theme() {
00299   return array(
00300     'locale_languages_overview_form' => array(
00301       'arguments' => array('form' => array()),
00302     ),
00303   );
00304 }
00305
00306 // ---------------------------------------------------------------------------------
00307 // Locale core functionality
00308
00323 function locale($string = NULL, $langcode = NULL, $reset = FALSE) {
00324   global $language;
00325   static $locale_t;
00326
00327   if ($reset) {
00328     // Reset in-memory cache.
00329     $locale_t = NULL;
00330   }
00331
00332   if (!isset($string)) {
00333     // Return all cached strings if no string was specified
00334     return $locale_t;
00335   }
00336
00337   $langcode = isset($langcode) ? $langcode : $language->language;
00338
00339   // Store database cached translations in a static var.
00340   if (!isset($locale_t[$langcode])) {
00341     $locale_t[$langcode] = array();
00342     // Disabling the usage of string caching allows a module to watch for
00343     // the exact list of strings used on a page. From a performance
00344     // perspective that is a really bad idea, so we have no user
00345     // interface for this. Be careful when turning this option off!
00346     if (variable_get('locale_cache_strings', 1) == 1) {
00347       if ($cache = cache_get('locale:'. $langcode, 'cache')) {
00348         $locale_t[$langcode] = $cache->data;
00349       }
00350       else {
00351         // Refresh database stored cache of translations for given language.
00352         // We only store short strings used in current version, to improve
00353         // performance and consume less memory.
00354         $result = db_query("SELECT s.source, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.textgroup = 'default' AND s.version = '%s' AND LENGTH(s.source) < 75", $langcode, VERSION);
00355         while ($data = db_fetch_object($result)) {
00356           $locale_t[$langcode][$data->source] = (empty($data->translation) ? TRUE : $data->translation);
00357         }
00358         cache_set('locale:'. $langcode, $locale_t[$langcode]);
00359       }
00360     }
00361   }
00362
00363   // If we have the translation cached, skip checking the database
00364   if (!isset($locale_t[$langcode][$string])) {
00365
00366     // We do not have this translation cached, so get it from the DB.
00367     $translation = db_fetch_object(db_query("SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.source = '%s' AND s.textgroup = 'default'", $langcode, $string));
00368     if ($translation) {
00369       // We have the source string at least.
00370       // Cache translation string or TRUE if no translation exists.
00371       $locale_t[$langcode][$string] = (empty($translation->translation) ? TRUE : $translation->translation);
00372
00373       if ($translation->version != VERSION) {
00374         // This is the first use of this string under current Drupal version. Save version
00375         // and clear cache, to include the string into caching next time. Saved version is
00376         // also a string-history information for later pruning of the tables.
00377         db_query("UPDATE {locales_source} SET version = '%s' WHERE lid = %d", VERSION, $translation->lid);
00378         cache_clear_all('locale:', 'cache', TRUE);
00379       }
00380     }
00381     else {
00382       // We don't have the source string, cache this as untranslated.
00383       db_query("INSERT INTO {locales_source} (location, source, textgroup, version) VALUES ('%s', '%s', 'default', '%s')", request_uri(), $string, VERSION);
00384       $locale_t[$langcode][$string] = TRUE;
00385       // Clear locale cache so this string can be added in a later request.
00386       cache_clear_all('locale:', 'cache', TRUE);
00387     }
00388   }
00389
00390   return ($locale_t[$langcode][$string] === TRUE ? $string : $locale_t[$langcode][$string]);
00391 }
00392
00404 function locale_get_plural($count, $langcode = NULL) {
00405   global $language;
00406   static $locale_formula, $plurals = array();
00407
00408   $langcode = $langcode ? $langcode : $language->language;
00409
00410   if (!isset($plurals[$langcode][$count])) {
00411     if (!isset($locale_formula)) {
00412       $language_list = language_list();
00413       $locale_formula[$langcode] = $language_list[$langcode]->formula;
00414     }
00415     if ($locale_formula[$langcode]) {
00416       $n = $count;
00417       $plurals[$langcode][$count] = @eval('return intval('. $locale_formula[$langcode] .');');
00418       return $plurals[$langcode][$count];
00419     }
00420     else {
00421       $plurals[$langcode][$count] = -1;
00422       return -1;
00423     }
00424   }
00425   return $plurals[$langcode][$count];
00426 }
00427
00428
00432 function locale_language_name($lang) {
00433   static $list = NULL;
00434   if (!isset($list)) {
00435     $list = locale_language_list();
00436   }
00437   return ($lang && isset($list[$lang])) ? $list[$lang] : t('All');
00438 }
00439
00449 function locale_language_list($field = 'name', $all = FALSE) {
00450   if ($all) {
00451     $languages = language_list();
00452   }
00453   else {
00454     $languages = language_list('enabled');
00455     $languages = $languages[1];
00456   }
00457   $list = array();
00458   foreach ($languages as $language) {
00459     $list[$language->language] = ($field == 'name') ? t($language->name) : $language->$field;
00460   }
00461   return $list;
00462 }
00463
00474 function locale_system_update($components) {
00475   include_once 'includes/locale.inc';
00476   if ($batch = locale_batch_by_component($components)) {
00477     batch_set($batch);
00478   }
00479 }
00480
00489 function locale_update_js_files() {
00490   global $language;
00491
00492   $dir = file_create_path(variable_get('locale_js_directory', 'languages'));
00493   $parsed = variable_get('javascript_parsed', array());
00494
00495   // The first three parameters are NULL in order to get an array with all
00496   // scopes. This is necessary to prevent recreation of JS translation files
00497   // when new files are added for example in the footer.
00498   $javascript = drupal_add_js(NULL, NULL, NULL);
00499   $files = $new_files = FALSE;
00500
00501   foreach ($javascript as $scope) {
00502     foreach ($scope as $type => $data) {
00503       if ($type != 'setting' && $type != 'inline') {
00504         foreach ($data as $filepath => $info) {
00505           $files = TRUE;
00506           if (!in_array($filepath, $parsed)) {
00507             // Don't parse our own translations files.
00508             if (substr($filepath, 0, strlen($dir)) != $dir) {
00509               locale_inc_callback('_locale_parse_js_file', $filepath);
00510               watchdog('locale', 'Parsed JavaScript file %file.', array('%file' => $filepath));
00511               $parsed[] = $filepath;
00512               $new_files = TRUE;
00513             }
00514           }
00515         }
00516       }
00517     }
00518   }
00519
00520   // If there are any new source files we parsed, invalidate existing
00521   // JavaScript translation files for all languages, adding the refresh
00522   // flags into the existing array.
00523   if ($new_files) {
00524     $parsed += locale_inc_callback('_locale_invalidate_js');
00525   }
00526
00527   // If necessary, rebuild the translation file for the current language.
00528   if (!empty($parsed['refresh:'. $language->language])) {
00529     // Don't clear the refresh flag on failure, so that another try will
00530     // be performed later.
00531     if (locale_inc_callback('_locale_rebuild_js')) {
00532       unset($parsed['refresh:'. $language->language]);
00533     }
00534     // Store any changes after refresh was attempted.
00535     variable_set('javascript_parsed', $parsed);
00536   }
00537   // If no refresh was attempted, but we have new source files, we need
00538   // to store them too. This occurs if current page is in English.
00539   else if ($new_files) {
00540     variable_set('javascript_parsed', $parsed);
00541   }
00542
00543   // Add the translation JavaScript file to the page.
00544   if ($files && !empty($language->javascript)) {
00545     drupal_add_js($dir .'/'. $language->language .'_'. $language->javascript .'.js', 'core');
00546   }
00547 }
00548
00549 // ---------------------------------------------------------------------------------
00550 // Language switcher block
00551
00556 function locale_block($op = 'list', $delta = 0) {
00557   if ($op == 'list') {
00558     $block[0]['info'] = t('Language switcher');
00559     // Not worth caching.
00560     $block[0]['cache'] = BLOCK_NO_CACHE;
00561     return $block;
00562   }
00563
00564   // Only show if we have at least two languages and language dependent
00565   // web addresses, so we can actually link to other language versions.
00566   elseif ($op == 'view' && variable_get('language_count', 1) > 1 && variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE) != LANGUAGE_NEGOTIATION_NONE) {
00567     $languages = language_list('enabled');
00568     $links = array();
00569     foreach ($languages[1] as $language) {
00570       $links[$language->language] = array(
00571         'href'       => $_GET['q'],
00572         'title'      => $language->native,
00573         'language'   => $language,
00574         'attributes' => array('class' => 'language-link'),
00575       );
00576     }
00577
00578     // Allow modules to provide translations for specific links.
00579     // A translation link may need to point to a different path or use
00580     // a translated link text before going through l(), which will just
00581     // handle the path aliases.
00582     drupal_alter('translation_link', $links, $_GET['q']);
00583
00584     $block['subject'] = t('Languages');
00585     $block['content'] = theme('links', $links, array());
00586     return $block;
00587   }
00588 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/mail.inc Source File

includes

mail.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: mail.inc,v 1.8 2008/01/25 17:04:00 goba Exp $
00003
00083 function drupal_mail($module, $key, $to, $language, $params = array(), $from = NULL, $send = TRUE) {
00084   $default_from = variable_get('site_mail', ini_get('sendmail_from'));
00085
00086   // Bundle up the variables into a structured array for altering.
00087   $message = array(
00088     'id'       => $module .'_'. $key,
00089     'to'       => $to,
00090     'from'     => isset($from) ? $from : $default_from,
00091     'language' => $language,
00092     'params'   => $params,
00093     'subject'  => '',
00094     'body'     => array()
00095   );
00096
00097   // Build the default headers
00098   $headers = array(
00099     'MIME-Version'              => '1.0',
00100     'Content-Type'              => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
00101     'Content-Transfer-Encoding' => '8Bit',
00102     'X-Mailer'                  => 'Drupal'
00103   );
00104   if ($default_from) {
00105     // To prevent e-mail from looking like spam, the addresses in the Sender and
00106     // Return-Path headers should have a domain authorized to use the originating
00107     // SMTP server. Errors-To is redundant, but shouldn't hurt.
00108     $headers['From'] = $headers['Reply-To'] = $headers['Sender'] = $headers['Return-Path'] = $headers['Errors-To'] = $default_from;
00109   }
00110   if ($from) {
00111     $headers['From'] = $headers['Reply-To'] = $from;
00112   }
00113   $message['headers'] = $headers;
00114
00115   // Build the e-mail (get subject and body, allow additional headers) by
00116   // invoking hook_mail() on this module. We cannot use module_invoke() as
00117   // we need to have $message by reference in hook_mail().
00118   if (function_exists($function = $module .'_mail')) {
00119     $function($key, $message, $params);
00120   }
00121
00122   // Invoke hook_mail_alter() to allow all modules to alter the resulting e-mail.
00123   drupal_alter('mail', $message);
00124
00125   // Concatenate and wrap the e-mail body.
00126   $message['body'] = is_array($message['body']) ? drupal_wrap_mail(implode("\n\n", $message['body'])) : drupal_wrap_mail($message['body']);
00127
00128   // Optionally send e-mail.
00129   if ($send) {
00130     $message['result'] = drupal_mail_send($message);
00131
00132     // Log errors
00133     if (!$message['result']) {
00134       watchdog('mail', 'Error sending e-mail (from %from to %to).', array('%from' => $message['from'], '%to' => $message['to']), WATCHDOG_ERROR);
00135       drupal_set_message(t('Unable to send e-mail. Please contact the site admin, if the problem persists.'), 'error');
00136     }
00137   }
00138
00139   return $message;
00140 }
00141
00173 function drupal_mail_send($message) {
00174   // Allow for a custom mail backend.
00175   if (variable_get('smtp_library', '') && file_exists(variable_get('smtp_library', ''))) {
00176     include_once './'. variable_get('smtp_library', '');
00177     return drupal_mail_wrapper($message);
00178   }
00179   else {
00180     $mimeheaders = array();
00181     foreach ($message['headers'] as $name => $value) {
00182       $mimeheaders[] = $name .': '. mime_header_encode($value);
00183     }
00184     return mail(
00185       $message['to'],
00186       mime_header_encode($message['subject']),
00187       // Note: e-mail uses CRLF for line-endings, but PHP's API requires LF.
00188       // They will appear correctly in the actual e-mail that is sent.
00189       str_replace("\r", '', $message['body']),
00190       join("\n", $mimeheaders)
00191     );
00192   }
00193 }
00194
00209 function drupal_wrap_mail($text, $indent = '') {
00210   // Convert CRLF into LF.
00211   $text = str_replace("\r", '', $text);
00212   // See if soft-wrapping is allowed.
00213   $clean_indent = _drupal_html_to_text_clean($indent);
00214   $soft = strpos($clean_indent, ' ') === FALSE;
00215   // Check if the string has line breaks.
00216   if (strpos($text, "\n") !== FALSE) {
00217     // Remove trailing spaces to make existing breaks hard.
00218     $text = preg_replace('/ +\n/m', "\n", $text);
00219     // Wrap each line at the needed width.
00220     $lines = explode("\n", $text);
00221     array_walk($lines, '_drupal_wrap_mail_line', array('soft' => $soft, 'length' => strlen($indent)));
00222     $text = implode("\n", $lines);
00223   }
00224   else {
00225     // Wrap this line.
00226     _drupal_wrap_mail_line($text, 0, array('soft' => $soft, 'length' => strlen($indent)));
00227   }
00228   // Empty lines with nothing but spaces.
00229   $text = preg_replace('/^ +\n/m', "\n", $text);
00230   // Space-stuff special lines.
00231   $text = preg_replace('/^(>| |From)/m', ' $1', $text);
00232   // Apply indentation. We only include non-'>' indentation on the first line.
00233   $text = $indent . substr(preg_replace('/^/m', $clean_indent, $text), strlen($indent));
00234
00235   return $text;
00236 }
00237
00259 function drupal_html_to_text($string, $allowed_tags = NULL) {
00260   // Cache list of supported tags.
00261   static $supported_tags;
00262   if (empty($supported_tags)) {
00263     $supported_tags = array('a', 'em', 'i', 'strong', 'b', 'br', 'p', 'blockquote', 'ul', 'ol', 'li', 'dl', 'dt', 'dd', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr');
00264   }
00265
00266   // Make sure only supported tags are kept.
00267   $allowed_tags = isset($allowed_tags) ? array_intersect($supported_tags, $allowed_tags) : $supported_tags;
00268
00269   // Make sure tags, entities and attributes are well-formed and properly nested.
00270   $string = _filter_htmlcorrector(filter_xss($string, $allowed_tags));
00271
00272   // Apply inline styles.
00273   $string = preg_replace('!</?(em|i)>!i', '/', $string);
00274   $string = preg_replace('!</?(strong|b)>!i', '*', $string);
00275
00276   // Replace inline <a> tags with the text of link and a footnote.
00277   // 'See <a href="http://drupal.org">the Drupal site</a>' becomes
00278   // 'See the Drupal site [1]' with the URL included as a footnote.
00279   _drupal_html_to_mail_urls(NULL, TRUE);
00280   $pattern = '@(<a[^>]+?href="([^"]*)"[^>]*?>(.+?)</a>)@i';
00281   $string = preg_replace_callback($pattern, '_drupal_html_to_mail_urls', $string);
00282   $urls = _drupal_html_to_mail_urls();
00283   $footnotes = '';
00284   if (count($urls)) {
00285     $footnotes .= "\n";
00286     for ($i = 0, $max = count($urls); $i < $max; $i++) {
00287       $footnotes .= '['. ($i + 1) .'] '. $urls[$i] ."\n";
00288     }
00289   }
00290
00291   // Split tags from text.
00292   $split = preg_split('/<([^>]+?)>/', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
00293   // Note: PHP ensures the array consists of alternating delimiters and literals
00294   // and begins and ends with a literal (inserting $null as required).
00295
00296   $tag = FALSE; // Odd/even counter (tag or no tag)
00297   $casing = NULL; // Case conversion function
00298   $output = '';
00299   $indent = array(); // All current indentation string chunks
00300   $lists = array(); // Array of counters for opened lists
00301   foreach ($split as $value) {
00302     $chunk = NULL; // Holds a string ready to be formatted and output.
00303
00304     // Process HTML tags (but don't output any literally).
00305     if ($tag) {
00306       list($tagname) = explode(' ', strtolower($value), 2);
00307       switch ($tagname) {
00308         // List counters
00309         case 'ul':
00310           array_unshift($lists, '*');
00311           break;
00312         case 'ol':
00313           array_unshift($lists, 1);
00314           break;
00315         case '/ul':
00316         case '/ol':
00317           array_shift($lists);
00318           $chunk = ''; // Ensure blank new-line.
00319           break;
00320
00321         // Quotation/list markers, non-fancy headers
00322         case 'blockquote':
00323           // Format=flowed indentation cannot be mixed with lists.
00324           $indent[] = count($lists) ? ' "' : '>';
00325           break;
00326         case 'li':
00327           $indent[] = is_numeric($lists[0]) ? ' '. $lists[0]++ .') ' : ' * ';
00328           break;
00329         case 'dd':
00330           $indent[] = '    ';
00331           break;
00332         case 'h3':
00333           $indent[] = '.... ';
00334           break;
00335         case 'h4':
00336           $indent[] = '.. ';
00337           break;
00338         case '/blockquote':
00339           if (count($lists)) {
00340             // Append closing quote for inline quotes (immediately).
00341             $output = rtrim($output, "> \n") ."\"\n";
00342             $chunk = ''; // Ensure blank new-line.
00343           }
00344           // Fall-through
00345         case '/li':
00346         case '/dd':
00347           array_pop($indent);
00348           break;
00349         case '/h3':
00350         case '/h4':
00351           array_pop($indent);
00352         case '/h5':
00353         case '/h6':
00354           $chunk = ''; // Ensure blank new-line.
00355           break;
00356
00357         // Fancy headers
00358         case 'h1':
00359           $indent[] = '======== ';
00360           $casing = 'drupal_strtoupper';
00361           break;
00362         case 'h2':
00363           $indent[] = '-------- ';
00364           $casing = 'drupal_strtoupper';
00365           break;
00366         case '/h1':
00367         case '/h2':
00368           $casing = NULL;
00369           // Pad the line with dashes.
00370           $output = _drupal_html_to_text_pad($output, ($tagname == '/h1') ? '=' : '-', ' ');
00371           array_pop($indent);
00372           $chunk = ''; // Ensure blank new-line.
00373           break;
00374
00375         // Horizontal rulers
00376         case 'hr':
00377           // Insert immediately.
00378           $output .= drupal_wrap_mail('', implode('', $indent)) ."\n";
00379           $output = _drupal_html_to_text_pad($output, '-');
00380           break;
00381
00382         // Paragraphs and definition lists
00383         case '/p':
00384         case '/dl':
00385           $chunk = ''; // Ensure blank new-line.
00386           break;
00387       }
00388     }
00389     // Process blocks of text.
00390     else {
00391       // Convert inline HTML text to plain text.
00392       $value = trim(preg_replace('/\s+/', ' ', decode_entities($value)));
00393       if (strlen($value)) {
00394         $chunk = $value;
00395       }
00396     }
00397
00398     // See if there is something waiting to be output.
00399     if (isset($chunk)) {
00400       // Apply any necessary case conversion.
00401       if (isset($casing)) {
00402         $chunk = $casing($chunk);
00403       }
00404       // Format it and apply the current indentation.
00405       $output .= drupal_wrap_mail($chunk, implode('', $indent)) ."\n";
00406       // Remove non-quotation markers from indentation.
00407       $indent = array_map('_drupal_html_to_text_clean', $indent);
00408     }
00409
00410     $tag = !$tag;
00411   }
00412
00413   return $output . $footnotes;
00414 }
00415
00421 function _drupal_wrap_mail_line(&$line, $key, $values) {
00422   // Use soft-breaks only for purely quoted or unindented text.
00423   $line = wordwrap($line, 77 - $values['length'], $values['soft'] ? "  \n" : "\n");
00424   // Break really long words at the maximum width allowed.
00425   $line = wordwrap($line, 996 - $values['length'], $values['soft'] ? " \n" : "\n");
00426 }
00427
00433 function _drupal_html_to_mail_urls($match = NULL, $reset = FALSE) {
00434   global $base_url, $base_path;
00435   static $urls = array(), $regexp;
00436
00437   if ($reset) {
00438     // Reset internal URL list.
00439     $urls = array();
00440   }
00441   else {
00442     if (empty($regexp)) {
00443       $regexp = '@^'. preg_quote($base_path, '@') .'@';
00444     }
00445     if ($match) {
00446       list(, , $url, $label) = $match;
00447       // Ensure all URLs are absolute.
00448       $urls[] = strpos($url, '://') ? $url : preg_replace($regexp, $base_url .'/', $url);
00449       return $label .' ['. count($urls) .']';
00450     }
00451   }
00452   return $urls;
00453 }
00454
00460 function _drupal_html_to_text_clean($indent) {
00461   return preg_replace('/[^>]/', ' ', $indent);
00462 }
00463
00469 function _drupal_html_to_text_pad($text, $pad, $prefix = '') {
00470   // Remove last line break.
00471   $text = substr($text, 0, -1);
00472   // Calculate needed padding space and add it.
00473   if (($p = strrpos($text, "\n")) === FALSE) {
00474     $p = -1;
00475   }
00476   $n = max(0, 79 - (strlen($text) - $p));
00477   // Add prefix and padding, and restore linebreak.
00478   return $text . $prefix . str_repeat($pad, $n - strlen($prefix)) ."\n";
00479 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/menu/menu.admin.inc Source File

modules » menu

menu.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: menu.admin.inc,v 1.26.2.3 2008/02/11 15:12:53 goba Exp $
00003
00012 function menu_overview_page() {
00013   $result = db_query("SELECT * FROM {menu_custom} ORDER BY title");
00014   $content = array();
00015   while ($menu = db_fetch_array($result)) {
00016     $menu['href'] = 'admin/build/menu-customize/'. $menu['menu_name'];
00017     $menu['localized_options'] = array();
00018     $content[] = $menu;
00019   }
00020   return theme('admin_block_content', $content);
00021 }
00022
00029 function menu_overview_form(&$form_state, $menu) {
00030   global $menu_admin;
00031   $sql = "
00032     SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
00033     FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path
00034     WHERE ml.menu_name = '%s'
00035     ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC";
00036   $result = db_query($sql, $menu['menu_name']);
00037   $tree = menu_tree_data($result);
00038   $node_links = array();
00039   menu_tree_collect_node_links($tree, $node_links);
00040   // We indicate that a menu administrator is running the menu access check.
00041   $menu_admin = TRUE;
00042   menu_tree_check_access($tree, $node_links);
00043   $menu_admin = FALSE;
00044
00045   $form = _menu_overview_tree_form($tree);
00046   $form['#menu'] =  $menu;
00047   if (element_children($form)) {
00048     $form['submit'] = array(
00049       '#type' => 'submit',
00050       '#value' => t('Save configuration'),
00051     );
00052   }
00053   else {
00054     $form['empty_menu'] = array('#value' => t('There are no menu items yet.'));
00055   }
00056   return $form;
00057 }
00058
00062 function _menu_overview_tree_form($tree) {
00063   static $form = array('#tree' => TRUE);
00064   foreach ($tree as $data) {
00065     $title = '';
00066     $item = $data['link'];
00067     // Don't show callbacks; these have $item['hidden'] < 0.
00068     if ($item && $item['hidden'] >= 0) {
00069       $mlid = 'mlid:'. $item['mlid'];
00070       $form[$mlid]['#item'] = $item;
00071       $form[$mlid]['#attributes'] = $item['hidden'] ? array('class' => 'menu-disabled') : array('class' => 'menu-enabled');
00072       $form[$mlid]['title']['#value'] = l($item['title'], $item['href'], $item['localized_options']) . ($item['hidden'] ? ' ('. t('disabled') .')' : '');
00073       $form[$mlid]['hidden'] = array(
00074         '#type' => 'checkbox',
00075         '#default_value' => !$item['hidden'],
00076       );
00077       $form[$mlid]['expanded'] = array(
00078         '#type' => 'checkbox',
00079         '#default_value' => $item['expanded'],
00080       );
00081       $form[$mlid]['weight'] = array(
00082         '#type' => 'weight',
00083         '#delta' => 50,
00084         '#default_value' => isset($form_state[$mlid]['weight']) ? $form_state[$mlid]['weight'] : $item['weight'],
00085       );
00086       $form[$mlid]['mlid'] = array(
00087         '#type' => 'hidden',
00088         '#value' => $item['mlid'],
00089       );
00090       $form[$mlid]['plid'] = array(
00091         '#type' => 'textfield',
00092         '#default_value' => isset($form_state[$mlid]['plid']) ? $form_state[$mlid]['plid'] : $item['plid'],
00093         '#size' => 6,
00094       );
00095       // Build a list of operations.
00096       $operations = array();
00097       $operations['edit'] = l(t('edit'), 'admin/build/menu/item/'. $item['mlid'] .'/edit');
00098       // Only items created by the menu module can be deleted.
00099       if ($item['module'] == 'menu' || $item['updated'] == 1) {
00100         $operations['delete'] = l(t('delete'), 'admin/build/menu/item/'. $item['mlid'] .'/delete');
00101       }
00102       // Set the reset column.
00103       elseif ($item['module'] == 'system' && $item['customized']) {
00104         $operations['reset'] = l(t('reset'), 'admin/build/menu/item/'. $item['mlid'] .'/reset');
00105       }
00106
00107       $form[$mlid]['operations'] = array();
00108       foreach ($operations as $op => $value) {
00109         $form[$mlid]['operations'][$op] = array('#value' => $value);
00110       }
00111     }
00112
00113     if ($data['below']) {
00114       _menu_overview_tree_form($data['below']);
00115     }
00116   }
00117   return $form;
00118 }
00119
00128 function menu_overview_form_submit($form, &$form_state) {
00129   // When dealing with saving menu items, the order in which these items are
00130   // saved is critical. If a changed child item is saved before its parent,
00131   // the child item could be saved with an invalid path past its immediate
00132   // parent. To prevent this, save items in the form in the same order they
00133   // are sent by $_POST, ensuring parents are saved first, then their children.
00134   // See http://drupal.org/node/181126#comment-632270
00135   $order = array_flip(array_keys($form['#post'])); // Get the $_POST order.
00136   $form = array_merge($order, $form); // Update our original form with the new order.
00137
00138   $updated_items = array();
00139   $fields = array('expanded', 'weight', 'plid');
00140   foreach (element_children($form) as $mlid) {
00141     if (isset($form[$mlid]['#item'])) {
00142       $element = $form[$mlid];
00143       // Update any fields that have changed in this menu item.
00144       foreach ($fields as $field) {
00145         if ($element[$field]['#value'] != $element[$field]['#default_value']) {
00146           $element['#item'][$field] = $element[$field]['#value'];
00147           $updated_items[$mlid] = $element['#item'];
00148         }
00149       }
00150       // Hidden is a special case, the value needs to be reversed.
00151       if ($element['hidden']['#value'] != $element['hidden']['#default_value']) {
00152         $element['#item']['hidden'] = !$element['hidden']['#value'];
00153         $updated_items[$mlid] = $element['#item'];
00154       }
00155     }
00156   }
00157
00158   // Save all our changed items to the database.
00159   foreach ($updated_items as $item) {
00160     $item['customized'] = 1;
00161     menu_link_save($item);
00162   }
00163 }
00164
00170 function theme_menu_overview_form($form) {
00171   drupal_add_tabledrag('menu-overview', 'match', 'parent', 'menu-plid', 'menu-plid', 'menu-mlid', TRUE, MENU_MAX_DEPTH - 1);
00172   drupal_add_tabledrag('menu-overview', 'order', 'sibling', 'menu-weight');
00173
00174   $header = array(
00175     t('Menu item'),
00176     array('data' => t('Enabled'), 'class' => 'checkbox'),
00177     array('data' => t('Expanded'), 'class' => 'checkbox'),
00178     t('Weight'),
00179     array('data' => t('Operations'), 'colspan' => '3'),
00180   );
00181
00182   $rows = array();
00183   foreach (element_children($form) as $mlid) {
00184     if (isset($form[$mlid]['hidden'])) {
00185       $element = &$form[$mlid];
00186       // Build a list of operations.
00187       $operations = array();
00188       foreach (element_children($element['operations']) as $op) {
00189         $operations[] = drupal_render($element['operations'][$op]);
00190       }
00191       while (count($operations) < 2) {
00192         $operations[] = '';
00193       }
00194
00195       // Add special classes to be used for tabledrag.js.
00196       $element['plid']['#attributes']['class'] = 'menu-plid';
00197       $element['mlid']['#attributes']['class'] = 'menu-mlid';
00198       $element['weight']['#attributes']['class'] = 'menu-weight';
00199
00200       // Change the parent field to a hidden. This allows any value but hides the field.
00201       $element['plid']['#type'] = 'hidden';
00202
00203       $row = array();
00204       $row[] = theme('indentation', $element['#item']['depth'] - 1) . drupal_render($element['title']);
00205       $row[] = array('data' => drupal_render($element['hidden']), 'class' => 'checkbox');
00206       $row[] = array('data' => drupal_render($element['expanded']), 'class' => 'checkbox');
00207       $row[] = drupal_render($element['weight']) . drupal_render($element['plid']) . drupal_render($element['mlid']);
00208       $row = array_merge($row, $operations);
00209
00210       $row = array_merge(array('data' => $row), $element['#attributes']);
00211       $row['class'] = !empty($row['class']) ? $row['class'] .' draggable' : 'draggable';
00212       $rows[] = $row;
00213     }
00214   }
00215   $output = '';
00216   if ($rows) {
00217     $output .= theme('table', $header, $rows, array('id' => 'menu-overview'));
00218   }
00219   $output .= drupal_render($form);
00220   return $output;
00221 }
00222
00226 function menu_edit_item(&$form_state, $type, $item, $menu) {
00227
00228   $form['menu'] = array(
00229     '#type' => 'fieldset',
00230     '#title' => t('Menu settings'),
00231     '#collapsible' => FALSE,
00232     '#tree' => TRUE,
00233     '#weight' => -2,
00234     '#attributes' => array('class' => 'menu-item-form'),
00235     '#item' => $item,
00236   );
00237   if ($type == 'add' || empty($item)) {
00238     // This is an add form, initialize the menu link.
00239     $item = array('link_title' => '', 'mlid' => 0, 'plid' => 0, 'menu_name' => $menu['menu_name'], 'weight' => 0, 'link_path' => '', 'options' => array(), 'module' => 'menu', 'expanded' => 0, 'hidden' => 0, 'has_children' => 0);
00240   }
00241   foreach (array('link_path', 'mlid', 'module', 'has_children', 'options') as $key) {
00242     $form['menu'][$key] = array('#type' => 'value', '#value' => $item[$key]);
00243   }
00244   // Any item created or edited via this interface is considered "customized".
00245   $form['menu']['customized'] = array('#type' => 'value', '#value' => 1);
00246   $form['menu']['original_item'] = array('#type' => 'value', '#value' => $item);
00247
00248   $path = $item['link_path'];
00249   if (isset($item['options']['query'])) {
00250     $path .= '?'. $item['options']['query'];
00251   }
00252   if (isset($item['options']['fragment'])) {
00253     $path .= '#'. $item['options']['fragment'];
00254   }
00255   if ($item['module'] == 'menu') {
00256     $form['menu']['link_path'] = array(
00257       '#type' => 'textfield',
00258       '#title' => t('Path'),
00259       '#default_value' => $path,
00260       '#description' => t('The path this menu item links to. This can be an internal Drupal path such as %add-node or an external URL such as %drupal. Enter %front to link to the front page.', array('%front' => '<front>', '%add-node' => 'node/add', '%drupal' => 'http://drupal.org')),
00261       '#required' => TRUE,
00262     );
00263     $form['delete'] = array(
00264       '#type' => 'submit',
00265       '#value' => t('Delete'),
00266       '#access' => $item['mlid'],
00267       '#submit' => array('menu_item_delete_submit'),
00268       '#weight' => 10,
00269     );
00270   }
00271   else {
00272     $form['menu']['_path'] = array(
00273       '#type' => 'item',
00274       '#title' => t('Path'),
00275       '#description' => l($item['link_title'], $item['href'], $item['options']),
00276     );
00277   }
00278   $form['menu']['link_title'] = array('#type' => 'textfield',
00279     '#title' => t('Menu link title'),
00280     '#default_value' => $item['link_title'],
00281     '#description' => t('The link text corresponding to this item that should appear in the menu.'),
00282     '#required' => TRUE,
00283   );
00284   $form['menu']['description'] = array(
00285     '#type' => 'textarea',
00286     '#title' => t('Description'),
00287     '#default_value' => isset($item['options']['attributes']['title']) ? $item['options']['attributes']['title'] : '',
00288     '#rows' => 1,
00289     '#description' => t('The description displayed when hovering over a menu item.'),
00290   );
00291   $form['menu']['enabled'] = array(
00292     '#type' => 'checkbox',
00293     '#title' => t('Enabled'),
00294     '#default_value' => !$item['hidden'],
00295     '#description' => t('Menu items that are not enabled will not be listed in any menu.'),
00296   );
00297   $form['menu']['expanded'] = array(
00298     '#type' => 'checkbox',
00299     '#title' => t('Expanded'),
00300     '#default_value' => $item['expanded'],
00301     '#description' => t('If selected and this menu item has children, the menu will always appear expanded.'),
00302   );
00303
00304   // Generate a list of possible parents (not including this item or descendants).
00305   $options = menu_parent_options(menu_get_menus(), $item);
00306   $default = $item['menu_name'] .':'. $item['plid'];
00307   if (!isset($options[$default])) {
00308     $default = 'navigation:0';
00309   }
00310   $form['menu']['parent'] = array(
00311     '#type' => 'select',
00312     '#title' => t('Parent item'),
00313     '#default_value' => $default,
00314     '#options' => $options,
00315     '#description' => t('The maximum depth for an item and all its children is fixed at !maxdepth. Some menu items may not be available as parents if selecting them would exceed this limit.', array('!maxdepth' => MENU_MAX_DEPTH)),
00316     '#attributes' => array('class' => 'menu-title-select'),
00317   );
00318   $form['menu']['weight'] = array(
00319     '#type' => 'weight',
00320     '#title' => t('Weight'),
00321     '#delta' => 50,
00322     '#default_value' => $item['weight'],
00323     '#description' => t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'),
00324   );
00325   $form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
00326
00327
00328   return $form;
00329 }
00330
00334 function menu_edit_item_validate($form, &$form_state) {
00335   $item = &$form_state['values']['menu'];
00336   $normal_path = drupal_get_normal_path($item['link_path']);
00337   if ($item['link_path'] != $normal_path) {
00338     drupal_set_message(t('The menu system stores system paths only, but will use the URL alias for display. %link_path has been stored as %normal_path', array('%link_path' => $item['link_path'], '%normal_path' => $normal_path)));
00339     $item['link_path'] = $normal_path;
00340   }
00341   if (!menu_path_is_external($item['link_path'])) {
00342     $parsed_link = parse_url($item['link_path']);
00343     if (isset($parsed_link['query'])) {
00344       $item['options']['query'] = $parsed_link['query'];
00345     }
00346     if (isset($parsed_link['fragment'])) {
00347       $item['options']['fragment'] = $parsed_link['fragment'];
00348     }
00349     if ($item['link_path'] != $parsed_link['path']) {
00350       $item['link_path'] = $parsed_link['path'];
00351     }
00352   }
00353   if (!trim($item['link_path']) || !menu_valid_path($item)) {
00354     form_set_error('link_path', t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $item['link_path'])));
00355   }
00356 }
00357
00361 function menu_item_delete_submit($form, &$form_state) {
00362   $form_state['redirect'] = 'admin/build/menu/item/'. $form_state['values']['menu']['mlid'] .'/delete';
00363 }
00364
00368 function menu_edit_item_submit($form, &$form_state) {
00369   $item = $form_state['values']['menu'];
00370
00371   // The value of "hidden" is the opposite of the value
00372   // supplied by the "enabled" checkbox.
00373   $item['hidden'] = (int) !$item['enabled'];
00374   unset($item['enabled']);
00375
00376   $item['options']['attributes']['title'] = $item['description'];
00377   list($item['menu_name'], $item['plid']) = explode(':', $item['parent']);
00378   if (!menu_link_save($item)) {
00379     drupal_set_message(t('There was an error saving the menu link.'), 'error');
00380   }
00381   $form_state['redirect'] = 'admin/build/menu-customize/'. $item['menu_name'];
00382 }
00383
00387 function menu_edit_menu(&$form_state, $type, $menu = array()) {
00388   if ($type == 'edit') {
00389     $form['menu_name'] = array('#type' => 'value', '#value' => $menu['menu_name']);
00390     $form['#insert'] = FALSE;
00391     $form['delete'] = array(
00392       '#type' => 'submit',
00393       '#value' => t('Delete'),
00394       '#access' => !in_array($menu['menu_name'], menu_list_system_menus()),
00395       '#submit' => array('menu_custom_delete_submit'),
00396       '#weight' => 10,
00397     );
00398   }
00399   else {
00400     $menu = array('menu_name' => '', 'title' => '', 'description' => '');
00401     $form['menu_name'] = array(
00402       '#type' => 'textfield',
00403       '#title' => t('Menu name'),
00404       '#maxsize' => MENU_MAX_MENU_NAME_LENGTH_UI,
00405       '#description' => t('The machine-readable name of this menu. This text will be used for constructing the URL of the <em>menu overview</em> page for this menu. This name must contain only lowercase letters, numbers, and hyphens, and must be unique.'),
00406       '#required' => TRUE,
00407     );
00408     $form['#insert'] = TRUE;
00409   }
00410   $form['#title'] = $menu['title'];
00411   $form['title'] = array(
00412     '#type' => 'textfield',
00413     '#title' => t('Title'),
00414     '#default_value' => $menu['title'],
00415     '#required' => TRUE,
00416   );
00417   $form['description'] = array(
00418     '#type' => 'textarea',
00419     '#title' => t('Description'),
00420     '#default_value' => $menu['description'],
00421   );
00422   $form['submit'] = array(
00423     '#type' => 'submit',
00424     '#value' => t('Save'),
00425   );
00426
00427   return $form;
00428 }
00429
00433 function menu_custom_delete_submit($form, &$form_state) {
00434   $form_state['redirect'] = 'admin/build/menu-customize/'. $form_state['values']['menu_name'] .'/delete';
00435 }
00436
00440 function menu_delete_menu_page($menu) {
00441   // System-defined menus may not be deleted.
00442   if (in_array($menu['menu_name'], menu_list_system_menus())) {
00443     drupal_access_denied();
00444     return;
00445   }
00446   return drupal_get_form('menu_delete_menu_confirm', $menu);
00447 }
00448
00452 function menu_delete_menu_confirm(&$form_state, $menu) {
00453   $form['#menu'] = $menu;
00454   $caption = '';
00455   $num_links = db_result(db_query("SELECT COUNT(*) FROM {menu_links} WHERE menu_name = '%s'", $menu['menu_name']));
00456   if ($num_links) {
00457     $caption .= '<p>'. format_plural($num_links, '<strong>Warning:</strong> There is currently 1 menu item in %title. It will be deleted (system-defined items will be reset).', '<strong>Warning:</strong> There are currently @count menu items in %title. They will be deleted (system-defined items will be reset).', array('%title' => $menu['title'])) .'</p>';
00458   }
00459   $caption .= '<p>'. t('This action cannot be undone.') .'</p>';
00460   return confirm_form($form, t('Are you sure you want to delete the custom menu %title?', array('%title' => $menu['title'])), 'admin/build/menu-customize/'. $menu['menu_name'], $caption, t('Delete'));
00461 }
00462
00466 function menu_delete_menu_confirm_submit($form, &$form_state) {
00467   $menu = $form['#menu'];
00468   $form_state['redirect'] = 'admin/build/menu';
00469   // System-defined menus may not be deleted - only menus defined by this module.
00470   if (in_array($menu['menu_name'], menu_list_system_menus())  || !db_result(db_query("SELECT COUNT(*) FROM {menu_custom} WHERE menu_name = '%s'", $menu['menu_name']))) {
00471     return;
00472   }
00473   // Reset all the menu links defined by the system via hook_menu.
00474   $result = db_query("SELECT * FROM {menu_links} ml INNER JOIN {menu_router} m ON ml.router_path = m.path WHERE ml.menu_name = '%s' AND ml.module = 'system' ORDER BY m.number_parts ASC", $menu['menu_name']);
00475   while ($item = db_fetch_array($result)) {
00476     menu_reset_item($item);
00477   }
00478   // Delete all links to the overview page for this menu.
00479   $result = db_query("SELECT mlid FROM {menu_links} ml WHERE ml.link_path = '%s'", 'admin/build/menu-customize/'. $menu['menu_name']);
00480   while ($m = db_fetch_array($result)) {
00481     menu_link_delete($m['mlid']);
00482   }
00483   // Delete all the links in the menu and the menu from the list of custom menus.
00484   db_query("DELETE FROM {menu_links} WHERE menu_name = '%s'", $menu['menu_name']);
00485   db_query("DELETE FROM {menu_custom} WHERE menu_name = '%s'", $menu['menu_name']);
00486   // Delete all the blocks for this menu.
00487   db_query("DELETE FROM {blocks} WHERE module = 'menu' AND delta = '%s'", $menu['menu_name']);
00488   db_query("DELETE FROM {blocks_roles} WHERE module = 'menu' AND delta = '%s'", $menu['menu_name']);
00489   menu_cache_clear_all();
00490   cache_clear_all();
00491   $t_args = array('%title' => $menu['title']);
00492   drupal_set_message(t('The custom menu %title has been deleted.', $t_args));
00493   watchdog('menu', 'Deleted custom menu %title and all its menu items.', $t_args, WATCHDOG_NOTICE);
00494 }
00495
00499 function menu_edit_menu_validate($form, &$form_state) {
00500   $item = $form_state['values'];
00501   if (preg_match('/[^a-z0-9-]/', $item['menu_name'])) {
00502     form_set_error('menu_name', t('The menu name may only consist of lowercase letters, numbers, and hyphens.'));
00503   }
00504   if (strlen($item['menu_name']) > MENU_MAX_MENU_NAME_LENGTH_UI) {
00505     form_set_error('menu_name', format_plural(MENU_MAX_MENU_NAME_LENGTH_UI, "The menu name can't be longer than 1 character.", "The menu name can't be longer than @count characters."));
00506   }
00507   if ($form['#insert']) {
00508     // We will add 'menu-' to the menu name to help avoid name-space conflicts.
00509     $item['menu_name'] = 'menu-'. $item['menu_name'];
00510     if (db_result(db_query("SELECT menu_name FROM {menu_custom} WHERE menu_name = '%s'", $item['menu_name'])) ||
00511       db_result(db_query_range("SELECT menu_name FROM {menu_links} WHERE menu_name = '%s'", $item['menu_name'], 0, 1))) {
00512       form_set_error('menu_name', t('The menu already exists.'));
00513     }
00514   }
00515 }
00516
00520 function menu_edit_menu_submit($form, &$form_state) {
00521   $menu = $form_state['values'];
00522   $path = 'admin/build/menu-customize/';
00523   if ($form['#insert']) {
00524     // Add 'menu-' to the menu name to help avoid name-space conflicts.
00525     $menu['menu_name'] = 'menu-'. $menu['menu_name'];
00526     $link['link_title'] = $menu['title'];
00527     $link['link_path'] = $path . $menu['menu_name'];
00528     $link['router_path'] = $path .'%';
00529     $link['module'] = 'menu';
00530     $link['plid'] = db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND module = '%s'", 'admin/build/menu', 'system'));
00531     menu_link_save($link);
00532     db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", $menu['menu_name'], $menu['title'], $menu['description']);
00533   }
00534   else {
00535     db_query("UPDATE {menu_custom} SET title = '%s', description = '%s' WHERE menu_name = '%s'", $menu['title'], $menu['description'], $menu['menu_name']);
00536     $result = db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s'", $path . $menu['menu_name']);
00537     while ($m = db_fetch_array($result)) {
00538       $link = menu_link_load($m['mlid']);
00539       $link['link_title'] = $menu['title'];
00540       menu_link_save($link);
00541     }
00542   }
00543   $form_state['redirect'] = $path . $menu['menu_name'];
00544 }
00545
00549 function menu_item_delete_page($item) {
00550   // Links defined via hook_menu may not be deleted. Updated items are an
00551   // exception, as they can be broken.
00552   if ($item['module'] == 'system' && !$item['updated']) {
00553     drupal_access_denied();
00554     return;
00555   }
00556   return drupal_get_form('menu_item_delete_form', $item);
00557 }
00558
00562 function menu_item_delete_form(&$form_state, $item) {
00563   $form['#item'] = $item;
00564   return confirm_form($form, t('Are you sure you want to delete the custom menu item %item?', array('%item' => $item['link_title'])), 'admin/build/menu-customize/'. $item['menu_name']);
00565 }
00566
00570 function menu_item_delete_form_submit($form, &$form_state) {
00571   $item = $form['#item'];
00572   menu_link_delete($item['mlid']);
00573   $t_args = array('%title' => $item['link_title']);
00574   drupal_set_message(t('The menu item %title has been deleted.', $t_args));
00575   watchdog('menu', 'Deleted menu item %title.', $t_args, WATCHDOG_NOTICE);
00576   $form_state['redirect'] = 'admin/build/menu-customize/'. $item['menu_name'];
00577 }
00578
00582 function menu_reset_item_confirm(&$form_state, $item) {
00583   $form['item'] = array('#type' => 'value', '#value' => $item);
00584   return confirm_form($form, t('Are you sure you want to reset the item %item to its default values?', array('%item' => $item['link_title'])), 'admin/build/menu-customize/'. $item['menu_name'], t('Any customizations will be lost. This action cannot be undone.'), t('Reset'));
00585 }
00586
00590 function menu_reset_item_confirm_submit($form, &$form_state) {
00591   $item = $form_state['values']['item'];
00592   $new_item = menu_reset_item($item);
00593   drupal_set_message(t('The menu item was reset to its default settings.'));
00594   $form_state['redirect'] = 'admin/build/menu-customize/'. $new_item['menu_name'];
00595 }
00596
00600 function menu_configure() {
00601   $form['intro'] = array(
00602     '#type' => 'item',
00603     '#value' => t('The menu module allows on-the-fly creation of menu links in the content authoring forms. The following option sets the default menu in which a new link will be added.'),
00604   );
00605
00606   $menu_options = menu_get_menus();
00607   $form['menu_default_node_menu'] = array(
00608     '#type' => 'select',
00609     '#title' => t('Default menu for content'),
00610     '#default_value' => variable_get('menu_default_node_menu', 'primary-links'),
00611     '#options' => $menu_options,
00612     '#description' => t('Choose the menu to be the default in the menu options in the content authoring form.'),
00613   );
00614
00615   $primary = variable_get('menu_primary_links_source', 'primary-links');
00616   $primary_options = array_merge($menu_options, array('' => t('No primary links')));
00617   $form['menu_primary_links_source'] = array(
00618     '#type' => 'select',
00619     '#title' => t('Source for the primary links'),
00620     '#default_value' => $primary,
00621     '#options' => $primary_options,
00622     '#tree' => FALSE,
00623     '#description' => t('Select what should be displayed as the primary links.'),
00624   );
00625
00626   $secondary_options = array_merge($menu_options, array('' => t('No secondary links')));
00627   $form["menu_secondary_links_source"] = array(
00628     '#type' => 'select',
00629     '#title' => t('Source for the secondary links'),
00630     '#default_value' => variable_get('menu_secondary_links_source', 'secondary-links'),
00631     '#options' => $secondary_options,
00632     '#tree' => FALSE,
00633     '#description' => t('Select what should be displayed as the secondary links. You can choose the same menu for secondary links as for primary links (currently %primary). If you do this, the children of the active primary menu link will be displayed as secondary links.', array('%primary' => $primary_options[$primary])),
00634   );
00635
00636   return system_settings_form($form);
00637 }
00638
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/menu.inc Source File

includes

menu.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: menu.inc,v 1.255.2.6 2008/02/08 20:39:54 goba Exp $
00003
00080 define('MENU_IS_ROOT', 0x0001);
00081 define('MENU_VISIBLE_IN_TREE', 0x0002);
00082 define('MENU_VISIBLE_IN_BREADCRUMB', 0x0004);
00083 define('MENU_LINKS_TO_PARENT', 0x0008);
00084 define('MENU_MODIFIED_BY_ADMIN', 0x0020);
00085 define('MENU_CREATED_BY_ADMIN', 0x0040);
00086 define('MENU_IS_LOCAL_TASK', 0x0080);
00087
00104 define('MENU_NORMAL_ITEM', MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IN_BREADCRUMB);
00105
00110 define('MENU_CALLBACK', MENU_VISIBLE_IN_BREADCRUMB);
00111
00118 define('MENU_SUGGESTED_ITEM', MENU_VISIBLE_IN_BREADCRUMB | 0x0010);
00119
00125 define('MENU_LOCAL_TASK', MENU_IS_LOCAL_TASK);
00126
00131 define('MENU_DEFAULT_LOCAL_TASK', MENU_IS_LOCAL_TASK | MENU_LINKS_TO_PARENT);
00132
00143 define('MENU_FOUND', 1);
00144 define('MENU_NOT_FOUND', 2);
00145 define('MENU_ACCESS_DENIED', 3);
00146 define('MENU_SITE_OFFLINE', 4);
00147
00161 define('MENU_MAX_PARTS', 7);
00162
00163
00167 define('MENU_MAX_DEPTH', 9);
00168
00169
00202 function menu_get_ancestors($parts) {
00203   $number_parts = count($parts);
00204   $placeholders = array();
00205   $ancestors = array();
00206   $length =  $number_parts - 1;
00207   $end = (1 << $number_parts) - 1;
00208   $masks = variable_get('menu_masks', array());
00209   // Only examine patterns that actually exist as router items (the masks).
00210   foreach ($masks as $i) {
00211     if ($i > $end) {
00212       // Only look at masks that are not longer than the path of interest.
00213       continue;
00214     }
00215     elseif ($i < (1 << $length)) {
00216       // We have exhausted the masks of a given length, so decrease the length.
00217       --$length;
00218     }
00219     $current = '';
00220     for ($j = $length; $j >= 0; $j--) {
00221       if ($i & (1 << $j)) {
00222         $current .= $parts[$length - $j];
00223       }
00224       else {
00225         $current .= '%';
00226       }
00227       if ($j) {
00228         $current .= '/';
00229       }
00230     }
00231     $placeholders[] = "'%s'";
00232     $ancestors[] = $current;
00233   }
00234   return array($ancestors, $placeholders);
00235 }
00236
00257 function menu_unserialize($data, $map) {
00258   if ($data = unserialize($data)) {
00259     foreach ($data as $k => $v) {
00260       if (is_int($v)) {
00261         $data[$k] = isset($map[$v]) ? $map[$v] : '';
00262       }
00263     }
00264     return $data;
00265   }
00266   else {
00267     return array();
00268   }
00269 }
00270
00271
00272
00284 function menu_set_item($path, $router_item) {
00285   menu_get_item($path, $router_item);
00286 }
00287
00303 function menu_get_item($path = NULL, $router_item = NULL) {
00304   static $router_items;
00305   if (!isset($path)) {
00306     $path = $_GET['q'];
00307   }
00308   if (isset($router_item)) {
00309     $router_items[$path] = $router_item;
00310   }
00311   if (!isset($router_items[$path])) {
00312     $original_map = arg(NULL, $path);
00313     $parts = array_slice($original_map, 0, MENU_MAX_PARTS);
00314     list($ancestors, $placeholders) = menu_get_ancestors($parts);
00315
00316     if ($router_item = db_fetch_array(db_query_range('SELECT * FROM {menu_router} WHERE path IN ('. implode (',', $placeholders) .') ORDER BY fit DESC', $ancestors, 0, 1))) {
00317       $map = _menu_translate($router_item, $original_map);
00318       if ($map === FALSE) {
00319         $router_items[$path] = FALSE;
00320         return FALSE;
00321       }
00322       if ($router_item['access']) {
00323         $router_item['map'] = $map;
00324         $router_item['page_arguments'] = array_merge(menu_unserialize($router_item['page_arguments'], $map), array_slice($map, $router_item['number_parts']));
00325       }
00326     }
00327     $router_items[$path] = $router_item;
00328   }
00329   return $router_items[$path];
00330 }
00331
00335 function menu_execute_active_handler($path = NULL) {
00336   if (_menu_site_is_offline()) {
00337     return MENU_SITE_OFFLINE;
00338   }
00339   if (variable_get('menu_rebuild_needed', FALSE)) {
00340     menu_rebuild();
00341   }
00342   if ($router_item = menu_get_item($path)) {
00343     if ($router_item['access']) {
00344       if ($router_item['file']) {
00345         require_once($router_item['file']);
00346       }
00347       return call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
00348     }
00349     else {
00350       return MENU_ACCESS_DENIED;
00351     }
00352   }
00353   return MENU_NOT_FOUND;
00354 }
00355
00370 function _menu_load_objects(&$item, &$map) {
00371   if ($load_functions = $item['load_functions']) {
00372     // If someone calls this function twice, then unserialize will fail.
00373     if ($load_functions_unserialized = unserialize($load_functions)) {
00374       $load_functions = $load_functions_unserialized;
00375     }
00376     $path_map = $map;
00377     foreach ($load_functions as $index => $function) {
00378       if ($function) {
00379         $value = isset($path_map[$index]) ? $path_map[$index] : '';
00380         if (is_array($function)) {
00381           // Set up arguments for the load function. These were pulled from
00382           // 'load arguments' in the hook_menu() entry, but they need
00383           // some processing. In this case the $function is the key to the
00384           // load_function array, and the value is the list of arguments.
00385           list($function, $args) = each($function);
00386           $load_functions[$index] = $function;
00387
00388           // Some arguments are placeholders for dynamic items to process.
00389           foreach ($args as $i => $arg) {
00390             if ($arg === '%index') {
00391               // Pass on argument index to the load function, so multiple
00392               // occurances of the same placeholder can be identified.
00393               $args[$i] = $index;
00394             }
00395             if ($arg === '%map') {
00396               // Pass on menu map by reference. The accepting function must
00397               // also declare this as a reference if it wants to modify
00398               // the map.
00399               $args[$i] = &$map;
00400             }
00401             if (is_int($arg)) {
00402               $args[$i] = isset($path_map[$arg]) ? $path_map[$arg] : '';
00403             }
00404           }
00405           array_unshift($args, $value);
00406           $return = call_user_func_array($function, $args);
00407         }
00408         else {
00409           $return = $function($value);
00410         }
00411         // If callback returned an error or there is no callback, trigger 404.
00412         if ($return === FALSE) {
00413           $item['access'] = FALSE;
00414           $map = FALSE;
00415           return FALSE;
00416         }
00417         $map[$index] = $return;
00418       }
00419     }
00420     $item['load_functions'] = $load_functions;
00421   }
00422   return TRUE;
00423 }
00424
00435 function _menu_check_access(&$item, $map) {
00436   // Determine access callback, which will decide whether or not the current
00437   // user has access to this path.
00438   $callback = empty($item['access_callback']) ? 0 : trim($item['access_callback']);
00439   // Check for a TRUE or FALSE value.
00440   if (is_numeric($callback)) {
00441     $item['access'] = (bool)$callback;
00442   }
00443   else {
00444     $arguments = menu_unserialize($item['access_arguments'], $map);
00445     // As call_user_func_array is quite slow and user_access is a very common
00446     // callback, it is worth making a special case for it.
00447     if ($callback == 'user_access') {
00448       $item['access'] = (count($arguments) == 1) ? user_access($arguments[0]) : user_access($arguments[0], $arguments[1]);
00449     }
00450     else {
00451       $item['access'] = call_user_func_array($callback, $arguments);
00452     }
00453   }
00454 }
00455
00481 function _menu_item_localize(&$item, $map, $link_translate = FALSE) {
00482   $callback = $item['title_callback'];
00483   $item['localized_options'] = $item['options'];
00484   // If we are not doing link translation or if the title matches the
00485   // link title of its router item, localize it.
00486   if (!$link_translate || (!empty($item['title']) && ($item['title'] == $item['link_title']))) {
00487     // t() is a special case. Since it is used very close to all the time,
00488     // we handle it directly instead of using indirect, slower methods.
00489     if ($callback == 't') {
00490       if (empty($item['title_arguments'])) {
00491         $item['title'] = t($item['title']);
00492       }
00493       else {
00494         $item['title'] = t($item['title'], menu_unserialize($item['title_arguments'], $map));
00495       }
00496     }
00497     elseif ($callback) {
00498       if (empty($item['title_arguments'])) {
00499         $item['title'] = $callback($item['title']);
00500       }
00501       else {
00502         $item['title'] = call_user_func_array($callback, menu_unserialize($item['title_arguments'], $map));
00503       }
00504       // Avoid calling check_plain again on l() function.
00505       if ($callback == 'check_plain') {
00506         $item['localized_options']['html'] = TRUE;
00507       }
00508     }
00509   }
00510   elseif ($link_translate) {
00511     $item['title'] = $item['link_title'];
00512   }
00513
00514   // Translate description, see the motivation above.
00515   if (!empty($item['description'])) {
00516     $original_description = $item['description'];
00517     $item['description'] = t($item['description']);
00518     if ($link_translate && $item['options']['attributes']['title'] == $original_description) {
00519       $item['localized_options']['attributes']['title'] = $item['description'];
00520     }
00521   }
00522 }
00523
00553 function _menu_translate(&$router_item, $map, $to_arg = FALSE) {
00554   $path_map = $map;
00555   if (!_menu_load_objects($router_item, $map)) {
00556     // An error occurred loading an object.
00557     $router_item['access'] = FALSE;
00558     return FALSE;
00559   }
00560   if ($to_arg) {
00561     _menu_link_map_translate($path_map, $router_item['to_arg_functions']);
00562   }
00563
00564   // Generate the link path for the page request or local tasks.
00565   $link_map = explode('/', $router_item['path']);
00566   for ($i = 0; $i < $router_item['number_parts']; $i++) {
00567     if ($link_map[$i] == '%') {
00568       $link_map[$i] = $path_map[$i];
00569     }
00570   }
00571   $router_item['href'] = implode('/', $link_map);
00572   $router_item['options'] = array();
00573   _menu_check_access($router_item, $map);
00574
00575   _menu_item_localize($router_item, $map);
00576
00577   return $map;
00578 }
00579
00590 function _menu_link_map_translate(&$map, $to_arg_functions) {
00591   if ($to_arg_functions) {
00592     $to_arg_functions = unserialize($to_arg_functions);
00593     foreach ($to_arg_functions as $index => $function) {
00594       // Translate place-holders into real values.
00595       $arg = $function(!empty($map[$index]) ? $map[$index] : '', $map, $index);
00596       if (!empty($map[$index]) || isset($arg)) {
00597         $map[$index] = $arg;
00598       }
00599       else {
00600         unset($map[$index]);
00601       }
00602     }
00603   }
00604 }
00605
00606 function menu_tail_to_arg($arg, $map, $index) {
00607   return implode('/', array_slice($map, $index));
00608 }
00609
00625 function _menu_link_translate(&$item) {
00626   $item['options'] = unserialize($item['options']);
00627   if ($item['external']) {
00628     $item['access'] = 1;
00629     $map = array();
00630     $item['href'] = $item['link_path'];
00631     $item['title'] = $item['link_title'];
00632     $item['localized_options'] = $item['options'];
00633   }
00634   else {
00635     $map = explode('/', $item['link_path']);
00636     _menu_link_map_translate($map, $item['to_arg_functions']);
00637     $item['href'] = implode('/', $map);
00638
00639     // Note - skip callbacks without real values for their arguments.
00640     if (strpos($item['href'], '%') !== FALSE) {
00641       $item['access'] = FALSE;
00642       return FALSE;
00643     }
00644     // menu_tree_check_access() may set this ahead of time for links to nodes.
00645     if (!isset($item['access'])) {
00646       if (!_menu_load_objects($item, $map)) {
00647         // An error occurred loading an object.
00648         $item['access'] = FALSE;
00649         return FALSE;
00650       }
00651       _menu_check_access($item, $map);
00652     }
00653
00654     _menu_item_localize($item, $map, TRUE);
00655   }
00656
00657   // Allow other customizations - e.g. adding a page-specific query string to the
00658   // options array. For performance reasons we only invoke this hook if the link
00659   // has the 'alter' flag set in the options array.
00660   if (!empty($item['options']['alter'])) {
00661     drupal_alter('translated_menu_link', $item, $map);
00662   }
00663
00664   return $map;
00665 }
00666
00687 function menu_get_object($type = 'node', $position = 1, $path = NULL) {
00688   $router_item = menu_get_item($path);
00689   if (isset($router_item['load_functions'][$position]) && !empty($router_item['map'][$position]) && $router_item['load_functions'][$position] == $type .'_load') {
00690     return $router_item['map'][$position];
00691   }
00692 }
00693
00706 function menu_tree($menu_name = 'navigation') {
00707   static $menu_output = array();
00708
00709   if (!isset($menu_output[$menu_name])) {
00710     $tree = menu_tree_page_data($menu_name);
00711     $menu_output[$menu_name] = menu_tree_output($tree);
00712   }
00713   return $menu_output[$menu_name];
00714 }
00715
00724 function menu_tree_output($tree) {
00725   $output = '';
00726   $items = array();
00727
00728   // Pull out just the menu items we are going to render so that we
00729   // get an accurate count for the first/last classes.
00730   foreach ($tree as $data) {
00731     if (!$data['link']['hidden']) {
00732       $items[] = $data;
00733     }
00734   }
00735
00736   $num_items = count($items);
00737   foreach ($items as $i => $data) {
00738     $extra_class = NULL;
00739     if ($i == 0) {
00740       $extra_class = 'first';
00741     }
00742     if ($i == $num_items - 1) {
00743       $extra_class = 'last';
00744     }
00745     $link = theme('menu_item_link', $data['link']);
00746     if ($data['below']) {
00747       $output .= theme('menu_item', $link, $data['link']['has_children'], menu_tree_output($data['below']), $data['link']['in_active_trail'], $extra_class);
00748     }
00749     else {
00750       $output .= theme('menu_item', $link, $data['link']['has_children'], '', $data['link']['in_active_trail'], $extra_class);
00751     }
00752   }
00753   return $output ? theme('menu_tree', $output) : '';
00754 }
00755
00771 function menu_tree_all_data($menu_name = 'navigation', $item = NULL) {
00772   static $tree = array();
00773
00774   // Use $mlid as a flag for whether the data being loaded is for the whole tree.
00775   $mlid = isset($item['mlid']) ? $item['mlid'] : 0;
00776   // Generate the cache ID.
00777   $cid = 'links:'. $menu_name .':all:'. $mlid;
00778
00779   if (!isset($tree[$cid])) {
00780     // If the static variable doesn't have the data, check {cache_menu}.
00781     $cache = cache_get($cid, 'cache_menu');
00782     if ($cache && isset($cache->data)) {
00783       $data = $cache->data;
00784     }
00785     else {
00786       // Build and run the query, and build the tree.
00787       if ($mlid) {
00788         // The tree is for a single item, so we need to match the values in its
00789         // p columns and 0 (the top level) with the plid values of other links.
00790         $args = array(0);
00791         for ($i = 1; $i < MENU_MAX_DEPTH; $i++) {
00792           $args[] = $item["p$i"];
00793         }
00794         $args = array_unique($args);
00795         $placeholders = implode(', ', array_fill(0, count($args), '%d'));
00796         $where = ' AND ml.plid IN ('. $placeholders .')';
00797         $parents = $args;
00798         $parents[] = $item['mlid'];
00799       }
00800       else {
00801         // Get all links in this menu.
00802         $where = '';
00803         $args = array();
00804         $parents = array();
00805       }
00806       array_unshift($args, $menu_name);
00807       // Select the links from the table, and recursively build the tree.  We
00808       // LEFT JOIN since there is no match in {menu_router} for an external
00809       // link.
00810       $data['tree'] = menu_tree_data(db_query("
00811         SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
00812         FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path
00813         WHERE ml.menu_name = '%s'". $where ."
00814         ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $args), $parents);
00815       $data['node_links'] = array();
00816       menu_tree_collect_node_links($data['tree'], $data['node_links']);
00817       // Cache the data.
00818       cache_set($cid, $data, 'cache_menu');
00819     }
00820     // Check access for the current user to each item in the tree.
00821     menu_tree_check_access($data['tree'], $data['node_links']);
00822     $tree[$cid] = $data['tree'];
00823   }
00824
00825   return $tree[$cid];
00826 }
00827
00843 function menu_tree_page_data($menu_name = 'navigation') {
00844   static $tree = array();
00845
00846   // Load the menu item corresponding to the current page.
00847   if ($item = menu_get_item()) {
00848     // Generate the cache ID.
00849     $cid = 'links:'. $menu_name .':page:'. $item['href'] .':'. (int)$item['access'];
00850
00851     if (!isset($tree[$cid])) {
00852       // If the static variable doesn't have the data, check {cache_menu}.
00853       $cache = cache_get($cid, 'cache_menu');
00854       if ($cache && isset($cache->data)) {
00855         $data = $cache->data;
00856       }
00857       else {
00858         // Build and run the query, and build the tree.
00859         if ($item['access']) {
00860           // Check whether a menu link exists that corresponds to the current path.
00861           $args = array($menu_name, $item['href']);
00862           $placeholders = "'%s'";
00863           if (drupal_is_front_page()) {
00864             $args[] = '<front>';
00865             $placeholders .= ", '%s'";
00866           }
00867           $parents = db_fetch_array(db_query("SELECT p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = '%s' AND link_path IN (". $placeholders .")", $args));
00868
00869           if (empty($parents)) {
00870             // If no link exists, we may be on a local task that's not in the links.
00871             // TODO: Handle the case like a local task on a specific node in the menu.
00872             $parents = db_fetch_array(db_query("SELECT p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = '%s' AND link_path = '%s'", $menu_name, $item['tab_root']));
00873           }
00874           // We always want all the top-level links with plid == 0.
00875           $parents[] = '0';
00876
00877           // Use array_values() so that the indices are numeric for array_merge().
00878           $args = $parents = array_unique(array_values($parents));
00879           $placeholders = implode(', ', array_fill(0, count($args), '%d'));
00880           $expanded = variable_get('menu_expanded', array());
00881           // Check whether the current menu has any links set to be expanded.
00882           if (in_array($menu_name, $expanded)) {
00883             // Collect all the links set to be expanded, and then add all of
00884             // their children to the list as well.
00885             do {
00886               $result = db_query("SELECT mlid FROM {menu_links} WHERE menu_name = '%s' AND expanded = 1 AND has_children = 1 AND plid IN (". $placeholders .') AND mlid NOT IN ('. $placeholders .')', array_merge(array($menu_name), $args, $args));
00887               $num_rows = FALSE;
00888               while ($item = db_fetch_array($result)) {
00889                 $args[] = $item['mlid'];
00890                 $num_rows = TRUE;
00891               }
00892               $placeholders = implode(', ', array_fill(0, count($args), '%d'));
00893             } while ($num_rows);
00894           }
00895           array_unshift($args, $menu_name);
00896         }
00897         else {
00898           // Show only the top-level menu items when access is denied.
00899           $args = array($menu_name, '0');
00900           $placeholders = '%d';
00901           $parents = array();
00902         }
00903         // Select the links from the table, and recursively build the tree. We
00904         // LEFT JOIN since there is no match in {menu_router} for an external
00905         // link.
00906         $data['tree'] = menu_tree_data(db_query("
00907           SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
00908           FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path
00909           WHERE ml.menu_name = '%s' AND ml.plid IN (". $placeholders .")
00910           ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $args), $parents);
00911         $data['node_links'] = array();
00912         menu_tree_collect_node_links($data['tree'], $data['node_links']);
00913         // Cache the data.
00914         cache_set($cid, $data, 'cache_menu');
00915       }
00916       // Check access for the current user to each item in the tree.
00917       menu_tree_check_access($data['tree'], $data['node_links']);
00918       $tree[$cid] = $data['tree'];
00919     }
00920     return $tree[$cid];
00921   }
00922
00923   return array();
00924 }
00925
00929 function menu_tree_collect_node_links(&$tree, &$node_links) {
00930   foreach ($tree as $key => $v) {
00931     if ($tree[$key]['link']['router_path'] == 'node/%') {
00932       $nid = substr($tree[$key]['link']['link_path'], 5);
00933       if (is_numeric($nid)) {
00934         $node_links[$nid][$tree[$key]['link']['mlid']] = &$tree[$key]['link'];
00935         $tree[$key]['link']['access'] = FALSE;
00936       }
00937     }
00938     if ($tree[$key]['below']) {
00939       menu_tree_collect_node_links($tree[$key]['below'], $node_links);
00940     }
00941   }
00942 }
00943
00947 function menu_tree_check_access(&$tree, $node_links = array()) {
00948
00949   if ($node_links) {
00950     // Use db_rewrite_sql to evaluate view access without loading each full node.
00951     $nids = array_keys($node_links);
00952     $placeholders = '%d'. str_repeat(', %d', count($nids) - 1);
00953     $result = db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.status = 1 AND n.nid IN (". $placeholders .")"), $nids);
00954     while ($node = db_fetch_array($result)) {
00955       $nid = $node['nid'];
00956       foreach ($node_links[$nid] as $mlid => $link) {
00957         $node_links[$nid][$mlid]['access'] = TRUE;
00958       }
00959     }
00960   }
00961   _menu_tree_check_access($tree);
00962   return;
00963 }
00964
00968 function _menu_tree_check_access(&$tree) {
00969   $new_tree = array();
00970   foreach ($tree as $key => $v) {
00971     $item = &$tree[$key]['link'];
00972     _menu_link_translate($item);
00973     if ($item['access']) {
00974       if ($tree[$key]['below']) {
00975         _menu_tree_check_access($tree[$key]['below']);
00976       }
00977       // The weights are made a uniform 5 digits by adding 50000 as an offset.
00978       // After _menu_link_translate(), $item['title'] has the localized link title.
00979       // Adding the mlid to the end of the index insures that it is unique.
00980       $new_tree[(50000 + $item['weight']) .' '. $item['title'] .' '. $item['mlid']] = $tree[$key];
00981     }
00982   }
00983   // Sort siblings in the tree based on the weights and localized titles.
00984   ksort($new_tree);
00985   $tree = $new_tree;
00986 }
00987
01001 function menu_tree_data($result = NULL, $parents = array(), $depth = 1) {
01002   list(, $tree) = _menu_tree_data($result, $parents, $depth);
01003   return $tree;
01004 }
01005
01013 function _menu_tree_data($result, $parents, $depth, $previous_element = '') {
01014   $remnant = NULL;
01015   $tree = array();
01016   while ($item = db_fetch_array($result)) {
01017     // We need to determine if we're on the path to root so we can later build
01018     // the correct active trail and breadcrumb.
01019     $item['in_active_trail'] = in_array($item['mlid'], $parents);
01020     // The current item is the first in a new submenu.
01021     if ($item['depth'] > $depth) {
01022       // _menu_tree returns an item and the menu tree structure.
01023       list($item, $below) = _menu_tree_data($result, $parents, $item['depth'], $item);
01024       if ($previous_element) {
01025         $tree[$previous_element['mlid']] = array(
01026           'link' => $previous_element,
01027           'below' => $below,
01028         );
01029       }
01030       else {
01031         $tree = $below;
01032       }
01033       // We need to fall back one level.
01034       if (!isset($item) || $item['depth'] < $depth) {
01035         return array($item, $tree);
01036       }
01037       // This will be the link to be output in the next iteration.
01038       $previous_element = $item;
01039     }
01040     // We are at the same depth, so we use the previous element.
01041     elseif ($item['depth'] == $depth) {
01042       if ($previous_element) {
01043         // Only the first time.
01044         $tree[$previous_element['mlid']] = array(
01045           'link' => $previous_element,
01046           'below' => FALSE,
01047         );
01048       }
01049       // This will be the link to be output in the next iteration.
01050       $previous_element = $item;
01051     }
01052     // The submenu ended with the previous item, so pass back the current item.
01053     else {
01054       $remnant = $item;
01055       break;
01056     }
01057   }
01058   if ($previous_element) {
01059     // We have one more link dangling.
01060     $tree[$previous_element['mlid']] = array(
01061       'link' => $previous_element,
01062       'below' => FALSE,
01063     );
01064   }
01065   return array($remnant, $tree);
01066 }
01067
01073 function theme_menu_item_link($link) {
01074   if (empty($link['localized_options'])) {
01075     $link['localized_options'] = array();
01076   }
01077
01078   return l($link['title'], $link['href'], $link['localized_options']);
01079 }
01080
01086 function theme_menu_tree($tree) {
01087   return '<ul class="menu">'. $tree .'</ul>';
01088 }
01089
01095 function theme_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
01096   $class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
01097   if (!empty($extra_class)) {
01098     $class .= ' '. $extra_class;
01099   }
01100   if ($in_active_trail) {
01101     $class .= ' active-trail';
01102   }
01103   return '<li class="'. $class .'">'. $link . $menu ."</li>\n";
01104 }
01105
01111 function theme_menu_local_task($link, $active = FALSE) {
01112   return '<li '. ($active ? 'class="active" ' : '') .'>'. $link ."</li>\n";
01113 }
01114
01118 function drupal_help_arg($arg = array()) {
01119   // Note - the number of empty elements should be > MENU_MAX_PARTS.
01120   return $arg + array('', '', '', '', '', '', '', '', '', '', '', '');
01121 }
01122
01126 function menu_get_active_help() {
01127   $output = '';
01128   $router_path = menu_tab_root_path();
01129
01130   $arg = drupal_help_arg(arg(NULL));
01131   $empty_arg = drupal_help_arg();
01132
01133   foreach (module_list() as $name) {
01134     if (module_hook($name, 'help')) {
01135       // Lookup help for this path.
01136       if ($help = module_invoke($name, 'help', $router_path, $arg)) {
01137         $output .= $help ."\n";
01138       }
01139       // Add "more help" link on admin pages if the module provides a
01140       // standalone help page.
01141       if ($arg[0] == "admin" && module_exists('help') && module_invoke($name, 'help', 'admin/help#'. $arg[2], $empty_arg) && $help) {
01142         $output .= theme("more_help_link", url('admin/help/'. $arg[2]));
01143       }
01144     }
01145   }
01146   return $output;
01147 }
01148
01152 function menu_get_names($reset = FALSE) {
01153   static $names;
01154
01155   if ($reset || empty($names)) {
01156     $names = array();
01157     $result = db_query("SELECT DISTINCT(menu_name) FROM {menu_links} ORDER BY menu_name");
01158     while ($name = db_fetch_array($result)) {
01159       $names[] = $name['menu_name'];
01160     }
01161   }
01162   return $names;
01163 }
01164
01168 function menu_list_system_menus() {
01169   return array('navigation', 'primary-links', 'secondary-links');
01170 }
01171
01175 function menu_primary_links() {
01176   return menu_navigation_links(variable_get('menu_primary_links_source', 'primary-links'));
01177 }
01178
01182 function menu_secondary_links() {
01183
01184   // If the secondary menu source is set as the primary menu, we display the
01185   // second level of the primary menu.
01186   if (variable_get('menu_secondary_links_source', 'secondary-links') == variable_get('menu_primary_links_source', 'primary-links')) {
01187     return menu_navigation_links(variable_get('menu_primary_links_source', 'primary-links'), 1);
01188   }
01189   else {
01190     return menu_navigation_links(variable_get('menu_secondary_links_source', 'secondary-links'), 0);
01191   }
01192 }
01193
01204 function menu_navigation_links($menu_name, $level = 0) {
01205   // Don't even bother querying the menu table if no menu is specified.
01206   if (empty($menu_name)) {
01207     return array();
01208   }
01209
01210   // Get the menu hierarchy for the current page.
01211   $tree = menu_tree_page_data($menu_name);
01212
01213   // Go down the active trail until the right level is reached.
01214   while ($level-- > 0 && $tree) {
01215     // Loop through the current level's items until we find one that is in trail.
01216     while ($item = array_shift($tree)) {
01217       if ($item['link']['in_active_trail']) {
01218         // If the item is in the active trail, we continue in the subtree.
01219         $tree = empty($item['below']) ? array() : $item['below'];
01220         break;
01221       }
01222     }
01223   }
01224
01225   // Create a single level of links.
01226   $links = array();
01227   foreach ($tree as $item) {
01228     if (!$item['link']['hidden']) {
01229       $l = $item['link']['localized_options'];
01230       $l['href'] = $item['link']['href'];
01231       $l['title'] = $item['link']['title'];
01232       // Keyed with unique menu id to generate classes from theme_links().
01233       $links['menu-'. $item['link']['mlid']] = $l;
01234     }
01235   }
01236   return $links;
01237 }
01238
01251 function menu_local_tasks($level = 0, $return_root = FALSE) {
01252   static $tabs;
01253   static $root_path;
01254
01255   if (!isset($tabs)) {
01256     $tabs = array();
01257
01258     $router_item = menu_get_item();
01259     if (!$router_item || !$router_item['access']) {
01260       return '';
01261     }
01262     // Get all tabs and the root page.
01263     $result = db_query("SELECT * FROM {menu_router} WHERE tab_root = '%s' ORDER BY weight, title", $router_item['tab_root']);
01264     $map = arg();
01265     $children = array();
01266     $tasks = array();
01267     $root_path = $router_item['path'];
01268
01269     while ($item = db_fetch_array($result)) {
01270       _menu_translate($item, $map, TRUE);
01271       if ($item['tab_parent']) {
01272         // All tabs, but not the root page.
01273         $children[$item['tab_parent']][$item['path']] = $item;
01274       }
01275       // Store the translated item for later use.
01276       $tasks[$item['path']] = $item;
01277     }
01278
01279     // Find all tabs below the current path.
01280     $path = $router_item['path'];
01281     // Tab parenting may skip levels, so the number of parts in the path may not
01282     // equal the depth. Thus we use the $depth counter (offset by 1000 for ksort).
01283     $depth = 1001;
01284     while (isset($children[$path])) {
01285       $tabs_current = '';
01286       $next_path = '';
01287       $count = 0;
01288       foreach ($children[$path] as $item) {
01289         if ($item['access']) {
01290           $count++;
01291           // The default task is always active.
01292           if ($item['type'] == MENU_DEFAULT_LOCAL_TASK) {
01293             // Find the first parent which is not a default local task.
01294             for ($p = $item['tab_parent']; $tasks[$p]['type'] == MENU_DEFAULT_LOCAL_TASK; $p = $tasks[$p]['tab_parent']);
01295             $link = theme('menu_item_link', array('href' => $tasks[$p]['href']) + $item);
01296             $tabs_current .= theme('menu_local_task', $link, TRUE);
01297             $next_path = $item['path'];
01298           }
01299           else {
01300             $link = theme('menu_item_link', $item);
01301             $tabs_current .= theme('menu_local_task', $link);
01302           }
01303         }
01304       }
01305       $path = $next_path;
01306       $tabs[$depth]['count'] = $count;
01307       $tabs[$depth]['output'] = $tabs_current;
01308       $depth++;
01309     }
01310
01311     // Find all tabs at the same level or above the current one.
01312     $parent = $router_item['tab_parent'];
01313     $path = $router_item['path'];
01314     $current = $router_item;
01315     $depth = 1000;
01316     while (isset($children[$parent])) {
01317       $tabs_current = '';
01318       $next_path = '';
01319       $next_parent = '';
01320       $count = 0;
01321       foreach ($children[$parent] as $item) {
01322         if ($item['access']) {
01323           $count++;
01324           if ($item['type'] == MENU_DEFAULT_LOCAL_TASK) {
01325             // Find the first parent which is not a default local task.
01326             for ($p = $item['tab_parent']; $tasks[$p]['type'] == MENU_DEFAULT_LOCAL_TASK; $p = $tasks[$p]['tab_parent']);
01327             $link = theme('menu_item_link', array('href' => $tasks[$p]['href']) + $item);
01328             if ($item['path'] == $router_item['path']) {
01329               $root_path = $tasks[$p]['path'];
01330             }
01331           }
01332           else {
01333             $link = theme('menu_item_link', $item);
01334           }
01335           // We check for the active tab.
01336           if ($item['path'] == $path) {
01337             $tabs_current .= theme('menu_local_task', $link, TRUE);
01338             $next_path = $item['tab_parent'];
01339             if (isset($tasks[$next_path])) {
01340               $next_parent = $tasks[$next_path]['tab_parent'];
01341             }
01342           }
01343           else {
01344             $tabs_current .= theme('menu_local_task', $link);
01345           }
01346         }
01347       }
01348       $path = $next_path;
01349       $parent = $next_parent;
01350       $tabs[$depth]['count'] = $count;
01351       $tabs[$depth]['output'] = $tabs_current;
01352       $depth--;
01353     }
01354     // Sort by depth.
01355     ksort($tabs);
01356     // Remove the depth, we are interested only in their relative placement.
01357     $tabs = array_values($tabs);
01358   }
01359
01360   if ($return_root) {
01361     return $root_path;
01362   }
01363   else {
01364     // We do not display single tabs.
01365     return (isset($tabs[$level]) && $tabs[$level]['count'] > 1) ? $tabs[$level]['output'] : '';
01366   }
01367 }
01368
01372 function menu_primary_local_tasks() {
01373   return menu_local_tasks(0);
01374 }
01375
01379 function menu_secondary_local_tasks() {
01380   return menu_local_tasks(1);
01381 }
01382
01386 function menu_tab_root_path() {
01387   return menu_local_tasks(0, TRUE);
01388 }
01389
01395 function theme_menu_local_tasks() {
01396   $output = '';
01397
01398   if ($primary = menu_primary_local_tasks()) {
01399     $output .= "<ul class=\"tabs primary\">\n". $primary ."</ul>\n";
01400   }
01401   if ($secondary = menu_secondary_local_tasks()) {
01402     $output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
01403   }
01404
01405   return $output;
01406 }
01407
01411 function menu_set_active_menu_name($menu_name = NULL) {
01412   static $active;
01413
01414   if (isset($menu_name)) {
01415     $active = $menu_name;
01416   }
01417   elseif (!isset($active)) {
01418     $active = 'navigation';
01419   }
01420   return $active;
01421 }
01422
01426 function menu_get_active_menu_name() {
01427   return menu_set_active_menu_name();
01428 }
01429
01440 function menu_set_active_item($path) {
01441   $_GET['q'] = $path;
01442 }
01443
01447 function menu_set_active_trail($new_trail = NULL) {
01448   static $trail;
01449
01450   if (isset($new_trail)) {
01451     $trail = $new_trail;
01452   }
01453   elseif (!isset($trail)) {
01454     $trail = array();
01455     $trail[] = array('title' => t('Home'), 'href' => '<front>', 'localized_options' => array(), 'type' => 0);
01456     $item = menu_get_item();
01457
01458     // Check whether the current item is a local task (displayed as a tab).
01459     if ($item['tab_parent']) {
01460       // The title of a local task is used for the tab, never the page title.
01461       // Thus, replace it with the item corresponding to the root path to get
01462       // the relevant href and title.  For example, the menu item corresponding
01463       // to 'admin' is used when on the 'By module' tab at 'admin/by-module'.
01464       $parts = explode('/', $item['tab_root']);
01465       $args = arg();
01466       // Replace wildcards in the root path using the current path.
01467       foreach ($parts as $index => $part) {
01468         if ($part == '%') {
01469           $parts[$index] = $args[$index];
01470         }
01471       }
01472       // Retrieve the menu item using the root path after wildcard replacement.
01473       $root_item = menu_get_item(implode('/', $parts));
01474       if ($root_item && $root_item['access']) {
01475         $item = $root_item;
01476       }
01477     }
01478
01479     $tree = menu_tree_page_data(menu_get_active_menu_name());
01480     list($key, $curr) = each($tree);
01481
01482     while ($curr) {
01483       // Terminate the loop when we find the current path in the active trail.
01484       if ($curr['link']['href'] == $item['href']) {
01485         $trail[] = $curr['link'];
01486         $curr = FALSE;
01487       }
01488       else {
01489         // Move to the child link if it's in the active trail.
01490         if ($curr['below'] && $curr['link']['in_active_trail']) {
01491           $trail[] = $curr['link'];
01492           $tree = $curr['below'];
01493         }
01494         list($key, $curr) = each($tree);
01495       }
01496     }
01497     // Make sure the current page is in the trail (needed for the page title),
01498     // but exclude tabs and the front page.
01499     $last = count($trail) - 1;
01500     if ($trail[$last]['href'] != $item['href'] && !(bool)($item['type'] & MENU_IS_LOCAL_TASK) && !drupal_is_front_page()) {
01501       $trail[] = $item;
01502     }
01503   }
01504   return $trail;
01505 }
01506
01510 function menu_get_active_trail() {
01511   return menu_set_active_trail();
01512 }
01513
01517 function menu_get_active_breadcrumb() {
01518   $breadcrumb = array();
01519
01520   // No breadcrumb for the front page.
01521   if (drupal_is_front_page()) {
01522     return $breadcrumb;
01523   }
01524
01525   $item = menu_get_item();
01526   if ($item && $item['access']) {
01527     $active_trail = menu_get_active_trail();
01528
01529     foreach ($active_trail as $parent) {
01530       $breadcrumb[] = l($parent['title'], $parent['href'], $parent['localized_options']);
01531     }
01532     $end = end($active_trail);
01533
01534     // Don't show a link to the current page in the breadcrumb trail.
01535     if ($item['href'] == $end['href'] || ($item['type'] == MENU_DEFAULT_LOCAL_TASK && $end['href'] != '<front>')) {
01536       array_pop($breadcrumb);
01537     }
01538   }
01539   return $breadcrumb;
01540 }
01541
01545 function menu_get_active_title() {
01546   $active_trail = menu_get_active_trail();
01547
01548   foreach (array_reverse($active_trail) as $item) {
01549     if (!(bool)($item['type'] & MENU_IS_LOCAL_TASK)) {
01550       return $item['title'];
01551     }
01552   }
01553 }
01554
01568 function menu_link_load($mlid) {
01569   if (is_numeric($mlid) && $item = db_fetch_array(db_query("SELECT m.*, ml.* FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path WHERE ml.mlid = %d", $mlid))) {
01570     _menu_link_translate($item);
01571     return $item;
01572   }
01573   return FALSE;
01574 }
01575
01579 function menu_cache_clear($menu_name = 'navigation') {
01580   static $cache_cleared = array();
01581
01582   if (empty($cache_cleared[$menu_name])) {
01583     cache_clear_all('links:'. $menu_name .':', 'cache_menu', TRUE);
01584     $cache_cleared[$menu_name] = 1;
01585   }
01586   elseif ($cache_cleared[$menu_name] == 1) {
01587     register_shutdown_function('cache_clear_all', 'links:'. $menu_name .':', 'cache_menu', TRUE);
01588     $cache_cleared[$menu_name] = 2;
01589   }
01590 }
01591
01596 function menu_cache_clear_all() {
01597   cache_clear_all('*', 'cache_menu', TRUE);
01598 }
01599
01610 function menu_rebuild() {
01611   variable_del('menu_rebuild_needed');
01612   menu_cache_clear_all();
01613   $menu = menu_router_build(TRUE);
01614   _menu_navigation_links_rebuild($menu);
01615   // Clear the page and block caches.
01616   _menu_clear_page_cache();
01617   if (defined('MAINTENANCE_MODE')) {
01618     variable_set('menu_rebuild_needed', TRUE);
01619   }
01620 }
01621
01625 function menu_router_build($reset = FALSE) {
01626   static $menu;
01627
01628   if (!isset($menu) || $reset) {
01629     if (!$reset && ($cache = cache_get('router:', 'cache_menu')) && isset($cache->data)) {
01630       $menu = $cache->data;
01631     }
01632     else {
01633       db_query('DELETE FROM {menu_router}');
01634       // We need to manually call each module so that we can know which module
01635       // a given item came from.
01636       $callbacks = array();
01637       foreach (module_implements('menu') as $module) {
01638         $router_items = call_user_func($module .'_menu');
01639         if (isset($router_items) && is_array($router_items)) {
01640           foreach (array_keys($router_items) as $path) {
01641             $router_items[$path]['module'] = $module;
01642           }
01643           $callbacks = array_merge($callbacks, $router_items);
01644         }
01645       }
01646       // Alter the menu as defined in modules, keys are like user/%user.
01647       drupal_alter('menu', $callbacks);
01648       $menu = _menu_router_build($callbacks);
01649       cache_set('router:', $menu, 'cache_menu');
01650     }
01651   }
01652   return $menu;
01653 }
01654
01658 function _menu_link_build($item) {
01659   if ($item['type'] == MENU_CALLBACK) {
01660     $item['hidden'] = -1;
01661   }
01662   elseif ($item['type'] == MENU_SUGGESTED_ITEM) {
01663     $item['hidden'] = 1;
01664   }
01665   // Note, we set this as 'system', so that we can be sure to distinguish all
01666   // the menu links generated automatically from entries in {menu_router}.
01667   $item['module'] = 'system';
01668   $item += array(
01669     'menu_name' => 'navigation',
01670     'link_title' => $item['title'],
01671     'link_path' => $item['path'],
01672     'hidden' => 0,
01673     'options' => empty($item['description']) ? array() : array('attributes' => array('title' => $item['description'])),
01674   );
01675   return $item;
01676 }
01677
01681 function _menu_navigation_links_rebuild($menu) {
01682   // Add normal and suggested items as links.
01683   $menu_links = array();
01684   foreach ($menu as $path => $item) {
01685     if ($item['_visible']) {
01686       $item = _menu_link_build($item);
01687       $menu_links[$path] = $item;
01688       $sort[$path] = $item['_number_parts'];
01689     }
01690   }
01691   if ($menu_links) {
01692     // Make sure no child comes before its parent.
01693     array_multisort($sort, SORT_NUMERIC, $menu_links);
01694
01695     foreach ($menu_links as $item) {
01696       $existing_item = db_fetch_array(db_query("SELECT mlid, menu_name, plid, customized FROM {menu_links} WHERE link_path = '%s' AND module = '%s'", $item['link_path'], 'system'));
01697       if ($existing_item) {
01698         $item['mlid'] = $existing_item['mlid'];
01699         $item['menu_name'] = $existing_item['menu_name'];
01700         $item['plid'] = $existing_item['plid'];
01701       }
01702       if (!$existing_item || !$existing_item['customized']) {
01703         menu_link_save($item);
01704       }
01705     }
01706   }
01707   $placeholders = db_placeholders($menu, 'varchar');
01708   $paths = array_keys($menu);
01709   // Updated items and customized items which router paths are gone need new
01710   // router paths.
01711   $result = db_query("SELECT ml.link_path, ml.mlid, ml.router_path, ml.updated FROM {menu_links} ml WHERE ml.updated = 1 OR (router_path NOT IN ($placeholders) AND external = 0 AND customized = 1)", $paths);
01712   while ($item = db_fetch_array($result)) {
01713     $router_path = _menu_find_router_path($menu, $item['link_path']);
01714     if (!empty($router_path) && ($router_path != $item['router_path'] || $item['updated'])) {
01715       // If the router path and the link path matches, it's surely a working
01716       // item, so we clear the updated flag.
01717       $updated = $item['updated'] && $router_path != $item['link_path'];
01718       db_query("UPDATE {menu_links} SET router_path = '%s', updated = %d WHERE mlid = %d", $router_path, $updated, $item['mlid']);
01719     }
01720   }
01721   // Find any items where their router path does not exist any more.
01722   $result = db_query('SELECT * FROM {menu_links} WHERE router_path NOT IN ('. $placeholders .') AND external = 0 AND updated = 0 AND customized = 0 ORDER BY depth DESC', array_keys($menu));
01723   // Remove all such items. Starting from those with the greatest depth will
01724   // minimize the amount of re-parenting done by menu_link_delete().
01725   while ($item = db_fetch_array($result)) {
01726     _menu_delete_item($item, TRUE);
01727   }
01728 }
01729
01738 function menu_link_delete($mlid, $path = NULL) {
01739   if (isset($mlid)) {
01740     _menu_delete_item(db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE mlid = %d", $mlid)));
01741   }
01742   else {
01743     $result = db_query("SELECT * FROM {menu_links} WHERE link_path = '%s'", $path);
01744     while ($link = db_fetch_array($result)) {
01745       _menu_delete_item($link);
01746     }
01747   }
01748 }
01749
01758 function _menu_delete_item($item, $force = FALSE) {
01759   if ($item && ($item['module'] != 'system' || $item['updated'] || $force)) {
01760     // Children get re-attached to the item's parent.
01761     if ($item['has_children']) {
01762       $result = db_query("SELECT mlid FROM {menu_links} WHERE plid = %d", $item['mlid']);
01763       while ($m = db_fetch_array($result)) {
01764         $child = menu_link_load($m['mlid']);
01765         $child['plid'] = $item['plid'];
01766         menu_link_save($child);
01767       }
01768     }
01769     db_query('DELETE FROM {menu_links} WHERE mlid = %d', $item['mlid']);
01770
01771     // Update the has_children status of the parent.
01772     _menu_update_parental_status($item);
01773     menu_cache_clear($item['menu_name']);
01774     _menu_clear_page_cache();
01775   }
01776 }
01777
01792 function menu_link_save(&$item) {
01793   $menu = menu_router_build();
01794
01795   drupal_alter('menu_link', $item, $menu);
01796
01797   // This is the easiest way to handle the unique internal path '<front>',
01798   // since a path marked as external does not need to match a router path.
01799   $item['_external'] = menu_path_is_external($item['link_path'])  || $item['link_path'] == '<front>';
01800   // Load defaults.
01801   $item += array(
01802     'menu_name' => 'navigation',
01803     'weight' => 0,
01804     'link_title' => '',
01805     'hidden' => 0,
01806     'has_children' => 0,
01807     'expanded' => 0,
01808     'options' => array(),
01809     'module' => 'menu',
01810     'customized' => 0,
01811     'updated' => 0,
01812   );
01813   $existing_item = FALSE;
01814   if (isset($item['mlid'])) {
01815     $existing_item = db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE mlid = %d", $item['mlid']));
01816   }
01817
01818   if (isset($item['plid'])) {
01819     $parent = db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE mlid = %d", $item['plid']));
01820   }
01821   else {
01822     // Find the parent - it must be unique.
01823     $parent_path = $item['link_path'];
01824     $where = "WHERE link_path = '%s'";
01825     // Only links derived from router items should have module == 'system', and
01826     // we want to find the parent even if it's in a different menu.
01827     if ($item['module'] == 'system') {
01828       $where .= " AND module = '%s'";
01829       $arg2 = 'system';
01830     }
01831     else {
01832       // If not derived from a router item, we respect the specified menu name.
01833       $where .= " AND menu_name = '%s'";
01834       $arg2 = $item['menu_name'];
01835     }
01836     do {
01837       $parent = FALSE;
01838       $parent_path = substr($parent_path, 0, strrpos($parent_path, '/'));
01839       $result = db_query("SELECT COUNT(*) FROM {menu_links} ". $where, $parent_path, $arg2);
01840       // Only valid if we get a unique result.
01841       if (db_result($result) == 1) {
01842         $parent = db_fetch_array(db_query("SELECT * FROM {menu_links} ". $where, $parent_path, $arg2));
01843       }
01844     } while ($parent === FALSE && $parent_path);
01845   }
01846   if ($parent !== FALSE) {
01847     $item['menu_name'] = $parent['menu_name'];
01848   }
01849   $menu_name = $item['menu_name'];
01850   // Menu callbacks need to be in the links table for breadcrumbs, but can't
01851   // be parents if they are generated directly from a router item.
01852   if (empty($parent['mlid']) || $parent['hidden'] < 0) {
01853     $item['plid'] =  0;
01854   }
01855   else {
01856     $item['plid'] = $parent['mlid'];
01857   }
01858
01859   if (!$existing_item) {
01860     db_query("INSERT INTO {menu_links} (
01861        menu_name, plid, link_path,
01862       hidden, external, has_children,
01863       expanded, weight,
01864       module, link_title, options,
01865       customized, updated) VALUES (
01866       '%s', %d, '%s',
01867       %d, %d, %d,
01868       %d, %d,
01869       '%s', '%s', '%s', %d, %d)",
01870       $item['menu_name'], $item['plid'], $item['link_path'],
01871       $item['hidden'], $item['_external'], $item['has_children'],
01872       $item['expanded'], $item['weight'],
01873       $item['module'],  $item['link_title'], serialize($item['options']),
01874       $item['customized'], $item['updated']);
01875     $item['mlid'] = db_last_insert_id('menu_links', 'mlid');
01876   }
01877
01878   if (!$item['plid']) {
01879     $item['p1'] = $item['mlid'];
01880     for ($i = 2; $i <= MENU_MAX_DEPTH; $i++) {
01881       $item["p$i"] = 0;
01882     }
01883     $item['depth'] = 1;
01884   }
01885   else {
01886     // Cannot add beyond the maximum depth.
01887     if ($item['has_children'] && $existing_item) {
01888       $limit = MENU_MAX_DEPTH - menu_link_children_relative_depth($existing_item) - 1;
01889     }
01890     else {
01891       $limit = MENU_MAX_DEPTH - 1;
01892     }
01893     if ($parent['depth'] > $limit) {
01894       return FALSE;
01895     }
01896     $item['depth'] = $parent['depth'] + 1;
01897     _menu_link_parents_set($item, $parent);
01898   }
01899   // Need to check both plid and menu_name, since plid can be 0 in any menu.
01900   if ($existing_item && ($item['plid'] != $existing_item['plid'] || $menu_name != $existing_item['menu_name'])) {
01901     _menu_link_move_children($item, $existing_item);
01902   }
01903   // Find the callback. During the menu update we store empty paths to be
01904   // fixed later, so we skip this.
01905   if (!isset($_SESSION['system_update_6021']) && (empty($item['router_path'])  || !$existing_item || ($existing_item['link_path'] != $item['link_path']))) {
01906     if ($item['_external']) {
01907       $item['router_path'] = '';
01908     }
01909     else {
01910       // Find the router path which will serve this path.
01911       $item['parts'] = explode('/', $item['link_path'], MENU_MAX_PARTS);
01912       $item['router_path'] = _menu_find_router_path($menu, $item['link_path']);
01913     }
01914   }
01915   db_query("UPDATE {menu_links} SET menu_name = '%s', plid = %d, link_path = '%s',
01916     router_path = '%s', hidden = %d, external = %d, has_children = %d,
01917     expanded = %d, weight = %d, depth = %d,
01918     p1 = %d, p2 = %d, p3 = %d, p4 = %d, p5 = %d, p6 = %d, p7 = %d, p8 = %d, p9 = %d,
01919     module = '%s', link_title = '%s', options = '%s', customized = %d WHERE mlid = %d",
01920     $item['menu_name'], $item['plid'], $item['link_path'],
01921     $item['router_path'], $item['hidden'], $item['_external'], $item['has_children'],
01922     $item['expanded'], $item['weight'],  $item['depth'],
01923     $item['p1'], $item['p2'], $item['p3'], $item['p4'], $item['p5'], $item['p6'], $item['p7'], $item['p8'], $item['p9'],
01924     $item['module'],  $item['link_title'], serialize($item['options']), $item['customized'], $item['mlid']);
01925   // Check the has_children status of the parent.
01926   _menu_update_parental_status($item);
01927   menu_cache_clear($menu_name);
01928   if ($existing_item && $menu_name != $existing_item['menu_name']) {
01929     menu_cache_clear($existing_item['menu_name']);
01930   }
01931
01932   _menu_clear_page_cache();
01933   return $item['mlid'];
01934 }
01935
01939 function _menu_clear_page_cache() {
01940   static $cache_cleared = 0;
01941
01942   // Clear the page and block caches, but at most twice, including at
01943   //  the end of the page load when there are multple links saved or deleted.
01944   if (empty($cache_cleared)) {
01945     cache_clear_all();
01946     // Keep track of which menus have expanded items.
01947     _menu_set_expanded_menus();
01948     $cache_cleared = 1;
01949   }
01950   elseif ($cache_cleared == 1) {
01951     register_shutdown_function('cache_clear_all');
01952     // Keep track of which menus have expanded items.
01953     register_shutdown_function('_menu_set_expanded_menus');
01954     $cache_cleared = 2;
01955   }
01956 }
01957
01961 function _menu_set_expanded_menus() {
01962   $names = array();
01963   $result = db_query("SELECT menu_name FROM {menu_links} WHERE expanded != 0 GROUP BY menu_name");
01964   while ($n = db_fetch_array($result)) {
01965     $names[] = $n['menu_name'];
01966   }
01967   variable_set('menu_expanded', $names);
01968 }
01969
01981 function _menu_find_router_path($menu, $link_path) {
01982   $parts = explode('/', $link_path, MENU_MAX_PARTS);
01983   $router_path = $link_path;
01984   if (!isset($menu[$router_path])) {
01985     list($ancestors) = menu_get_ancestors($parts);
01986     $ancestors[] = '';
01987     foreach ($ancestors as $key => $router_path) {
01988       if (isset($menu[$router_path])) {
01989         break;
01990       }
01991     }
01992   }
01993   return $router_path;
01994 }
01995
02011 function menu_link_maintain($module, $op, $link_path, $link_title) {
02012   switch ($op) {
02013     case 'insert':
02014       $menu_link = array(
02015         'link_title' => $link_title,
02016         'link_path' => $link_path,
02017         'module' => $module,
02018       );
02019       return menu_link_save($menu_link);
02020       break;
02021     case 'update':
02022       db_query("UPDATE {menu_links} SET link_title = '%s' WHERE link_path = '%s' AND customized = 0 AND module = '%s'", $link_title, $link_path, $module);
02023       menu_cache_clear();
02024       break;
02025     case 'delete':
02026       menu_link_delete(NULL, $link_path);
02027       break;
02028   }
02029 }
02030
02043 function menu_link_children_relative_depth($item) {
02044   $i = 1;
02045   $match = '';
02046   $args[] = $item['menu_name'];
02047   $p = 'p1';
02048   while ($i <= MENU_MAX_DEPTH && $item[$p]) {
02049     $match .= " AND $p = %d";
02050     $args[] = $item[$p];
02051     $p = 'p'. ++$i;
02052   }
02053
02054   $max_depth = db_result(db_query_range("SELECT depth FROM {menu_links} WHERE menu_name = '%s'". $match ." ORDER BY depth DESC", $args, 0, 1));
02055
02056   return ($max_depth > $item['depth']) ? $max_depth - $item['depth'] : 0;
02057 }
02058
02065 function _menu_link_move_children($item, $existing_item) {
02066
02067   $args[] = $item['menu_name'];
02068   $set[] = "menu_name = '%s'";
02069
02070   $i = 1;
02071   while ($i <= $item['depth']) {
02072     $p = 'p'. $i++;
02073     $set[] = "$p = %d";
02074     $args[] = $item[$p];
02075   }
02076   $j = $existing_item['depth'] + 1;
02077   while ($i <= MENU_MAX_DEPTH && $j <= MENU_MAX_DEPTH) {
02078     $set[] = 'p'. $i++ .' = p'. $j++;
02079   }
02080   while ($i <= MENU_MAX_DEPTH) {
02081     $set[] = 'p'. $i++ .' = 0';
02082   }
02083
02084   $shift = $item['depth'] - $existing_item['depth'];
02085   if ($shift < 0) {
02086     $args[] = -$shift;
02087     $set[] = 'depth = depth - %d';
02088   }
02089   elseif ($shift > 0) {
02090     // The order of $set must be reversed so the new values don't overwrite the
02091     // old ones before they can be used because "Single-table UPDATE
02092     // assignments are generally evaluated from left to right"
02093     // see: http://dev.mysql.com/doc/refman/5.0/en/update.html
02094     $set = array_reverse($set);
02095     $args = array_reverse($args);
02096
02097     $args[] = $shift;
02098     $set[] = 'depth = depth + %d';
02099   }
02100   $where[] = "menu_name = '%s'";
02101   $args[] = $existing_item['menu_name'];
02102   $p = 'p1';
02103   for ($i = 1; $i <= MENU_MAX_DEPTH && $existing_item[$p]; $p = 'p'. ++$i) {
02104     $where[] = "$p = %d";
02105     $args[] = $existing_item[$p];
02106   }
02107
02108   db_query("UPDATE {menu_links} SET ". implode(', ', $set) ." WHERE ". implode(' AND ', $where), $args);
02109   // Check the has_children status of the parent, while excluding this item.
02110   _menu_update_parental_status($existing_item, TRUE);
02111 }
02112
02116 function _menu_update_parental_status($item, $exclude = FALSE) {
02117   // If plid == 0, there is nothing to update.
02118   if ($item['plid']) {
02119     // We may want to exclude the passed link as a possible child.
02120     $where = $exclude ? " AND mlid != %d" : '';
02121     // Check if at least one visible child exists in the table.
02122     $parent_has_children = (bool)db_result(db_query_range("SELECT mlid FROM {menu_links} WHERE menu_name = '%s' AND plid = %d AND hidden = 0". $where, $item['menu_name'], $item['plid'], $item['mlid'], 0, 1));
02123     db_query("UPDATE {menu_links} SET has_children = %d WHERE mlid = %d", $parent_has_children, $item['plid']);
02124   }
02125 }
02126
02130 function _menu_link_parents_set(&$item, $parent) {
02131   $i = 1;
02132   while ($i < $item['depth']) {
02133     $p = 'p'. $i++;
02134     $item[$p] = $parent[$p];
02135   }
02136   $p = 'p'. $i++;
02137   // The parent (p1 - p9) corresponding to the depth always equals the mlid.
02138   $item[$p] = $item['mlid'];
02139   while ($i <= MENU_MAX_DEPTH) {
02140     $p = 'p'. $i++;
02141     $item[$p] = 0;
02142   }
02143 }
02144
02148 function _menu_router_build($callbacks) {
02149   // First pass: separate callbacks from paths, making paths ready for
02150   // matching. Calculate fitness, and fill some default values.
02151   $menu = array();
02152   foreach ($callbacks as $path => $item) {
02153     $load_functions = array();
02154     $to_arg_functions = array();
02155     $fit = 0;
02156     $move = FALSE;
02157
02158     $parts = explode('/', $path, MENU_MAX_PARTS);
02159     $number_parts = count($parts);
02160     // We store the highest index of parts here to save some work in the fit
02161     // calculation loop.
02162     $slashes = $number_parts - 1;
02163     // Extract load and to_arg functions.
02164     foreach ($parts as $k => $part) {
02165       $match = FALSE;
02166       if (preg_match('/^%([a-z_]*)$/', $part, $matches)) {
02167         if (empty($matches[1])) {
02168           $match = TRUE;
02169           $load_functions[$k] = NULL;
02170         }
02171         else {
02172           if (function_exists($matches[1] .'_to_arg')) {
02173             $to_arg_functions[$k] = $matches[1] .'_to_arg';
02174             $load_functions[$k] = NULL;
02175             $match = TRUE;
02176           }
02177           if (function_exists($matches[1] .'_load')) {
02178             $function = $matches[1] .'_load';
02179             // Create an array of arguments that will be passed to the _load
02180             // function when this menu path is checked, if 'load arguments'
02181             // exists.
02182             $load_functions[$k] = isset($item['load arguments']) ? array($function => $item['load arguments']) : $function;
02183             $match = TRUE;
02184           }
02185         }
02186       }
02187       if ($match) {
02188         $parts[$k] = '%';
02189       }
02190       else {
02191         $fit |=  1 << ($slashes - $k);
02192       }
02193     }
02194     if ($fit) {
02195       $move = TRUE;
02196     }
02197     else {
02198       // If there is no %, it fits maximally.
02199       $fit = (1 << $number_parts) - 1;
02200     }
02201     $masks[$fit] = 1;
02202     $item['load_functions'] = empty($load_functions) ? '' : serialize($load_functions);
02203     $item['to_arg_functions'] = empty($to_arg_functions) ? '' : serialize($to_arg_functions);
02204     $item += array(
02205       'title' => '',
02206       'weight' => 0,
02207       'type' => MENU_NORMAL_ITEM,
02208       '_number_parts' => $number_parts,
02209       '_parts' => $parts,
02210       '_fit' => $fit,
02211     );
02212     $item += array(
02213       '_visible' => (bool)($item['type'] & MENU_VISIBLE_IN_BREADCRUMB),
02214       '_tab' => (bool)($item['type'] & MENU_IS_LOCAL_TASK),
02215     );
02216     if ($move) {
02217       $new_path = implode('/', $item['_parts']);
02218       $menu[$new_path] = $item;
02219       $sort[$new_path] = $number_parts;
02220     }
02221     else {
02222       $menu[$path] = $item;
02223       $sort[$path] = $number_parts;
02224     }
02225   }
02226   array_multisort($sort, SORT_NUMERIC, $menu);
02227
02228   // Apply inheritance rules.
02229   foreach ($menu as $path => $v) {
02230     $item = &$menu[$path];
02231     if (!$item['_tab']) {
02232       // Non-tab items.
02233       $item['tab_parent'] = '';
02234       $item['tab_root'] = $path;
02235     }
02236     for ($i = $item['_number_parts'] - 1; $i; $i--) {
02237       $parent_path = implode('/', array_slice($item['_parts'], 0, $i));
02238       if (isset($menu[$parent_path])) {
02239
02240         $parent = $menu[$parent_path];
02241
02242         if (!isset($item['tab_parent'])) {
02243           // Parent stores the parent of the path.
02244           $item['tab_parent'] = $parent_path;
02245         }
02246         if (!isset($item['tab_root']) && !$parent['_tab']) {
02247           $item['tab_root'] = $parent_path;
02248         }
02249         // If a callback is not found, we try to find the first parent that
02250         // has a callback.
02251         if (!isset($item['access callback']) && isset($parent['access callback'])) {
02252           $item['access callback'] = $parent['access callback'];
02253           if (!isset($item['access arguments']) && isset($parent['access arguments'])) {
02254             $item['access arguments'] = $parent['access arguments'];
02255           }
02256         }
02257         // Same for page callbacks.
02258         if (!isset($item['page callback']) && isset($parent['page callback'])) {
02259           $item['page callback'] = $parent['page callback'];
02260           if (!isset($item['page arguments']) && isset($parent['page arguments'])) {
02261             $item['page arguments'] = $parent['page arguments'];
02262           }
02263           if (!isset($item['file']) && isset($parent['file'])) {
02264             $item['file'] = $parent['file'];
02265           }
02266           if (!isset($item['file path']) && isset($parent['file path'])) {
02267             $item['file path'] = $parent['file path'];
02268           }
02269         }
02270       }
02271     }
02272     if (!isset($item['access callback']) && isset($item['access arguments'])) {
02273       // Default callback.
02274       $item['access callback'] = 'user_access';
02275     }
02276     if (!isset($item['access callback']) || empty($item['page callback'])) {
02277       $item['access callback'] = 0;
02278     }
02279     if (is_bool($item['access callback'])) {
02280       $item['access callback'] = intval($item['access callback']);
02281     }
02282
02283     $item += array(
02284       'access arguments' => array(),
02285       'access callback' => '',
02286       'page arguments' => array(),
02287       'page callback' => '',
02288       'block callback' => '',
02289       'title arguments' => array(),
02290       'title callback' => 't',
02291       'description' => '',
02292       'position' => '',
02293       'tab_parent' => '',
02294       'tab_root' => $path,
02295       'path' => $path,
02296       'file' => '',
02297       'file path' => '',
02298       'include file' => '',
02299     );
02300
02301     // Calculate out the file to be included for each callback, if any.
02302     if ($item['file']) {
02303       $file_path = $item['file path'] ? $item['file path'] : drupal_get_path('module', $item['module']);
02304       $item['include file'] = $file_path .'/'. $item['file'];
02305     }
02306
02307     $title_arguments = $item['title arguments'] ? serialize($item['title arguments']) : '';
02308     db_query("INSERT INTO {menu_router}
02309       (path, load_functions, to_arg_functions, access_callback,
02310       access_arguments, page_callback, page_arguments, fit,
02311       number_parts, tab_parent, tab_root,
02312       title, title_callback, title_arguments,
02313       type, block_callback, description, position, weight, file)
02314       VALUES ('%s', '%s', '%s', '%s',
02315       '%s', '%s', '%s', %d,
02316       %d, '%s', '%s',
02317       '%s', '%s', '%s',
02318       %d, '%s', '%s', '%s', %d, '%s')",
02319       $path, $item['load_functions'], $item['to_arg_functions'], $item['access callback'],
02320       serialize($item['access arguments']), $item['page callback'], serialize($item['page arguments']), $item['_fit'],
02321       $item['_number_parts'], $item['tab_parent'], $item['tab_root'],
02322       $item['title'], $item['title callback'], $title_arguments,
02323       $item['type'], $item['block callback'], $item['description'], $item['position'], $item['weight'], $item['include file']);
02324   }
02325   // Sort the masks so they are in order of descending fit, and store them.
02326   $masks = array_keys($masks);
02327   rsort($masks);
02328   variable_set('menu_masks', $masks);
02329   return $menu;
02330 }
02331
02335 function menu_path_is_external($path) {
02336   $colonpos = strpos($path, ':');
02337   return $colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && filter_xss_bad_protocol($path, FALSE) == check_plain($path);
02338 }
02339
02351 function _menu_site_is_offline() {
02352   // Check if site is set to off-line mode.
02353   if (variable_get('site_offline', 0)) {
02354     // Check if the user has administration privileges.
02355     if (user_access('administer site configuration')) {
02356       // Ensure that the off-line message is displayed only once [allowing for
02357       // page redirects], and specifically suppress its display on the site
02358       // maintenance page.
02359       if (drupal_get_normal_path($_GET['q']) != 'admin/settings/site-maintenance') {
02360         drupal_set_message(t('Operating in off-line mode.'), 'status', FALSE);
02361       }
02362     }
02363     else {
02364       // Anonymous users get a FALSE at the login prompt, TRUE otherwise.
02365       if (user_is_anonymous()) {
02366         return $_GET['q'] != 'user' && $_GET['q'] != 'user/login';
02367       }
02368       // Logged in users are unprivileged here, so they are logged out.
02369       require_once drupal_get_path('module', 'user') .'/user.pages.inc';
02370       user_logout();
02371     }
02372   }
02373   return FALSE;
02374 }
02375
02383 function menu_valid_path($form_item) {
02384   global $menu_admin;
02385   $item = array();
02386   $path = $form_item['link_path'];
02387   // We indicate that a menu administrator is running the menu access check.
02388   $menu_admin = TRUE;
02389   if ($path == '<front>' || menu_path_is_external($path)) {
02390     $item = array('access' => TRUE);
02391   }
02392   elseif (preg_match('/\/\%/', $path)) {
02393     // Path is dynamic (ie 'user/%'), so check directly against menu_router table.
02394     if ($item = db_fetch_array(db_query("SELECT * FROM {menu_router} where path = '%s' ", $path))) {
02395       $item['link_path']  = $form_item['link_path'];
02396       $item['link_title'] = $form_item['link_title'];
02397       $item['external']   = FALSE;
02398       $item['options'] = '';
02399       _menu_link_translate($item);
02400     }
02401   }
02402   else {
02403     $item = menu_get_item($path);
02404   }
02405   $menu_admin = FALSE;
02406   return $item && $item['access'];
02407 }
02408
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/menu/menu.install Source File

modules » menu

menu.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: menu.install,v 1.9 2008/01/30 20:27:28 goba Exp $
00003
00007 function menu_install() {
00008   // Create tables.
00009   drupal_install_schema('menu');
00010
00011   $t = get_t();
00012   db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", 'navigation', $t('Navigation'), $t('The navigation menu is provided by Drupal and is the main interactive menu for any site. It is usually the only menu that contains personalized links for authenticated users, and is often not even visible to anonymous users.'));
00013   db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", 'primary-links', $t('Primary links'), $t('Primary links are often used at the theme layer to show the major sections of a site. A typical representation for primary links would be tabs along the top.'));
00014   db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", 'secondary-links', $t('Secondary links'), $t('Secondary links are often used for pages like legal notices, contact details, and other secondary navigation items that play a lesser role than primary links'));
00015 }
00016
00020 function menu_uninstall() {
00021   // Remove tables.
00022   drupal_uninstall_schema('menu');
00023   menu_rebuild();
00024 }
00025
00029 function menu_schema() {
00030   $schema['menu_custom'] = array(
00031     'description' => t('Holds definitions for top-level custom menus (for example, Primary Links).'),
00032     'fields' => array(
00033       'menu_name' => array(
00034         'type' => 'varchar',
00035         'length' => 32,
00036         'not null' => TRUE,
00037         'default' => '',
00038         'description' => t('Primary Key: Unique key for menu. This is used as a block delta so length is 32.'),
00039       ),
00040       'title' => array(
00041         'type' => 'varchar',
00042         'length' => 255,
00043         'not null' => TRUE,
00044         'default' => '',
00045         'description' => t('Menu title; displayed at top of block.'),
00046       ),
00047       'description' => array(
00048         'type' => 'text',
00049         'not null' => FALSE,
00050         'description' => t('Menu description.'),
00051       ),
00052     ),
00053     'primary key' => array('menu_name'),
00054   );
00055
00056   return $schema;
00057 }
00058
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/menu/menu.module Source File

modules » menu

menu.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: menu.module,v 1.157.2.1 2008/02/11 15:12:53 goba Exp $
00003
00013 define('MENU_MAX_MENU_NAME_LENGTH_UI', 27);
00014
00018 function menu_help($path, $arg) {
00019   switch ($path) {
00020     case 'admin/help#menu':
00021       $output = '<p>'. t("The menu module provides an interface to control and customize Drupal's powerful menu system. Menus are a hierarchical collection of links, or menu items, used to navigate a website, and are positioned and displayed using Drupal's flexible block system. By default, three menus are created during installation: <em>Navigation</em>, <em>Primary links</em>, and <em>Secondary links</em>. The <em>Navigation</em> menu contains most links necessary for working with and navigating your site, and is often displayed in either the left or right sidebar. Most Drupal themes also provide support for <em>Primary links</em> and <em>Secondary links</em>, by displaying them in either the header or footer of each page. By default, <em>Primary links</em> and <em>Secondary links</em> contain no menu items but may be configured to contain custom menu items specific to your site.") .'</p>';
00022       $output .= '<p>'. t('The <a href="@menu">menus page</a> displays all menus currently available on your site. Select a menu from this list to add or edit a menu item, or to rearrange items within the menu. Create new menus using the <a href="@add-menu">add menu page</a> (the block containing a new menu must also be enabled on the <a href="@blocks">blocks administration page</a>).', array('@menu' => url('admin/build/menu'), '@add-menu' => url('admin/build/menu/add'), '@blocks' => url('admin/build/block'))) .'</p>';
00023       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@menu">Menu module</a>.', array('@menu' => 'http://drupal.org/handbook/modules/menu/')) .'</p>';
00024       return $output;
00025     case 'admin/build/menu':
00026       return '<p>'. t('Menus are a collection of links (menu items) used to navigate a website. The menus currently available on your site are displayed below. Select a menu from this list to manage its menu items.') .'</p>';
00027     case 'admin/build/menu/add':
00028       return '<p>'. t('Enter the name for your new menu. Remember to enable the newly created block in the <a href="@blocks">blocks administration page</a>.', array('@blocks' => url('admin/build/block'))) .'</p>';
00029     case 'admin/build/menu-customize/%':
00030       return '<p>'. t('To rearrange menu items, grab a drag-and-drop handle under the <em>Menu item</em> column and drag the items (or group of items) to a new location in the list. (Grab a handle by clicking and holding the mouse while hovering over a handle icon.) Remember that your changes will not be saved until you click the <em>Save configuration</em> button at the bottom of the page.') .'<p>';
00031     case 'admin/build/menu/item/add':
00032       return '<p>'. t('Enter the title and path for your new menu item.') .'</p>';
00033   }
00034 }
00035
00039 function menu_perm() {
00040   return array('administer menu');
00041 }
00042
00046 function menu_menu() {
00047   $items['admin/build/menu'] = array(
00048     'title' => 'Menus',
00049     'description' => "Control your site's navigation menu, primary links and secondary links. as well as rename and reorganize menu items.",
00050     'page callback' => 'menu_overview_page',
00051     'access callback' => 'user_access',
00052     'access arguments' => array('administer menu'),
00053     'file' => 'menu.admin.inc',
00054   );
00055
00056   $items['admin/build/menu/list'] = array(
00057     'title' => 'List menus',
00058     'type' => MENU_DEFAULT_LOCAL_TASK,
00059     'weight' => -10,
00060     'file' => 'menu.admin.inc',
00061   );
00062   $items['admin/build/menu/add'] = array(
00063     'title' => 'Add menu',
00064     'page callback' => 'drupal_get_form',
00065     'page arguments' => array('menu_edit_menu', 'add'),
00066     'type' => MENU_LOCAL_TASK,
00067     'file' => 'menu.admin.inc',
00068   );
00069   $items['admin/build/menu/settings'] = array(
00070     'title' => 'Settings',
00071     'page callback' => 'drupal_get_form',
00072     'page arguments' => array('menu_configure'),
00073     'type' => MENU_LOCAL_TASK,
00074     'weight' => 5,
00075     'file' => 'menu.admin.inc',
00076   );
00077   $items['admin/build/menu-customize/%menu'] = array(
00078     'title' => 'Customize menu',
00079     'page callback' => 'drupal_get_form',
00080     'page arguments' => array('menu_overview_form', 3),
00081     'title callback' => 'menu_overview_title',
00082     'title arguments' => array(3),
00083     'access arguments' => array('administer menu'),
00084     'type' => MENU_CALLBACK,
00085     'file' => 'menu.admin.inc',
00086   );
00087   $items['admin/build/menu-customize/%menu/list'] = array(
00088     'title' => 'List items',
00089     'weight' => -10,
00090     'type' => MENU_DEFAULT_LOCAL_TASK,
00091     'file' => 'menu.admin.inc',
00092   );
00093   $items['admin/build/menu-customize/%menu/add'] = array(
00094     'title' => 'Add item',
00095     'page callback' => 'drupal_get_form',
00096     'page arguments' => array('menu_edit_item', 'add', NULL, 3),
00097     'type' => MENU_LOCAL_TASK,
00098     'file' => 'menu.admin.inc',
00099   );
00100   $items['admin/build/menu-customize/%menu/edit'] = array(
00101     'title' => 'Edit menu',
00102     'page callback' => 'drupal_get_form',
00103     'page arguments' => array('menu_edit_menu', 'edit', 3),
00104     'type' => MENU_LOCAL_TASK,
00105     'file' => 'menu.admin.inc',
00106   );
00107   $items['admin/build/menu-customize/%menu/delete'] = array(
00108     'title' => 'Delete menu',
00109     'page callback' => 'menu_delete_menu_page',
00110     'page arguments' => array(3),
00111     'type' => MENU_CALLBACK,
00112     'file' => 'menu.admin.inc',
00113   );
00114   $items['admin/build/menu/item/%menu_link/edit'] = array(
00115     'title' => 'Edit menu item',
00116     'page callback' => 'drupal_get_form',
00117     'page arguments' => array('menu_edit_item', 'edit', 4, NULL),
00118     'type' => MENU_CALLBACK,
00119     'file' => 'menu.admin.inc',
00120   );
00121   $items['admin/build/menu/item/%menu_link/reset'] = array(
00122     'title' => 'Reset menu item',
00123     'page callback' => 'drupal_get_form',
00124     'page arguments' => array('menu_reset_item_confirm', 4),
00125     'type' => MENU_CALLBACK,
00126     'file' => 'menu.admin.inc',
00127   );
00128   $items['admin/build/menu/item/%menu_link/delete'] = array(
00129     'title' => 'Delete menu item',
00130     'page callback' => 'menu_item_delete_page',
00131     'page arguments' => array(4),
00132     'type' => MENU_CALLBACK,
00133     'file' => 'menu.admin.inc',
00134   );
00135
00136   return $items;
00137 }
00138
00142 function menu_theme() {
00143   return array(
00144     'menu_overview_form' => array(
00145       'file' => 'menu.admin.inc',
00146       'arguments' => array('form' => NULL),
00147     ),
00148   );
00149 }
00150
00156 function menu_enable() {
00157   menu_rebuild();
00158   $link = db_fetch_array(db_query("SELECT mlid AS plid, menu_name from {menu_links} WHERE link_path = 'admin/build/menu' AND module = 'system'"));
00159   $link['router_path'] = 'admin/build/menu-customize/%';
00160   $link['module'] = 'menu';
00161   $result = db_query("SELECT * FROM {menu_custom}");
00162   while ($menu = db_fetch_array($result)) {
00163     $link['mlid'] = 0;
00164     $link['link_title'] = $menu['title'];
00165     $link['link_path'] = 'admin/build/menu-customize/'. $menu['menu_name'];
00166     if (!db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND plid = %d", $link['link_path'], $link['plid']))) {
00167       menu_link_save($link);
00168     }
00169   }
00170   menu_cache_clear_all();
00171 }
00172
00176 function menu_overview_title($menu) {
00177   return $menu['title'];
00178 }
00179
00183 function menu_load($menu_name) {
00184   return db_fetch_array(db_query("SELECT * FROM {menu_custom} WHERE menu_name = '%s'", $menu_name));
00185 }
00186
00199 function menu_parent_options($menus, $item) {
00200   // The menu_links table can be practically any size and we need a way to
00201   // allow contrib modules to provide more scalable pattern choosers.
00202   // hook_form_alter is too late in itself because all the possible parents are
00203   // retrieved here, unless menu_override_parent_selector is set to TRUE.
00204   if (variable_get('menu_override_parent_selector', FALSE)) {
00205     return array();
00206   }
00207   // If the item has children, there is an added limit to the depth of valid parents.
00208   if (isset($item['parent_depth_limit'])) {
00209     $limit = $item['parent_depth_limit'];
00210   }
00211   else {
00212     $limit = _menu_parent_depth_limit($item);
00213   }
00214
00215   foreach ($menus as $menu_name => $title) {
00216     $tree = menu_tree_all_data($menu_name, NULL);
00217     $options[$menu_name .':0'] = '<'. $title .'>';
00218     _menu_parents_recurse($tree, $menu_name, '--', $options, $item['mlid'], $limit);
00219   }
00220   return $options;
00221 }
00222
00226 function _menu_parents_recurse($tree, $menu_name, $indent, &$options, $exclude, $depth_limit) {
00227   foreach ($tree as $data) {
00228     if ($data['link']['depth'] > $depth_limit) {
00229       // Don't iterate through any links on this level.
00230       break;
00231     }
00232     if ($data['link']['mlid'] != $exclude && $data['link']['hidden'] >= 0) {
00233       $title = $indent .' '. truncate_utf8($data['link']['title'], 30, TRUE, FALSE);
00234       if ($data['link']['hidden']) {
00235         $title .= ' ('. t('disabled') .')';
00236       }
00237       $options[$menu_name .':'. $data['link']['mlid']] = $title;
00238       if ($data['below']) {
00239         _menu_parents_recurse($data['below'], $menu_name, $indent .'--', $options, $exclude, $depth_limit);
00240       }
00241     }
00242   }
00243 }
00244
00248 function menu_reset_item($item) {
00249   $router = menu_router_build();
00250   $new_item = _menu_link_build($router[$item['router_path']]);
00251   foreach (array('mlid', 'has_children') as $key) {
00252     $new_item[$key] = $item[$key];
00253   }
00254   menu_link_save($new_item);
00255   return $new_item;
00256 }
00257
00261 function menu_block($op = 'list', $delta = 0) {
00262   $menus = menu_get_menus();
00263   // The Navigation menu is handled by the user module.
00264   unset($menus['navigation']);
00265   if ($op == 'list') {
00266     $blocks = array();
00267     foreach ($menus as $name => $title) {
00268       // Default "Navigation" block is handled by user.module.
00269       $blocks[$name]['info'] = check_plain($title);
00270       // Menu blocks can't be cached because each menu item can have
00271       // a custom access callback. menu.inc manages its own caching.
00272       $blocks[$name]['cache'] = BLOCK_NO_CACHE;
00273     }
00274     return $blocks;
00275   }
00276   else if ($op == 'view') {
00277     $data['subject'] = check_plain($menus[$delta]);
00278     $data['content'] = menu_tree($delta);
00279     return $data;
00280   }
00281 }
00282
00286 function menu_nodeapi(&$node, $op) {
00287   switch ($op) {
00288     case 'insert':
00289     case 'update':
00290       if (isset($node->menu)) {
00291         $item = $node->menu;
00292         if (!empty($item['delete'])) {
00293           menu_link_delete($item['mlid']);
00294         }
00295         elseif (trim($item['link_title'])) {
00296           $item['link_title'] = trim($item['link_title']);
00297           $item['link_path'] = "node/$node->nid";
00298           if (!$item['customized']) {
00299             $item['options']['attributes']['title'] = trim($node->title);
00300           }
00301           if (!menu_link_save($item)) {
00302             drupal_set_message(t('There was an error saving the menu link.'), 'error');
00303           }
00304         }
00305       }
00306       break;
00307     case 'delete':
00308       // Delete all menu module links that point to this node.
00309       $result = db_query("SELECT mlid FROM {menu_links} WHERE link_path = 'node/%d' AND module = 'menu'", $node->nid);
00310       while ($m = db_fetch_array($result)) {
00311         menu_link_delete($m['mlid']);
00312       }
00313       break;
00314     case 'prepare':
00315       if (empty($node->menu)) {
00316         // Prepare the node for the edit form so that $node->menu always exists.
00317         $menu_name = variable_get('menu_default_node_menu', 'primary-links');
00318         $item = array();
00319         if (isset($node->nid)) {
00320           // Give priority to the default menu
00321           $mlid = db_result(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = 'node/%d' AND menu_name = '%s' AND module = 'menu' ORDER BY mlid ASC", $node->nid, $menu_name, 0, 1));
00322           // Check all menus if a link does not exist in the default menu.
00323           if (!$mlid) {
00324             $mlid = db_result(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = 'node/%d' AND module = 'menu' ORDER BY mlid ASC", $node->nid, 0, 1));
00325           }
00326           if ($mlid) {
00327             $item = menu_link_load($mlid);
00328           }
00329         }
00330         // Set default values.
00331         $node->menu = $item + array('link_title' => '', 'mlid' => 0, 'plid' => 0, 'menu_name' => $menu_name, 'weight' => 0, 'options' => array(), 'module' => 'menu', 'expanded' => 0, 'hidden' => 0, 'has_children' => 0, 'customized' => 0);
00332       }
00333       // Find the depth limit for the parent select.
00334       if (!isset($node->menu['parent_depth_limit'])) {
00335         $node->menu['parent_depth_limit'] = _menu_parent_depth_limit($node->menu);
00336       }
00337       break;
00338   }
00339 }
00340
00344 function _menu_parent_depth_limit($item) {
00345   return MENU_MAX_DEPTH - 1 - (($item['mlid'] && $item['has_children']) ? menu_link_children_relative_depth($item) : 0);
00346 }
00347
00351 function menu_form_alter(&$form, $form_state, $form_id) {
00352   if (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id) {
00353     // Note - doing this to make sure the delete checkbox stays in the form.
00354     $form['#cache'] = TRUE;
00355
00356     $form['menu'] = array(
00357       '#type' => 'fieldset',
00358       '#title' => t('Menu settings'),
00359       '#access' => user_access('administer menu'),
00360       '#collapsible' => TRUE,
00361       '#collapsed' => FALSE,
00362       '#tree' => TRUE,
00363       '#weight' => -2,
00364       '#attributes' => array('class' => 'menu-item-form'),
00365     );
00366     $item = $form['#node']->menu;
00367
00368     if ($item['mlid']) {
00369       // There is an existing link.
00370       $form['menu']['delete'] = array(
00371         '#type' => 'checkbox',
00372         '#title' => t('Delete this menu item.'),
00373       );
00374     }
00375     if (!$item['link_title']) {
00376       $form['menu']['#collapsed'] = TRUE;
00377     }
00378
00379     foreach (array('mlid', 'module', 'hidden', 'has_children', 'customized', 'options', 'expanded', 'hidden', 'parent_depth_limit') as $key) {
00380       $form['menu'][$key] = array('#type' => 'value', '#value' => $item[$key]);
00381     }
00382     $form['menu']['#item'] = $item;
00383
00384     $form['menu']['link_title'] = array('#type' => 'textfield',
00385       '#title' => t('Menu link title'),
00386       '#default_value' => $item['link_title'],
00387       '#description' => t('The link text corresponding to this item that should appear in the menu. Leave blank if you do not wish to add this post to the menu.'),
00388       '#required' => FALSE,
00389     );
00390     // Generate a list of possible parents (not including this item or descendants).
00391     $options = menu_parent_options(menu_get_menus(), $item);
00392     $default = $item['menu_name'] .':'. $item['plid'];
00393     if (!isset($options[$default])) {
00394       $default = 'primary-links:0';
00395     }
00396     $form['menu']['parent'] = array(
00397       '#type' => 'select',
00398       '#title' => t('Parent item'),
00399       '#default_value' => $default,
00400       '#options' => $options,
00401       '#description' => t('The maximum depth for an item and all its children is fixed at !maxdepth. Some menu items may not be available as parents if selecting them would exceed this limit.', array('!maxdepth' => MENU_MAX_DEPTH)),
00402       '#attributes' => array('class' => 'menu-title-select'),
00403     );
00404     $form['#submit'][] = 'menu_node_form_submit';
00405
00406     $form['menu']['weight'] = array(
00407       '#type' => 'weight',
00408       '#title' => t('Weight'),
00409       '#delta' => 50,
00410       '#default_value' => $item['weight'],
00411       '#description' => t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'),
00412     );
00413   }
00414 }
00415
00419 function menu_node_form_submit($form, &$form_state) {
00420   list($form_state['values']['menu']['menu_name'], $form_state['values']['menu']['plid']) = explode(':', $form_state['values']['menu']['parent']);
00421 }
00422
00433 function menu_get_menus($all = TRUE) {
00434   $system_menus = menu_list_system_menus();
00435   $sql = 'SELECT * FROM {menu_custom}';
00436   if (!$all) {
00437     $sql .= ' WHERE menu_name NOT IN ('. implode(',', array_fill(0, count($system_menus), "'%s'")) .')';
00438   }
00439   $sql .= ' ORDER BY title';
00440   $result = db_query($sql, $system_menus);
00441   $rows = array();
00442   while ($r = db_fetch_array($result)) {
00443     $rows[$r['menu_name']] = $r['title'];
00444   }
00445   return $rows;
00446 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/minnelli/color/color.inc Source File

themes » garland » minnelli » color

color.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: color.inc,v 1.4 2007/12/14 17:00:14 goba Exp $
00003
00004 $info = array(
00005
00006   // Pre-defined color schemes.
00007   'schemes' => array(
00008     '#0072b9,#027ac6,#2385c2,#5ab5ee,#494949' => t('Blue Lagoon (Default)'),
00009     '#464849,#2f416f,#2a2b2d,#5d6779,#494949' => t('Ash'),
00010     '#55c0e2,#000000,#085360,#007e94,#696969' => t('Aquamarine'),
00011     '#d5b048,#6c420e,#331900,#971702,#494949' => t('Belgian Chocolate'),
00012     '#3f3f3f,#336699,#6598cb,#6598cb,#000000' => t('Bluemarine'),
00013     '#d0cb9a,#917803,#efde01,#e6fb2d,#494949' => t('Citrus Blast'),
00014     '#0f005c,#434f8c,#4d91ff,#1a1575,#000000' => t('Cold Day'),
00015     '#c9c497,#0c7a00,#03961e,#7be000,#494949' => t('Greenbeam'),
00016     '#ffe23d,#a9290a,#fc6d1d,#a30f42,#494949' => t('Mediterrano'),
00017     '#788597,#3f728d,#a9adbc,#d4d4d4,#707070' => t('Mercury'),
00018     '#5b5fa9,#5b5faa,#0a2352,#9fa8d5,#494949' => t('Nocturnal'),
00019     '#7db323,#6a9915,#b5d52a,#7db323,#191a19' => t('Olivia'),
00020     '#12020b,#1b1a13,#f391c6,#f41063,#898080' => t('Pink Plastic'),
00021     '#b7a0ba,#c70000,#a1443a,#f21107,#515d52' => t('Shiny Tomato'),
00022     '#18583d,#1b5f42,#34775a,#52bf90,#2d2d2d' => t('Teal Top'),
00023   ),
00024
00025   // Images to copy over.
00026   'copy' => array(
00027     '../images/menu-collapsed.gif',
00028     '../images/menu-collapsed-rtl.gif',
00029     '../images/menu-expanded.gif',
00030     '../images/menu-leaf.gif',
00031   ),
00032
00033   // CSS files (excluding @import) to rewrite with new color scheme.
00034   'css' => array(
00035     '../style.css',
00036   ),
00037
00038   // Coordinates of gradient (x, y, width, height).
00039   'gradient' => array(0, 37, 760, 121),
00040
00041   // Color areas to fill (x, y, width, height).
00042   'fill' => array(
00043     'base' => array(0, 0, 760, 568),
00044     'link' => array(107, 533, 41, 23),
00045   ),
00046
00047   // Coordinates of all the theme slices (x, y, width, height)
00048   // with their filename as used in the stylesheet.
00049   'slices' => array(
00050     '../images/body.png'                      => array(0, 37, 1, 280),
00051     '../images/bg-bar.png'                    => array(202, 530, 76, 14),
00052     '../images/bg-bar-white.png'              => array(202, 506, 76, 14),
00053     '../images/bg-tab.png'                    => array(107, 533, 41, 23),
00054     '../images/bg-navigation.png'             => array(0, 0, 7, 37),
00055     '../images/bg-content-left.png'           => array(40, 117, 50, 352),
00056     '../images/bg-content-right.png'          => array(510, 117, 50, 352),
00057     '../images/bg-content.png'                => array(299, 117, 7, 200),
00058     '../images/bg-navigation-item.png'        => array(32, 37, 17, 12),
00059     '../images/bg-navigation-item-hover.png'  => array(54, 37, 17, 12),
00060     '../images/gradient-inner.png'            => array(646, 307, 112, 42),
00061
00062     'logo.png'                                => array(622, 51, 64, 73),
00063     'screenshot.png'                          => array(0, 37, 400, 240),
00064   ),
00065
00066   // Reference color used for blending. Matches the base.png's colors.
00067   'blend_target' => '#ffffff',
00068
00069   // Preview files.
00070   'preview_image' => 'color/preview.png',
00071   'preview_css' => '../color/preview.css',
00072
00073   // Base file for image generation.
00074   'base_image' => 'color/base.png',
00075 );
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/module.inc Source File

includes

module.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: module.inc,v 1.115 2007/12/27 12:31:05 goba Exp $
00003
00012 function module_load_all() {
00013   foreach (module_list(TRUE, FALSE) as $module) {
00014     drupal_load('module', $module);
00015   }
00016 }
00017
00021 function module_iterate($function, $argument = '') {
00022   foreach (module_list() as $name) {
00023     $function($name, $argument);
00024   }
00025 }
00026
00047 function module_list($refresh = FALSE, $bootstrap = TRUE, $sort = FALSE, $fixed_list = NULL) {
00048   static $list, $sorted_list;
00049
00050   if ($refresh || $fixed_list) {
00051     unset($sorted_list);
00052     $list = array();
00053     if ($fixed_list) {
00054       foreach ($fixed_list as $name => $module) {
00055         drupal_get_filename('module', $name, $module['filename']);
00056         $list[$name] = $name;
00057       }
00058     }
00059     else {
00060       if ($bootstrap) {
00061         $result = db_query("SELECT name, filename, throttle FROM {system} WHERE type = 'module' AND status = 1 AND bootstrap = 1 ORDER BY weight ASC, filename ASC");
00062       }
00063       else {
00064         $result = db_query("SELECT name, filename, throttle FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC");
00065       }
00066       while ($module = db_fetch_object($result)) {
00067         if (file_exists($module->filename)) {
00068           // Determine the current throttle status and see if the module should be
00069           // loaded based on server load. We have to directly access the throttle
00070           // variables, since throttle.module may not be loaded yet.
00071           $throttle = ($module->throttle && variable_get('throttle_level', 0) > 0);
00072           if (!$throttle) {
00073             drupal_get_filename('module', $module->name, $module->filename);
00074             $list[$module->name] = $module->name;
00075           }
00076         }
00077       }
00078     }
00079   }
00080   if ($sort) {
00081     if (!isset($sorted_list)) {
00082       $sorted_list = $list;
00083       ksort($sorted_list);
00084     }
00085     return $sorted_list;
00086   }
00087   return $list;
00088 }
00089
00096 function module_rebuild_cache() {
00097   // Get current list of modules
00098   $files = drupal_system_listing('\.module$', 'modules', 'name', 0);
00099
00100   // Extract current files from database.
00101   system_get_files_database($files, 'module');
00102
00103   ksort($files);
00104
00105   // Set defaults for module info
00106   $defaults = array(
00107     'dependencies' => array(),
00108     'dependents' => array(),
00109     'description' => '',
00110     'version' => NULL,
00111     'php' => DRUPAL_MINIMUM_PHP,
00112   );
00113
00114   foreach ($files as $filename => $file) {
00115     // Look for the info file.
00116     $file->info = drupal_parse_info_file(dirname($file->filename) .'/'. $file->name .'.info');
00117
00118     // Skip modules that don't provide info.
00119     if (empty($file->info)) {
00120       unset($files[$filename]);
00121       continue;
00122     }
00123     // Merge in defaults and save.
00124     $files[$filename]->info = $file->info + $defaults;
00125
00126     // Invoke hook_system_info_alter() to give installed modules a chance to
00127     // modify the data in the .info files if necessary.
00128     drupal_alter('system_info', $files[$filename]->info, $files[$filename]);
00129
00130     // Log the critical hooks implemented by this module.
00131     $bootstrap = 0;
00132     foreach (bootstrap_hooks() as $hook) {
00133       if (module_hook($file->name, $hook)) {
00134         $bootstrap = 1;
00135         break;
00136       }
00137     }
00138
00139     // Update the contents of the system table:
00140     if (isset($file->status) || (isset($file->old_filename) && $file->old_filename != $file->filename)) {
00141       db_query("UPDATE {system} SET info = '%s', name = '%s', filename = '%s', bootstrap = %d WHERE filename = '%s'", serialize($files[$filename]->info), $file->name, $file->filename, $bootstrap, $file->old_filename);
00142     }
00143     else {
00144       // This is a new module.
00145       $files[$filename]->status = 0;
00146       $files[$filename]->throttle = 0;
00147       db_query("INSERT INTO {system} (name, info, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d, %d)", $file->name, serialize($files[$filename]->info), 'module', $file->filename, 0, 0, $bootstrap);
00148     }
00149   }
00150   $files = _module_build_dependencies($files);
00151   return $files;
00152 }
00153
00172 function _module_build_dependencies($files) {
00173   do {
00174     $new_dependency = FALSE;
00175     foreach ($files as $filename => $file) {
00176       // We will modify this object (module A, see doxygen for module A, B, C).
00177       $file = &$files[$filename];
00178       if (isset($file->info['dependencies']) && is_array($file->info['dependencies'])) {
00179         foreach ($file->info['dependencies'] as $dependency_name) {
00180           // This is a nonexistent module.
00181           if ($dependency_name == '-circular-' || !isset($files[$dependency_name])) {
00182             continue;
00183           }
00184           // $dependency_name is module B (again, see doxygen).
00185           $files[$dependency_name]->info['dependents'][$filename] = $filename;
00186           $dependency = $files[$dependency_name];
00187           if (isset($dependency->info['dependencies']) && is_array($dependency->info['dependencies'])) {
00188             // Let's find possible C modules.
00189             foreach ($dependency->info['dependencies'] as $candidate) {
00190               if (array_search($candidate, $file->info['dependencies']) === FALSE) {
00191                 // Is this a circular dependency?
00192                 if ($candidate == $filename) {
00193                   // As a module name can not contain dashes, this makes
00194                   // impossible to switch on the module.
00195                   $candidate = '-circular-';
00196                   // Do not display the message or add -circular- more than once.
00197                   if (array_search($candidate, $file->info['dependencies']) !== FALSE) {
00198                     continue;
00199                   }
00200                   drupal_set_message(t('%module is part of a circular dependency. This is not supported and you will not be able to switch it on.', array('%module' => $file->info['name'])), 'error');
00201                 }
00202                 else {
00203                   // We added a new dependency to module A. The next loop will
00204                   // be able to use this as "B module" thus finding even
00205                   // deeper dependencies.
00206                   $new_dependency = TRUE;
00207                 }
00208                 $file->info['dependencies'][] = $candidate;
00209               }
00210             }
00211           }
00212         }
00213       }
00214       // Don't forget to break the reference.
00215       unset($file);
00216     }
00217   } while ($new_dependency);
00218   return $files;
00219 }
00220
00229 function module_exists($module) {
00230   $list = module_list();
00231   return array_key_exists($module, $list);
00232 }
00233
00237 function module_load_install($module) {
00238   // Make sure the installation API is available
00239   include_once './includes/install.inc';
00240
00241   module_load_include('install', $module);
00242 }
00243
00254 function module_load_include($type, $module, $name = NULL) {
00255   if (empty($name)) {
00256     $name = $module;
00257   }
00258
00259   $file = './'. drupal_get_path('module', $module) ."/$name.$type";
00260
00261   if (is_file($file)) {
00262     require_once $file;
00263   }
00264   else {
00265     return FALSE;
00266   }
00267 }
00268
00273 function module_load_all_includes($type, $name = NULL) {
00274   $modules = module_list();
00275   foreach ($modules as $module) {
00276     module_load_include($type, $module, $name);
00277   }
00278 }
00279
00286 function module_enable($module_list) {
00287   $invoke_modules = array();
00288   foreach ($module_list as $module) {
00289     $existing = db_fetch_object(db_query("SELECT status FROM {system} WHERE type = '%s' AND name = '%s'", 'module', $module));
00290     if ($existing->status == 0) {
00291       module_load_install($module);
00292       db_query("UPDATE {system} SET status = %d, throttle = %d WHERE type = '%s' AND name = '%s'", 1, 0, 'module', $module);
00293       drupal_load('module', $module);
00294       $invoke_modules[] = $module;
00295     }
00296   }
00297
00298   if (!empty($invoke_modules)) {
00299     // Refresh the module list to include the new enabled module.
00300     module_list(TRUE, FALSE);
00301     // Force to regenerate the stored list of hook implementations.
00302     module_implements('', FALSE, TRUE);
00303   }
00304
00305   foreach ($invoke_modules as $module) {
00306     module_invoke($module, 'enable');
00307     // Check if node_access table needs rebuilding.
00308     // We check for the existence of node_access_needs_rebuild() since
00309     // at install time, module_enable() could be called while node.module
00310     // is not enabled yet.
00311     if (function_exists('node_access_needs_rebuild') && !node_access_needs_rebuild() && module_hook($module, 'node_grants')) {
00312       node_access_needs_rebuild(TRUE);
00313     }
00314   }
00315 }
00316
00323 function module_disable($module_list) {
00324   $invoke_modules = array();
00325   foreach ($module_list as $module) {
00326     if (module_exists($module)) {
00327       // Check if node_access table needs rebuilding.
00328       if (!node_access_needs_rebuild() && module_hook($module, 'node_grants')) {
00329         node_access_needs_rebuild(TRUE);
00330       }
00331
00332       module_load_install($module);
00333       module_invoke($module, 'disable');
00334       db_query("UPDATE {system} SET status = %d, throttle = %d WHERE type = '%s' AND name = '%s'", 0, 0, 'module', $module);
00335       $invoke_modules[] = $module;
00336     }
00337   }
00338
00339   if (!empty($invoke_modules)) {
00340     // Refresh the module list to exclude the disabled modules.
00341     module_list(TRUE, FALSE);
00342     // Force to regenerate the stored list of hook implementations.
00343     module_implements('', FALSE, TRUE);
00344   }
00345
00346   // If there remains no more node_access module, rebuilding will be
00347   // straightforward, we can do it right now.
00348   if (node_access_needs_rebuild() && count(module_implements('node_grants')) == 0) {
00349     node_access_rebuild();
00350   }
00351 }
00352
00385 function module_hook($module, $hook) {
00386   return function_exists($module .'_'. $hook);
00387 }
00388
00404 function module_implements($hook, $sort = FALSE, $refresh = FALSE) {
00405   static $implementations;
00406
00407   if ($refresh) {
00408     $implementations = array();
00409     return;
00410   }
00411
00412   if (!isset($implementations[$hook])) {
00413     $implementations[$hook] = array();
00414     $list = module_list(FALSE, TRUE, $sort);
00415     foreach ($list as $module) {
00416       if (module_hook($module, $hook)) {
00417         $implementations[$hook][] = $module;
00418       }
00419     }
00420   }
00421
00422   // The explicit cast forces a copy to be made. This is needed because
00423   // $implementations[$hook] is only a reference to an element of
00424   // $implementations and if there are nested foreaches (due to nested node
00425   // API calls, for example), they would both manipulate the same array's
00426   // references, which causes some modules' hooks not to be called.
00427   // See also http://www.zend.com/zend/art/ref-count.php.
00428   return (array)$implementations[$hook];
00429 }
00430
00443 function module_invoke() {
00444   $args = func_get_args();
00445   $module = $args[0];
00446   $hook = $args[1];
00447   unset($args[0], $args[1]);
00448   $function = $module .'_'. $hook;
00449   if (module_hook($module, $hook)) {
00450     return call_user_func_array($function, $args);
00451   }
00452 }
00464 function module_invoke_all() {
00465   $args = func_get_args();
00466   $hook = $args[0];
00467   unset($args[0]);
00468   $return = array();
00469   foreach (module_implements($hook) as $module) {
00470     $function = $module .'_'. $hook;
00471     $result = call_user_func_array($function, $args);
00472     if (isset($result) && is_array($result)) {
00473       $return = array_merge_recursive($return, $result);
00474     }
00475     else if (isset($result)) {
00476       $return[] = $result;
00477     }
00478   }
00479
00480   return $return;
00481 }
00482
00490 function drupal_required_modules() {
00491   return array('block', 'filter', 'node', 'system', 'user');
00492 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/comment/comment.tpl.php Source File

modules » comment

comment.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: comment.tpl.php,v 1.4 2008/01/04 19:24:23 goba Exp $
00003
00028 ?>
00029 <div class="comment<?php print ($comment->new) ? ' comment-new' : ''; print ' '. $status ?> clear-block">
00030   <?php print $picture ?>
00031
00032   <?php if ($comment->new): ?>
00033     <span class="new"><?php print $new ?></span>
00034   <?php endif; ?>
00035
00036   <h3><?php print $title ?></h3>
00037
00038   <div class="submitted">
00039     <?php print $submitted ?>
00040   </div>
00041
00042   <div class="content">
00043     <?php print $content ?>
00044     <?php if ($signature): ?>
00045     <div class="user-signature clear-block">
00046       <?php print $signature ?>
00047     </div>
00048     <?php endif; ?>
00049   </div>
00050
00051   <?php print $links ?>
00052 </div>
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/node/node.tpl.php Source File

modules » node

node.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: node.tpl.php,v 1.4 2008/01/25 21:21:44 goba Exp $
00003
00050 ?>
00051 <div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?> clear-block">
00052
00053 <?php print $picture ?>
00054
00055 <?php if (!$page): ?>
00056   <h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
00057 <?php endif; ?>
00058
00059   <div class="meta">
00060   <?php if ($submitted): ?>
00061     <span class="submitted"><?php print $submitted ?></span>
00062   <?php endif; ?>
00063
00064   <?php if ($terms): ?>
00065     <div class="terms terms-inline"><?php print $terms ?></div>
00066   <?php endif;?>
00067   </div>
00068
00069   <div class="content">
00070     <?php print $content ?>
00071   </div>
00072
00073   <?php print $links; ?>
00074 </div>
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/system/block.tpl.php Source File

modules » system

block.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: block.tpl.php,v 1.4 2007/09/01 05:42:48 dries Exp $
00003
00028 ?>
00029 <div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="block block-<?php print $block->module ?>">
00030 <?php if ($block->subject): ?>
00031   <h2><?php print $block->subject ?></h2>
00032 <?php endif;?>
00033
00034   <div class="content">
00035     <?php print $block->content ?>
00036   </div>
00037 </div>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/system/box.tpl.php Source File

modules » system

box.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: box.tpl.php,v 1.3 2007/12/16 21:01:45 goba Exp $
00003
00015 ?>
00016 <div class="box">
00017
00018 <?php if ($title): ?>
00019   <h2><?php print $title ?></h2>
00020 <?php endif; ?>
00021
00022   <div class="content"><?php print $content ?></div>
00023 </div>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/system/maintenance-page.tpl.php Source File

modules » system

maintenance-page.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: maintenance-page.tpl.php,v 1.2 2008/01/24 09:42:51 goba Exp $
00003
00016 ?>
00017 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
00018   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
00019 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language ?>" lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
00020
00021 <head>
00022   <title><?php print $head_title; ?></title>
00023   <?php print $head; ?>
00024   <?php print $styles; ?>
00025   <?php print $scripts; ?>
00026   <script type="text/javascript"><?php /* Needed to avoid Flash of Unstyled Content in IE */ ?> </script>
00027 </head>
00028 <body class="<?php print $body_classes; ?>">
00029   <div id="page">
00030     <div id="header">
00031       <div id="logo-title">
00032
00033         <?php if (!empty($logo)): ?>
00034           <a href="<?php print $base_path; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
00035             <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
00036           </a>
00037         <?php endif; ?>
00038
00039         <div id="name-and-slogan">
00040           <?php if (!empty($site_name)): ?>
00041             <h1 id="site-name">
00042               <a href="<?php print $base_path ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
00043             </h1>
00044           <?php endif; ?>
00045
00046           <?php if (!empty($site_slogan)): ?>
00047             <div id="site-slogan"><?php print $site_slogan; ?></div>
00048           <?php endif; ?>
00049         </div> <!-- /name-and-slogan -->
00050       </div> <!-- /logo-title -->
00051
00052       <?php if (!empty($header)): ?>
00053         <div id="header-region">
00054           <?php print $header; ?>
00055         </div>
00056       <?php endif; ?>
00057
00058     </div> <!-- /header -->
00059
00060     <div id="container" class="clear-block">
00061
00062       <?php if (!empty($left)): ?>
00063         <div id="sidebar-left" class="column sidebar">
00064           <?php print $left; ?>
00065         </div> <!-- /sidebar-left -->
00066       <?php endif; ?>
00067
00068       <div id="main" class="column"><div id="main-squeeze">
00069
00070         <div id="content">
00071           <?php if (!empty($title)): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?>
00072           <?php if (!empty($messages)): print $messages; endif; ?>
00073           <div id="content-content" class="clear-block">
00074             <?php print $content; ?>
00075           </div> <!-- /content-content -->
00076         </div> <!-- /content -->
00077
00078       </div></div> <!-- /main-squeeze /main -->
00079
00080       <?php if (!empty($right)): ?>
00081         <div id="sidebar-right" class="column sidebar">
00082           <?php print $right; ?>
00083         </div> <!-- /sidebar-right -->
00084       <?php endif; ?>
00085
00086     </div> <!-- /container -->
00087
00088     <div id="footer-wrapper">
00089       <div id="footer">
00090         <?php print $footer_message; ?>
00091         <?php if (!empty($footer)): print $footer; endif; ?>
00092       </div> <!-- /footer -->
00093     </div> <!-- /footer-wrapper -->
00094
00095   </div> <!-- /page -->
00096
00097 </body>
00098 </html>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/system/page.tpl.php Source File

modules » system

page.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: page.tpl.php,v 1.11 2008/01/24 09:42:51 goba Exp $
00003
00077 ?>
00078 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
00079   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
00080 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language ?>" lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
00081
00082 <head>
00083   <title><?php print $head_title; ?></title>
00084   <?php print $head; ?>
00085   <?php print $styles; ?>
00086   <?php print $scripts; ?>
00087   <script type="text/javascript"><?php /* Needed to avoid Flash of Unstyled Content in IE */ ?> </script>
00088 </head>
00089 <body class="<?php print $body_classes; ?>">
00090   <div id="page">
00091     <div id="header">
00092       <div id="logo-title">
00093
00094         <?php if (!empty($logo)): ?>
00095           <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
00096             <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
00097           </a>
00098         <?php endif; ?>
00099
00100         <div id="name-and-slogan">
00101           <?php if (!empty($site_name)): ?>
00102             <h1 id="site-name">
00103               <a href="<?php print $front_page ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
00104             </h1>
00105           <?php endif; ?>
00106
00107           <?php if (!empty($site_slogan)): ?>
00108             <div id="site-slogan"><?php print $site_slogan; ?></div>
00109           <?php endif; ?>
00110         </div> <!-- /name-and-slogan -->
00111       </div> <!-- /logo-title -->
00112
00113       <?php if (!empty($search_box)): ?>
00114         <div id="search-box"><?php print $search_box; ?></div>
00115       <?php endif; ?>
00116
00117       <?php if (!empty($header)): ?>
00118         <div id="header-region">
00119           <?php print $header; ?>
00120         </div>
00121       <?php endif; ?>
00122
00123     </div> <!-- /header -->
00124
00125     <div id="container" class="clear-block">
00126
00127       <div id="navigation" class="menu <?php if (!empty($primary_links)) { print "withprimary"; } if (!empty($secondary_links)) { print " withsecondary"; } ?> ">
00128         <?php if (!empty($primary_links)): ?>
00129           <div id="primary" class="clear-block">
00130             <?php print theme('links', $primary_links, array('class' => 'links primary-links')); ?>
00131           </div>
00132         <?php endif; ?>
00133
00134         <?php if (!empty($secondary_links)): ?>
00135           <div id="secondary" class="clear-block">
00136             <?php print theme('links', $secondary_links, array('class' => 'links secondary-links')); ?>
00137           </div>
00138         <?php endif; ?>
00139       </div> <!-- /navigation -->
00140
00141       <?php if (!empty($left)): ?>
00142         <div id="sidebar-left" class="column sidebar">
00143           <?php print $left; ?>
00144         </div> <!-- /sidebar-left -->
00145       <?php endif; ?>
00146
00147       <div id="main" class="column"><div id="main-squeeze">
00148         <?php if (!empty($breadcrumb)): ?><div id="breadcrumb"><?php print $breadcrumb; ?></div><?php endif; ?>
00149         <?php if (!empty($mission)): ?><div id="mission"><?php print $mission; ?></div><?php endif; ?>
00150
00151         <div id="content">
00152           <?php if (!empty($title)): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?>
00153           <?php if (!empty($tabs)): ?><div class="tabs"><?php print $tabs; ?></div><?php endif; ?>
00154           <?php if (!empty($messages)): print $messages; endif; ?>
00155           <?php if (!empty($help)): print $help; endif; ?>
00156           <div id="content-content" class="clear-block">
00157             <?php print $content; ?>
00158           </div> <!-- /content-content -->
00159           <?php print $feed_icons; ?>
00160         </div> <!-- /content -->
00161
00162       </div></div> <!-- /main-squeeze /main -->
00163
00164       <?php if (!empty($right)): ?>
00165         <div id="sidebar-right" class="column sidebar">
00166           <?php print $right; ?>
00167         </div> <!-- /sidebar-right -->
00168       <?php endif; ?>
00169
00170     </div> <!-- /container -->
00171
00172     <div id="footer-wrapper">
00173       <div id="footer">
00174         <?php print $footer_message; ?>
00175         <?php if (!empty($footer)): print $footer; endif; ?>
00176       </div> <!-- /footer -->
00177     </div> <!-- /footer-wrapper -->
00178
00179     <?php print $closure; ?>
00180
00181   </div> <!-- /page -->
00182
00183 </body>
00184 </html>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/multipage_form_example.module Source File

docs » examples

multipage_form_example.module

Go to the documentation of this file.
00001 <?php
00002
00003 // $Id: multipage_form_example.module,v 1.8 2006/04/08 03:35:39 drumm Exp $
00004
00008 function multipage_form_example_help($section) {
00009   switch ($section) {
00010     case 'admin/modules#description':
00011       return t('An example module showing how to handle multipage forms in FAPI.');
00012     case 'node/add#multipage_form_example':
00013       return t('This will show you an example multipage form submission.');
00014   }
00015 }
00016
00020 function multipage_form_example_menu($may_cache) {
00021   $items = array();
00022
00023   if (!$may_cache) {
00024
00025     $items[] = array('title'    => t('multipage form example'),
00026                      'path'     => 'node/add/multipage_form_example',
00027                      'access'   => TRUE,
00028     );
00029   }
00030
00031   return $items;
00032 }
00033
00037 function multipage_form_example_access($op, $node) {
00038   return TRUE;
00039 }
00040
00044 function multipage_form_example_node_info() {
00045   return array('multipage_form_example' => array('name' => t('multipage form example'), 'base' => 'multipage_form_example'));
00046 }
00047
00052 function multipage_form_example_form(&$node) {
00053   $form = array();
00054
00055   // 'checkboxes' elements are just ridiculously hard--i recommend just
00056   //  using a bunch of individual checkbox elements instead.
00057   //  I suspect that multiselects would also be pretty difficult...
00058
00059   // Here's a new form element, which enables you to store hidden values
00060   // in an array.  Check out the element definition functions at the bottom
00061   // if you want to use this in a module.  Keys show up in the
00062   // $_POST/$form_values like:
00063   // $_POST['edit']['test_hidden_array']['n'] = 'north'
00064   // $form_values['test_hidden_array']['n'] = 'north'
00065
00066   $form['test_hidden_array'] = array(
00067     '#type'          => 'hidden_array',
00068     '#values'        => array('n' => 'north', 'e' => 'east', 'w' => 'west', 's' => 'south', ),
00069   );
00070
00071
00072
00073   // Helper for our multipage - does field switching, sets options
00074   // based on validated $form_values instead of $_POST, and so forth.
00075   $form['#pre_render'] = array('multipage_form_example_pre_render');
00076
00077   // Title and body, page 1
00078   $form['title'] = array(
00079     '#type'          => 'textfield',
00080     '#title'         => t('Title'),
00081     '#default_value' => isset($node->title) ? $node->title : NULL,
00082     '#description'   => t("Enter a title for your favorites section."),
00083     '#size'          => 60,
00084     '#maxlength'     => 128,
00085     '#required'      => TRUE,
00086   );
00087   $form['body'] = array(
00088     '#type'          => 'textarea',
00089     '#title'         => t('Description'),
00090     '#default_value' => isset($node->body) ? $node->body : NULL,
00091     '#description'   => t('Add any additional info about your favorites.'),
00092     '#rows'          => 20,
00093   );
00094
00095   // Person, page 2
00096   $form['person'] = array(
00097     '#type'          => 'fieldset',
00098     '#title'         => t('Your favorite person'),
00099   );
00100   $form['person']['fav_person'] = array(
00101     '#type'          => 'textfield',
00102     '#title'         => t('Name'),
00103     '#default_value' => isset($node->fav_person) ? $node->fav_person : NULL,
00104     '#description'   => t('Enter their real name, or their code name if they like to fly stealth.'),
00105     '#required'      => TRUE,
00106   );
00107   $form['person']['fav_person_desc'] = array(
00108     '#type'          => 'textarea',
00109     '#title'         => t('Description'),
00110     '#default_value' => isset($node->fav_person_desc) ? $node->fav_person_desc : NULL,
00111     '#description'   => t('Juicy details go here...'),
00112     '#required'      => TRUE,
00113   );
00114   $form['person']['fav_gummi'] = array(
00115     '#type'          => 'checkbox',
00116     '#default_value' => isset($node->fav_gummi) ? $node->fav_gummi : 0,
00117     '#title'         => t('Do they like gummi bears?'),
00118   );
00119
00120   // Color and number, page 3
00121   $form['fav_color'] = array(
00122     '#type'          => 'select',
00123     '#title'         => t('Favorite color'),
00124     '#default_value' => isset($node->fav_color) ? $node->fav_color : 'red',
00125     '#options'       => array('red' => t('Red'), 'green' => t('Green'), 'blue' => t('Blue'), 'yellow' => t('Yellow')),
00126     '#required'      => TRUE,
00127   );
00128   $form['fav_number'] = array(
00129     '#type'          => 'textfield',
00130     '#title'         => t('Favorite number'),
00131     '#default_value' => isset($node->fav_number) ? $node->fav_number : NULL,
00132     '#required'      => TRUE,
00133   );
00134
00135   // Movie and tv show, page 4
00136   $form['fav_movie'] = array(
00137     '#type'          => 'textfield',
00138     '#title'         => t('Favorite movie'),
00139     '#default_value' => isset($node->fav_movie) ? $node->fav_movie : NULL,
00140     '#required'      => TRUE,
00141   );
00142   $form['fav_tv'] = array(
00143     '#type'          => 'radios',
00144     '#title'         => t('How often do you watch your favorite tv show?'),
00145     '#default_value' => isset($node->fav_tv) ? $node->fav_tv : 'daily',
00146     '#options'       => array('daily' => t('Daily'), 'weekly' => t('Weekly'), 'monthly' => t('Monthly'),),
00147     '#required'      => TRUE,
00148   );
00149
00150   // Add a back button
00151   $form['back'] = array(
00152     '#type'          => 'button',
00153     '#value'         => t('Back'),
00154     '#weight'        => 35,
00155   );
00156
00157   return $form;
00158 }
00159
00160 function theme_multipage_form_example_node_form($form) {
00161   $content = '';
00162
00163   if (in_array($form['page']['#value'], array(3,4))) {
00164     $content .= '<p>'. t('Your favorite person is %person, and they %like gummi bears.', array('%person' => check_plain($form['person']['fav_person']['#value']), '%like' => ($form['person']['fav_gummi']['#value'] ? t('like') : t('don\'t like')))) .'</p>';
00165   }
00166
00167   if (in_array($form['page']['#value'], array(4))) {
00168     $content .= '<p>'. t('Your favorite color is %color, and your favorite number is %number.', array('%color' => check_plain($form['fav_color']['#value']), '%number' => check_plain($form['fav_number']['#value'])));
00169   }
00170
00171   foreach (element_children($form) as $key) {
00172     $content .= form_render($form[$key]);
00173   }
00174   return $content;
00175 }
00176
00181 function multipage_form_example_form_alter($form_id, &$form) {
00182   // Make sure it's our multipage form.
00183   if ($form_id == 'multipage_form_example_node_form') {
00184
00185     // Determine which page of the multipage form we're on. We don't do
00186     // any incrementing here - that's something that our #pre_render'er
00187     // will do when this page of the form has successfully validated.
00188     $form['page'] = array(
00189       '#type' => 'hidden',
00190       '#value' => isset($_POST['edit']['page']) ? $_POST['edit']['page'] : 1,
00191     );
00192
00193     // If back button is pressed, back up the form stage, Also, if preview
00194     // is hit we need to decrement the counter here to keep us on the same page.
00195     if ($_POST['op'] == t('Back')) {
00196       $form['page']['#value']--;
00197     }
00198
00199     // This modifies the form for validation purposes. once validation is
00200     // completed, it'll be called one more time (through Drupal's Form API)
00201     // at which point it'll advance the form to the next page.
00202     multipage_form_example_pre_render($form_id, $form, FALSE);
00203
00204     // Here we're augmenting the regular node form validation/submission with
00205     // some of our own.  Note that these are inside the conditional check for
00206     // this particular form.
00207     $form['#validate'] = array_merge($form['#validate'], array('multipage_form_example_custom_validate' => array()));
00208     $form['#submit'] = array_merge($form['#submit'], array('multipage_form_example_custom_submit' => array()));
00209   }
00210
00211   return $form;
00212 }
00213
00217 function multipage_form_example_custom_validate() {
00218   global $form_values;
00219   // validate our number, but don't bother if the back button was hit
00220   if (($form_values['page'] ==  3 ) && !is_numeric($form_values['fav_number']) && ($_POST['op'] != t('Back'))) {
00221     form_set_error('fav_number', t('Favorite number is a <em>number</em>, dummy!'));
00222   }
00223 }
00224
00232 function multipage_form_example_pre_render($form_id, &$form, $next_page = TRUE) {
00233   global $form_values;
00234
00235   // Make sure it's our multipage form.
00236   if ($form_id == 'multipage_form_example_node_form') {
00237     // Are we ready for the next page in our form?
00238     if ($next_page && isset($_POST['edit']['page']) && ($_POST['op'] != t('Back')) && ($_POST['op'] != t('Preview'))) {
00239       $form['page']['#value'] = $form['page']['#value'] + 1;
00240     }
00241
00242     // Validation errors? Show previous page for correcting.
00243     if (form_get_errors()) {
00244       $form['page']['#value']--;
00245     }
00246
00247     // Modify the #required/#type values depending on our current page.
00248     // The arrays tell us the pages the changes should take place in.
00249
00250     // Title/body, stage 1
00251     multipage_form_set_element_visibility($form['title'],                     in_array($form['page']['#value'], array(1)));
00252     multipage_form_set_element_visibility($form['body'],                      in_array($form['page']['#value'], array(1)));
00253
00254     // Person, stage 2
00255     multipage_form_set_element_visibility($form['person'],                    in_array($form['page']['#value'], array(2)));
00256     multipage_form_set_element_visibility($form['person']['fav_person'],      in_array($form['page']['#value'], array(2)));
00257     multipage_form_set_element_visibility($form['person']['fav_person_desc'], in_array($form['page']['#value'], array(2)));
00258     multipage_form_set_element_visibility($form['person']['fav_gummi'],       in_array($form['page']['#value'], array(2)), $next_page);
00259
00260     // Color and number, page 3
00261     multipage_form_set_element_visibility($form['fav_color'],                 in_array($form['page']['#value'], array(3)));
00262     multipage_form_set_element_visibility($form['fav_number'],                in_array($form['page']['#value'], array(3)));
00263
00264     // Movie and tv show, page 4
00265     multipage_form_set_element_visibility($form['fav_movie'],                 in_array($form['page']['#value'], array(4)));
00266     multipage_form_set_element_visibility($form['fav_tv'],                    in_array($form['page']['#value'], array(4)), $next_page);
00267
00268     // Buttons
00269     multipage_form_set_element_visibility($form['back'],                      in_array($form['page']['#value'], array(2, 3, 4)), $next_page);
00270     multipage_form_set_element_visibility($form['preview'],                   in_array($form['page']['#value'], array(4)), $next_page);
00271     multipage_form_set_element_visibility($form['submit'],                    in_array($form['page']['#value'], array(4)), $next_page);
00272
00273     // The button text actually helps determine if a form has actually been
00274     // submitted because the name is also the value of a clicked button. By
00275     // changing it for building, but not rendering, the form is not fully
00276     // sumbitted until we name it 'Submit', the usual value.
00277     if ($next_page) {
00278       $submit_text = array(NULL, t('Next (person)'), t('Next (color/number)'), t('Next (tv/movie)'), t('Submit'));
00279       $form['submit']['#value'] = $submit_text[$form['page']['#value']];
00280     }
00281   }
00282 }
00283
00284 // Handles form submission.  We're just throwing our data into the variable
00285 // table to keep things simple
00286 function multipage_form_example_custom_submit() {
00287   global $form_values;
00288   foreach ($form_values as $key => $value) {
00289     if (in_array($key, array('fav_person', 'fav_person_desc', 'fav_gummi', 'fav_color', 'fav_number', 'fav_movie', 'fav_tv',))) {
00290       $array[$key] = $value;
00291     }
00292   }
00293
00294     // A little hack so we can save new node info properly to the variable table
00295   if (isset($form_values['nid'])) {
00296     $nid = $form_values['nid'];
00297   }
00298   else {
00299     $nid = db_result(db_query("SELECT id FROM {sequences} WHERE name = 'node_nid'"));
00300   }
00301
00302   variable_set('multipage_form_example_'. $nid, $array);
00303 }
00304
00312 function multipage_form_example_load($node) {
00313   $additions = variable_get('multipage_form_example_'. $node->nid, NULL);
00314   $additions = (object) $additions;
00315   return $additions;
00316 }
00317
00323 function multipage_form_example_delete($node) {
00324   // Notice that we're matching all revision, by using the node's nid.
00325   variable_del('multipage_form_example_'. $node->nid);
00326 }
00327
00334 function multipage_form_example_view(&$node, $teaser = FALSE, $page = FALSE) {
00335   $node = node_prepare($node, $teaser);
00336   $favorites = theme('multipage_form_example', $node);
00337   $node->body .= $favorites;
00338   $node->teaser .= $favorites;
00339 }
00340
00349 function theme_multipage_form_example($node) {
00350   $person_display = t('Your favorite person is %person, and they %like gummi bears. <br >', array('%person' => check_plain($node->fav_person), '%like' => ($node->fav_gummi ? t('like') : t('don\'t like'))));
00351   $color_number_display = t('Your favorite color is %color, and your favorite number is %number. <br >', array('%color' => check_plain($node->fav_color), '%number' => check_plain($node->fav_number)));
00352   $tv_movie_display = t('Your favorite movie is %movie, and you watch your favorite tv show %watch.', array('%movie' => check_plain($node->fav_movie), '%watch' => check_plain($node->fav_tv)));
00353
00354   $output = '<div class="multipage_form_example">';
00355   $output .= $person_display . $color_number_display . $tv_movie_display;
00356   $output .= '</div>';
00357
00358   return $output;
00359 }
00360
00372 function multipage_form_set_element_visibility(&$element, $visible, $next_page = TRUE) {
00373   multipage_form_restore_attributes($element);
00374   if (!$visible) {
00375     switch ($element['#type']) {
00376       case 'textfield':
00377       case 'textarea':
00378       case 'select':
00379         multipage_form_set_attribute($element, '#type', 'hidden');
00380         multipage_form_set_attribute($element, '#required', FALSE);
00381         break;
00382
00383       case 'radios':
00384         // Radios elements cannot be hidden unless they have been processed.
00385         if ($next_page) {
00386           multipage_form_set_attribute($element, '#type', 'hidden');
00387           multipage_form_set_attribute($element, '#required', FALSE);
00388         }
00389         break;
00390
00391       case 'radio':
00392       case 'checkbox':
00393         // We can't change these to hidden until right before the next page is rendered, otherwise
00394         // the value is lost sometimes.
00395         if ($next_page) {
00396           multipage_form_set_attribute($element, '#type', 'hidden');
00397         }
00398         break;
00399
00400       case 'fieldset':
00401         multipage_form_set_attribute($element, '#type', NULL);
00402         break;
00403
00404       case 'button':
00405         if ($next_page) {
00406           multipage_form_set_attribute($element, '#type', 'value');
00407         }
00408         break;
00409
00410       case 'submit':
00411         if ($next_page) {
00412           multipage_form_set_attribute($element, '#type', 'button');
00413         }
00414         break;
00415     }
00416   }
00417
00418   foreach (element_children($element) as $key) {
00419     multipage_form_set_element_visibility($element[$key], $visible, $next_page);
00420   }
00421 }
00422
00434 function multipage_form_set_attribute(&$element, $key, $new_value) {
00435   $element['#multipage_form_original_'. $key] = $element[$key];
00436   $element[$key] = $new_value;
00437 }
00438
00446 function multipage_form_restore_attributes(&$element) {
00447   foreach (array_filter(array_keys($element), create_function('$key', 'return (strpos($key, "#multipage_form_original_") === 0);')) as $key) {
00448     $element[str_replace('#multipage_form_original_', '', $key)] = $element[$key];
00449   }
00450 }
00451
00457 function multipage_form_example_elements() {
00458    $type['hidden_array'] = array('#input' => TRUE, '#process' => array('expand_hidden_array' => array()), '#tree' => TRUE);
00459    return $type;
00460 }
00461
00462 function expand_hidden_array($element) {
00463   $values = is_array($element['#values']) ? $element['#values'] : array();
00464   $element['#tree'] = TRUE;
00465   foreach ($values as $key => $value) {
00466     $element[$key] = array('#type' => 'hidden', '#processed' => TRUE, '#value' => $value);
00467   }
00468   return $element;
00469 }
00470
00471 function theme_hidden_array($element) {
00472   return $element['#children'];
00473 }
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/node/node.admin.inc Source File

modules » node

node.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: node.admin.inc,v 1.19 2008/02/03 19:39:52 goba Exp $
00003
00012 function node_configure() {
00013   // Only show rebuild button if there is 0 or more than 2 rows in node_access table,
00014   // or if there are modules that implement node_grant.
00015   if (db_result(db_query('SELECT COUNT(*) FROM {node_access}')) != 1 || count(module_implements('node_grants')) > 0) {
00016     $status = '<p>'. t('If the site is experiencing problems with permissions to content, you may have to rebuild the permissions cache. Possible causes for permission problems are disabling modules or configuration changes to permissions. Rebuilding will remove all privileges to posts, and replace them with permissions based on the current modules and settings.') .'</p>';
00017     $status .= '<p>'. t('Rebuilding may take some time if there is a lot of content or complex permission settings. After rebuilding has completed posts will automatically use the new permissions.') .'</p>';
00018
00019     $form['access'] = array(
00020       '#type' => 'fieldset',
00021       '#title' => t('Node access status'),
00022     );
00023     $form['access']['status'] = array('#value' => $status);
00024     $form['access']['rebuild'] = array(
00025       '#type' => 'submit',
00026       '#value' => t('Rebuild permissions'),
00027     );
00028   }
00029
00030   $form['default_nodes_main'] = array(
00031     '#type' => 'select', '#title' => t('Number of posts on main page'), '#default_value' => variable_get('default_nodes_main', 10),
00032     '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
00033     '#description' => t('The default maximum number of posts to display per page on overview pages such as the main page.')
00034   );
00035   $form['teaser_length'] = array(
00036     '#type' => 'select', '#title' => t('Length of trimmed posts'), '#default_value' => variable_get('teaser_length', 600),
00037     '#options' => array(
00038       0 => t('Unlimited'),
00039       200 => t('200 characters'),
00040       400 => t('400 characters'),
00041       600 => t('600 characters'),
00042       800 => t('800 characters'),
00043       1000 => t('1000 characters'),
00044       1200 => t('1200 characters'),
00045       1400 => t('1400 characters'),
00046       1600 => t('1600 characters'),
00047       1800 => t('1800 characters'),
00048       2000 => t('2000 characters'),
00049     ),
00050     '#description' => t("The maximum number of characters used in the trimmed version of a post. Drupal will use this setting to determine at which offset long posts should be trimmed. The trimmed version of a post is typically used as a teaser when displaying the post on the main page, in XML feeds, etc. To disable teasers, set to 'Unlimited'. Note that this setting will only affect new or updated content and will not affect existing teasers.")
00051   );
00052
00053   $form['node_preview'] = array(
00054     '#type' => 'radios',
00055     '#title' => t('Preview post'),
00056     '#default_value' => variable_get('node_preview', 0),
00057     '#options' => array(t('Optional'), t('Required')),
00058     '#description' => t('Must users preview posts before submitting?'),
00059   );
00060
00061   $form['#validate'] = array('node_configure_validate');
00062
00063   return system_settings_form($form);
00064 }
00065
00069 function node_configure_validate($form, &$form_state) {
00070   if ($form_state['values']['op'] == t('Rebuild permissions')) {
00071     drupal_goto('admin/content/node-settings/rebuild');
00072   }
00073 }
00074
00078 function node_configure_rebuild_confirm() {
00079   return confirm_form(array(), t('Are you sure you want to rebuild the permissions on site content?'),
00080                   'admin/content/node-settings', t('This action rebuilds all permissions on site content, and may be a lengthy process. This action cannot be undone.'), t('Rebuild permissions'), t('Cancel'));
00081 }
00082
00086 function node_configure_rebuild_confirm_submit($form, &$form_state) {
00087   node_access_rebuild(TRUE);
00088   $form_state['redirect'] = 'admin/content/node-settings';
00089   return;
00090 }
00091
00095 function node_node_operations() {
00096   $operations = array(
00097     'publish' => array(
00098       'label' => t('Publish'),
00099       'callback' => 'node_mass_update',
00100       'callback arguments' => array('updates' => array('status' => 1)),
00101     ),
00102     'unpublish' => array(
00103       'label' => t('Unpublish'),
00104       'callback' => 'node_mass_update',
00105       'callback arguments' => array('updates' => array('status' => 0)),
00106     ),
00107     'promote' => array(
00108       'label' => t('Promote to front page'),
00109       'callback' => 'node_mass_update',
00110       'callback arguments' => array('updates' => array('status' => 1, 'promote' => 1)),
00111     ),
00112     'demote' => array(
00113       'label' => t('Demote from front page'),
00114       'callback' => 'node_mass_update',
00115       'callback arguments' => array('updates' => array('promote' => 0)),
00116     ),
00117     'sticky' => array(
00118       'label' => t('Make sticky'),
00119       'callback' => 'node_mass_update',
00120       'callback arguments' => array('updates' => array('status' => 1, 'sticky' => 1)),
00121     ),
00122     'unsticky' => array(
00123       'label' => t('Remove stickiness'),
00124       'callback' => 'node_mass_update',
00125       'callback arguments' => array('updates' => array('sticky' => 0)),
00126     ),
00127     'delete' => array(
00128       'label' => t('Delete'),
00129       'callback' => NULL,
00130     ),
00131   );
00132   return $operations;
00133 }
00134
00138 function node_filters() {
00139   // Regular filters
00140   $filters['status'] = array(
00141     'title' => t('status'),
00142     'options' => array(
00143       'status-1' => t('published'),
00144       'status-0' => t('not published'),
00145       'promote-1' => t('promoted'),
00146       'promote-0' => t('not promoted'),
00147       'sticky-1' => t('sticky'),
00148       'sticky-0' => t('not sticky'),
00149     ),
00150   );
00151   // Include translation states if we have this module enabled
00152   if (module_exists('translation')) {
00153     $filters['status']['options'] += array(
00154       'translate-0' => t('Up to date translation'),
00155       'translate-1' => t('Outdated translation'),
00156     );
00157   }
00158
00159   $filters['type'] = array('title' => t('type'), 'options' => node_get_types('names'));
00160
00161   // The taxonomy filter
00162   if ($taxonomy = module_invoke('taxonomy', 'form_all', 1)) {
00163     $filters['category'] = array('title' => t('category'), 'options' => $taxonomy);
00164   }
00165   // Language filter if there is a list of languages
00166   if ($languages = module_invoke('locale', 'language_list')) {
00167     $languages = array('' => t('Language neutral')) + $languages;
00168     $filters['language'] = array('title' => t('language'), 'options' => $languages);
00169   }
00170   return $filters;
00171 }
00172
00176 function node_build_filter_query() {
00177   $filters = node_filters();
00178
00179   // Build query
00180   $where = $args = array();
00181   $join = '';
00182   foreach ($_SESSION['node_overview_filter'] as $index => $filter) {
00183     list($key, $value) = $filter;
00184     switch ($key) {
00185       case 'status':
00186         // Note: no exploitable hole as $key/$value have already been checked when submitted
00187         list($key, $value) = explode('-', $value, 2);
00188         $where[] = 'n.'. $key .' = %d';
00189         break;
00190       case 'category':
00191         $table = "tn$index";
00192         $where[] = "$table.tid = %d";
00193         $join .= "INNER JOIN {term_node} $table ON n.nid = $table.nid ";
00194         break;
00195       case 'type':
00196         $where[] = "n.type = '%s'";
00197         break;
00198       case 'language':
00199         $where[] = "n.language = '%s'";
00200         break;
00201     }
00202     $args[] = $value;
00203   }
00204   $where = count($where) ? 'WHERE '. implode(' AND ', $where) : '';
00205
00206   return array('where' => $where, 'join' => $join, 'args' => $args);
00207 }
00208
00212 function node_filter_form() {
00213   $session = &$_SESSION['node_overview_filter'];
00214   $session = is_array($session) ? $session : array();
00215   $filters = node_filters();
00216
00217   $i = 0;
00218   $form['filters'] = array(
00219     '#type' => 'fieldset',
00220     '#title' => t('Show only items where'),
00221     '#theme' => 'node_filters',
00222   );
00223   $form['#submit'][] = 'node_filter_form_submit';
00224   foreach ($session as $filter) {
00225     list($type, $value) = $filter;
00226     if ($type == 'category') {
00227       // Load term name from DB rather than search and parse options array.
00228       $value = module_invoke('taxonomy', 'get_term', $value);
00229       $value = $value->name;
00230     }
00231     else if ($type == 'language') {
00232       $value = empty($value) ? t('Language neutral') : module_invoke('locale', 'language_name', $value);
00233     }
00234     else {
00235       $value = $filters[$type]['options'][$value];
00236     }
00237     if ($i++) {
00238       $form['filters']['current'][] = array('#value' => t('<em>and</em> where <strong>%a</strong> is <strong>%b</strong>', array('%a' => $filters[$type]['title'], '%b' => $value)));
00239     }
00240     else {
00241       $form['filters']['current'][] = array('#value' => t('<strong>%a</strong> is <strong>%b</strong>', array('%a' => $filters[$type]['title'], '%b' => $value)));
00242     }
00243     if (in_array($type, array('type', 'language'))) {
00244       // Remove the option if it is already being filtered on.
00245       unset($filters[$type]);
00246     }
00247   }
00248
00249   foreach ($filters as $key => $filter) {
00250     $names[$key] = $filter['title'];
00251     $form['filters']['status'][$key] = array('#type' => 'select', '#options' => $filter['options']);
00252   }
00253
00254   $form['filters']['filter'] = array('#type' => 'radios', '#options' => $names, '#default_value' => 'status');
00255   $form['filters']['buttons']['submit'] = array('#type' => 'submit', '#value' => (count($session) ? t('Refine') : t('Filter')));
00256   if (count($session)) {
00257     $form['filters']['buttons']['undo'] = array('#type' => 'submit', '#value' => t('Undo'));
00258     $form['filters']['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset'));
00259   }
00260
00261   drupal_add_js('misc/form.js', 'core');
00262
00263   return $form;
00264 }
00265
00271 function theme_node_filter_form($form) {
00272   $output = '';
00273   $output .= '<div id="node-admin-filter">';
00274   $output .= drupal_render($form['filters']);
00275   $output .= '</div>';
00276   $output .= drupal_render($form);
00277   return $output;
00278 }
00279
00285 function theme_node_filters($form) {
00286   $output = '';
00287   $output .= '<ul class="clear-block">';
00288   if (!empty($form['current'])) {
00289     foreach (element_children($form['current']) as $key) {
00290       $output .= '<li>'. drupal_render($form['current'][$key]) .'</li>';
00291     }
00292   }
00293
00294   $output .= '<li><dl class="multiselect">'. (!empty($form['current']) ? '<dt><em>'. t('and') .'</em> '. t('where') .'</dt>' : '') .'<dd class="a">';
00295   foreach (element_children($form['filter']) as $key) {
00296     $output .= drupal_render($form['filter'][$key]);
00297   }
00298   $output .= '</dd>';
00299
00300   $output .= '<dt>'. t('is') .'</dt><dd class="b">';
00301
00302   foreach (element_children($form['status']) as $key) {
00303     $output .= drupal_render($form['status'][$key]);
00304   }
00305   $output .= '</dd>';
00306
00307   $output .= '</dl>';
00308   $output .= '<div class="container-inline" id="node-admin-buttons">'. drupal_render($form['buttons']) .'</div>';
00309   $output .= '</li></ul>';
00310
00311   return $output;
00312 }
00313
00317 function node_filter_form_submit($form, &$form_state) {
00318   $filters = node_filters();
00319   switch ($form_state['values']['op']) {
00320     case t('Filter'):
00321     case t('Refine'):
00322       if (isset($form_state['values']['filter'])) {
00323         $filter = $form_state['values']['filter'];
00324
00325         // Flatten the options array to accommodate hierarchical/nested options.
00326         $flat_options = form_options_flatten($filters[$filter]['options']);
00327
00328         if (isset($flat_options[$form_state['values'][$filter]])) {
00329           $_SESSION['node_overview_filter'][] = array($filter, $form_state['values'][$filter]);
00330         }
00331       }
00332       break;
00333     case t('Undo'):
00334       array_pop($_SESSION['node_overview_filter']);
00335       break;
00336     case t('Reset'):
00337       $_SESSION['node_overview_filter'] = array();
00338       break;
00339   }
00340 }
00341
00356 function node_mass_update($nodes, $updates) {
00357   // We use batch processing to prevent timeout when updating a large number
00358   // of nodes.
00359   if (count($nodes) > 10) {
00360     $batch = array(
00361       'operations' => array(
00362         array('_node_mass_update_batch_process', array($nodes, $updates))
00363       ),
00364       'finished' => '_node_mass_update_batch_finished',
00365       'title' => t('Processing'),
00366       // We use a single multi-pass operation, so the default
00367       // 'Remaining x of y operations' message will be confusing here.
00368       'progress_message' => '',
00369       'error_message' => t('The update has encountered an error.'),
00370       // The operations do not live in the .module file, so we need to
00371       // tell the batch engine which file to load before calling them.
00372       'file' => drupal_get_path('module', 'node') .'/node.admin.inc',
00373     );
00374     batch_set($batch);
00375   }
00376   else {
00377     foreach ($nodes as $nid) {
00378       _node_mass_update_helper($nid, $updates);
00379     }
00380     drupal_set_message(t('The update has been performed.'));
00381   }
00382 }
00383
00387 function _node_mass_update_helper($nid, $updates) {
00388   $node = node_load($nid, NULL, TRUE);
00389   foreach ($updates as $name => $value) {
00390     $node->$name = $value;
00391   }
00392   node_save($node);
00393   return $node;
00394 }
00395
00399 function _node_mass_update_batch_process($nodes, $updates, &$context) {
00400   if (!isset($context['sandbox']['progress'])) {
00401     $context['sandbox']['progress'] = 0;
00402     $context['sandbox']['max'] = count($nodes);
00403     $context['sandbox']['nodes'] = $nodes;
00404   }
00405
00406   // Process nodes by groups of 5.
00407   $count = min(5, count($context['sandbox']['nodes']));
00408   for ($i = 1; $i <= $count; $i++) {
00409     // For each nid, load the node, reset the values, and save it.
00410     $nid = array_shift($context['sandbox']['nodes']);
00411     $node = _node_mass_update_helper($nid, $updates);
00412
00413     // Store result for post-processing in the finished callback.
00414     $context['results'][] = l($node->title, 'node/'. $node->nid);
00415
00416     // Update our progress information.
00417     $context['sandbox']['progress']++;
00418   }
00419
00420   // Inform the batch engine that we are not finished,
00421   // and provide an estimation of the completion level we reached.
00422   if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
00423     $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
00424   }
00425 }
00426
00430 function _node_mass_update_batch_finished($success, $results, $operations) {
00431   if ($success) {
00432     drupal_set_message(t('The update has been performed.'));
00433   }
00434   else {
00435     drupal_set_message(t('An error occurred and processing did not complete.'), 'error');
00436     $message = format_plural(count($results), '1 item successfully processed:', '@count items successfully processed:');
00437     $message .= theme('item_list', $results);
00438     drupal_set_message($message);
00439   }
00440 }
00441
00445 function node_admin_content($form_state) {
00446   if (isset($form_state['values']['operation']) && $form_state['values']['operation'] == 'delete') {
00447     return node_multiple_delete_confirm($form_state, array_filter($form_state['values']['nodes']));
00448   }
00449   $form = node_filter_form();
00450
00451   $form['#theme'] = 'node_filter_form';
00452   $form['admin']  = node_admin_nodes();
00453
00454   return $form;
00455 }
00456
00460 function node_admin_nodes() {
00461
00462   $filter = node_build_filter_query();
00463
00464   $result = pager_query(db_rewrite_sql('SELECT n.*, u.name FROM {node} n '. $filter['join'] .' INNER JOIN {users} u ON n.uid = u.uid '. $filter['where'] .' ORDER BY n.changed DESC'), 50, 0, NULL, $filter['args']);
00465
00466   // Enable language column if locale is enabled or if we have any node with language
00467   $count = db_result(db_query("SELECT COUNT(*) FROM {node} n WHERE language != ''"));
00468   $multilanguage = (module_exists('locale') || $count);
00469
00470   $form['options'] = array(
00471     '#type' => 'fieldset',
00472     '#title' => t('Update options'),
00473     '#prefix' => '<div class="container-inline">',
00474     '#suffix' => '</div>',
00475   );
00476   $options = array();
00477   foreach (module_invoke_all('node_operations') as $operation => $array) {
00478     $options[$operation] = $array['label'];
00479   }
00480   $form['options']['operation'] = array(
00481     '#type' => 'select',
00482     '#options' => $options,
00483     '#default_value' => 'approve',
00484   );
00485   $form['options']['submit'] = array(
00486     '#type' => 'submit',
00487     '#value' => t('Update'),
00488     '#submit' => array('node_admin_nodes_submit'),
00489   );
00490
00491   $languages = language_list();
00492   $destination = drupal_get_destination();
00493   $nodes = array();
00494   while ($node = db_fetch_object($result)) {
00495     $nodes[$node->nid] = '';
00496     $options = empty($node->language) ? array() : array('language' => $languages[$node->language]);
00497     $form['title'][$node->nid] = array('#value' => l($node->title, 'node/'. $node->nid, $options) .' '. theme('mark', node_mark($node->nid, $node->changed)));
00498     $form['name'][$node->nid] =  array('#value' => check_plain(node_get_types('name', $node)));
00499     $form['username'][$node->nid] = array('#value' => theme('username', $node));
00500     $form['status'][$node->nid] =  array('#value' => ($node->status ? t('published') : t('not published')));
00501     if ($multilanguage) {
00502       $form['language'][$node->nid] = array('#value' => empty($node->language) ? t('Language neutral') : t($languages[$node->language]->name));
00503     }
00504     $form['operations'][$node->nid] = array('#value' => l(t('edit'), 'node/'. $node->nid .'/edit', array('query' => $destination)));
00505   }
00506   $form['nodes'] = array('#type' => 'checkboxes', '#options' => $nodes);
00507   $form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
00508   $form['#theme'] = 'node_admin_nodes';
00509   return $form;
00510 }
00511
00518 function node_admin_nodes_validate($form, &$form_state) {
00519   $nodes = array_filter($form_state['values']['nodes']);
00520   if (count($nodes) == 0) {
00521     form_set_error('', t('No items selected.'));
00522   }
00523 }
00524
00530 function node_admin_nodes_submit($form, &$form_state) {
00531   $operations = module_invoke_all('node_operations');
00532   $operation = $operations[$form_state['values']['operation']];
00533   // Filter out unchecked nodes
00534   $nodes = array_filter($form_state['values']['nodes']);
00535   if ($function = $operation['callback']) {
00536     // Add in callback arguments if present.
00537     if (isset($operation['callback arguments'])) {
00538       $args = array_merge(array($nodes), $operation['callback arguments']);
00539     }
00540     else {
00541       $args = array($nodes);
00542     }
00543     call_user_func_array($function, $args);
00544
00545     cache_clear_all();
00546   }
00547   else {
00548     // We need to rebuild the form to go to a second step.  For example, to
00549     // show the confirmation form for the deletion of nodes.
00550     $form_state['rebuild'] = TRUE;
00551   }
00552 }
00553
00554
00560 function theme_node_admin_nodes($form) {
00561   // If there are rows in this form, then $form['title'] contains a list of
00562   // the title form elements.
00563   $has_posts = isset($form['title']) && is_array($form['title']);
00564   $select_header = $has_posts ? theme('table_select_header_cell') : '';
00565   $header = array($select_header, t('Title'), t('Type'), t('Author'), t('Status'));
00566   if (isset($form['language'])) {
00567     $header[] = t('Language');
00568   }
00569   $header[] = t('Operations');
00570   $output = '';
00571
00572   $output .= drupal_render($form['options']);
00573   if ($has_posts) {
00574     foreach (element_children($form['title']) as $key) {
00575       $row = array();
00576       $row[] = drupal_render($form['nodes'][$key]);
00577       $row[] = drupal_render($form['title'][$key]);
00578       $row[] = drupal_render($form['name'][$key]);
00579       $row[] = drupal_render($form['username'][$key]);
00580       $row[] = drupal_render($form['status'][$key]);
00581       if (isset($form['language'])) {
00582         $row[] = drupal_render($form['language'][$key]);
00583       }
00584       $row[] = drupal_render($form['operations'][$key]);
00585       $rows[] = $row;
00586     }
00587
00588   }
00589   else {
00590     $rows[] = array(array('data' => t('No posts available.'), 'colspan' => '6'));
00591   }
00592
00593   $output .= theme('table', $header, $rows);
00594   if ($form['pager']['#value']) {
00595     $output .= drupal_render($form['pager']);
00596   }
00597
00598   $output .= drupal_render($form);
00599
00600   return $output;
00601 }
00602
00603 function node_multiple_delete_confirm(&$form_state, $nodes) {
00604
00605   $form['nodes'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
00606   // array_filter returns only elements with TRUE values
00607   foreach ($nodes as $nid => $value) {
00608     $title = db_result(db_query('SELECT title FROM {node} WHERE nid = %d', $nid));
00609     $form['nodes'][$nid] = array(
00610       '#type' => 'hidden',
00611       '#value' => $nid,
00612       '#prefix' => '<li>',
00613       '#suffix' => check_plain($title) ."</li>\n",
00614     );
00615   }
00616   $form['operation'] = array('#type' => 'hidden', '#value' => 'delete');
00617   $form['#submit'][] = 'node_multiple_delete_confirm_submit';
00618   return confirm_form($form,
00619                       t('Are you sure you want to delete these items?'),
00620                       'admin/content/node', t('This action cannot be undone.'),
00621                       t('Delete all'), t('Cancel'));
00622 }
00623
00624 function node_multiple_delete_confirm_submit($form, &$form_state) {
00625   if ($form_state['values']['confirm']) {
00626     foreach ($form_state['values']['nodes'] as $nid => $value) {
00627       node_delete($nid);
00628     }
00629     drupal_set_message(t('The items have been deleted.'));
00630   }
00631   $form_state['redirect'] = 'admin/content/node';
00632   return;
00633 }
00634
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/node/node.install Source File

modules » node

node.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: node.install,v 1.4 2007/12/18 12:59:21 dries Exp $
00003
00007 function node_schema() {
00008   $schema['node'] = array(
00009     'description' => t('The base table for nodes.'),
00010     'fields' => array(
00011       'nid' => array(
00012         'description' => t('The primary identifier for a node.'),
00013         'type' => 'serial',
00014         'unsigned' => TRUE,
00015         'not null' => TRUE),
00016       'vid' => array(
00017         'description' => t('The current {node_revisions}.vid version identifier.'),
00018         'type' => 'int',
00019         'unsigned' => TRUE,
00020         'not null' => TRUE,
00021         'default' => 0),
00022       'type' => array(
00023         'description' => t('The {node_type}.type of this node.'),
00024         'type' => 'varchar',
00025         'length' => 32,
00026         'not null' => TRUE,
00027         'default' => ''),
00028       'language' => array(
00029         'description' => t('The {languages}.language of this node.'),
00030         'type' => 'varchar',
00031         'length' => 12,
00032         'not null' => TRUE,
00033         'default' => ''),
00034       'title' => array(
00035         'description' => t('The title of this node, always treated a non-markup plain text.'),
00036         'type' => 'varchar',
00037         'length' => 255,
00038         'not null' => TRUE,
00039         'default' => ''),
00040       'uid' => array(
00041         'description' => t('The {users}.uid that owns this node; initially, this is the user that created it.'),
00042         'type' => 'int',
00043         'not null' => TRUE,
00044         'default' => 0),
00045       'status' => array(
00046         'description' => t('Boolean indicating whether the node is published (visible to non-administrators).'),
00047         'type' => 'int',
00048         'not null' => TRUE,
00049         'default' => 1),
00050       'created' => array(
00051         'description' => t('The Unix timestamp when the node was created.'),
00052         'type' => 'int',
00053         'not null' => TRUE,
00054         'default' => 0),
00055       'changed' => array(
00056         'description' => t('The Unix timestamp when the node was most recently saved.'),
00057         'type' => 'int',
00058         'not null' => TRUE,
00059         'default' => 0),
00060       'comment' => array(
00061         'description' => t('Whether comments are allowed on this node: 0 = no, 1 = read only, 2 = read/write.'),
00062         'type' => 'int',
00063         'not null' => TRUE,
00064         'default' => 0),
00065       'promote' => array(
00066         'description' => t('Boolean indicating whether the node should displayed on the front page.'),
00067         'type' => 'int',
00068         'not null' => TRUE,
00069         'default' => 0),
00070       'moderate' => array(
00071         'description' => t('Previously, a boolean indicating whether the node was "in moderation"; mostly no longer used.'),
00072         'type' => 'int',
00073         'not null' => TRUE,
00074         'default' => 0),
00075       'sticky' => array(
00076         'description' => t('Boolean indicating whether the node should be displayed at the top of lists in which it appears.'),
00077         'type' => 'int',
00078         'not null' => TRUE,
00079         'default' => 0),
00080       'tnid' => array(
00081         'description' => t('The translation set id for this node, which equals the node id of the source post in each set.'),
00082         'type' => 'int',
00083         'unsigned' => TRUE,
00084         'not null' => TRUE,
00085         'default' => 0),
00086       'translate' => array(
00087         'description' => t('A boolean indicating whether this translation page needs to be updated.'),
00088         'type' => 'int',
00089         'not null' => TRUE,
00090         'default' => 0),
00091       ),
00092     'indexes' => array(
00093       'node_changed'        => array('changed'),
00094       'node_created'        => array('created'),
00095       'node_moderate'       => array('moderate'),
00096       'node_promote_status' => array('promote', 'status'),
00097       'node_status_type'    => array('status', 'type', 'nid'),
00098       'node_title_type'     => array('title', array('type', 4)),
00099       'node_type'           => array(array('type', 4)),
00100       'uid'                 => array('uid'),
00101       'tnid'                => array('tnid'),
00102       'translate'           => array('translate'),
00103       ),
00104     'unique keys' => array(
00105       'vid'     => array('vid')
00106       ),
00107     'primary key' => array('nid'),
00108     );
00109
00110   $schema['node_access'] = array(
00111     'description' => t('Identifies which realm/grant pairs a user must possess in order to view, update, or delete specific nodes.'),
00112     'fields' => array(
00113       'nid' => array(
00114         'description' => t('The {node}.nid this record affects.'),
00115         'type' => 'int',
00116         'unsigned' => TRUE,
00117         'not null' => TRUE,
00118         'default' => 0),
00119       'gid' => array(
00120         'description' => t("The grant ID a user must possess in the specified realm to gain this row's privileges on the node."),
00121         'type' => 'int',
00122         'unsigned' => TRUE,
00123         'not null' => TRUE,
00124         'default' => 0),
00125       'realm' => array(
00126         'description' => t('The realm in which the user must possess the grant ID. Each node access node can define one or more realms.'),
00127         'type' => 'varchar',
00128         'length' => 255,
00129         'not null' => TRUE,
00130         'default' => ''),
00131       'grant_view' => array(
00132         'description' => t('Boolean indicating whether a user with the realm/grant pair can view this node.'),
00133         'type' => 'int',
00134         'unsigned' => TRUE,
00135         'not null' => TRUE,
00136         'default' => 0,
00137         'size' => 'tiny'),
00138       'grant_update' => array(
00139         'description' => t('Boolean indicating whether a user with the realm/grant pair can edit this node.'),
00140         'type' => 'int',
00141         'unsigned' => TRUE,
00142         'not null' => TRUE,
00143         'default' => 0,
00144         'size' => 'tiny'),
00145       'grant_delete' => array(
00146         'description' => t('Boolean indicating whether a user with the realm/grant pair can delete this node.'),
00147         'type' => 'int',
00148         'unsigned' => TRUE,
00149         'not null' => TRUE,
00150         'default' => 0,
00151         'size' => 'tiny')
00152       ),
00153     'primary key' => array('nid', 'gid', 'realm'),
00154     );
00155
00156   $schema['node_counter'] = array(
00157     'description' => t('Access statistics for {node}s.'),
00158     'fields' => array(
00159       'nid' => array(
00160         'description' => t('The {node}.nid for these statistics.'),
00161         'type' => 'int',
00162         'not null' => TRUE,
00163         'default' => 0),
00164       'totalcount' => array(
00165         'description' => t('The total number of times the {node} has been viewed.'),
00166         'type' => 'int',
00167         'unsigned' => TRUE,
00168         'not null' => TRUE,
00169         'default' => 0,
00170         'size' => 'big'),
00171       'daycount' => array(
00172         'description' => t('The total number of times the {node} has been viewed today.'),
00173         'type' => 'int',
00174         'unsigned' => TRUE,
00175         'not null' => TRUE,
00176         'default' => 0,
00177         'size' => 'medium'),
00178       'timestamp' => array(
00179         'description' => t('The most recent time the {node} has been viewed.'),
00180         'type' => 'int',
00181         'unsigned' => TRUE,
00182         'not null' => TRUE,
00183         'default' => 0)
00184       ),
00185     'primary key' => array('nid'),
00186     );
00187
00188   $schema['node_revisions'] = array(
00189     'description' => t('Stores information about each saved version of a {node}.'),
00190     'fields' => array(
00191       'nid' => array(
00192         'description' => t('The {node} this version belongs to.'),
00193         'type' => 'int',
00194         'unsigned' => TRUE,
00195         'not null' => TRUE,
00196         'default' => 0),
00197       'vid' => array(
00198         'description' => t('The primary identifier for this version.'),
00199         'type' => 'serial',
00200         'unsigned' => TRUE,
00201         'not null' => TRUE),
00202       'uid' => array(
00203         'description' => t('The {users}.uid that created this version.'),
00204         'type' => 'int',
00205         'not null' => TRUE,
00206         'default' => 0),
00207       'title' => array(
00208         'description' => t('The title of this version.'),
00209         'type' => 'varchar',
00210         'length' => 255,
00211         'not null' => TRUE,
00212         'default' => ''),
00213       'body' => array(
00214         'description' => t('The body of this version.'),
00215         'type' => 'text',
00216         'not null' => TRUE,
00217         'size' => 'big'),
00218       'teaser' => array(
00219         'description' => t('The teaser of this version.'),
00220         'type' => 'text',
00221         'not null' => TRUE,
00222         'size' => 'big'),
00223       'log' => array(
00224         'description' => t('The log entry explaining the changes in this version.'),
00225         'type' => 'text',
00226         'not null' => TRUE,
00227         'size' => 'big'),
00228       'timestamp' => array(
00229         'description' => t('A Unix timestamp indicating when this version was created.'),
00230         'type' => 'int',
00231         'not null' => TRUE,
00232         'default' => 0),
00233       'format' => array(
00234         'description' => t("The input format used by this version's body."),
00235         'type' => 'int',
00236         'not null' => TRUE,
00237         'default' => 0)
00238       ),
00239     'indexes' => array(
00240       'nid' => array('nid'),
00241       'uid' => array('uid')
00242       ),
00243     'primary key' => array('vid'),
00244     );
00245
00246   $schema['node_type'] = array(
00247     'description' => t('Stores information about all defined {node} types.'),
00248     'fields' => array(
00249       'type' => array(
00250         'description' => t('The machine-readable name of this type.'),
00251         'type' => 'varchar',
00252         'length' => 32,
00253         'not null' => TRUE),
00254       'name' => array(
00255         'description' => t('The human-readable name of this type.'),
00256         'type' => 'varchar',
00257         'length' => 255,
00258         'not null' => TRUE,
00259         'default' => ''),
00260       'module' => array(
00261         'description' => t('The module that implements this type.'),
00262         'type' => 'varchar',
00263         'length' => 255,
00264         'not null' => TRUE),
00265       'description'    => array(
00266         'description' => t('A brief description of this type.'),
00267         'type' => 'text',
00268         'not null' => TRUE,
00269         'size' => 'medium'),
00270       'help' => array(
00271         'description' => t('Help information shown to the user when creating a {node} of this type.'),
00272         'type' => 'text',
00273         'not null' => TRUE,
00274         'size' => 'medium'),
00275       'has_title' => array(
00276         'description' => t('Boolean indicating whether this type uses the {node}.title field.'),
00277         'type' => 'int',
00278         'unsigned' => TRUE,
00279         'not null' => TRUE,
00280         'size' => 'tiny'),
00281       'title_label' => array(
00282         'description' => t('The label displayed for the title field on the edit form.'),
00283         'type' => 'varchar',
00284         'length' => 255,
00285         'not null' => TRUE,
00286         'default' => ''),
00287       'has_body' => array(
00288         'description' => t('Boolean indicating whether this type uses the {node_revisions}.body field.'),
00289         'type' => 'int',
00290         'unsigned' => TRUE,
00291         'not null' => TRUE,
00292         'size' => 'tiny'),
00293       'body_label' => array(
00294         'description' => t('The label displayed for the body field on the edit form.'),
00295         'type' => 'varchar',
00296         'length' => 255,
00297         'not null' => TRUE,
00298         'default' => ''),
00299       'min_word_count' => array(
00300         'description' => t('The minimum number of words the body must contain.'),
00301         'type' => 'int',
00302         'unsigned' => TRUE,
00303         'not null' => TRUE,
00304         'size' => 'small'),
00305       'custom' => array(
00306         'description' => t('A boolean indicating whether this type is defined by a module (FALSE) or by a user via a module like the Content Construction Kit (TRUE).'),
00307         'type' => 'int',
00308         'not null' => TRUE,
00309         'default' => 0,
00310         'size' => 'tiny'),
00311       'modified' => array(
00312         'description' => t('A boolean indicating whether this type has been modified by an administrator; currently not used in any way.'),
00313         'type' => 'int',
00314         'not null' => TRUE,
00315         'default' => 0,
00316         'size' => 'tiny'),
00317       'locked' => array(
00318         'description' => t('A boolean indicating whether the administrator can change the machine name of this type.'),
00319         'type' => 'int',
00320         'not null' => TRUE,
00321         'default' => 0,
00322         'size' => 'tiny'),
00323       'orig_type' => array(
00324         'description' => t('The original machine-readable name of this node type. This may be different from the current type name if the locked field is 0.'),
00325         'type' => 'varchar',
00326         'length' => 255,
00327         'not null' => TRUE,
00328         'default' => '')
00329       ),
00330     'primary key' => array('type'),
00331     );
00332
00333   return $schema;
00334 }
00335
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/node/node.module Source File

modules » node

node.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: node.module,v 1.947 2008/02/03 19:41:47 goba Exp $
00003
00010 define('NODE_NEW_LIMIT', time() - 30 * 24 * 60 * 60);
00011
00012 define('NODE_BUILD_NORMAL', 0);
00013 define('NODE_BUILD_PREVIEW', 1);
00014 define('NODE_BUILD_SEARCH_INDEX', 2);
00015 define('NODE_BUILD_SEARCH_RESULT', 3);
00016 define('NODE_BUILD_RSS', 4);
00017 define('NODE_BUILD_PRINT', 5);
00018
00022 function node_help($path, $arg) {
00023   // Remind site administrators about the {node_access} table being flagged
00024   // for rebuild. We don't need to issue the message on the confirm form, or
00025   // while the rebuild is being processed.
00026   if ($path != 'admin/content/node-settings/rebuild' && $path != 'batch' && strpos($path, '#') === FALSE
00027       && user_access('access administration pages') && node_access_needs_rebuild()) {
00028     if ($path == 'admin/content/node-settings') {
00029       $message = t('The content access permissions need to be rebuilt.');
00030     }
00031     else {
00032       $message = t('The content access permissions need to be rebuilt. Please visit <a href="@node_access_rebuild">this page</a>.', array('@node_access_rebuild' => url('admin/content/node-settings/rebuild')));
00033     }
00034     drupal_set_message($message, 'error');
00035   }
00036
00037   switch ($path) {
00038     case 'admin/help#node':
00039       $output = '<p>'. t('The node module manages content on your site, and stores all posts (regardless of type) as a "node". In addition to basic publishing settings, including whether the post has been published, promoted to the site front page, or should remain present (or sticky) at the top of lists, the node module also records basic information about the author of a post. Optional revision control over edits is available. For additional functionality, the node module is often extended by other modules.') .'</p>';
00040       $output .= '<p>'. t('Though each post on your site is a node, each post is also of a particular <a href="@content-type">content type</a>. <a href="@content-type">Content types</a> are used to define the characteristics of a post, including the title and description of the fields displayed on its add and edit pages. Each content type may have different default settings for <em>Publishing options</em> and other workflow controls. By default, the two content types in a standard Drupal installation are <em>Page</em> and <em>Story</em>. Use the <a href="@content-type">content types page</a> to add new or edit existing content types. Additional content types also become available as you enable additional core, contributed and custom modules.', array('@content-type' => url('admin/content/types'))) .'</p>';
00041       $output .= '<p>'. t('The administrative <a href="@content">content page</a> allows you to review and manage your site content. The <a href="@post-settings">post settings page</a> sets certain options for the display of posts. The node module makes a number of permissions available for each content type, which may be set by role on the <a href="@permissions">permissions page</a>.', array('@content' => url('admin/content/node'), '@post-settings' => url('admin/content/node-settings'), '@permissions' => url('admin/user/permissions'))) .'</p>';
00042       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@node">Node module</a>.', array('@node' => 'http://drupal.org/handbook/modules/node/')) .'</p>';
00043       return $output;
00044     case 'admin/content/node':
00045       return ' '; // Return a non-null value so that the 'more help' link is shown.
00046     case 'admin/content/types':
00047       return '<p>'. t('Below is a list of all the content types on your site. All posts that exist on your site are instances of one of these content types.') .'</p>';
00048     case 'admin/content/types/add':
00049       return '<p>'. t('To create a new content type, enter the human-readable name, the machine-readable name, and all other relevant fields that are on this page. Once created, users of your site will be able to create posts that are instances of this content type.') .'</p>';
00050     case 'node/%/revisions':
00051       return '<p>'. t('The revisions let you track differences between multiple versions of a post.') .'</p>';
00052     case 'node/%/edit':
00053       $node = node_load($arg[1]);
00054       $type = node_get_types('type', $node->type);
00055       return (!empty($type->help) ? '<p>'. filter_xss_admin($type->help) .'</p>' : '');
00056   }
00057
00058   if ($arg[0] == 'node' && $arg[1] == 'add' && $arg[2]) {
00059     $type = node_get_types('type', str_replace('-', '_', $arg[2]));
00060     return (!empty($type->help) ? '<p>'. filter_xss_admin($type->help) .'</p>' : '');
00061   }
00062 }
00063
00067 function node_theme() {
00068   return array(
00069     'node' => array(
00070       'arguments' => array('node' => NULL, 'teaser' => FALSE, 'page' => FALSE),
00071       'template' => 'node',
00072     ),
00073     'node_list' => array(
00074       'arguments' => array('items' => NULL, 'title' => NULL),
00075     ),
00076     'node_search_admin' => array(
00077       'arguments' => array('form' => NULL),
00078     ),
00079     'node_filter_form' => array(
00080       'arguments' => array('form' => NULL),
00081       'file' => 'node.admin.inc',
00082     ),
00083     'node_filters' => array(
00084       'arguments' => array('form' => NULL),
00085       'file' => 'node.admin.inc',
00086     ),
00087     'node_admin_nodes' => array(
00088       'arguments' => array('form' => NULL),
00089       'file' => 'node.admin.inc',
00090     ),
00091     'node_add_list' => array(
00092       'arguments' => array('content' => NULL),
00093       'file' => 'node.pages.inc',
00094     ),
00095     'node_form' => array(
00096       'arguments' => array('form' => NULL),
00097       'file' => 'node.pages.inc',
00098     ),
00099     'node_preview' => array(
00100       'arguments' => array('node' => NULL),
00101       'file' => 'node.pages.inc',
00102     ),
00103     'node_log_message' => array(
00104       'arguments' => array('log' => NULL),
00105     ),
00106     'node_submitted' => array(
00107       'arguments' => array('node' => NULL),
00108     ),
00109   );
00110 }
00111
00115 function node_cron() {
00116   db_query('DELETE FROM {history} WHERE timestamp < %d', NODE_NEW_LIMIT);
00117 }
00118
00134 function node_title_list($result, $title = NULL) {
00135   $items = array();
00136   $num_rows = FALSE;
00137   while ($node = db_fetch_object($result)) {
00138     $items[] = l($node->title, 'node/'. $node->nid, !empty($node->comment_count) ? array('title' => format_plural($node->comment_count, '1 comment', '@count comments')) : array());
00139     $num_rows = TRUE;
00140   }
00141
00142   return $num_rows ? theme('node_list', $items, $title) : FALSE;
00143 }
00144
00150 function theme_node_list($items, $title = NULL) {
00151   return theme('item_list', $items, $title);
00152 }
00153
00157 function node_tag_new($nid) {
00158   global $user;
00159
00160   if ($user->uid) {
00161     if (node_last_viewed($nid)) {
00162       db_query('UPDATE {history} SET timestamp = %d WHERE uid = %d AND nid = %d', time(), $user->uid, $nid);
00163     }
00164     else {
00165       @db_query('INSERT INTO {history} (uid, nid, timestamp) VALUES (%d, %d, %d)', $user->uid, $nid, time());
00166     }
00167   }
00168 }
00169
00174 function node_last_viewed($nid) {
00175   global $user;
00176   static $history;
00177
00178   if (!isset($history[$nid])) {
00179     $history[$nid] = db_fetch_object(db_query("SELECT timestamp FROM {history} WHERE uid = %d AND nid = %d", $user->uid, $nid));
00180   }
00181
00182   return (isset($history[$nid]->timestamp) ? $history[$nid]->timestamp : 0);
00183 }
00184
00195 function node_mark($nid, $timestamp) {
00196   global $user;
00197   static $cache;
00198
00199   if (!$user->uid) {
00200     return MARK_READ;
00201   }
00202   if (!isset($cache[$nid])) {
00203     $cache[$nid] = node_last_viewed($nid);
00204   }
00205   if ($cache[$nid] == 0 && $timestamp > NODE_NEW_LIMIT) {
00206     return MARK_NEW;
00207   }
00208   elseif ($timestamp > $cache[$nid] && $timestamp > NODE_NEW_LIMIT) {
00209     return MARK_UPDATED;
00210   }
00211   return MARK_READ;
00212 }
00213
00217 function node_teaser_js(&$form, &$form_state) {
00218   if (isset($form['#post']['teaser_js'])) {
00219     // Glue the teaser to the body.
00220     if (trim($form_state['values']['teaser_js'])) {
00221       // Space the teaser from the body
00222       $body = trim($form_state['values']['teaser_js']) ."\r\n<!--break-->\r\n". trim($form_state['values']['body']);
00223     }
00224     else {
00225       // Empty teaser, no spaces.
00226       $body = '<!--break-->'. $form_state['values']['body'];
00227     }
00228     // Pass updated body value on to preview/submit form processing.
00229     form_set_value($form['body'], $body, $form_state);
00230     // Pass updated body value back onto form for those cases
00231     // in which the form is redisplayed.
00232     $form['body']['#value'] = $body;
00233   }
00234   return $form;
00235 }
00236
00252 function node_teaser_include_verify(&$form, &$form_state) {
00253   $message = '';
00254
00255   // $form['#post'] is set only when the form is built for preview/submit.
00256   if (isset($form['#post']['body']) && isset($form_state['values']['teaser_include']) && !$form_state['values']['teaser_include']) {
00257     // "teaser_include" checkbox is present and unchecked.
00258     if (strpos($form_state['values']['body'], '<!--break-->') === 0) {
00259       // Teaser is empty string.
00260       $message = t('You specified that the summary should not be shown when this post is displayed in full view. This setting is ignored when the summary is empty.');
00261     }
00262     elseif (strpos($form_state['values']['body'], '<!--break-->') === FALSE) {
00263       // Teaser delimiter is not present in the body.
00264       $message = t('You specified that the summary should not be shown when this post is displayed in full view. This setting has been ignored since you have not defined a summary for the post. (To define a summary, insert the delimiter "&lt;!--break--&gt;" (without the quotes) in the Body of the post to indicate the end of the summary and the start of the main content.)');
00265     }
00266
00267     if (!empty($message)) {
00268       drupal_set_message($message, 'warning');
00269       // Pass new checkbox value on to preview/submit form processing.
00270       form_set_value($form['teaser_include'], 1, $form_state);
00271       // Pass new checkbox value back onto form for those cases
00272       // in which form is redisplayed.
00273       $form['teaser_include']['#value'] = 1;
00274     }
00275   }
00276
00277   return $form;
00278 }
00279
00301 function node_teaser($body, $format = NULL, $size = NULL) {
00302
00303   if (!isset($size)) {
00304     $size = variable_get('teaser_length', 600);
00305   }
00306
00307   // Find where the delimiter is in the body
00308   $delimiter = strpos($body, '<!--break-->');
00309
00310   // If the size is zero, and there is no delimiter, the entire body is the teaser.
00311   if ($size == 0 && $delimiter === FALSE) {
00312     return $body;
00313   }
00314
00315   // If a valid delimiter has been specified, use it to chop off the teaser.
00316   if ($delimiter !== FALSE) {
00317     return substr($body, 0, $delimiter);
00318   }
00319
00320   // We check for the presence of the PHP evaluator filter in the current
00321   // format. If the body contains PHP code, we do not split it up to prevent
00322   // parse errors.
00323   if (isset($format)) {
00324     $filters = filter_list_format($format);
00325     if (isset($filters['php/0']) && strpos($body, '<?') !== FALSE) {
00326       return $body;
00327     }
00328   }
00329
00330   // If we have a short body, the entire body is the teaser.
00331   if (drupal_strlen($body) <= $size) {
00332     return $body;
00333   }
00334
00335   // If the delimiter has not been specified, try to split at paragraph or
00336   // sentence boundaries.
00337
00338   // The teaser may not be longer than maximum length specified. Initial slice.
00339   $teaser = truncate_utf8($body, $size);
00340
00341   // Store the actual length of the UTF8 string -- which might not be the same
00342   // as $size.
00343   $max_rpos = strlen($teaser);
00344
00345   // How much to cut off the end of the teaser so that it doesn't end in the
00346   // middle of a paragraph, sentence, or word.
00347   // Initialize it to maximum in order to find the minimum.
00348   $min_rpos = $max_rpos;
00349
00350   // Store the reverse of the teaser.  We use strpos on the reversed needle and
00351   // haystack for speed and convenience.
00352   $reversed = strrev($teaser);
00353
00354   // Build an array of arrays of break points grouped by preference.
00355   $break_points = array();
00356
00357   // A paragraph near the end of sliced teaser is most preferable.
00358   $break_points[] = array('</p>' => 0);
00359
00360   // If no complete paragraph then treat line breaks as paragraphs.
00361   $line_breaks = array('<br />' => 6, '<br>' => 4);
00362   // Newline only indicates a line break if line break converter
00363   // filter is present.
00364   if (isset($filters['filter/1'])) {
00365     $line_breaks["\n"] = 1;
00366   }
00367   $break_points[] = $line_breaks;
00368
00369   // If the first paragraph is too long, split at the end of a sentence.
00370   $break_points[] = array('. ' => 1, '! ' => 1, '? ' => 1, '。' => 0, '؟ ' => 1);
00371
00372   // Iterate over the groups of break points until a break point is found.
00373   foreach ($break_points as $points) {
00374     // Look for each break point, starting at the end of the teaser.
00375     foreach ($points as $point => $offset) {
00376       // The teaser is already reversed, but the break point isn't.
00377       $rpos = strpos($reversed, strrev($point));
00378       if ($rpos !== FALSE) {
00379         $min_rpos = min($rpos + $offset, $min_rpos);
00380       }
00381     }
00382
00383     // If a break point was found in this group, slice and return the teaser.
00384     if ($min_rpos !== $max_rpos) {
00385       // Don't slice with length 0.  Length must be <0 to slice from RHS.
00386       return ($min_rpos === 0) ? $teaser : substr($teaser, 0, 0 - $min_rpos);
00387     }
00388   }
00389
00390   // If a break point was not found, still return a teaser.
00391   return $teaser;
00392 }
00393
00413 function node_get_types($op = 'types', $node = NULL, $reset = FALSE) {
00414   static $_node_types, $_node_names;
00415
00416   if ($reset || !isset($_node_types)) {
00417     list($_node_types, $_node_names) = _node_types_build();
00418   }
00419
00420   if ($node) {
00421     if (is_array($node)) {
00422       $type = $node['type'];
00423     }
00424     elseif (is_object($node)) {
00425       $type = $node->type;
00426     }
00427     elseif (is_string($node)) {
00428       $type = $node;
00429     }
00430     if (!isset($_node_types[$type])) {
00431       return FALSE;
00432     }
00433   }
00434   switch ($op) {
00435     case 'types':
00436       return $_node_types;
00437     case 'type':
00438       return isset($_node_types[$type]) ? $_node_types[$type] : FALSE;
00439     case 'module':
00440       return isset($_node_types[$type]->module) ? $_node_types[$type]->module : FALSE;
00441     case 'names':
00442       return $_node_names;
00443     case 'name':
00444       return isset($_node_names[$type]) ? $_node_names[$type] : FALSE;
00445   }
00446 }
00447
00452 function node_types_rebuild() {
00453   _node_types_build();
00454
00455   $node_types = node_get_types('types', NULL, TRUE);
00456
00457   foreach ($node_types as $type => $info) {
00458     if (!empty($info->is_new)) {
00459       node_type_save($info);
00460     }
00461     if (!empty($info->disabled)) {
00462       node_type_delete($info->type);
00463     }
00464   }
00465
00466   _node_types_build();
00467 }
00468
00478 function node_type_save($info) {
00479   $is_existing = FALSE;
00480   $existing_type = !empty($info->old_type) ? $info->old_type : $info->type;
00481   $is_existing = db_result(db_query("SELECT COUNT(*) FROM {node_type} WHERE type = '%s'", $existing_type));
00482   if (!isset($info->help)) {
00483     $info->help = '';
00484   }
00485   if (!isset($info->min_word_count)) {
00486     $info->min_word_count = 0;
00487   }
00488   if (!isset($info->body_label)) {
00489     $info->body_label = '';
00490   }
00491
00492   if ($is_existing) {
00493     db_query("UPDATE {node_type} SET type = '%s', name = '%s', module = '%s', has_title = %d, title_label = '%s', has_body = %d, body_label = '%s', description = '%s', help = '%s', min_word_count = %d, custom = %d, modified = %d, locked = %d WHERE type = '%s'", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->min_word_count, $info->custom, $info->modified, $info->locked, $existing_type);
00494
00495     module_invoke_all('node_type', 'update', $info);
00496     return SAVED_UPDATED;
00497   }
00498   else {
00499     db_query("INSERT INTO {node_type} (type, name, module, has_title, title_label, has_body, body_label, description, help, min_word_count, custom, modified, locked, orig_type) VALUES ('%s', '%s', '%s', %d, '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d, '%s')", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->min_word_count, $info->custom, $info->modified, $info->locked, $info->orig_type);
00500
00501     module_invoke_all('node_type', 'insert', $info);
00502     return SAVED_NEW;
00503   }
00504 }
00505
00512 function node_type_delete($type) {
00513   $info = node_get_types('type', $type);
00514   db_query("DELETE FROM {node_type} WHERE type = '%s'", $type);
00515   module_invoke_all('node_type', 'delete', $info);
00516 }
00517
00529 function node_type_update_nodes($old_type, $type) {
00530   db_query("UPDATE {node} SET type = '%s' WHERE type = '%s'", $type, $old_type);
00531   return db_affected_rows();
00532 }
00533
00541 function _node_types_build() {
00542   $_node_types = array();
00543   $_node_names = array();
00544
00545   $info_array = module_invoke_all('node_info');
00546   foreach ($info_array as $type => $info) {
00547     $info['type'] = $type;
00548     $_node_types[$type] = (object) _node_type_set_defaults($info);
00549     $_node_names[$type] = $info['name'];
00550   }
00551
00552   $type_result = db_query(db_rewrite_sql('SELECT nt.type, nt.* FROM {node_type} nt ORDER BY nt.type ASC', 'nt', 'type'));
00553   while ($type_object = db_fetch_object($type_result)) {
00554     // Check for node types from disabled modules and mark their types for removal.
00555     // Types defined by the node module in the database (rather than by a separate
00556     // module using hook_node_info) have a module value of 'node'.
00557     if ($type_object->module != 'node' && empty($info_array[$type_object->type])) {
00558       $type_object->disabled = TRUE;
00559     }
00560     if (!isset($_node_types[$type_object->type]) || $type_object->modified) {
00561       $_node_types[$type_object->type] = $type_object;
00562       $_node_names[$type_object->type] = $type_object->name;
00563
00564       if ($type_object->type != $type_object->orig_type) {
00565         unset($_node_types[$type_object->orig_type]);
00566         unset($_node_names[$type_object->orig_type]);
00567       }
00568     }
00569   }
00570
00571   asort($_node_names);
00572
00573   return array($_node_types, $_node_names);
00574 }
00575
00579 function _node_type_set_defaults($info) {
00580   if (!isset($info['has_title'])) {
00581     $info['has_title'] = TRUE;
00582   }
00583   if ($info['has_title'] && !isset($info['title_label'])) {
00584     $info['title_label'] = t('Title');
00585   }
00586
00587   if (!isset($info['has_body'])) {
00588     $info['has_body'] = TRUE;
00589   }
00590   if ($info['has_body'] && !isset($info['body_label'])) {
00591     $info['body_label'] = t('Body');
00592   }
00593
00594   if (!isset($info['help'])) {
00595     $info['help'] = '';
00596   }
00597   if (!isset($info['min_word_count'])) {
00598     $info['min_word_count'] = 0;
00599   }
00600   if (!isset($info['custom'])) {
00601     $info['custom'] = FALSE;
00602   }
00603   if (!isset($info['modified'])) {
00604     $info['modified'] = FALSE;
00605   }
00606   if (!isset($info['locked'])) {
00607     $info['locked'] = TRUE;
00608   }
00609
00610   $info['orig_type'] = $info['type'];
00611   $info['is_new'] = TRUE;
00612
00613   return $info;
00614 }
00615
00626 function node_hook(&$node, $hook) {
00627   $module = node_get_types('module', $node);
00628   if ($module == 'node') {
00629     $module = 'node_content'; // Avoid function name collisions.
00630   }
00631   return module_hook($module, $hook);
00632 }
00633
00646 function node_invoke(&$node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) {
00647   if (node_hook($node, $hook)) {
00648     $module = node_get_types('module', $node);
00649     if ($module == 'node') {
00650       $module = 'node_content'; // Avoid function name collisions.
00651     }
00652     $function = $module .'_'. $hook;
00653     return ($function($node, $a2, $a3, $a4));
00654   }
00655 }
00656
00669 function node_invoke_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
00670   $return = array();
00671   foreach (module_implements('nodeapi') as $name) {
00672     $function = $name .'_nodeapi';
00673     $result = $function($node, $op, $a3, $a4);
00674     if (isset($result) && is_array($result)) {
00675       $return = array_merge($return, $result);
00676     }
00677     else if (isset($result)) {
00678       $return[] = $result;
00679     }
00680   }
00681   return $return;
00682 }
00683
00697 function node_load($param = array(), $revision = NULL, $reset = NULL) {
00698   static $nodes = array();
00699
00700   if ($reset) {
00701     $nodes = array();
00702   }
00703
00704   $cachable = ($revision == NULL);
00705   $arguments = array();
00706   if (is_numeric($param)) {
00707     if ($cachable) {
00708       // Is the node statically cached?
00709       if (isset($nodes[$param])) {
00710         return is_object($nodes[$param]) ? drupal_clone($nodes[$param]) : $nodes[$param];
00711       }
00712     }
00713     $cond = 'n.nid = %d';
00714     $arguments[] = $param;
00715   }
00716   elseif (is_array($param)) {
00717     // Turn the conditions into a query.
00718     foreach ($param as $key => $value) {
00719       $cond[] = 'n.'. db_escape_string($key) ." = '%s'";
00720       $arguments[] = $value;
00721     }
00722     $cond = implode(' AND ', $cond);
00723   }
00724   else {
00725     return FALSE;
00726   }
00727
00728   // Retrieve a field list based on the site's schema.
00729   $fields = drupal_schema_fields_sql('node', 'n');
00730   $fields = array_merge($fields, drupal_schema_fields_sql('node_revisions', 'r'));
00731   $fields = array_merge($fields, array('u.name', 'u.picture', 'u.data'));
00732   // Remove fields not needed in the query: n.vid and r.nid are redundant,
00733   // n.title is unnecessary because the node title comes from the
00734   // node_revisions table.  We'll keep r.vid, r.title, and n.nid.
00735   $fields = array_diff($fields, array('n.vid', 'n.title', 'r.nid'));
00736   $fields = implode(', ', $fields);
00737   // Rename timestamp field for clarity.
00738   $fields = str_replace('r.timestamp', 'r.timestamp AS revision_timestamp', $fields);
00739   // Change name of revision uid so it doesn't conflict with n.uid.
00740   $fields = str_replace('r.uid', 'r.uid AS revision_uid', $fields);
00741
00742   // Retrieve the node.
00743   // No db_rewrite_sql is applied so as to get complete indexing for search.
00744   if ($revision) {
00745     array_unshift($arguments, $revision);
00746     $node = db_fetch_object(db_query('SELECT '. $fields .' FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = %d WHERE '. $cond, $arguments));
00747   }
00748   else {
00749     $node = db_fetch_object(db_query('SELECT '. $fields .' FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.vid = n.vid WHERE '. $cond, $arguments));
00750   }
00751
00752   if ($node && $node->nid) {
00753     // Call the node specific callback (if any) and piggy-back the
00754     // results to the node or overwrite some values.
00755     if ($extra = node_invoke($node, 'load')) {
00756       foreach ($extra as $key => $value) {
00757         $node->$key = $value;
00758       }
00759     }
00760
00761     if ($extra = node_invoke_nodeapi($node, 'load')) {
00762       foreach ($extra as $key => $value) {
00763         $node->$key = $value;
00764       }
00765     }
00766     if ($cachable) {
00767       $nodes[$node->nid] = is_object($node) ? drupal_clone($node) : $node;
00768     }
00769   }
00770
00771   return $node;
00772 }
00773
00777 function node_validate($node, $form = array()) {
00778   // Convert the node to an object, if necessary.
00779   $node = (object)$node;
00780   $type = node_get_types('type', $node);
00781
00782   // Make sure the body has the minimum number of words.
00783   // TODO : use a better word counting algorithm that will work in other languages
00784   if (!empty($type->min_word_count) && isset($node->body) && count(explode(' ', $node->body)) < $type->min_word_count) {
00785     form_set_error('body', t('The body of your @type is too short. You need at least %words words.', array('%words' => $type->min_word_count, '@type' => $type->name)));
00786   }
00787
00788   if (isset($node->nid) && (node_last_changed($node->nid) > $node->changed)) {
00789     form_set_error('changed', t('This content has been modified by another user, changes cannot be saved.'));
00790   }
00791
00792   if (user_access('administer nodes')) {
00793     // Validate the "authored by" field.
00794     if (!empty($node->name) && !($account = user_load(array('name' => $node->name)))) {
00795       // The use of empty() is mandatory in the context of usernames
00796       // as the empty string denotes the anonymous user. In case we
00797       // are dealing with an anonymous user we set the user ID to 0.
00798       form_set_error('name', t('The username %name does not exist.', array('%name' => $node->name)));
00799     }
00800
00801     // Validate the "authored on" field. As of PHP 5.1.0, strtotime returns FALSE instead of -1 upon failure.
00802     if (!empty($node->date) && strtotime($node->date) <= 0) {
00803       form_set_error('date', t('You have to specify a valid date.'));
00804     }
00805   }
00806
00807   // Do node-type-specific validation checks.
00808   node_invoke($node, 'validate', $form);
00809   node_invoke_nodeapi($node, 'validate', $form);
00810 }
00811
00815 function node_submit($node) {
00816   global $user;
00817
00818   // Convert the node to an object, if necessary.
00819   $node = (object)$node;
00820
00821   // Generate the teaser, but only if it hasn't been set (e.g. by a
00822   // module-provided 'teaser' form item).
00823   if (!isset($node->teaser)) {
00824     if (isset($node->body)) {
00825       $node->teaser = node_teaser($node->body, isset($node->format) ? $node->format : NULL);
00826       // Chop off the teaser from the body if needed. The teaser_include
00827       // property might not be set (eg. in Blog API postings), so only act on
00828       // it, if it was set with a given value.
00829       if (isset($node->teaser_include) && !$node->teaser_include && $node->teaser == substr($node->body, 0, strlen($node->teaser))) {
00830         $node->body = substr($node->body, strlen($node->teaser));
00831       }
00832     }
00833     else {
00834       $node->teaser = '';
00835     }
00836   }
00837
00838   if (user_access('administer nodes')) {
00839     // Populate the "authored by" field.
00840     if ($account = user_load(array('name' => $node->name))) {
00841       $node->uid = $account->uid;
00842     }
00843     else {
00844       $node->uid = 0;
00845     }
00846   }
00847   $node->created = !empty($node->date) ? strtotime($node->date) : time();
00848   $node->validated = TRUE;
00849
00850   return $node;
00851 }
00852
00856 function node_save(&$node) {
00857   // Let modules modify the node before it is saved to the database.
00858   node_invoke_nodeapi($node, 'presave');
00859   global $user;
00860
00861   $node->is_new = FALSE;
00862
00863   // Apply filters to some default node fields:
00864   if (empty($node->nid)) {
00865     // Insert a new node.
00866     $node->is_new = TRUE;
00867
00868     // When inserting a node, $node->log must be set because
00869     // {node_revisions}.log does not (and cannot) have a default
00870     // value.  If the user does not have permission to create
00871     // revisions, however, the form will not contain an element for
00872     // log so $node->log will be unset at this point.
00873     if (!isset($node->log)) {
00874       $node->log = '';
00875     }
00876
00877     // For the same reasons, make sure we have $node->teaser and
00878     // $node->body.  We should consider making these fields nullable
00879     // in a future version since node types are not required to use them.
00880     if (!isset($node->teaser)) {
00881       $node->teaser = '';
00882     }
00883     if (!isset($node->body)) {
00884       $node->body = '';
00885     }
00886   }
00887   elseif (!empty($node->revision)) {
00888     $node->old_vid = $node->vid;
00889   }
00890   else {
00891     // When updating a node, avoid clobberring an existing log entry with an empty one.
00892     if (empty($node->log)) {
00893       unset($node->log);
00894     }
00895   }
00896
00897   // Set some required fields:
00898   if (empty($node->created)) {
00899     $node->created = time();
00900   }
00901   // The changed timestamp is always updated for bookkeeping purposes (revisions, searching, ...)
00902   $node->changed = time();
00903
00904   $node->timestamp = time();
00905   $node->format = isset($node->format) ? $node->format : FILTER_FORMAT_DEFAULT;
00906   $update_node = TRUE;
00907
00908   // Generate the node table query and the node_revisions table query.
00909   if ($node->is_new) {
00910     drupal_write_record('node', $node);
00911     _node_save_revision($node, $user->uid);
00912     $op = 'insert';
00913   }
00914   else {
00915     drupal_write_record('node', $node, 'nid');
00916     if (!empty($node->revision)) {
00917       _node_save_revision($node, $user->uid);
00918     }
00919     else {
00920       _node_save_revision($node, $user->uid, 'vid');
00921       $update_node = FALSE;
00922     }
00923     $op = 'update';
00924   }
00925   if ($update_node) {
00926     db_query('UPDATE {node} SET vid = %d WHERE nid = %d', $node->vid, $node->nid);
00927   }
00928
00929   // Call the node specific callback (if any).
00930   node_invoke($node, $op);
00931   node_invoke_nodeapi($node, $op);
00932
00933   // Update the node access table for this node.
00934   node_access_acquire_grants($node);
00935
00936   // Clear the page and block caches.
00937   cache_clear_all();
00938 }
00939
00946 function _node_save_revision(&$node, $uid, $update = NULL) {
00947   $temp_uid = $node->uid;
00948   $node->uid = $uid;
00949   if (isset($update)) {
00950     drupal_write_record('node_revisions', $node, $update);
00951   }
00952   else {
00953     drupal_write_record('node_revisions', $node);
00954   }
00955   $node->uid = $temp_uid;
00956 }
00957
00961 function node_delete($nid) {
00962
00963   $node = node_load($nid);
00964
00965   if (node_access('delete', $node)) {
00966     db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
00967     db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);
00968
00969     // Call the node-specific callback (if any):
00970     node_invoke($node, 'delete');
00971     node_invoke_nodeapi($node, 'delete');
00972
00973     // Clear the page and block caches.
00974     cache_clear_all();
00975
00976     // Remove this node from the search index if needed.
00977     if (function_exists('search_wipe')) {
00978       search_wipe($node->nid, 'node');
00979     }
00980     watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
00981     drupal_set_message(t('@type %title has been deleted.', array('@type' => node_get_types('name', $node), '%title' => $node->title)));
00982   }
00983 }
00984
01000 function node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE) {
01001   $node = (object)$node;
01002
01003   $node = node_build_content($node, $teaser, $page);
01004
01005   if ($links) {
01006     $node->links = module_invoke_all('link', 'node', $node, $teaser);
01007     drupal_alter('link', $node->links, $node);
01008   }
01009
01010   // Set the proper node part, then unset unused $node part so that a bad
01011   // theme can not open a security hole.
01012   $content = drupal_render($node->content);
01013   if ($teaser) {
01014     $node->teaser = $content;
01015     unset($node->body);
01016   }
01017   else {
01018     $node->body = $content;
01019     unset($node->teaser);
01020   }
01021
01022   // Allow modules to modify the fully-built node.
01023   node_invoke_nodeapi($node, 'alter', $teaser, $page);
01024
01025   return theme('node', $node, $teaser, $page);
01026 }
01027
01031 function node_prepare($node, $teaser = FALSE) {
01032   // First we'll overwrite the existing node teaser and body with
01033   // the filtered copies! Then, we'll stick those into the content
01034   // array and set the read more flag if appropriate.
01035   $node->readmore = (strlen($node->teaser) < strlen($node->body));
01036
01037   if ($teaser == FALSE) {
01038     $node->body = check_markup($node->body, $node->format, FALSE);
01039   }
01040   else {
01041     $node->teaser = check_markup($node->teaser, $node->format, FALSE);
01042   }
01043
01044   $node->content['body'] = array(
01045     '#value' => $teaser ? $node->teaser : $node->body,
01046     '#weight' => 0,
01047   );
01048
01049   return $node;
01050 }
01051
01066 function node_build_content($node, $teaser = FALSE, $page = FALSE) {
01067
01068   // The build mode identifies the target for which the node is built.
01069   if (!isset($node->build_mode)) {
01070     $node->build_mode = NODE_BUILD_NORMAL;
01071   }
01072
01073   // Remove the delimiter (if any) that separates the teaser from the body.
01074   $node->body = isset($node->body) ? str_replace('<!--break-->', '', $node->body) : '';
01075
01076   // The 'view' hook can be implemented to overwrite the default function
01077   // to display nodes.
01078   if (node_hook($node, 'view')) {
01079     $node = node_invoke($node, 'view', $teaser, $page);
01080   }
01081   else {
01082     $node = node_prepare($node, $teaser);
01083   }
01084
01085   // Allow modules to make their own additions to the node.
01086   node_invoke_nodeapi($node, 'view', $teaser, $page);
01087
01088   return $node;
01089 }
01090
01094 function node_show($node, $cid, $message = FALSE) {
01095   if ($message) {
01096     drupal_set_title(t('Revision of %title from %date', array('%title' => $node->title, '%date' => format_date($node->revision_timestamp))));
01097   }
01098   $output = node_view($node, FALSE, TRUE);
01099
01100   if (function_exists('comment_render') && $node->comment) {
01101     $output .= comment_render($node, $cid);
01102   }
01103
01104   // Update the history table, stating that this user viewed this node.
01105   node_tag_new($node->nid);
01106
01107   return $output;
01108 }
01109
01115 function theme_node_log_message($log) {
01116   return '<div class="log"><div class="title">'. t('Log') .':</div>'. $log .'</div>';
01117 }
01118
01122 function node_perm() {
01123   $perms = array('administer content types', 'administer nodes', 'access content', 'view revisions', 'revert revisions', 'delete revisions');
01124
01125   foreach (node_get_types() as $type) {
01126     if ($type->module == 'node') {
01127       $name = check_plain($type->type);
01128       $perms[] = 'create '. $name .' content';
01129       $perms[] = 'delete own '. $name .' content';
01130       $perms[] = 'delete any '. $name .' content';
01131       $perms[] = 'edit own '. $name .' content';
01132       $perms[] = 'edit any '. $name .' content';
01133     }
01134   }
01135
01136   return $perms;
01137 }
01138
01142 function node_search($op = 'search', $keys = NULL) {
01143   switch ($op) {
01144     case 'name':
01145       return t('Content');
01146
01147     case 'reset':
01148       db_query("UPDATE {search_dataset} SET reindex = %d WHERE type = 'node'", time());
01149       return;
01150
01151     case 'status':
01152       $total = db_result(db_query('SELECT COUNT(*) FROM {node} WHERE status = 1'));
01153       $remaining = db_result(db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0"));
01154       return array('remaining' => $remaining, 'total' => $total);
01155
01156     case 'admin':
01157       $form = array();
01158       // Output form for defining rank factor weights.
01159       $form['content_ranking'] = array(
01160         '#type' => 'fieldset',
01161         '#title' => t('Content ranking'),
01162       );
01163       $form['content_ranking']['#theme'] = 'node_search_admin';
01164       $form['content_ranking']['info'] = array(
01165         '#value' => '<em>'. t('The following numbers control which properties the content search should favor when ordering the results. Higher numbers mean more influence, zero means the property is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') .'</em>'
01166       );
01167
01168       $ranking = array('node_rank_relevance' => t('Keyword relevance'),
01169                        'node_rank_recent' => t('Recently posted'));
01170       if (module_exists('comment')) {
01171         $ranking['node_rank_comments'] = t('Number of comments');
01172       }
01173       if (module_exists('statistics') && variable_get('statistics_count_content_views', 0)) {
01174         $ranking['node_rank_views'] = t('Number of views');
01175       }
01176
01177       // Note: reversed to reflect that higher number = higher ranking.
01178       $options = drupal_map_assoc(range(0, 10));
01179       foreach ($ranking as $var => $title) {
01180         $form['content_ranking']['factors'][$var] = array(
01181           '#title' => $title,
01182           '#type' => 'select',
01183           '#options' => $options,
01184           '#default_value' => variable_get($var, 5),
01185         );
01186       }
01187       return $form;
01188
01189     case 'search':
01190       // Build matching conditions
01191       list($join1, $where1) = _db_rewrite_sql();
01192       $arguments1 = array();
01193       $conditions1 = 'n.status = 1';
01194
01195       if ($type = search_query_extract($keys, 'type')) {
01196         $types = array();
01197         foreach (explode(',', $type) as $t) {
01198           $types[] = "n.type = '%s'";
01199           $arguments1[] = $t;
01200         }
01201         $conditions1 .= ' AND ('. implode(' OR ', $types) .')';
01202         $keys = search_query_insert($keys, 'type');
01203       }
01204
01205       if ($category = search_query_extract($keys, 'category')) {
01206         $categories = array();
01207         foreach (explode(',', $category) as $c) {
01208           $categories[] = "tn.tid = %d";
01209           $arguments1[] = $c;
01210         }
01211         $conditions1 .= ' AND ('. implode(' OR ', $categories) .')';
01212         $join1 .= ' INNER JOIN {term_node} tn ON n.vid = tn.vid';
01213         $keys = search_query_insert($keys, 'category');
01214       }
01215
01216       // Build ranking expression (we try to map each parameter to a
01217       // uniform distribution in the range 0..1).
01218       $ranking = array();
01219       $arguments2 = array();
01220       $join2 = '';
01221       // Used to avoid joining on node_comment_statistics twice
01222       $stats_join = FALSE;
01223       $total = 0;
01224       if ($weight = (int)variable_get('node_rank_relevance', 5)) {
01225         // Average relevance values hover around 0.15
01226         $ranking[] = '%d * i.relevance';
01227         $arguments2[] = $weight;
01228         $total += $weight;
01229       }
01230       if ($weight = (int)variable_get('node_rank_recent', 5)) {
01231         // Exponential decay with half-life of 6 months, starting at last indexed node
01232         $ranking[] = '%d * POW(2, (GREATEST(MAX(n.created), MAX(n.changed), MAX(c.last_comment_timestamp)) - %d) * 6.43e-8)';
01233         $arguments2[] = $weight;
01234         $arguments2[] = (int)variable_get('node_cron_last', 0);
01235         $join2 .= ' LEFT JOIN {node_comment_statistics} c ON c.nid = i.sid';
01236         $stats_join = TRUE;
01237         $total += $weight;
01238       }
01239       if (module_exists('comment') && $weight = (int)variable_get('node_rank_comments', 5)) {
01240         // Inverse law that maps the highest reply count on the site to 1 and 0 to 0.
01241         $scale = variable_get('node_cron_comments_scale', 0.0);
01242         $ranking[] = '%d * (2.0 - 2.0 / (1.0 + MAX(c.comment_count) * %f))';
01243         $arguments2[] = $weight;
01244         $arguments2[] = $scale;
01245         if (!$stats_join) {
01246           $join2 .= ' LEFT JOIN {node_comment_statistics} c ON c.nid = i.sid';
01247         }
01248         $total += $weight;
01249       }
01250       if (module_exists('statistics') && variable_get('statistics_count_content_views', 0) &&
01251           $weight = (int)variable_get('node_rank_views', 5)) {
01252         // Inverse law that maps the highest view count on the site to 1 and 0 to 0.
01253         $scale = variable_get('node_cron_views_scale', 0.0);
01254         $ranking[] = '%d * (2.0 - 2.0 / (1.0 + MAX(nc.totalcount) * %f))';
01255         $arguments2[] = $weight;
01256         $arguments2[] = $scale;
01257         $join2 .= ' LEFT JOIN {node_counter} nc ON nc.nid = i.sid';
01258         $total += $weight;
01259       }
01260       $select2 = (count($ranking) ? implode(' + ', $ranking) : 'i.relevance') .' AS score';
01261
01262       // Do search
01263       $find = do_search($keys, 'node', 'INNER JOIN {node} n ON n.nid = i.sid '. $join1 .' INNER JOIN {users} u ON n.uid = u.uid', $conditions1 . (empty($where1) ? '' : ' AND '. $where1), $arguments1, $select2, $join2, $arguments2);
01264
01265       // Load results
01266       $results = array();
01267       foreach ($find as $item) {
01268         // Build the node body.
01269         $node = node_load($item->sid);
01270         $node->build_mode = NODE_BUILD_SEARCH_RESULT;
01271         $node = node_build_content($node, FALSE, FALSE);
01272         $node->body = drupal_render($node->content);
01273
01274         // Fetch comments for snippet
01275         $node->body .= module_invoke('comment', 'nodeapi', $node, 'update index');
01276         // Fetch terms for snippet
01277         $node->body .= module_invoke('taxonomy', 'nodeapi', $node, 'update index');
01278
01279         $extra = node_invoke_nodeapi($node, 'search result');
01280         $results[] = array(
01281           'link' => url('node/'. $item->sid, array('absolute' => TRUE)),
01282           'type' => check_plain(node_get_types('name', $node)),
01283           'title' => $node->title,
01284           'user' => theme('username', $node),
01285           'date' => $node->changed,
01286           'node' => $node,
01287           'extra' => $extra,
01288           'score' => $item->score / $total,
01289           'snippet' => search_excerpt($keys, $node->body),
01290         );
01291       }
01292       return $results;
01293   }
01294 }
01295
01299 function node_user($op, &$edit, &$user) {
01300   if ($op == 'delete') {
01301     db_query('UPDATE {node} SET uid = 0 WHERE uid = %d', $user->uid);
01302     db_query('UPDATE {node_revisions} SET uid = 0 WHERE uid = %d', $user->uid);
01303   }
01304 }
01305
01311 function theme_node_search_admin($form) {
01312   $output = drupal_render($form['info']);
01313
01314   $header = array(t('Factor'), t('Weight'));
01315   foreach (element_children($form['factors']) as $key) {
01316     $row = array();
01317     $row[] = $form['factors'][$key]['#title'];
01318     unset($form['factors'][$key]['#title']);
01319     $row[] = drupal_render($form['factors'][$key]);
01320     $rows[] = $row;
01321   }
01322   $output .= theme('table', $header, $rows);
01323
01324   $output .= drupal_render($form);
01325   return $output;
01326 }
01327
01331 function node_comment_mode($nid) {
01332   static $comment_mode;
01333   if (!isset($comment_mode[$nid])) {
01334     $comment_mode[$nid] = db_result(db_query('SELECT comment FROM {node} WHERE nid = %d', $nid));
01335   }
01336   return $comment_mode[$nid];
01337 }
01338
01342 function node_link($type, $node = NULL, $teaser = FALSE) {
01343   $links = array();
01344
01345   if ($type == 'node') {
01346     if ($teaser == 1 && $node->teaser && !empty($node->readmore)) {
01347       $links['node_read_more'] = array(
01348         'title' => t('Read more'),
01349         'href' => "node/$node->nid",
01350         // The title attribute gets escaped when the links are processed, so
01351         // there is no need to escape here.
01352         'attributes' => array('title' => t('Read the rest of !title.', array('!title' => $node->title)))
01353       );
01354     }
01355   }
01356
01357   return $links;
01358 }
01359
01360 function _node_revision_access($node, $op = 'view') {
01361   static $access = array();
01362   if (!isset($access[$node->vid])) {
01363     $node_current_revision = node_load($node->nid);
01364     $is_current_revision = $node_current_revision->vid == $node->vid;
01365     // There should be at least two revisions. If the vid of the given node
01366     // and the vid of the current revision differs, then we already have two
01367     // different revisions so there is no need for a separate database check.
01368     // Also, if you try to revert to or delete the current revision, that's
01369     // not good.
01370     if ($is_current_revision && (db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', $node->nid)) == 1 || $op == 'update' || $op == 'delete')) {
01371       $access[$node->vid] = FALSE;
01372     }
01373     elseif (user_access('administer nodes')) {
01374       $access[$node->vid] = TRUE;
01375     }
01376     else {
01377       $map = array('view' => 'view revisions', 'update' => 'revert revisions', 'delete' => 'delete revisions');
01378       // First check the user permission, second check the access to the
01379       // current revision and finally, if the node passed in is not the current
01380       // revision then access to that, too.
01381       $access[$node->vid] = isset($map[$op]) && user_access($map[$op]) && node_access($op, $node_current_revision) && ($is_current_revision || node_access($op, $node));
01382     }
01383   }
01384   return $access[$node->vid];
01385 }
01386
01387 function _node_add_access() {
01388   $types = node_get_types();
01389   foreach ($types as $type) {
01390     if (node_hook($type->type, 'form') && node_access('create', $type->type)) {
01391       return TRUE;
01392     }
01393   }
01394   return FALSE;
01395 }
01396
01400 function node_menu() {
01401   $items['admin/content/node'] = array(
01402     'title' => 'Content',
01403     'description' => "View, edit, and delete your site's content.",
01404     'page callback' => 'drupal_get_form',
01405     'page arguments' => array('node_admin_content'),
01406     'access arguments' => array('administer nodes'),
01407     'file' => 'node.admin.inc',
01408   );
01409
01410   $items['admin/content/node/overview'] = array(
01411     'title' => 'List',
01412     'type' => MENU_DEFAULT_LOCAL_TASK,
01413     'weight' => -10,
01414   );
01415
01416   $items['admin/content/node-settings'] = array(
01417     'title' => 'Post settings',
01418     'description' => 'Control posting behavior, such as teaser length, requiring previews before posting, and the number of posts on the front page.',
01419     'page callback' => 'drupal_get_form',
01420     'page arguments' => array('node_configure'),
01421     'access arguments' => array('administer nodes'),
01422     'file' => 'node.admin.inc',
01423   );
01424   $items['admin/content/node-settings/rebuild'] = array(
01425     'title' => 'Rebuild permissions',
01426     'page arguments' => array('node_configure_rebuild_confirm'),
01427     'file' => 'node.admin.inc',
01428     // Any user than can potentially trigger a node_acess_needs_rebuild(TRUE)
01429     // has to be allowed access to the 'node access rebuild' confirm form.
01430     'access arguments' => array('access administration pages'),
01431     'type' => MENU_CALLBACK,
01432   );
01433
01434   $items['admin/content/types'] = array(
01435     'title' => 'Content types',
01436     'description' => 'Manage posts by content type, including default status, front page promotion, etc.',
01437     'page callback' => 'node_overview_types',
01438     'access arguments' => array('administer content types'),
01439     'file' => 'content_types.inc',
01440   );
01441   $items['admin/content/types/list'] = array(
01442     'title' => 'List',
01443     'type' => MENU_DEFAULT_LOCAL_TASK,
01444     'weight' => -10,
01445   );
01446   $items['admin/content/types/add'] = array(
01447     'title' => 'Add content type',
01448     'page callback' => 'drupal_get_form',
01449     'page arguments' => array('node_type_form'),
01450     'file' => 'content_types.inc',
01451     'type' => MENU_LOCAL_TASK,
01452   );
01453   $items['node'] = array(
01454     'title' => 'Content',
01455     'page callback' => 'node_page_default',
01456     'access arguments' => array('access content'),
01457     'type' => MENU_CALLBACK,
01458   );
01459   $items['node/add'] = array(
01460     'title' => 'Create content',
01461     'page callback' => 'node_add_page',
01462     'access callback' => '_node_add_access',
01463     'weight' => 1,
01464     'file' => 'node.pages.inc',
01465   );
01466   $items['rss.xml'] = array(
01467     'title' => 'RSS feed',
01468     'page callback' => 'node_feed',
01469     'access arguments' => array('access content'),
01470     'type' => MENU_CALLBACK,
01471   );
01472   foreach (node_get_types('types', NULL, TRUE) as $type) {
01473     $type_url_str = str_replace('_', '-', $type->type);
01474     $items['node/add/'. $type_url_str] = array(
01475       'title' => drupal_ucfirst($type->name),
01476       'title callback' => 'check_plain',
01477       'page callback' => 'node_add',
01478       'page arguments' => array(2),
01479       'access callback' => 'node_access',
01480       'access arguments' => array('create', $type->type),
01481       'description' => $type->description,
01482       'file' => 'node.pages.inc',
01483     );
01484     $items['admin/content/node-type/'. $type_url_str] = array(
01485       'title' => $type->name,
01486       'page callback' => 'drupal_get_form',
01487       'page arguments' => array('node_type_form', $type),
01488       'file' => 'content_types.inc',
01489       'type' => MENU_CALLBACK,
01490     );
01491     $items['admin/content/node-type/'. $type_url_str .'/edit'] = array(
01492       'title' => 'Edit',
01493       'type' => MENU_DEFAULT_LOCAL_TASK,
01494     );
01495     $items['admin/content/node-type/'. $type_url_str .'/delete'] = array(
01496       'title' => 'Delete',
01497       'page arguments' => array('node_type_delete_confirm', $type),
01498       'file' => 'content_types.inc',
01499       'type' => MENU_CALLBACK,
01500     );
01501   }
01502   $items['node/%node'] = array(
01503     'title callback' => 'node_page_title',
01504     'title arguments' => array(1),
01505     'page callback' => 'node_page_view',
01506     'page arguments' => array(1),
01507     'access callback' => 'node_access',
01508     'access arguments' => array('view', 1),
01509     'type' => MENU_CALLBACK);
01510   $items['node/%node/view'] = array(
01511     'title' => 'View',
01512     'type' => MENU_DEFAULT_LOCAL_TASK,
01513     'weight' => -10);
01514   $items['node/%node/edit'] = array(
01515     'title' => 'Edit',
01516     'page callback' => 'node_page_edit',
01517     'page arguments' => array(1),
01518     'access callback' => 'node_access',
01519     'access arguments' => array('update', 1),
01520     'weight' => 1,
01521     'file' => 'node.pages.inc',
01522     'type' => MENU_LOCAL_TASK,
01523   );
01524   $items['node/%node/delete'] = array(
01525     'title' => 'Delete',
01526     'page callback' => 'drupal_get_form',
01527     'page arguments' => array('node_delete_confirm', 1),
01528     'access callback' => 'node_access',
01529     'access arguments' => array('delete', 1),
01530     'file' => 'node.pages.inc',
01531     'weight' => 1,
01532     'type' => MENU_CALLBACK);
01533   $items['node/%node/revisions'] = array(
01534     'title' => 'Revisions',
01535     'page callback' => 'node_revision_overview',
01536     'page arguments' => array(1),
01537     'access callback' => '_node_revision_access',
01538     'access arguments' => array(1),
01539     'weight' => 2,
01540     'file' => 'node.pages.inc',
01541     'type' => MENU_LOCAL_TASK,
01542   );
01543   $items['node/%node/revisions/%/view'] = array(
01544     'title' => 'Revisions',
01545     'load arguments' => array(3),
01546     'page callback' => 'node_show',
01547     'page arguments' => array(1, NULL, TRUE),
01548     'type' => MENU_CALLBACK,
01549   );
01550   $items['node/%node/revisions/%/revert'] = array(
01551     'title' => 'Revert to earlier revision',
01552     'load arguments' => array(3),
01553     'page callback' => 'drupal_get_form',
01554     'page arguments' => array('node_revision_revert_confirm', 1),
01555     'access callback' => '_node_revision_access',
01556     'access arguments' => array(1, 'update'),
01557     'file' => 'node.pages.inc',
01558     'type' => MENU_CALLBACK,
01559   );
01560   $items['node/%node/revisions/%/delete'] = array(
01561     'title' => 'Delete earlier revision',
01562     'load arguments' => array(3),
01563     'page callback' => 'drupal_get_form',
01564     'page arguments' => array('node_revision_delete_confirm', 1),
01565     'access callback' => '_node_revision_access',
01566     'access arguments' => array(1, 'delete'),
01567     'file' => 'node.pages.inc',
01568     'type' => MENU_CALLBACK,
01569   );
01570   return $items;
01571 }
01572
01576 function node_page_title($node) {
01577   return $node->title;
01578 }
01579
01583 function node_init() {
01584   drupal_add_css(drupal_get_path('module', 'node') .'/node.css');
01585 }
01586
01587 function node_last_changed($nid) {
01588   $node = db_fetch_object(db_query('SELECT changed FROM {node} WHERE nid = %d', $nid));
01589   return ($node->changed);
01590 }
01591
01595 function node_revision_list($node) {
01596   $revisions = array();
01597   $result = db_query('SELECT r.vid, r.title, r.log, r.uid, n.vid AS current_vid, r.timestamp, u.name FROM {node_revisions} r LEFT JOIN {node} n ON n.vid = r.vid INNER JOIN {users} u ON u.uid = r.uid WHERE r.nid = %d ORDER BY r.timestamp DESC', $node->nid);
01598   while ($revision = db_fetch_object($result)) {
01599     $revisions[$revision->vid] = $revision;
01600   }
01601
01602   return $revisions;
01603 }
01604
01608 function node_block($op = 'list', $delta = 0) {
01609   if ($op == 'list') {
01610     $blocks[0]['info'] = t('Syndicate');
01611     // Not worth caching.
01612     $blocks[0]['cache'] = BLOCK_NO_CACHE;
01613     return $blocks;
01614   }
01615   else if ($op == 'view') {
01616     $block['subject'] = t('Syndicate');
01617     $block['content'] = theme('feed_icon', url('rss.xml'), t('Syndicate'));
01618
01619     return $block;
01620   }
01621 }
01622
01634 function node_feed($nids = FALSE, $channel = array()) {
01635   global $base_url, $language;
01636
01637   if ($nids === FALSE) {
01638     $nids = array();
01639     $result = db_query_range(db_rewrite_sql('SELECT n.nid, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.created DESC'), 0, variable_get('feed_default_items', 10));
01640     while ($row = db_fetch_object($result)) {
01641       $nids[] = $row->nid;
01642     }
01643   }
01644
01645   $item_length = variable_get('feed_item_length', 'teaser');
01646   $namespaces = array('xmlns:dc' => 'http://purl.org/dc/elements/1.1/');
01647
01648   $items = '';
01649   foreach ($nids as $nid) {
01650     // Load the specified node:
01651     $item = node_load($nid);
01652     $item->build_mode = NODE_BUILD_RSS;
01653     $item->link = url("node/$nid", array('absolute' => TRUE));
01654
01655     if ($item_length != 'title') {
01656       $teaser = ($item_length == 'teaser') ? TRUE : FALSE;
01657
01658       // Filter and prepare node teaser
01659       if (node_hook($item, 'view')) {
01660         $item = node_invoke($item, 'view', $teaser, FALSE);
01661       }
01662       else {
01663         $item = node_prepare($item, $teaser);
01664       }
01665
01666       // Allow modules to change $node->teaser before viewing.
01667       node_invoke_nodeapi($item, 'view', $teaser, FALSE);
01668     }
01669
01670     // Allow modules to add additional item fields and/or modify $item
01671     $extra = node_invoke_nodeapi($item, 'rss item');
01672     $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' => format_date($item->created, 'custom', 'r')), array('key' => 'dc:creator', 'value' => $item->name), array('key' => 'guid', 'value' => $item->nid .' at '. $base_url, 'attributes' => array('isPermaLink' => 'false'))));
01673     foreach ($extra as $element) {
01674       if (isset($element['namespace'])) {
01675         $namespaces = array_merge($namespaces, $element['namespace']);
01676       }
01677     }
01678
01679     // Prepare the item description
01680     switch ($item_length) {
01681       case 'fulltext':
01682         $item_text = $item->body;
01683         break;
01684       case 'teaser':
01685         $item_text = $item->teaser;
01686         if (!empty($item->readmore)) {
01687           $item_text .= '<p>'. l(t('read more'), 'node/'. $item->nid, array('absolute' => TRUE, 'attributes' => array('target' => '_blank'))) .'</p>';
01688         }
01689         break;
01690       case 'title':
01691         $item_text = '';
01692         break;
01693     }
01694
01695     $items .= format_rss_item($item->title, $item->link, $item_text, $extra);
01696   }
01697
01698   $channel_defaults = array(
01699     'version'     => '2.0',
01700     'title'       => variable_get('site_name', 'Drupal'),
01701     'link'        => $base_url,
01702     'description' => variable_get('site_mission', ''),
01703     'language'    => $language->language
01704   );
01705   $channel = array_merge($channel_defaults, $channel);
01706
01707   $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
01708   $output .= "<rss version=\"". $channel["version"] ."\" xml:base=\"". $base_url ."\" ". drupal_attributes($namespaces) .">\n";
01709   $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']);
01710   $output .= "</rss>\n";
01711
01712   drupal_set_header('Content-Type: application/rss+xml; charset=utf-8');
01713   print $output;
01714 }
01715
01719 function node_page_default() {
01720   $result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), variable_get('default_nodes_main', 10));
01721
01722   $output = '';
01723   $num_rows = FALSE;
01724   while ($node = db_fetch_object($result)) {
01725     $output .= node_view(node_load($node->nid), 1);
01726     $num_rows = TRUE;
01727   }
01728
01729   if ($num_rows) {
01730     $feed_url = url('rss.xml', array('absolute' => TRUE));
01731     drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') .' '. t('RSS'));
01732     $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
01733   }
01734   else {
01735     $default_message = t('<h1 class="title">Welcome to your new Drupal website!</h1><p>Please follow these steps to set up and start using your website:</p>');
01736     $default_message .= '<ol>';
01737
01738     $default_message .= '<li>'. t('<strong>Configure your website</strong> Once logged in, visit the <a href="@admin">administration section</a>, where you can <a href="@config">customize and configure</a> all aspects of your website.', array('@admin' => url('admin'), '@config' => url('admin/settings'))) .'</li>';
01739     $default_message .= '<li>'. t('<strong>Enable additional functionality</strong> Next, visit the <a href="@modules">module list</a> and enable features which suit your specific needs. You can find additional modules in the <a href="@download_modules">Drupal modules download section</a>.', array('@modules' => url('admin/build/modules'), '@download_modules' => 'http://drupal.org/project/modules')) .'</li>';
01740     $default_message .= '<li>'. t('<strong>Customize your website design</strong> To change the "look and feel" of your website, visit the <a href="@themes">themes section</a>. You may choose from one of the included themes or download additional themes from the <a href="@download_themes">Drupal themes download section</a>.', array('@themes' => url('admin/build/themes'), '@download_themes' => 'http://drupal.org/project/themes')) .'</li>';
01741     $default_message .= '<li>'. t('<strong>Start posting content</strong> Finally, you can <a href="@content">create content</a> for your website. This message will disappear once you have promoted a post to the front page.', array('@content' => url('node/add'))) .'</li>';
01742     $default_message .= '</ol>';
01743     $default_message .= '<p>'. t('For more information, please refer to the <a href="@help">help section</a>, or the <a href="@handbook">online Drupal handbooks</a>. You may also post at the <a href="@forum">Drupal forum</a>, or view the wide range of <a href="@support">other support options</a> available.', array('@help' => url('admin/help'), '@handbook' => 'http://drupal.org/handbooks', '@forum' => 'http://drupal.org/forum', '@support' => 'http://drupal.org/support')) .'</p>';
01744
01745     $output = '<div id="first-time">'. $default_message .'</div>';
01746   }
01747   drupal_set_title('');
01748
01749   return $output;
01750 }
01751
01755 function node_page_view($node, $cid = NULL) {
01756   drupal_set_title(check_plain($node->title));
01757   return node_show($node, $cid);
01758 }
01759
01763 function node_update_index() {
01764   $limit = (int)variable_get('search_cron_limit', 100);
01765
01766   // Store the maximum possible comments per thread (used for ranking by reply count)
01767   variable_set('node_cron_comments_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}'))));
01768   variable_set('node_cron_views_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(totalcount) FROM {node_counter}'))));
01769
01770   $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit);
01771
01772   while ($node = db_fetch_object($result)) {
01773     _node_index_node($node);
01774   }
01775 }
01776
01783 function _node_index_node($node) {
01784   $node = node_load($node->nid);
01785
01786   // save the changed time of the most recent indexed node, for the search results half-life calculation
01787   variable_set('node_cron_last', $node->changed);
01788
01789   // Build the node body.
01790   $node->build_mode = NODE_BUILD_SEARCH_INDEX;
01791   $node = node_build_content($node, FALSE, FALSE);
01792   $node->body = drupal_render($node->content);
01793
01794   $text = '<h1>'. check_plain($node->title) .'</h1>'. $node->body;
01795
01796   // Fetch extra data normally not visible
01797   $extra = node_invoke_nodeapi($node, 'update index');
01798   foreach ($extra as $t) {
01799     $text .= $t;
01800   }
01801
01802   // Update index
01803   search_index($node->nid, 'node', $text);
01804 }
01805
01809 function node_form_alter(&$form, $form_state, $form_id) {
01810   // Advanced node search form
01811   if ($form_id == 'search_form' && $form['module']['#value'] == 'node' && user_access('use advanced search')) {
01812     // Keyword boxes:
01813     $form['advanced'] = array(
01814       '#type' => 'fieldset',
01815       '#title' => t('Advanced search'),
01816       '#collapsible' => TRUE,
01817       '#collapsed' => TRUE,
01818       '#attributes' => array('class' => 'search-advanced'),
01819     );
01820     $form['advanced']['keywords'] = array(
01821       '#prefix' => '<div class="criterion">',
01822       '#suffix' => '</div>',
01823     );
01824     $form['advanced']['keywords']['or'] = array(
01825       '#type' => 'textfield',
01826       '#title' => t('Containing any of the words'),
01827       '#size' => 30,
01828       '#maxlength' => 255,
01829     );
01830     $form['advanced']['keywords']['phrase'] = array(
01831       '#type' => 'textfield',
01832       '#title' => t('Containing the phrase'),
01833       '#size' => 30,
01834       '#maxlength' => 255,
01835     );
01836     $form['advanced']['keywords']['negative'] = array(
01837       '#type' => 'textfield',
01838       '#title' => t('Containing none of the words'),
01839       '#size' => 30,
01840       '#maxlength' => 255,
01841     );
01842
01843     // Taxonomy box:
01844     if ($taxonomy = module_invoke('taxonomy', 'form_all', 1)) {
01845       $form['advanced']['category'] = array(
01846         '#type' => 'select',
01847         '#title' => t('Only in the category(s)'),
01848         '#prefix' => '<div class="criterion">',
01849         '#size' => 10,
01850         '#suffix' => '</div>',
01851         '#options' => $taxonomy,
01852         '#multiple' => TRUE,
01853       );
01854     }
01855
01856     // Node types:
01857     $types = array_map('check_plain', node_get_types('names'));
01858     $form['advanced']['type'] = array(
01859       '#type' => 'checkboxes',
01860       '#title' => t('Only of the type(s)'),
01861       '#prefix' => '<div class="criterion">',
01862       '#suffix' => '</div>',
01863       '#options' => $types,
01864     );
01865     $form['advanced']['submit'] = array(
01866       '#type' => 'submit',
01867       '#value' => t('Advanced search'),
01868       '#prefix' => '<div class="action">',
01869       '#suffix' => '</div>',
01870     );
01871
01872     $form['#validate'][] = 'node_search_validate';
01873   }
01874 }
01875
01879 function node_search_validate($form, &$form_state) {
01880   // Initialise using any existing basic search keywords.
01881   $keys = $form_state['values']['processed_keys'];
01882
01883   // Insert extra restrictions into the search keywords string.
01884   if (isset($form_state['values']['type']) && is_array($form_state['values']['type'])) {
01885     // Retrieve selected types - Forms API sets the value of unselected checkboxes to 0.
01886     $form_state['values']['type'] = array_filter($form_state['values']['type']);
01887     if (count($form_state['values']['type'])) {
01888       $keys = search_query_insert($keys, 'type', implode(',', array_keys($form_state['values']['type'])));
01889     }
01890   }
01891
01892   if (isset($form_state['values']['category']) && is_array($form_state['values']['category'])) {
01893     $keys = search_query_insert($keys, 'category', implode(',', $form_state['values']['category']));
01894   }
01895   if ($form_state['values']['or'] != '') {
01896     if (preg_match_all('/ ("[^"]+"|[^" ]+)/i', ' '. $form_state['values']['or'], $matches)) {
01897       $keys .= ' '. implode(' OR ', $matches[1]);
01898     }
01899   }
01900   if ($form_state['values']['negative'] != '') {
01901     if (preg_match_all('/ ("[^"]+"|[^" ]+)/i', ' '. $form_state['values']['negative'], $matches)) {
01902       $keys .= ' -'. implode(' -', $matches[1]);
01903     }
01904   }
01905   if ($form_state['values']['phrase'] != '') {
01906     $keys .= ' "'. str_replace('"', ' ', $form_state['values']['phrase']) .'"';
01907   }
01908   if (!empty($keys)) {
01909     form_set_value($form['basic']['inline']['processed_keys'], trim($keys), $form_state);
01910   }
01911 }
01912
01965 function node_access($op, $node, $account = NULL) {
01966   global $user;
01967
01968   if (!$node) {
01969     return FALSE;
01970   }
01971   // Convert the node to an object if necessary:
01972   if ($op != 'create') {
01973     $node = (object)$node;
01974   }
01975   // If no user object is supplied, the access check is for the current user.
01976   if (empty($account)) {
01977     $account = $user;
01978   }
01979   // If the node is in a restricted format, disallow editing.
01980   if ($op == 'update' && !filter_access($node->format)) {
01981     return FALSE;
01982   }
01983
01984   if (user_access('administer nodes', $account)) {
01985     return TRUE;
01986   }
01987
01988   if (!user_access('access content', $account)) {
01989     return FALSE;
01990   }
01991
01992   // Can't use node_invoke(), because the access hook takes the $op parameter
01993   // before the $node parameter.
01994   $module = node_get_types('module', $node);
01995   if ($module == 'node') {
01996     $module = 'node_content'; // Avoid function name collisions.
01997   }
01998   $access = module_invoke($module, 'access', $op, $node, $account);
01999   if (!is_null($access)) {
02000     return $access;
02001   }
02002
02003   // If the module did not override the access rights, use those set in the
02004   // node_access table.
02005   if ($op != 'create' && $node->nid && $node->status) {
02006     $grants = array();
02007     foreach (node_access_grants($op, $account) as $realm => $gids) {
02008       foreach ($gids as $gid) {
02009         $grants[] = "(gid = $gid AND realm = '$realm')";
02010       }
02011     }
02012
02013     $grants_sql = '';
02014     if (count($grants)) {
02015       $grants_sql = 'AND ('. implode(' OR ', $grants) .')';
02016     }
02017
02018     $sql = "SELECT COUNT(*) FROM {node_access} WHERE (nid = 0 OR nid = %d) $grants_sql AND grant_$op >= 1";
02019     $result = db_query($sql, $node->nid);
02020     return (db_result($result));
02021   }
02022
02023   // Let authors view their own nodes.
02024   if ($op == 'view' && $account->uid == $node->uid && $account->uid != 0) {
02025     return TRUE;
02026   }
02027
02028   return FALSE;
02029 }
02030
02043 function _node_access_join_sql($node_alias = 'n', $node_access_alias = 'na') {
02044   if (user_access('administer nodes')) {
02045     return '';
02046   }
02047
02048   return 'INNER JOIN {node_access} '. $node_access_alias .' ON '. $node_access_alias .'.nid = '. $node_alias .'.nid';
02049 }
02050
02065 function _node_access_where_sql($op = 'view', $node_access_alias = 'na', $account = NULL) {
02066   if (user_access('administer nodes')) {
02067     return;
02068   }
02069
02070   $grants = array();
02071   foreach (node_access_grants($op, $account) as $realm => $gids) {
02072     foreach ($gids as $gid) {
02073       $grants[] = "($node_access_alias.gid = $gid AND $node_access_alias.realm = '$realm')";
02074     }
02075   }
02076
02077   $grants_sql = '';
02078   if (count($grants)) {
02079     $grants_sql = 'AND ('. implode(' OR ', $grants) .')';
02080   }
02081
02082   $sql = "$node_access_alias.grant_$op >= 1 $grants_sql";
02083   return $sql;
02084 }
02085
02102 function node_access_grants($op, $account = NULL) {
02103
02104   if (!isset($account)) {
02105     $account = $GLOBALS['user'];
02106   }
02107
02108   return array_merge(array('all' => array(0)), module_invoke_all('node_grants', $account, $op));
02109 }
02110
02114 function node_access_view_all_nodes() {
02115   static $access;
02116
02117   if (!isset($access)) {
02118     $grants = array();
02119     foreach (node_access_grants('view') as $realm => $gids) {
02120       foreach ($gids as $gid) {
02121         $grants[] = "(gid = $gid AND realm = '$realm')";
02122       }
02123     }
02124
02125     $grants_sql = '';
02126     if (count($grants)) {
02127       $grants_sql = 'AND ('. implode(' OR ', $grants) .')';
02128     }
02129
02130     $sql = "SELECT COUNT(*) FROM {node_access} WHERE nid = 0 $grants_sql AND grant_view >= 1";
02131     $result = db_query($sql);
02132     $access = db_result($result);
02133   }
02134
02135   return $access;
02136 }
02137
02141 function node_db_rewrite_sql($query, $primary_table, $primary_field) {
02142   if ($primary_field == 'nid' && !node_access_view_all_nodes()) {
02143     $return['join'] = _node_access_join_sql($primary_table);
02144     $return['where'] = _node_access_where_sql();
02145     $return['distinct'] = 1;
02146     return $return;
02147   }
02148 }
02149
02162 function node_access_acquire_grants($node) {
02163   $grants = module_invoke_all('node_access_records', $node);
02164   if (empty($grants)) {
02165     $grants[] = array('realm' => 'all', 'gid' => 0, 'grant_view' => 1, 'grant_update' => 0, 'grant_delete' => 0);
02166   }
02167   else {
02168     // retain grants by highest priority
02169     $grant_by_priority = array();
02170     foreach ($grants as $g) {
02171       $grant_by_priority[intval($g['priority'])][] = $g;
02172     }
02173     krsort($grant_by_priority);
02174     $grants = array_shift($grant_by_priority);
02175   }
02176
02177   node_access_write_grants($node, $grants);
02178 }
02179
02202 function node_access_write_grants($node, $grants, $realm = NULL, $delete = TRUE) {
02203   if ($delete) {
02204     $query = 'DELETE FROM {node_access} WHERE nid = %d';
02205     if ($realm) {
02206       $query .= " AND realm in ('%s', 'all')";
02207     }
02208     db_query($query, $node->nid, $realm);
02209   }
02210
02211   // Only perform work when node_access modules are active.
02212   if (count(module_implements('node_grants'))) {
02213     foreach ($grants as $grant) {
02214       if ($realm && $realm != $grant['realm']) {
02215         continue;
02216       }
02217       // Only write grants; denies are implicit.
02218       if ($grant['grant_view'] || $grant['grant_update'] || $grant['grant_delete']) {
02219         db_query("INSERT INTO {node_access} (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (%d, '%s', %d, %d, %d, %d)", $node->nid, $grant['realm'], $grant['gid'], $grant['grant_view'], $grant['grant_update'], $grant['grant_delete']);
02220       }
02221     }
02222   }
02223 }
02224
02242 function node_access_needs_rebuild($rebuild = NULL) {
02243   if (!isset($rebuild)) {
02244     return variable_get('node_access_needs_rebuild', FALSE);
02245   }
02246   elseif ($rebuild) {
02247     variable_set('node_access_needs_rebuild', TRUE);
02248   }
02249   else {
02250     variable_del('node_access_needs_rebuild');
02251   }
02252 }
02253
02276 function node_access_rebuild($batch_mode = FALSE) {
02277   db_query("DELETE FROM {node_access}");
02278   // Only recalculate if the site is using a node_access module.
02279   if (count(module_implements('node_grants'))) {
02280     if ($batch_mode) {
02281       $batch = array(
02282         'title' => t('Rebuilding content access permissions'),
02283         'operations' => array(
02284           array('_node_access_rebuild_batch_operation', array()),
02285         ),
02286         'finished' => '_node_access_rebuild_batch_finished'
02287       );
02288       batch_set($batch);
02289     }
02290     else {
02291       // If not in 'safe mode', increase the maximum execution time.
02292       if (!ini_get('safe_mode')) {
02293         set_time_limit(240);
02294       }
02295       $result = db_query("SELECT nid FROM {node}");
02296       while ($node = db_fetch_object($result)) {
02297         $loaded_node = node_load($node->nid, NULL, TRUE);
02298         // To preserve database integrity, only aquire grants if the node
02299         // loads successfully.
02300         if (!empty($loaded_node)) {
02301           node_access_acquire_grants($loaded_node);
02302         }
02303       }
02304     }
02305   }
02306   else {
02307     // Not using any node_access modules. Add the default grant.
02308     db_query("INSERT INTO {node_access} VALUES (0, 0, 'all', 1, 0, 0)");
02309   }
02310
02311   if (!isset($batch)) {
02312     drupal_set_message(t('Content permissions have been rebuilt.'));
02313     node_access_needs_rebuild(FALSE);
02314     cache_clear_all();
02315   }
02316 }
02317
02325 function _node_access_rebuild_batch_operation(&$context) {
02326   if (empty($context['sandbox'])) {
02327     // Initiate multistep processing.
02328     $context['sandbox']['progress'] = 0;
02329     $context['sandbox']['current_node'] = 0;
02330     $context['sandbox']['max'] = db_result(db_query('SELECT COUNT(DISTINCT nid) FROM {node}'));
02331   }
02332
02333   // Process the next 20 nodes.
02334   $limit = 20;
02335   $result = db_query_range("SELECT nid FROM {node} WHERE nid > %d ORDER BY nid ASC", $context['sandbox']['current_node'], 0, $limit);
02336   while ($row = db_fetch_array($result)) {
02337     $loaded_node = node_load($row['nid'], NULL, TRUE);
02338     // To preserve database integrity, only aquire grants if the node
02339     // loads successfully.
02340     if (!empty($loaded_node)) {
02341       node_access_acquire_grants($loaded_node);
02342     }
02343     $context['sandbox']['progress']++;
02344     $context['sandbox']['current_node'] = $loaded_node->nid;
02345   }
02346
02347   // Multistep processing : report progress.
02348   if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
02349     $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
02350   }
02351 }
02352
02356 function _node_access_rebuild_batch_finished($success, $results, $operations) {
02357   if ($success) {
02358     drupal_set_message(t('The content access permissions have been rebuilt.'));
02359     node_access_needs_rebuild(FALSE);
02360   }
02361   else {
02362     drupal_set_message(t('The content access permissions have not been properly rebuilt.'), 'error');
02363   }
02364   cache_clear_all();
02365 }
02366
02382 function node_content_access($op, $node, $account) {
02383   $type = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
02384
02385   if ($op == 'create') {
02386     return user_access('create '. $type .' content', $account);
02387   }
02388
02389   if ($op == 'update') {
02390     if (user_access('edit any '. $type .' content', $account) || (user_access('edit own '. $type .' content', $account) && ($account->uid == $node->uid))) {
02391       return TRUE;
02392     }
02393   }
02394
02395   if ($op == 'delete') {
02396     if (user_access('delete any '. $type .' content', $account) || (user_access('delete own '. $type .' content', $account) && ($account->uid == $node->uid))) {
02397       return TRUE;
02398     }
02399   }
02400 }
02401
02405 function node_content_form($node, $form_state) {
02406   $type = node_get_types('type', $node);
02407   $form = array();
02408
02409   if ($type->has_title) {
02410     $form['title'] = array(
02411       '#type' => 'textfield',
02412       '#title' => check_plain($type->title_label),
02413       '#required' => TRUE,
02414       '#default_value' => $node->title,
02415       '#maxlength' => 255,
02416       '#weight' => -5,
02417     );
02418   }
02419
02420   if ($type->has_body) {
02421     $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
02422   }
02423
02424   return $form;
02425 }
02426
02434 function node_forms() {
02435   $forms = array();
02436   if ($types = node_get_types()) {
02437     foreach (array_keys($types) as $type) {
02438       $forms[$type .'_node_form']['callback'] = 'node_form';
02439     }
02440   }
02441   return $forms;
02442 }
02443
02449 function theme_node_submitted($node) {
02450   return t('Submitted by !username on @datetime',
02451     array(
02452       '!username' => theme('username', $node),
02453       '@datetime' => format_date($node->created),
02454     ));
02455 }
02456
02460 function node_hook_info() {
02461   return array(
02462     'node' => array(
02463       'nodeapi' => array(
02464         'presave' => array(
02465           'runs when' => t('When either saving a new post or updating an existing post'),
02466         ),
02467         'insert' => array(
02468           'runs when' => t('After saving a new post'),
02469         ),
02470         'update' => array(
02471           'runs when' => t('After saving an updated post'),
02472         ),
02473         'delete' => array(
02474           'runs when' => t('After deleting a post')
02475         ),
02476         'view' => array(
02477           'runs when' => t('When content is viewed by an authenticated user')
02478         ),
02479       ),
02480     ),
02481   );
02482 }
02483
02487 function node_action_info() {
02488   return array(
02489     'node_publish_action' => array(
02490       'type' => 'node',
02491       'description' => t('Publish post'),
02492       'configurable' => FALSE,
02493       'behavior' => array('changes_node_property'),
02494       'hooks' => array(
02495         'nodeapi' => array('presave'),
02496         'comment' => array('insert', 'update'),
02497       ),
02498     ),
02499     'node_unpublish_action' => array(
02500       'type' => 'node',
02501       'description' => t('Unpublish post'),
02502       'configurable' => FALSE,
02503       'behavior' => array('changes_node_property'),
02504       'hooks' => array(
02505         'nodeapi' => array('presave'),
02506         'comment' => array('delete', 'insert', 'update'),
02507       ),
02508     ),
02509     'node_make_sticky_action' => array(
02510       'type' => 'node',
02511       'description' => t('Make post sticky'),
02512       'configurable' => FALSE,
02513       'behavior' => array('changes_node_property'),
02514       'hooks' => array(
02515         'nodeapi' => array('presave'),
02516         'comment' => array('insert', 'update'),
02517       ),
02518     ),
02519     'node_make_unsticky_action' => array(
02520       'type' => 'node',
02521       'description' => t('Make post unsticky'),
02522       'configurable' => FALSE,
02523       'behavior' => array('changes_node_property'),
02524       'hooks' => array(
02525         'nodeapi' => array('presave'),
02526         'comment' => array('delete', 'insert', 'update'),
02527       ),
02528     ),
02529     'node_promote_action' => array(
02530       'type' => 'node',
02531       'description' => t('Promote post to front page'),
02532       'configurable' => FALSE,
02533       'behavior' => array('changes_node_property'),
02534       'hooks' => array(
02535         'nodeapi' => array('presave'),
02536         'comment' => array('insert', 'update'),
02537       ),
02538     ),
02539     'node_unpromote_action' => array(
02540       'type' => 'node',
02541       'description' => t('Remove post from front page'),
02542       'configurable' => FALSE,
02543       'behavior' => array('changes_node_property'),
02544       'hooks' => array(
02545         'nodeapi' => array('presave'),
02546         'comment' => array('delete', 'insert', 'update'),
02547       ),
02548     ),
02549     'node_assign_owner_action' => array(
02550       'type' => 'node',
02551       'description' => t('Change the author of a post'),
02552       'configurable' => TRUE,
02553       'behavior' => array('changes_node_property'),
02554       'hooks' => array(
02555         'any' => TRUE,
02556         'nodeapi' => array('presave'),
02557         'comment' => array('delete', 'insert', 'update'),
02558       ),
02559     ),
02560     'node_save_action' => array(
02561       'type' => 'node',
02562       'description' => t('Save post'),
02563       'configurable' => FALSE,
02564       'hooks' => array(
02565         'comment' => array('delete', 'insert', 'update'),
02566       ),
02567     ),
02568     'node_unpublish_by_keyword_action' => array(
02569       'type' => 'node',
02570       'description' => t('Unpublish post containing keyword(s)'),
02571       'configurable' => TRUE,
02572       'hooks' => array(
02573         'nodeapi' => array('presave', 'insert', 'update'),
02574       ),
02575     ),
02576   );
02577 }
02578
02583 function node_publish_action(&$node, $context = array()) {
02584   $node->status = 1;
02585   watchdog('action', 'Set @type %title to published.', array('@type' => node_get_types('name', $node), '%title' => $node->title));
02586 }
02587
02592 function node_unpublish_action(&$node, $context = array()) {
02593   $node->status = 0;
02594   watchdog('action', 'Set @type %title to unpublished.', array('@type' => node_get_types('name', $node), '%title' => $node->title));
02595 }
02596
02601 function node_make_sticky_action(&$node, $context = array()) {
02602   $node->sticky = 1;
02603   watchdog('action', 'Set @type %title to sticky.', array('@type' => node_get_types('name', $node), '%title' => $node->title));
02604 }
02605
02610 function node_make_unsticky_action(&$node, $context = array()) {
02611   $node->sticky = 0;
02612   watchdog('action', 'Set @type %title to unsticky.', array('@type' => node_get_types('name', $node), '%title' => $node->title));
02613 }
02614
02619 function node_promote_action(&$node, $context = array()) {
02620   $node->promote = 1;
02621   watchdog('action', 'Promoted @type %title to front page.', array('@type' => node_get_types('type', $node), '%title' => $node->title));
02622 }
02623
02628 function node_unpromote_action(&$node, $context = array()) {
02629   $node->promote = 0;
02630   watchdog('action', 'Removed @type %title from front page.', array('@type' => node_get_types('type', $node), '%title' => $node->title));
02631 }
02632
02637 function node_save_action($node) {
02638   node_save($node);
02639   watchdog('action', 'Saved @type %title', array('@type' => node_get_types('type', $node), '%title' => $node->title));
02640 }
02641
02646 function node_assign_owner_action(&$node, $context) {
02647   $node->uid = $context['owner_uid'];
02648   $owner_name = db_result(db_query("SELECT name FROM {users} WHERE uid = %d", $context['owner_uid']));
02649   watchdog('action', 'Changed owner of @type %title to uid %name.', array('@type' => node_get_types('type', $node), '%title' => $node->title, '%name' => $owner_name));
02650 }
02651
02652 function node_assign_owner_action_form($context) {
02653   $description = t('The username of the user to which you would like to assign ownership.');
02654   $count = db_result(db_query("SELECT COUNT(*) FROM {users}"));
02655   $owner_name = '';
02656   if (isset($context['owner_uid'])) {
02657     $owner_name = db_result(db_query("SELECT name FROM {users} WHERE uid = %d", $context['owner_uid']));
02658   }
02659
02660   // Use dropdown for fewer than 200 users; textbox for more than that.
02661   if (intval($count) < 200) {
02662     $options = array();
02663     $result = db_query("SELECT uid, name FROM {users} WHERE uid > 0 ORDER BY name");
02664     while ($data = db_fetch_object($result)) {
02665       $options[$data->name] = $data->name;
02666     }
02667     $form['owner_name'] = array(
02668       '#type' => 'select',
02669       '#title' => t('Username'),
02670       '#default_value' => $owner_name,
02671       '#options' => $options,
02672       '#description' => $description,
02673     );
02674   }
02675   else {
02676     $form['owner_name'] = array(
02677       '#type' => 'textfield',
02678       '#title' => t('Username'),
02679       '#default_value' => $owner_name,
02680       '#autocomplete_path' => 'user/autocomplete',
02681       '#size' => '6',
02682       '#maxlength' => '7',
02683       '#description' => $description,
02684     );
02685   }
02686   return $form;
02687 }
02688
02689 function node_assign_owner_action_validate($form, $form_state) {
02690   $count = db_result(db_query("SELECT COUNT(*) FROM {users} WHERE name = '%s'", $form_state['values']['owner_name']));
02691   if (intval($count) != 1) {
02692     form_set_error('owner_name', t('Please enter a valid username.'));
02693   }
02694 }
02695
02696 function node_assign_owner_action_submit($form, $form_state) {
02697   // Username can change, so we need to store the ID, not the username.
02698   $uid = db_result(db_query("SELECT uid from {users} WHERE name = '%s'", $form_state['values']['owner_name']));
02699   return array('owner_uid' => $uid);
02700 }
02701
02702 function node_unpublish_by_keyword_action_form($context) {
02703   $form['keywords'] = array(
02704     '#title' => t('Keywords'),
02705     '#type' => 'textarea',
02706     '#description' => t('The post will be unpublished if it contains any of the character sequences above. Use a comma-separated list of character sequences. Example: funny, bungee jumping, "Company, Inc.". Character sequences are case-sensitive.'),
02707     '#default_value' => isset($context['keywords']) ? drupal_implode_tags($context['keywords']) : '',
02708   );
02709   return $form;
02710 }
02711
02712 function node_unpublish_by_keyword_action_submit($form, $form_state) {
02713   return array('keywords' => drupal_explode_tags($form_state['values']['keywords']));
02714 }
02715
02725 function node_unpublish_by_keyword_action($node, $context) {
02726   foreach ($context['keywords'] as $keyword) {
02727     if (strstr(node_view(drupal_clone($node)), $keyword) || strstr($node->title, $keyword)) {
02728       $node->status = 0;
02729       watchdog('action', 'Set @type %title to unpublished.', array('@type' => node_get_types('name', $node), '%title' => $node->title));
02730       break;
02731     }
02732   }
02733 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/node/node.pages.inc Source File

modules » node

node.pages.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: node.pages.inc,v 1.28 2008/02/03 19:26:10 goba Exp $
00003
00013 function node_page_edit($node) {
00014   drupal_set_title($node->title);
00015   return drupal_get_form($node->type .'_node_form', $node);
00016 }
00017
00018 function node_add_page() {
00019   $item = menu_get_item();
00020   $content = system_admin_menu_block($item);
00021   return theme('node_add_list', $content);
00022 }
00023
00029 function theme_node_add_list($content) {
00030   $output = '';
00031
00032   if ($content) {
00033     $output = '<dl class="node-type-list">';
00034     foreach ($content as $item) {
00035       $output .= '<dt>'. l($item['title'], $item['href'], $item['options']) .'</dt>';
00036       $output .= '<dd>'. filter_xss_admin($item['description']) .'</dd>';
00037     }
00038     $output .= '</dl>';
00039   }
00040   return $output;
00041 }
00042
00043
00047 function node_add($type) {
00048   global $user;
00049
00050   $types = node_get_types();
00051   $type = isset($type) ? str_replace('-', '_', $type) : NULL;
00052   // If a node type has been specified, validate its existence.
00053   if (isset($types[$type]) && node_access('create', $type)) {
00054     // Initialize settings:
00055     $node = array('uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => $type, 'language' => '');
00056
00057     drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)));
00058     $output = drupal_get_form($type .'_node_form', $node);
00059   }
00060
00061   return $output;
00062 }
00063
00064 function node_form_validate($form, &$form_state) {
00065   node_validate($form_state['values'], $form);
00066 }
00067
00068 function node_object_prepare(&$node) {
00069   // Set up default values, if required.
00070   $node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
00071   // If this is a new node, fill in the default values.
00072   if (!isset($node->nid)) {
00073     foreach (array('status', 'promote', 'sticky') as $key) {
00074       $node->$key = in_array($key, $node_options);
00075     }
00076     global $user;
00077     $node->uid = $user->uid;
00078     $node->created = time();
00079   }
00080   else {
00081     $node->date = format_date($node->created, 'custom', 'Y-m-d H:i:s O');
00082   }
00083   // Always use the default revision setting.
00084   $node->revision = in_array('revision', $node_options);
00085
00086   node_invoke($node, 'prepare');
00087   node_invoke_nodeapi($node, 'prepare');
00088 }
00089
00093 function node_form(&$form_state, $node) {
00094   global $user;
00095
00096   if (isset($form_state['node'])) {
00097     $node = $form_state['node'] + (array)$node;
00098   }
00099   if (isset($form_state['node_preview'])) {
00100     $form['#prefix'] = $form_state['node_preview'];
00101   }
00102   $node = (object)$node;
00103   foreach (array('body', 'title', 'format') as $key) {
00104     if (!isset($node->$key)) {
00105       $node->$key = NULL;
00106     }
00107   }
00108   if (!isset($form_state['node_preview'])) {
00109     node_object_prepare($node);
00110   }
00111   else {
00112     $node->build_mode = NODE_BUILD_PREVIEW;
00113   }
00114
00115   // Set the id of the top-level form tag
00116   $form['#id'] = 'node-form';
00117
00118   // Basic node information.
00119   // These elements are just values so they are not even sent to the client.
00120   foreach (array('nid', 'vid', 'uid', 'created', 'type', 'language') as $key) {
00121     $form[$key] = array(
00122       '#type' => 'value',
00123       '#value' => isset($node->$key) ? $node->$key : NULL,
00124     );
00125   }
00126
00127   // Changed must be sent to the client, for later overwrite error checking.
00128   $form['changed'] = array(
00129     '#type' => 'hidden',
00130     '#default_value' => isset($node->changed) ? $node->changed : NULL,
00131   );
00132   // Get the node-specific bits.
00133   if ($extra = node_invoke($node, 'form', $form_state)) {
00134     $form = array_merge_recursive($form, $extra);
00135   }
00136   if (!isset($form['title']['#weight'])) {
00137     $form['title']['#weight'] = -5;
00138   }
00139
00140   $form['#node'] = $node;
00141
00142   // Add a log field if the "Create new revision" option is checked, or if the
00143   // current user has the ability to check that option.
00144   if (!empty($node->revision) || user_access('administer nodes')) {
00145     $form['revision_information'] = array(
00146       '#type' => 'fieldset',
00147       '#title' => t('Revision information'),
00148       '#collapsible' => TRUE,
00149       // Collapsed by default when "Create new revision" is unchecked
00150       '#collapsed' => !$node->revision,
00151       '#weight' => 20,
00152     );
00153     $form['revision_information']['revision'] = array(
00154       '#access' => user_access('administer nodes'),
00155       '#type' => 'checkbox',
00156       '#title' => t('Create new revision'),
00157       '#default_value' => $node->revision,
00158     );
00159     $form['revision_information']['log'] = array(
00160       '#type' => 'textarea',
00161       '#title' => t('Log message'),
00162       '#rows' => 2,
00163       '#description' => t('An explanation of the additions or updates being made to help other authors understand your motivations.'),
00164     );
00165   }
00166
00167   // Node author information for administrators
00168   $form['author'] = array(
00169     '#type' => 'fieldset',
00170     '#access' => user_access('administer nodes'),
00171     '#title' => t('Authoring information'),
00172     '#collapsible' => TRUE,
00173     '#collapsed' => TRUE,
00174     '#weight' => 20,
00175   );
00176   $form['author']['name'] = array(
00177     '#type' => 'textfield',
00178     '#title' => t('Authored by'),
00179     '#maxlength' => 60,
00180     '#autocomplete_path' => 'user/autocomplete',
00181     '#default_value' => $node->name ? $node->name : '',
00182     '#weight' => -1,
00183     '#description' => t('Leave blank for %anonymous.', array('%anonymous' => variable_get('anonymous', t('Anonymous')))),
00184   );
00185   $form['author']['date'] = array(
00186     '#type' => 'textfield',
00187     '#title' => t('Authored on'),
00188     '#maxlength' => 25,
00189     '#description' => t('Format: %time. Leave blank to use the time of form submission.', array('%time' => !empty($node->date) ? $node->date : format_date($node->created, 'custom', 'Y-m-d H:i:s O'))),
00190   );
00191
00192   if (isset($node->date)) {
00193     $form['author']['date']['#default_value'] = $node->date;
00194   }
00195
00196   // Node options for administrators
00197   $form['options'] = array(
00198     '#type' => 'fieldset',
00199     '#access' => user_access('administer nodes'),
00200     '#title' => t('Publishing options'),
00201     '#collapsible' => TRUE,
00202     '#collapsed' => TRUE,
00203     '#weight' => 25,
00204   );
00205   $form['options']['status'] = array(
00206     '#type' => 'checkbox',
00207     '#title' => t('Published'),
00208     '#default_value' => $node->status,
00209   );
00210   $form['options']['promote'] = array(
00211     '#type' => 'checkbox',
00212     '#title' => t('Promoted to front page'),
00213     '#default_value' => $node->promote,
00214   );
00215   $form['options']['sticky'] = array(
00216     '#type' => 'checkbox',
00217     '#title' => t('Sticky at top of lists'),
00218     '#default_value' => $node->sticky,
00219   );
00220
00221   // These values are used when the user has no administrator access.
00222   foreach (array('uid', 'created') as $key) {
00223     $form[$key] = array(
00224       '#type' => 'value',
00225       '#value' => $node->$key,
00226     );
00227   }
00228
00229   // Add the buttons.
00230   $form['buttons'] = array();
00231   $form['buttons']['submit'] = array(
00232     '#type' => 'submit',
00233     '#value' => t('Save'),
00234     '#weight' => 5,
00235     '#submit' => array('node_form_submit'),
00236   );
00237   $form['buttons']['preview'] = array(
00238     '#type' => 'submit',
00239     '#value' => t('Preview'),
00240     '#weight' => 10,
00241     '#submit' => array('node_form_build_preview'),
00242   );
00243   if (!empty($node->nid) && node_access('delete', $node)) {
00244     $form['buttons']['delete'] = array(
00245       '#type' => 'submit',
00246       '#value' => t('Delete'),
00247       '#weight' => 15,
00248       '#submit' => array('node_form_delete_submit'),
00249     );
00250   }
00251   $form['#validate'][] = 'node_form_validate';
00252   $form['#theme'] = array($node->type .'_node_form', 'node_form');
00253   return $form;
00254 }
00255
00259 function node_body_field(&$node, $label, $word_count) {
00260
00261   // Check if we need to restore the teaser at the beginning of the body.
00262   $include = !isset($node->teaser) || ($node->teaser == substr($node->body, 0, strlen($node->teaser)));
00263
00264   $form = array(
00265     '#after_build' => array('node_teaser_js', 'node_teaser_include_verify'));
00266
00267   $form['#prefix'] = '<div class="body-field-wrapper">';
00268   $form['#suffix'] = '</div>';
00269
00270   $form['teaser_js'] = array(
00271     '#type' => 'textarea',
00272     '#rows' => 10,
00273     '#teaser' => 'edit-body',
00274     '#teaser_checkbox' => 'edit-teaser-include',
00275     '#disabled' => TRUE,
00276   );
00277
00278   $form['teaser_include'] = array(
00279     '#type' => 'checkbox',
00280     '#title' => t('Show summary in full view'),
00281     '#default_value' => $include,
00282     '#prefix' => '<div class="teaser-checkbox">',
00283     '#suffix' => '</div>',
00284   );
00285
00286   $form['body'] = array(
00287     '#type' => 'textarea',
00288     '#title' => check_plain($label),
00289     '#default_value' => $include ? $node->body : ($node->teaser . $node->body),
00290     '#rows' => 20,
00291     '#required' => ($word_count > 0),
00292   );
00293
00294   $form['format'] = filter_form($node->format);
00295
00296   return $form;
00297 }
00298
00302 function node_form_delete_submit($form, &$form_state) {
00303   $destination = '';
00304   if (isset($_REQUEST['destination'])) {
00305     $destination = drupal_get_destination();
00306     unset($_REQUEST['destination']);
00307   }
00308   $node = $form['#node'];
00309   $form_state['redirect'] = array('node/'. $node->nid .'/delete', $destination);
00310 }
00311
00312
00313 function node_form_build_preview($form, &$form_state) {
00314   $node = node_form_submit_build_node($form, $form_state);
00315   $form_state['node_preview'] = node_preview($node);
00316 }
00317
00323 function theme_node_form($form) {
00324   $output = "\n<div class=\"node-form\">\n";
00325
00326   // Admin form fields and submit buttons must be rendered first, because
00327   // they need to go to the bottom of the form, and so should not be part of
00328   // the catch-all call to drupal_render().
00329   $admin = '';
00330   if (isset($form['author'])) {
00331     $admin .= "    <div class=\"authored\">\n";
00332     $admin .= drupal_render($form['author']);
00333     $admin .= "    </div>\n";
00334   }
00335   if (isset($form['options'])) {
00336     $admin .= "    <div class=\"options\">\n";
00337     $admin .= drupal_render($form['options']);
00338     $admin .= "    </div>\n";
00339   }
00340   $buttons = drupal_render($form['buttons']);
00341
00342   // Everything else gets rendered here, and is displayed before the admin form
00343   // field and the submit buttons.
00344   $output .= "  <div class=\"standard\">\n";
00345   $output .= drupal_render($form);
00346   $output .= "  </div>\n";
00347
00348   if (!empty($admin)) {
00349     $output .= "  <div class=\"admin\">\n";
00350     $output .= $admin;
00351     $output .= "  </div>\n";
00352   }
00353   $output .= $buttons;
00354   $output .= "</div>\n";
00355
00356   return $output;
00357 }
00358
00362 function node_preview($node) {
00363   if (node_access('create', $node) || node_access('update', $node)) {
00364     // Load the user's name when needed.
00365     if (isset($node->name)) {
00366       // The use of isset() is mandatory in the context of user IDs, because
00367       // user ID 0 denotes the anonymous user.
00368       if ($user = user_load(array('name' => $node->name))) {
00369         $node->uid = $user->uid;
00370         $node->picture = $user->picture;
00371       }
00372       else {
00373         $node->uid = 0; // anonymous user
00374       }
00375     }
00376     else if ($node->uid) {
00377       $user = user_load(array('uid' => $node->uid));
00378       $node->name = $user->name;
00379       $node->picture = $user->picture;
00380     }
00381
00382     $node->changed = time();
00383
00384     // Extract a teaser, if it hasn't been set (e.g. by a module-provided
00385     // 'teaser' form item).
00386     if (!isset($node->teaser)) {
00387       $node->teaser = empty($node->body) ? '' : node_teaser($node->body, $node->format);
00388       // Chop off the teaser from the body if needed.
00389       if (!$node->teaser_include && $node->teaser == substr($node->body, 0, strlen($node->teaser))) {
00390         $node->body = substr($node->body, strlen($node->teaser));
00391       }
00392     }
00393
00394     // Display a preview of the node.
00395     // Previewing alters $node so it needs to be cloned.
00396     if (!form_get_errors()) {
00397       $cloned_node = drupal_clone($node);
00398       $cloned_node->build_mode = NODE_BUILD_PREVIEW;
00399       $output = theme('node_preview', $cloned_node);
00400     }
00401     drupal_set_title(t('Preview'));
00402
00403     return $output;
00404   }
00405 }
00406
00415 function theme_node_preview($node) {
00416   $output = '<div class="preview">';
00417
00418   $preview_trimmed_version = FALSE;
00419   // Do we need to preview trimmed version of post as well as full version?
00420   if (isset($node->teaser) && isset($node->body)) {
00421     $teaser = trim($node->teaser);
00422     $body = trim(str_replace('<!--break-->', '', $node->body));
00423
00424     // Preview trimmed version if teaser and body will appear different;
00425     // also (edge case) if both teaser and body have been specified by the user
00426     // and are actually the same.
00427     if ($teaser != $body || ($body && strpos($node->body, '<!--break-->') === 0)) {
00428       $preview_trimmed_version = TRUE;
00429     }
00430   }
00431
00432   if ($preview_trimmed_version) {
00433     drupal_set_message(t('The trimmed version of your post shows what your post looks like when promoted to the main page or when exported for syndication.<span class="no-js"> You can insert the delimiter "&lt;!--break--&gt;" (without the quotes) to fine-tune where your post gets split.</span>'));
00434     $output .= '<h3>'. t('Preview trimmed version') .'</h3>';
00435     $output .= node_view(drupal_clone($node), 1, FALSE, 0);
00436     $output .= '<h3>'. t('Preview full version') .'</h3>';
00437     $output .= node_view($node, 0, FALSE, 0);
00438   }
00439   else {
00440     $output .= node_view($node, 0, FALSE, 0);
00441   }
00442   $output .= "</div>\n";
00443
00444   return $output;
00445 }
00446
00447 function node_form_submit($form, &$form_state) {
00448   global $user;
00449
00450   $node = node_form_submit_build_node($form, $form_state);
00451   $insert = empty($node->nid);
00452   node_save($node);
00453   $node_link = l(t('view'), 'node/'. $node->nid);
00454   $watchdog_args = array('@type' => $node->type, '%title' => $node->title);
00455   $t_args = array('@type' => node_get_types('name', $node), '%title' => $node->title);
00456
00457   if ($insert) {
00458     watchdog('content', '@type: added %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
00459     drupal_set_message(t('@type %title has been created.', $t_args));
00460   }
00461   else {
00462     watchdog('content', '@type: updated %title.', $watchdog_args, WATCHDOG_NOTICE, $node_link);
00463     drupal_set_message(t('@type %title has been updated.', $t_args));
00464   }
00465   if ($node->nid) {
00466     unset($form_state['rebuild']);
00467     $form_state['nid'] = $node->nid;
00468     $form_state['redirect'] = 'node/'. $node->nid;
00469   }
00470   else {
00471     // In the unlikely case something went wrong on save, the node will be
00472     // rebuilt and node form redisplayed the same way as in preview.
00473     drupal_set_message(t('The post could not be saved.'), 'error');
00474   }
00475 }
00476
00480 function node_form_submit_build_node($form, &$form_state) {
00481   // Unset any button-level handlers, execute all the form-level submit
00482   // functions to process the form values into an updated node.
00483   unset($form_state['submit_handlers']);
00484   form_execute_handlers('submit', $form, $form_state);
00485   $node = node_submit($form_state['values']);
00486   $form_state['node'] = (array)$node;
00487   $form_state['rebuild'] = TRUE;
00488   return $node;
00489 }
00490
00494 function node_delete_confirm(&$form_state, $node) {
00495   $form['nid'] = array(
00496     '#type' => 'value',
00497     '#value' => $node->nid,
00498   );
00499
00500   return confirm_form($form,
00501     t('Are you sure you want to delete %title?', array('%title' => $node->title)),
00502     isset($_GET['destination']) ? $_GET['destination'] : 'node/'. $node->nid,
00503     t('This action cannot be undone.'),
00504     t('Delete'),
00505     t('Cancel')
00506   );
00507 }
00508
00512 function node_delete_confirm_submit($form, &$form_state) {
00513   if ($form_state['values']['confirm']) {
00514     node_delete($form_state['values']['nid']);
00515   }
00516
00517   $form_state['redirect'] = '<front>';
00518 }
00519
00523 function node_revision_overview($node) {
00524   drupal_set_title(t('Revisions for %title', array('%title' => $node->title)));
00525
00526   $header = array(t('Revision'), array('data' => t('Operations'), 'colspan' => 2));
00527
00528   $revisions = node_revision_list($node);
00529
00530   $rows = array();
00531   $revert_permission = FALSE;
00532   if ((user_access('revert revisions') || user_access('administer nodes')) && node_access('update', $node)) {
00533     $revert_permission = TRUE;
00534   }
00535   $delete_permission = FALSE;
00536   if ((user_access('delete revisions') || user_access('administer nodes')) && node_access('delete', $node)) {
00537     $delete_permission = TRUE;
00538   }
00539   foreach ($revisions as $revision) {
00540     $row = array();
00541     $operations = array();
00542
00543     if ($revision->current_vid > 0) {
00544       $row[] = array('data' => t('!date by !username', array('!date' => l(format_date($revision->timestamp, 'small'), "node/$node->nid"), '!username' => theme('username', $revision)))
00545                                . (($revision->log != '') ? '<p class="revision-log">'. filter_xss($revision->log) .'</p>' : ''),
00546                      'class' => 'revision-current');
00547       $operations[] = array('data' => theme('placeholder', t('current revision')), 'class' => 'revision-current', 'colspan' => 2);
00548     }
00549     else {
00550       $row[] = t('!date by !username', array('!date' => l(format_date($revision->timestamp, 'small'), "node/$node->nid/revisions/$revision->vid/view"), '!username' => theme('username', $revision)))
00551                . (($revision->log != '') ? '<p class="revision-log">'. filter_xss($revision->log) .'</p>' : '');
00552       if ($revert_permission) {
00553         $operations[] = l(t('revert'), "node/$node->nid/revisions/$revision->vid/revert");
00554       }
00555       if ($delete_permission) {
00556         $operations[] = l(t('delete'), "node/$node->nid/revisions/$revision->vid/delete");
00557       }
00558     }
00559     $rows[] = array_merge($row, $operations);
00560   }
00561
00562   return theme('table', $header, $rows);
00563 }
00564
00568 function node_revision_revert_confirm($form_state, $node_revision) {
00569   $form['#node_revision'] = $node_revision;
00570   return confirm_form($form, t('Are you sure you want to revert to the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/'. $node_revision->nid .'/revisions', '', t('Revert'), t('Cancel'));
00571 }
00572
00573 function node_revision_revert_confirm_submit($form, &$form_state) {
00574   $node_revision = $form['#node_revision'];
00575   $node_revision->revision = 1;
00576   $node_revision->log = t('Copy of the revision from %date.', array('%date' => format_date($node_revision->revision_timestamp)));
00577   if (module_exists('taxonomy')) {
00578     $node_revision->taxonomy = array_keys($node_revision->taxonomy);
00579   }
00580
00581   node_save($node_revision);
00582
00583   watchdog('content', '@type: reverted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->title, '%revision' => $node_revision->vid));
00584   drupal_set_message(t('@type %title has been reverted back to the revision from %revision-date.', array('@type' => node_get_types('name', $node_revision), '%title' => $node_revision->title, '%revision-date' => format_date($node_revision->revision_timestamp))));
00585   $form_state['redirect'] = 'node/'. $node_revision->nid .'/revisions';
00586 }
00587
00588 function node_revision_delete_confirm($form_state, $node_revision) {
00589   $form['#node_revision'] = $node_revision;
00590   return confirm_form($form, t('Are you sure you want to delete the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/'. $node_revision->nid .'/revisions', t('This action cannot be undone.'), t('Delete'), t('Cancel'));
00591 }
00592
00593 function node_revision_delete_confirm_submit($form, &$form_state) {
00594   $node_revision = $form['#node_revision'];
00595   db_query("DELETE FROM {node_revisions} WHERE nid = %d AND vid = %d", $node_revision->nid, $node_revision->vid);
00596   node_invoke_nodeapi($node_revision, 'delete revision');
00597   watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->title, '%revision' => $node_revision->vid));
00598   drupal_set_message(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($node_revision->revision_timestamp), '@type' => node_get_types('name', $node_revision), '%title' => $node_revision->title)));
00599   $form_state['redirect'] = 'node/'. $node_revision->nid;
00600   if (db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', $node_revision->nid)) > 1) {
00601     $form_state['redirect'] .= '/revisions';
00602   }
00603 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/hooks/node.php Source File

docs » hooks

node.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: node.php,v 1.40 2008/02/10 17:58:11 darrenoh Exp $
00003
00069 function hook_node_info() {
00070   return array(
00071     'book' => array(
00072       'name' => t('book page'),
00073       'module' => 'book',
00074       'description' => t("A book is a collaborative writing effort: users can collaborate writing the pages of the book, positioning the pages in the right order, and reviewing or modifying pages previously written. So when you have some information to share or when you read a page of the book and you didn't like it, or if you think a certain page could have been written better, you can do something about it."),
00075     )
00076   );
00077 }
00078
00094 function hook_node_type($op, $info) {
00095
00096   switch ($op){
00097     case 'delete':
00098       variable_del('comment_'. $info->type);
00099       break;
00100     case 'update':
00101       if (!empty($info->old_type) && $info->old_type != $info->type) {
00102         $setting = variable_get('comment_'. $info->old_type, COMMENT_NODE_READ_WRITE);
00103         variable_del('comment_'. $info->old_type);
00104         variable_set('comment_'. $info->type, $setting);
00105       }
00106       break;
00107   }
00108 }
00109
00143 function hook_access($op, $node, $account) {
00144   if ($op == 'create') {
00145     return user_access('create stories', $account);
00146   }
00147
00148   if ($op == 'update' || $op == 'delete') {
00149     if (user_access('edit own stories', $account) && ($account->uid == $node->uid)) {
00150       return TRUE;
00151     }
00152   }
00153 }
00154
00172 function hook_delete(&$node) {
00173   db_query('DELETE FROM {mytable} WHERE nid = %d', $node->nid);
00174 }
00175
00190 function hook_submit(&$node) {
00191   // if a file was uploaded, move it to the files directory
00192   if ($file = file_check_upload('file')) {
00193     $node->file = file_save_upload($file, file_directory_path(), false);
00194   }
00195 }
00196
00208 function hook_prepare(&$node) {
00209   if ($file = file_check_upload($field_name)) {
00210     $file = file_save_upload($field_name, _image_filename($file->filename, NULL, TRUE));
00211     if ($file) {
00212       if (!image_get_info($file->filepath)) {
00213         form_set_error($field_name, t('Uploaded file is not a valid image'));
00214         return;
00215       }
00216     }
00217     else {
00218       return;
00219     }
00220     $node->images['_original'] = $file->filepath;
00221     _image_build_derivatives($node, true);
00222     $node->new_file = TRUE;
00223   }
00224 }
00225
00226
00250 function hook_form(&$node, &$param) {
00251   $type = node_get_types('type', $node);
00252
00253   $form['title'] = array(
00254     '#type'=> 'textfield',
00255     '#title' => check_plain($type->title_label),
00256     '#required' => TRUE,
00257   );
00258   $form['body'] = array(
00259     '#type' => 'textarea',
00260     '#title' => check_plain($type->body_label),
00261     '#rows' => 20,
00262     '#required' => TRUE,
00263   );
00264   $form['field1'] = array(
00265     '#type' => 'textfield',
00266     '#title' => t('Custom field'),
00267     '#default_value' => $node->field1,
00268     '#maxlength' => 127,
00269   );
00270   $form['selectbox'] = array(
00271     '#type' => 'select',
00272     '#title' => t('Select box'),
00273     '#default_value' => $node->selectbox,
00274     '#options' => array(
00275       1 => 'Option A',
00276       2 => 'Option B',
00277       3 => 'Option C',
00278     ),
00279     '#description' => t('Please choose an option.'),
00280   );
00281
00282   return $form;
00283 }
00284
00302 function hook_insert($node) {
00303   db_query("INSERT INTO {mytable} (nid, extra)
00304     VALUES (%d, '%s')", $node->nid, $node->extra);
00305 }
00306
00327 function hook_load($node) {
00328   $additions = db_fetch_object(db_query('SELECT * FROM {mytable} WHERE vid = %d', $node->vid));
00329   return $additions;
00330 }
00331
00349 function hook_update($node) {
00350   db_query("UPDATE {mytable} SET extra = '%s' WHERE nid = %d",
00351     $node->extra, $node->nid);
00352 }
00353
00377 function hook_validate($node) {
00378   if (isset($node->end) && isset($node->start)) {
00379     if ($node->start > $node->end) {
00380       form_set_error('time', t('An event may not end before it starts.'));
00381     }
00382   }
00383 }
00384
00416 function hook_view($node, $teaser = FALSE, $page = FALSE) {
00417   if ($page) {
00418     $breadcrumb = array();
00419     $breadcrumb[] = array('path' => 'example', 'title' => t('example'));
00420     $breadcrumb[] = array('path' => 'example/'. $node->field1,
00421       'title' => t('%category', array('%category' => $node->field1)));
00422     $breadcrumb[] = array('path' => 'node/'. $node->nid);
00423     menu_set_location($breadcrumb);
00424   }
00425
00426   $node = node_prepare($node, $teaser);
00427   $node->content['myfield'] = array(
00428     '#value' => theme('mymodule_myfield', $node->myfield),
00429     '#weight' => 1,
00430   );
00431
00432   return $node;
00433 }
00434
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/node_access_example.install Source File

docs » examples

node_access_example.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: node_access_example.install,v 1.6 2007/10/05 16:44:50 drewish Exp $
00003
00007 function node_access_example_install() {
00008   drupal_install_schema('node_access_example');
00009 }
00010
00014 function node_access_example_uninstall() {
00015   drupal_uninstall_schema('node_access_example');
00016 }
00017
00021 function node_access_example_schema() {
00022   $schema['node_access_example'] = array(
00023     'fields' => array(
00024       'nid'     => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
00025       'private' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
00026     ),
00027     'primary key' => array('nid'),
00028   );
00029
00030   return $schema;
00031 }
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/node_access_example.module Source File

docs » examples

node_access_example.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: node_access_example.module,v 1.8 2007/09/09 01:27:07 yched Exp $
00003
00034 function node_access_example_perm() {
00035   return array('access private content', 'edit private content');
00036 }
00037
00051 function node_access_example_node_grants($account, $op) {
00052   if ($op == 'view' && user_access('access private content', $account)) {
00053     $grants['example'] = array(1);
00054   }
00055
00056   if (($op == 'update' || $op == 'delete') && user_access('edit private content', $account)) {
00057     $grants['example'] = array(1);
00058   }
00059
00060   $grants['example_author'] = array($account->uid);
00061   return $grants;
00062 }
00063
00073 function node_access_example_node_access_records($node) {
00074   // We only care about the node if it's been marked private. If not, it is
00075   // treated just like any other node and we completely ignore it.
00076   if ($node->private) {
00077     $grants = array();
00078     $grants[] = array(
00079       'realm' => 'example',
00080       'gid' => TRUE,
00081       'grant_view' => TRUE,
00082       'grant_update' => FALSE,
00083       'grant_delete' => FALSE,
00084       'priority' => 0,
00085     );
00086
00087     // For the example_author array, the GID is equivalent to a UID, which
00088     // means there are many many groups of just 1 user.
00089     $grants[] = array(
00090       'realm' => 'example_author',
00091       'gid' => $node->uid,
00092       'grant_view' => TRUE,
00093       'grant_update' => TRUE,
00094       'grant_delete' => TRUE,
00095       'priority' => 0,
00096     );
00097     return $grants;
00098   }
00099 }
00100
00108 function node_access_example_form_alter(&$form, $form_state) {
00109   if ($form['#id'] == 'node-form') {
00110     $form['private'] = array(
00111       '#type' => 'checkbox',
00112       '#title' => t('Private'),
00113       '#description' => t('Check here if this content should be set private and only shown to privileged users.'),
00114       '#default_value' => isset($form['#node']->private) ? $form['#node']->private : FALSE,
00115     );
00116   }
00117 }
00118
00125 function node_access_example_nodeapi(&$node, $op, $arg = 0) {
00126   switch ($op) {
00127     case 'load':
00128       $result = db_fetch_object(db_query('SELECT * FROM {node_access_example} WHERE nid = %d', $node->nid));
00129       $node->private = $result->private;
00130       break;
00131     case 'delete':
00132       db_query('DELETE FROM {node_access_example} WHERE nid = %d', $node->nid);
00133       break;
00134     case 'insert':
00135       db_query('INSERT INTO {node_access_example} (nid, private) VALUES (%d, %d)', $node->nid, $node->private);
00136       break;
00137     case 'update':
00138       db_query('UPDATE {node_access_example} SET private = %d WHERE nid = %d', $node->private, $node->nid);
00139       break;
00140   }
00141 }
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/node_example.install Source File

docs » examples

node_example.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: node_example.install,v 1.4 2007/10/05 16:44:50 drewish Exp $
00003
00007 function node_example_install() {
00008   drupal_install_schema('node_example');
00009 }
00010
00014 function node_example_uninstall() {
00015   drupal_uninstall_schema('node_example');
00016 }
00017
00021 function node_example_schema() {
00022   $schema['node_example'] = array(
00023     'fields' => array(
00024       'vid'      => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
00025       'nid'      => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
00026       'color'    => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
00027       'quantity' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
00028     ),
00029     'primary key' => array('vid', 'nid'),
00030   );
00031
00032   return $schema;
00033 }
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/node_example.module Source File

docs » examples

node_example.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: node_example.module,v 1.26 2008/01/19 21:13:58 bdragon Exp $
00003
00051 function node_example_node_info() {
00052   return array(
00053     'node_example' => array(
00054       'name' => t('Example node'),
00055       'module' => 'node_example',
00056       'description' => t("This is an example node type with a few fields."),
00057       'has_title' => TRUE,
00058       'title_label' => t('Example Title'),
00059       'has_body' => TRUE,
00060       'body_label' => t('Example Body'),
00061     )
00062   );
00063 }
00064
00071 function node_example_access($op, $node, $account) {
00072   if ($op == 'create') {
00073     return user_access('create example content', $account);
00074   }
00075
00076   if ($op == 'update') {
00077     if (user_access('edit any example content', $account) || (user_access('edit own example content', $account) && ($account->uid == $node->uid))) {
00078       return TRUE;
00079     }
00080   }
00081
00082   if ($op == 'delete') {
00083     if (user_access('delete any example content', $account) || (user_access('delete own example content', $account) && ($account->uid == $node->uid))) {
00084       return TRUE;
00085     }
00086   }
00087 }
00088
00096 function node_example_perm() {
00097   return array(
00098     'create example content',
00099     'delete own example content',
00100     'delete any example content',
00101     'edit own example content',
00102     'edit any example content',
00103   );
00104 }
00105
00113 function node_example_form(&$node) {
00114   // The site admin can decide if this node type has a title and body, and how
00115   // the fields should be labeled. We need to load these settings so we can
00116   // build the node form correctly.
00117   $type = node_get_types('type', $node);
00118
00119   if ($type->has_title) {
00120     $form['title'] = array(
00121       '#type' => 'textfield',
00122       '#title' => check_plain($type->title_label),
00123       '#required' => TRUE,
00124       '#default_value' => $node->title,
00125       '#weight' => -5
00126     );
00127   }
00128
00129   if ($type->has_body) {
00130     // In Drupal 6, we can use node_body_field() to get the body and filter
00131     // elements. This replaces the old textarea + filter_form() method of
00132     // setting this up. It will also ensure the teaser splitter gets set up
00133     // properly.
00134     $form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
00135   }
00136
00137   // Now we define the form elements specific to our node type.
00138   $form['color'] = array(
00139     '#type' => 'textfield',
00140     '#title' => t('Color'),
00141     '#default_value' => isset($node->color) ? $node->color : '',
00142   );
00143   $form['quantity'] = array(
00144     '#type' => 'textfield',
00145     '#title' => t('Quantity'),
00146     '#default_value' => isset($node->quantity) ? $node->quantity : 0,
00147     '#size' => 10,
00148     '#maxlength' => 10
00149   );
00150
00151   return $form;
00152 }
00153
00163 function node_example_validate(&$node) {
00164   if ($node->quantity) {
00165     if (!is_numeric($node->quantity)) {
00166       form_set_error('quantity', t('The quantity must be a number.'));
00167     }
00168   }
00169   else {
00170     // Let an empty field mean "zero."
00171     $node->quantity = 0;
00172   }
00173 }
00174
00181 function node_example_insert($node) {
00182   db_query("INSERT INTO {node_example} (vid, nid, color, quantity) VALUES (%d, %d, '%s', %d)", $node->vid, $node->nid, $node->color, $node->quantity);
00183 }
00184
00191 function node_example_update($node) {
00192   // if this is a new node or we're adding a new revision,
00193   if ($node->revision) {
00194     node_example_insert($node);
00195   }
00196   else {
00197     db_query("UPDATE {node_example} SET color = '%s', quantity = %d WHERE vid = %d", $node->color, $node->quantity, $node->vid);
00198   }
00199 }
00200
00208 function node_example_nodeapi(&$node, $op, $teaser, $page) {
00209   switch ($op) {
00210     case 'delete revision':
00211       // Notice that we're matching a single revision based on the node's vid.
00212       db_query('DELETE FROM {node_example} WHERE vid = %d', $node->vid);
00213       break;
00214   }
00215 }
00216
00222 function node_example_delete($node) {
00223   // Notice that we're matching all revision, by using the node's nid.
00224   db_query('DELETE FROM {node_example} WHERE nid = %d', $node->nid);
00225 }
00226
00234 function node_example_load($node) {
00235   $additions = db_fetch_object(db_query('SELECT color, quantity FROM {node_example} WHERE vid = %d', $node->vid));
00236   return $additions;
00237 }
00238
00245 function node_example_view($node, $teaser = FALSE, $page = FALSE) {
00246   $node = node_prepare($node, $teaser);
00247   $node->content['myfield'] = array(
00248     '#value' => theme('node_example_order_info', $node),
00249     '#weight' => 1,
00250   );
00251
00252   return $node;
00253 }
00254
00255
00261 function node_example_theme() {
00262   return array(
00263     'node_example_order_info' => array(
00264       'arguments' => array('node'),
00265     ),
00266   );
00267 }
00268
00277 function theme_node_example_order_info($node) {
00278   $output = '<div class="node_example_order_info">';
00279   $output .= t('The order is for %quantity %color items.', array('%quantity' => check_plain($node->quantity), '%color' => check_plain($node->color)));
00280   $output .= '</div>';
00281   return $output;
00282 }
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/nodeapi_example.install Source File

docs » examples

nodeapi_example.install

Go to the documentation of this file.
00001 <?php
00002
00003 // $Id: nodeapi_example.install,v 1.4 2007/10/05 16:44:50 drewish Exp $
00004
00008 function nodeapi_example_install() {
00009   drupal_install_schema('nodeapi_example');
00010 }
00011
00015 function nodeapi_example_uninstall() {
00016   drupal_uninstall_schema('nodeapi_example');
00017 }
00018
00022 function nodeapi_example_schema() {
00023   $schema['nodeapi_example'] = array(
00024     'fields' => array(
00025       'nid'    => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
00026       'rating' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
00027     ),
00028     'primary key' => array('nid'),
00029   );
00030
00031   return $schema;
00032 }
00033
00034 function nodeapi_example_update_1() {
00035   return _system_update_utf8(array('nodeapi_example'));
00036 }
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/nodeapi_example.module Source File

docs » examples

nodeapi_example.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: nodeapi_example.module,v 1.7 2007/10/05 18:12:12 drewish Exp $
00003
00023 function nodeapi_example_form_alter(&$form, $form_state, $form_id) {
00024   if ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
00025     // Alter the node type's configuration form to add our setting. We don't
00026     // need to worry about saving this value back to the variable, the form
00027     // we're altering will do it for us.
00028     $form['workflow']['nodeapi_example'] = array(
00029       '#type' => 'radios',
00030       '#title' => t('NodeAPI Example Rating'),
00031       '#default_value' => variable_get('nodeapi_example_'. $form['#node_type']->type, 0),
00032       '#options' => array(0 => t('Disabled'), 1 => t('Enabled')),
00033       '#description' => t('Should this node have a rating attached to it?'),
00034     );
00035   }
00036   // If the type and node field are set this may be a node edit form.
00037   else if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
00038     // If the rating is enabled for this node type, we insert our control
00039     // into the form.
00040     $node = $form['#node'];
00041     if (variable_get('nodeapi_example_'. $form['type']['#value'], 0)) {
00042       $form['nodeapi_example_rating'] = array(
00043         '#type' => 'select',
00044         '#title' => t('Rating'),
00045         '#default_value' => isset($node->nodeapi_example_rating) ? $node->nodeapi_example_rating : '',
00046         '#options' => array(0 => t('Unrated'), 1, 2, 3, 4, 5),
00047         '#required' => TRUE,
00048         '#weight' => 0,
00049       );
00050     }
00051   }
00052 }
00053
00061 function nodeapi_example_nodeapi(&$node, $op, $teaser, $page) {
00062   switch ($op) {
00063     // When the content editing form is submitted, we need to validate the input
00064     // to make sure the user made a selection, since we are requiring the rating
00065     // field. We have to check that the value has been set to avoid showing an
00066     // error message when a new blank form is presented. Calling form_set_error()
00067     // when the field is set but zero ensures not only that an error message is
00068     // presented, but also that the user must correct the error before being able
00069     // to submit the node.
00070     case 'validate':
00071       if (variable_get('nodeapi_example_'. $node->type, TRUE)) {
00072         if (isset($node->nodeapi_example_rating) && !$node->nodeapi_example_rating) {
00073           form_set_error('nodeapi_example_rating', t('You must rate this content.'));
00074         }
00075       }
00076       break;
00077
00078     // Now we need to take care of loading one of the extended nodes from the
00079     // database. An array containing our extra field needs to be returned.
00080     case 'load':
00081       $rating = db_result(db_query('SELECT rating FROM {nodeapi_example} WHERE nid = %d', $node->nid));
00082       return array('nodeapi_example_rating' => $rating);
00083       break;
00084
00085     // Insert is called after the node has been validated and saved to the
00086     // database. It gives us a chance to create our own record in the database.
00087     case 'insert':
00088       db_query('INSERT INTO {nodeapi_example} (nid, rating) VALUES (%d, %d)', $node->nid, $node->nodeapi_example_rating);
00089       break;
00090
00091     // Update is called when an existing node has been changed. Here, we use a
00092     // DELETE then an INSERT rather than an UPDATE. The reason is that a node
00093     // created before this module was installed won't already have a rating
00094     // saved so there would be nothing to update.
00095     case 'update':
00096       db_query('DELETE FROM {nodeapi_example} WHERE nid = %d', $node->nid);
00097       db_query('INSERT INTO {nodeapi_example} (nid, rating) VALUES (%d, %d)', $node->nid, $node->nodeapi_example_rating);
00098       break;
00099
00100     // Delete is called whn the node is being deleted, it gives us a chance
00101     // to delete the rating too.
00102     case 'delete':
00103       db_query('DELETE FROM {nodeapi_example} WHERE nid = %d', $node->nid);
00104       break;
00105
00106     // Finally, we need to take care of displaying our rating when the node is
00107     // viewed. This operation is called after the node has already been prepared
00108     // into HTML and filtered as necessary, so we know we are dealing with an
00109     // HTML teaser and body. We will inject our additional information at the front
00110     // of the node copy.
00111     //
00112     // Using nodeapi('view') is more appropriate than using a filter here, because
00113     // filters transform user-supplied content, whereas we are extending it with
00114     // additional information.
00115     case 'view':
00116       $node->content['nodeapi_example'] = array(
00117         '#value' => theme('nodeapi_example_rating', $node->nodeapi_example_rating),
00118         '#weight' => -1,
00119       );
00120       break;
00121   }
00122 }
00123
00129 function nodeapi_example_theme() {
00130   return array(
00131     'nodeapi_example_rating' => array(
00132       'arguments' => array('rating'),
00133     ),
00134   );
00135 }
00136
00145 function theme_nodeapi_example_rating($rating) {
00146   $options = array(
00147     0 => t('Unrated'),
00148     1 => t('Poor'),
00149     2 => t('Needs improvement'),
00150     3 => t('Acceptable'),
00151     4 => t('Good'),
00152     5 => t('Excellent'));
00153   $output = '<div class="nodeapi_example_rating">';
00154   $output .= t('Rating: %rating', array('%rating' => $options[(int) $rating]));
00155   $output .= '</div>';
00156   return $output;
00157 }
00158
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal Programming from an Object-Oriented Perspective

Drupal often gets criticized by newcomers who believe that object-oriented programming (OOP) is always the best way to design software architecture, and since they do not see the word "class" in the Drupal code, it must be inferior to other solutions. In fact, it is true that Drupal does not use many of the OOP features of PHP, but it is a mistake to think that the use of classes is synonymous with object-oriented design. This article will cover several of the features of Drupal from an object-oriented perspective, so programmers comfortable with that paradigm can begin to feel at home in the Drupal code base, and hopefully be able to choose the right tool for the job.

Motivations for Current Design

As of version 4.6, Drupal does not use PHP's class construct. This decision was made for several reasons.

First, PHP's support for object-oriented constructs was much less mature at the time of Drupal's design. Drupal was built on PHP 4, and most of the improvements in PHP 5 relate to its object-oriented features.

Second, Drupal code is highly compartmentalized into modules, each of which defines its own set of functions. The inclusion of files is handled inside functions as well; PHP's performance suffers if all code is included on each page call, so Drupal attempts to load as little code as possible per request. This is a critical consideration, especially in the absence of a PHP accelerator; the act of compiling the code accounts for more than half of a Drupal page request. Functions are therefore defined inside other functions in Drupal, with respect to the runtime scope. This is perfectly legal. However, PHP does not allow the same kind of nesting with class declarations. This means that the inclusion of files defining classes must be "top-level," and not inside any function, which leads either to slower code (always including the files defining classes) or a large amount of logic in the main index.php file.

Finally, using classes to implement Drupal constructs is difficult due to the use of some advanced object-oriented design patterns used by Drupal itself. While this may sound self-contradictory, it should become clear in the following discussion that the lack of certain OOP constructs such as Objective-C's "categories" in PHP would mean that implementing some Drupal mechanisms (such as the theme system) would be more complicated using classes than using functions.

OOP Concepts in Drupal

Despite the lack of explicitly-declared classes in Drupal, many object-oriented paradigms are still used in its design. There are many sets of "essential features" that are said to be necessary to classify a system as object-oriented; we will look at one of the more popular definitions and examine some ways in which Drupal exhibits those characteristics.

Objects

There are many constructs in Drupal that fit the description of an "object". Some of the more prominent Drupal components that could be considered objects are modules, themes, nodes, and users.

Nodes are the basic content building blocks of a Drupal site, and bundle together the data that makes up a "page" or "story" on a typical site. The methods that operate on this object are defined in node.module, usually called by the node_invoke() function. User objects similarly package data together, bringing together information about each account on the site, profile information, and session tracking. In both cases, the data structure is defined by a database table instead of a class. Drupal exploits the relational nature of its supported databases to allow other modules to extend the objects with additional data fields.

Modules and themes are object-like as well, filling the "controller" role in many ways. Each module is a source file, but also bundles together related functions and follows a pattern of defining Drupal hooks.

Abstraction

Drupal's hook system is the basis for its interface abstraction. Hooks define the operations that can be performed on or by a module. If a module implements a hook, it enters into a contract to perform a particular task when the hook is invoked. The calling code need not know anything else about the module or the way the hook is implemented in order to get useful work done by invoking the hook.

Encapsulation

Like most other object-oriented systems, Drupal does not have a way of strictly limiting access to an object's inner workings, but rather relies on convention to accomplish this. Since Drupal code is based around functions, which share a single namespace, this namespace is subdivided by the use of prefixes. By following this simple convention, each module can declare its own functions and variables without the worry of conflict with others.

Convention also delineates the public API of a class from its internal implementation. Internal functions are prefixed by an underscore to indicate that they should not be called by outside modules. For example, _user_categories() is a private function which is subject to change without notice, while user_save() is part of the public interface to the user object and can be called with the expectation that the user object will be saved to the database (even though the method of doing this is private).

Polymorphism

Nodes are polymorphic in the classical sense. If a module needs to display a node, for example, it can call node_view() on that node to get an HTML representation. The actual rendering, though, will depend on which type of node is passed to the function; this is directly analogous to having the class of an object determine its behavior when a message is sent to it. Drupal itself handles the same introspection tasks required of an OOP language's runtime library.

Furthermore, the rendering of the node in this example can be affected by the active theme. Themes are polymorphic in the same way; the theme is passed a "render this node" message, and responds to it in a different way depending on the implementation of the active theme, though the interface is constant.

Inheritance

Modules and themes can define whatever functions they please. However, they can both be thought to inherit their behavior from an abstract base class. In the case of themes, the behavior of this class is determined by the functions in theme.inc; if a theme does not override a function defined there, the default rendering of an interface component is used, but the theme can instead provide its own rendering. Modules similarly have the selection of all Drupal hooks to override at will, and may pick and choose which ones to implement.

Design Patterns in Drupal

Much of Drupal's internal structure is more complicated than simple inheritance and message passing, however. The more interesting features of the system result from using established software design patterns. Many of the patterns detailed in the seminal Gang of Four Design Patterns book can be observed in Drupal, for instance.

Singleton

If we are to think of modules and themes as objects, then they follow the singleton pattern. In general these objects do not encapsulate data; what separates one module from another is the set of functions it contains, so it should be thought of as a class with a singleton instance.

Decorator

Drupal makes extensive use of the decorator pattern. The polymorphism of node objects was discussed earlier, but this is only a small piece of the power of the node system. More interesting is the use of hook_nodeapi(), which allows arbitrary modules to extend the behavior of all nodes.

This feature allows for a wide variety of behaviors to be added to nodes without the need for subclassing. For instance, a basic story node has only a few pieces of associated data: title, author, body, teaser, and a handful of metadata. A common need is for files to be uploaded and attached to a node, so one could design a new node type that had the story node's features plus the ability to attach files. Drupal's upload module satisfies this need in a much more modular fashion by using nodeAPI to grant every node that requests it the ability to have attached files.

This behavior could be imitated by the use of decorators, wrapping them around each node object. More simply, languages that support categories, like Objective-C, could augment the common base class of all node objects to add the new behavior. Drupal's implementation is a simple ramification of the hook system and the presence of node_invoke_all().

Observer

The above interaction is also similar to the use of observers in object-oriented systems. This Observer pattern is pervasive throughout Drupal. When a modification is made to a vocabulary in Drupal's taxonomy system, the taxonomy hook is called in all modules that implement it. By implementing the hook, they have registered as observers of the vocabulary object; any changes to it can then be acted on as is appropriate.

Bridge

The Drupal database abstraction layer is implemented in a fashion similar to the Bridge design pattern. Modules need to be written in a way that is independent of the database system being used, and the abstraction layer provides for this. New database layers can be written that conform to the API defined by the bridge, adding support for additional database systems without the need to modify module code.

Chain of Responsibility

Drupal's menu system follows the Chain of Responsibility pattern. On each page request, the menu system determines whether there is a module to handle the request, whether the user has access to the resource requested, and which function will be called to do the work. To do this, a message is passed to the menu item corresponding to the path of the request. If the menu item cannot handle the request, it is passed up the chain. This continues until a module handles the request, a module denies access to the user, or the chain is exhausted.

Command

Many of Drupal's hooks use the Command pattern to reduce the number of functions that are necessary to implement, passing the operation as a parameter along with the arguments. In fact, the hook system itself uses this pattern, so that modules do not have to define every hook, but rather just the ones they care to implement.

Why Not to Use Classes

The above hopefully clarifies the ways in which Drupal embodies various OOP concepts. Why, then, doesn't Drupal move in the direction of using classes to solve these problems in the future? Some of the reasons are historical, and were discussed earlier. Others, though, become clearer now that we have stepped through some of the design patterns used in Drupal.

A good example is the extensibility of the theme system. A theme defines functions for each of the interface elements it wants to display in a special way. As noted earlier, this makes themes seem like a good candidate to inherit from an abstract base class that defines the default rendering of the elements.

What happens, though, when a module is added that adds a new interface element? The theme should be able to override the rendering of this element as well, but if a base class is defined, the new module has no way of adding another method to that class. Complicated patterns could be set up to emulate this behavior, but Drupal's theme architecture quite elegantly handles the situation using its own function dispatch system. In this case and others like it, the classes that on the surface simplify the system end up serving to make it more cumbersome and difficult to extend.

Room for Improvement

While Drupal does reflect many object-oriented practices, there are some aspects of OOP that could be brought to bear on the project in more powerful ways.

Encapsulation, while adequate in theory, is not applied consistently enough across the code base. Modules should more rigorously define which functions are public and which are private; the tendency right now is to publish most functions in the public namespace even if the interface is volatile. This problem is exacerbated by Drupal's policy of forgoing backward compatibility in exchange for cleaner APIs whenever necessary. This policy has led to some very good code, but would need to be excercised much less often if better encapsulation conventions were followed.

Inheritance is also weak in the system. While, as noted above, all modules share a common set of behavior, it is difficult to extend this to new modules. One can create new modules easily that augment the behavior of existing ones, but there is not a way to override just some of a module's behavior. The impact of this can be marginalized by breaking large modules into smaller "a la carte" bundles of functionality, so that undesired aspects of a module may be more easily left out of the system.

Other Paradigms

Drupal is on the surface a procedural system, because it is built in a procedural language (PHP without classes). The paradigm behind a piece of software is not entirely dependent on its representation in code, however. Drupal is not afraid to borrow concepts from many disparate programming paradigms where it is convenient. A great deal of the power of Drupal comes from its underlying relational database, and relational programming techniques that mirror it. The fact that Drupal's work, much like that of any web application, consists of many reactions to discrete and rapid page requests should make the behavior of the system resonate with proponents of event-driven programming. To an aspect-oriented programmer, the invocation of hooks in arbitrary modules may look strikingly similar to a pointcut. And, as should be abundantly clear by now, Drupal is no stranger to object-oriented concepts either.


Drupal 6: modules/openid/openid.inc Source File

modules » openid

openid.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: openid.inc,v 1.8 2008/01/30 22:11:22 goba Exp $
00003
00009 // Diffie-Hellman Key Exchange Default Value.
00010 define('OPENID_DH_DEFAULT_MOD', '155172898181473697471232257763715539915724801'.
00011        '966915404479707795314057629378541917580651227423698188993727816152646631'.
00012        '438561595825688188889951272158842675419950341258706556549803580104870537'.
00013        '681476726513255747040765857479291291572334510643245094715007229621094194'.
00014        '349783925984760375594985848253359305585439638443');
00015
00016 // Constants for Diffie-Hellman key exchange computations.
00017 define('OPENID_DH_DEFAULT_GEN', '2');
00018 define('OPENID_SHA1_BLOCKSIZE', 64);
00019 define('OPENID_RAND_SOURCE', '/dev/urandom');
00020
00021 // OpenID namespace URLs
00022 define('OPENID_NS_2_0', 'http://specs.openid.net/auth/2.0');
00023 define('OPENID_NS_1_1', 'http://openid.net/signon/1.1');
00024 define('OPENID_NS_1_0', 'http://openid.net/signon/1.0');
00025
00029 function openid_redirect_http($url, $message) {
00030   $query = array();
00031   foreach ($message as $key => $val) {
00032     $query[] = $key .'='. urlencode($val);
00033   }
00034
00035   $sep = (strpos($url, '?') === FALSE) ? '?' : '&';
00036   header('Location: '. $url . $sep . implode('&', $query), TRUE, 302);
00037   exit;
00038 }
00039
00043 function openid_redirect($url, $message) {
00044   $output = '<html><head><title>'. t('OpenID redirect') ."</title></head>\n<body>";
00045   $output .= drupal_get_form('openid_redirect_form', $url, $message);
00046   $output .= '<script type="text/javascript">document.getElementById("openid-redirect-form").submit();</script>';
00047   $output .= "</body></html>\n";
00048   print $output;
00049   exit;
00050 }
00051
00052 function openid_redirect_form(&$form_state, $url, $message) {
00053   $form = array();
00054   $form['#action'] = $url;
00055   $form['#method'] = "post";
00056   foreach ($message as $key => $value) {
00057     $form[$key] = array(
00058       '#type' => 'hidden',
00059       '#name' => $key,
00060       '#value' => $value,
00061     );
00062   }
00063   $form['submit'] = array(
00064     '#type' => 'submit',
00065     '#prefix' => '<noscript>',
00066     '#suffix' => '</noscript>',
00067     '#value' => t('Send'),
00068   );
00069
00070   return $form;
00071 }
00072
00076 function _openid_is_xri($identifier) {
00077   $firstchar = substr($identifier, 0, 1);
00078   if ($firstchar == "@" || $firstchar == "=")
00079     return TRUE;
00080
00081   if (stristr($identifier, 'xri://') !== FALSE) {
00082     return TRUE;
00083   }
00084
00085   return FALSE;
00086 }
00087
00091 function _openid_normalize($identifier) {
00092   if (_openid_is_xri($identifier)) {
00093     return _openid_normalize_xri($identifier);
00094   }
00095   else {
00096     return _openid_normalize_url($identifier);
00097   }
00098 }
00099
00100 function _openid_normalize_xri($xri) {
00101   $normalized_xri = $xri;
00102   if (stristr($xri, 'xri://') !== FALSE) {
00103     $normalized_xri = substr($xri, 6);
00104   }
00105   return $normalized_xri;
00106 }
00107
00108 function _openid_normalize_url($url) {
00109   $normalized_url = $url;
00110
00111   if (stristr($url, '://') === FALSE) {
00112     $normalized_url = 'http://'. $url;
00113   }
00114
00115   if (substr_count($normalized_url, '/') < 3) {
00116     $normalized_url .= '/';
00117   }
00118
00119   return $normalized_url;
00120 }
00121
00125 function _openid_create_message($data) {
00126   $serialized = '';
00127
00128   foreach ($data as $key => $value) {
00129     if ((strpos($key, ':') !== FALSE) || (strpos($key, "\n") !== FALSE) || (strpos($value, "\n") !== FALSE)) {
00130       return null;
00131     }
00132     $serialized .= "$key:$value\n";
00133   }
00134   return $serialized;
00135 }
00136
00140 function _openid_encode_message($message) {
00141   $encoded_message = '';
00142
00143   $items = explode("\n", $message);
00144   foreach ($items as $item) {
00145     $parts = explode(':', $item, 2);
00146
00147     if (count($parts) == 2) {
00148       if ($encoded_message != '') {
00149         $encoded_message .= '&';
00150       }
00151       $encoded_message .= rawurlencode(trim($parts[0])) .'='. rawurlencode(trim($parts[1]));
00152     }
00153   }
00154
00155   return $encoded_message;
00156 }
00157
00162 function _openid_parse_message($message) {
00163   $parsed_message = array();
00164
00165   $items = explode("\n", $message);
00166   foreach ($items as $item) {
00167     $parts = explode(':', $item, 2);
00168
00169     if (count($parts) == 2) {
00170       $parsed_message[$parts[0]] = $parts[1];
00171     }
00172   }
00173
00174   return $parsed_message;
00175 }
00176
00180 function _openid_nonce() {
00181   // YYYY-MM-DDThh:mm:ssTZD UTC, plus some optional extra unique chars
00182   return gmstrftime('%Y-%m-%dT%H:%M:%S%Z') .
00183     chr(mt_rand(0, 25) + 65) .
00184     chr(mt_rand(0, 25) + 65) .
00185     chr(mt_rand(0, 25) + 65) .
00186     chr(mt_rand(0, 25) + 65);
00187 }
00188
00192 function _openid_link_href($rel, $html) {
00193   $rel = preg_quote($rel);
00194   preg_match('|<link\s+rel=["\'](.*)'. $rel .'(.*)["\'](.*)/?>|iUs', $html, $matches);
00195   if (isset($matches[3])) {
00196     preg_match('|href=["\']([^"]+)["\']|iU', $matches[3], $href);
00197     return trim($href[1]);
00198   }
00199   return FALSE;
00200 }
00201
00205 function _openid_meta_httpequiv($equiv, $html) {
00206   preg_match('|<meta\s+http-equiv=["\']'. $equiv .'["\'](.*)/?>|iUs', $html, $matches);
00207   if (isset($matches[1])) {
00208     preg_match('|content=["\']([^"]+)["\']|iUs', $matches[1], $content);
00209     if (isset($content[1])) {
00210       return $content[1];
00211     }
00212   }
00213   return FALSE;
00214 }
00215
00224 function _openid_signature($association, $message_array, $keys_to_sign) {
00225   $signature = '';
00226   $sign_data = array();
00227
00228   foreach ($keys_to_sign as $key) {
00229     if (isset($message_array['openid.'. $key])) {
00230       $sign_data[$key] = $message_array['openid.'. $key];
00231     }
00232   }
00233
00234   $message = _openid_create_message($sign_data);
00235   $secret = base64_decode($association->mac_key);
00236   $signature = _openid_hmac($secret, $message);
00237
00238   return base64_encode($signature);
00239 }
00240
00241 function _openid_hmac($key, $text) {
00242   if (strlen($key) > OPENID_SHA1_BLOCKSIZE) {
00243     $key = _openid_sha1($key, true);
00244   }
00245
00246   $key = str_pad($key, OPENID_SHA1_BLOCKSIZE, chr(0x00));
00247   $ipad = str_repeat(chr(0x36), OPENID_SHA1_BLOCKSIZE);
00248   $opad = str_repeat(chr(0x5c), OPENID_SHA1_BLOCKSIZE);
00249   $hash1 = _openid_sha1(($key ^ $ipad) . $text, true);
00250   $hmac = _openid_sha1(($key ^ $opad) . $hash1, true);
00251
00252   return $hmac;
00253 }
00254
00255 function _openid_sha1($text) {
00256   $hex = sha1($text);
00257   $raw = '';
00258   for ($i = 0; $i < 40; $i += 2) {
00259     $hexcode = substr($hex, $i, 2);
00260     $charcode = (int)base_convert($hexcode, 16, 10);
00261     $raw .= chr($charcode);
00262   }
00263   return $raw;
00264 }
00265
00266 function _openid_dh_base64_to_long($str) {
00267   $b64 = base64_decode($str);
00268
00269   return _openid_dh_binary_to_long($b64);
00270 }
00271
00272 function _openid_dh_long_to_base64($str) {
00273   return base64_encode(_openid_dh_long_to_binary($str));
00274 }
00275
00276 function _openid_dh_binary_to_long($str) {
00277   $bytes = array_merge(unpack('C*', $str));
00278
00279   $n = 0;
00280   foreach ($bytes as $byte) {
00281     $n = bcmul($n, pow(2, 8));
00282     $n = bcadd($n, $byte);
00283   }
00284
00285   return $n;
00286 }
00287
00288 function _openid_dh_long_to_binary($long) {
00289   $cmp = bccomp($long, 0);
00290   if ($cmp < 0) {
00291     return FALSE;
00292   }
00293
00294   if ($cmp == 0) {
00295     return "\x00";
00296   }
00297
00298   $bytes = array();
00299
00300   while (bccomp($long, 0) > 0) {
00301     array_unshift($bytes, bcmod($long, 256));
00302     $long = bcdiv($long, pow(2, 8));
00303   }
00304
00305   if ($bytes && ($bytes[0] > 127)) {
00306     array_unshift($bytes, 0);
00307   }
00308
00309   $string = '';
00310   foreach ($bytes as $byte) {
00311     $string .= pack('C', $byte);
00312   }
00313
00314   return $string;
00315 }
00316
00317 function _openid_dh_xorsecret($shared, $secret) {
00318   $dh_shared_str = _openid_dh_long_to_binary($shared);
00319   $sha1_dh_shared = _openid_sha1($dh_shared_str);
00320   $xsecret = "";
00321   for ($i = 0; $i < strlen($secret); $i++) {
00322     $xsecret .= chr(ord($secret[$i]) ^ ord($sha1_dh_shared[$i]));
00323   }
00324
00325   return $xsecret;
00326 }
00327
00328 function _openid_dh_rand($stop) {
00329   static $duplicate_cache = array();
00330
00331   // Used as the key for the duplicate cache
00332   $rbytes = _openid_dh_long_to_binary($stop);
00333
00334   if (array_key_exists($rbytes, $duplicate_cache)) {
00335     list($duplicate, $nbytes) = $duplicate_cache[$rbytes];
00336   }
00337   else {
00338     if ($rbytes[0] == "\x00") {
00339       $nbytes = strlen($rbytes) - 1;
00340     }
00341     else {
00342       $nbytes = strlen($rbytes);
00343     }
00344
00345     $mxrand = bcpow(256, $nbytes);
00346
00347     // If we get a number less than this, then it is in the
00348     // duplicated range.
00349     $duplicate = bcmod($mxrand, $stop);
00350
00351     if (count($duplicate_cache) > 10) {
00352       $duplicate_cache = array();
00353     }
00354
00355     $duplicate_cache[$rbytes] = array($duplicate, $nbytes);
00356   }
00357
00358   do {
00359     $bytes = "\x00". _openid_get_bytes($nbytes);
00360     $n = _openid_dh_binary_to_long($bytes);
00361     // Keep looping if this value is in the low duplicated range.
00362   } while (bccomp($n, $duplicate) < 0);
00363
00364   return bcmod($n, $stop);
00365 }
00366
00367 function _openid_get_bytes($num_bytes) {
00368   static $f = null;
00369   $bytes = '';
00370   if (!isset($f)) {
00371     $f = @fopen(OPENID_RAND_SOURCE, "r");
00372   }
00373   if (!$f) {
00374     // pseudorandom used
00375     $bytes = '';
00376     for ($i = 0; $i < $num_bytes; $i += 4) {
00377       $bytes .= pack('L', mt_rand());
00378     }
00379     $bytes = substr($bytes, 0, $num_bytes);
00380   }
00381   else {
00382     $bytes = fread($f, $num_bytes);
00383   }
00384   return $bytes;
00385 }
00386
00387 function _openid_response($str = NULL) {
00388   $data = array();
00389
00390   if (isset($_SERVER['REQUEST_METHOD'])) {
00391     $data = _openid_get_params($_SERVER['QUERY_STRING']);
00392
00393     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
00394       $str = file_get_contents('php://input');
00395
00396       $post = array();
00397       if ($str !== false) {
00398         $post = _openid_get_params($str);
00399       }
00400
00401       $data = array_merge($data, $post);
00402     }
00403   }
00404
00405   return $data;
00406 }
00407
00408 function _openid_get_params($str) {
00409   $chunks = explode("&", $str);
00410
00411   $data = array();
00412   foreach ($chunks as $chunk) {
00413     $parts = explode("=", $chunk, 2);
00414
00415     if (count($parts) == 2) {
00416       list($k, $v) = $parts;
00417       $data[$k] = urldecode($v);
00418     }
00419   }
00420   return $data;
00421 }
00422
00426 if (!function_exists('bcpowmod')) {
00427   function bcpowmod($base, $exp, $mod) {
00428     $square = bcmod($base, $mod);
00429     $result = 1;
00430     while (bccomp($exp, 0) > 0) {
00431       if (bcmod($exp, 2)) {
00432         $result = bcmod(bcmul($result, $square), $mod);
00433       }
00434       $square = bcmod(bcmul($square, $square), $mod);
00435       $exp = bcdiv($exp, 2);
00436     }
00437     return $result;
00438   }
00439 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/openid/openid.install Source File

modules » openid

openid.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: openid.install,v 1.3 2007/10/10 11:39:33 goba Exp $
00003
00007 function openid_install() {
00008   // Create table.
00009   drupal_install_schema('openid');
00010 }
00011
00015 function openid_uninstall() {
00016   // Remove table.
00017   drupal_uninstall_schema('openid');
00018 }
00019
00023 function openid_schema() {
00024   $schema['openid_association'] = array(
00025     'description' => t('Stores temporary shared key association information for OpenID authentication.'),
00026     'fields' => array(
00027       'idp_endpoint_uri' => array(
00028         'type' => 'varchar',
00029         'length' => 255,
00030         'description' => t('URI of the OpenID Provider endpoint.'),
00031       ),
00032       'assoc_handle' => array(
00033         'type' => 'varchar',
00034         'length' => 255,
00035         'not null' => TRUE,
00036         'description' => t('Primary Key: Used to refer to this association in subsequent messages.'),
00037       ),
00038       'assoc_type' => array(
00039         'type' => 'varchar',
00040         'length' => 32,
00041         'description' => t('The signature algorithm used: one of HMAC-SHA1 or HMAC-SHA256.'),
00042       ),
00043       'session_type' => array(
00044         'type' => 'varchar',
00045         'length' => 32,
00046         'description' => t('Valid association session types: "no-encryption", "DH-SHA1", and "DH-SHA256".'),
00047       ),
00048       'mac_key' => array(
00049         'type' => 'varchar',
00050         'length' => 255,
00051         'description' => t('The MAC key (shared secret) for this association.'),
00052       ),
00053       'created' => array(
00054         'type' => 'int',
00055         'not null' => TRUE,
00056         'default' => 0,
00057         'description' => t('UNIX timestamp for when the association was created.'),
00058       ),
00059       'expires_in' => array(
00060         'type' => 'int',
00061         'not null' => TRUE,
00062         'default' => 0,
00063         'description' => t('The lifetime, in seconds, of this association.'),
00064       ),
00065     ),
00066     'primary key' => array('assoc_handle'),
00067   );
00068
00069   return $schema;
00070 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/openid/openid.module Source File

modules » openid

openid.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: openid.module,v 1.19 2008/01/30 22:11:22 goba Exp $
00003
00012 function openid_menu() {
00013   $items['openid/authenticate'] = array(
00014     'title' => 'OpenID Login',
00015     'page callback' => 'openid_authentication_page',
00016     'access callback' => 'user_is_anonymous',
00017     'type' => MENU_CALLBACK,
00018     'file' => 'openid.pages.inc',
00019   );
00020   $items['user/%user/openid'] = array(
00021     'title' => 'OpenID identities',
00022     'page callback' => 'openid_user_identities',
00023     'page arguments' => array(1),
00024     'access callback' => 'user_edit_access',
00025     'access arguments' => array(1),
00026     'type' => MENU_LOCAL_TASK,
00027     'file' => 'openid.pages.inc',
00028   );
00029   $items['user/%user/openid/delete'] = array(
00030     'title' => 'Delete OpenID',
00031     'page callback' => 'openid_user_delete',
00032     'page arguments' => array(1),
00033     'type' => MENU_CALLBACK,
00034     'file' => 'openid.pages.inc',
00035   );
00036   return $items;
00037 }
00038
00042 function openid_help($path, $arg) {
00043   switch ($path) {
00044
00045   case 'user/%/openid':
00046       $output = '<p>'. t('This site supports <a href="@openid-net">OpenID</a>, a secure way to log into many websites using a single username and password. OpenID can reduce the necessity of managing many usernames and passwords for many websites.', array('@openid-net' => url('http://openid.net'))) .'</p>';
00047       $output .= '<p>'. t('To use OpenID you must first establish an identity on a public or private OpenID server. If you do not have an OpenID and would like one, look into one of the <a href="@openid-providers">free public providers</a>. You can find out more about OpenID at <a href="@openid-net">this website</a>.', array('@openid-providers' => url('http://openid.net/wiki/index.php/OpenIDServers'), '@openid-net' => url('http://openid.net'))) .'</p>';
00048       $output .= '<p>'. t('If you already have an OpenID, enter the URL to your OpenID server below (e.g. myusername.openidprovider.com). Next time you login, you will be able to use this URL instead of a regular username and password. You can have multiple OpenID servers if you like; just keep adding them here.') .'</p>';
00049       return $output;
00050
00051     case 'admin/help#openid':
00052       $output = '<p>'. t('OpenID is a secure method for logging into many websites with a single username and password. It does not require special software, and it does not share passwords with any site to which it is associated; including your site.') .'</p>';
00053       $output .= '<p>'. t('Users can create accounts using their OpenID, assign one or more OpenIDs to an existing account, and log in using an OpenID. This lowers the barrier to registration, which is good for the site, and offers convenience and security to the users. OpenID is not a trust system, so email verification is still necessary. The benefit stems from the fact that users can have a single password that they can use on many websites. This means they can easily update their single password from a centralized location, rather than having to change dozens of passwords individually.') .'</p>';
00054       $output .= '<p>'. t('The basic concept is as follows: A user has an account on an OpenID server. This account provides them with a unique URL (such as myusername.openidprovider.com). When the user comes to your site, they are presented with the option of entering this URL. Your site then communicates with the OpenID server, asking it to verify the identity of the user. If the user is logged into their OpenID server, the server communicates back to your site, verifying the user. If they are not logged in, the OpenID server will ask the user for their password. At no point does your site record, or need to record the user\'s password.') .'</p>';
00055       $output .= '<p>'. t('More information on OpenID is available at <a href="@openid-net">OpenID.net</a>.', array('@openid-net' => url('http://openid.net'))) .'</p>';
00056       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@handbook">OpenID module</a>.', array('@handbook' => 'http://drupal.org/handbook/modules/openid')) .'</p>';
00057       return $output;
00058   }
00059 }
00060
00064 function openid_user($op, &$edit, &$account, $category = NULL) {
00065   if ($op == 'insert' && isset($_SESSION['openid']['values'])) {
00066     // The user has registered after trying to login via OpenID.
00067     if (variable_get('user_email_verification', TRUE)) {
00068       drupal_set_message(t('Once you have verified your email address, you may log in via OpenID.'));
00069     }
00070     unset($_SESSION['openid']);
00071   }
00072 }
00073
00077 function openid_form_alter(&$form, $form_state, $form_id) {
00078   if ($form_id == 'user_login_block' || $form_id == 'user_login') {
00079     drupal_add_css(drupal_get_path('module', 'openid') .'/openid.css', 'module');
00080     drupal_add_js(drupal_get_path('module', 'openid') .'/openid.js');
00081     if (!empty($form_state['post']['openid_identifier'])) {
00082       $form['name']['#required'] = FALSE;
00083       $form['pass']['#required'] = FALSE;
00084       unset($form['#submit']);
00085       $form['#validate'] = array('openid_login_validate');
00086     }
00087
00088     $items = array();
00089     $items[] = array(
00090       'data' => l(t('Log in using OpenID'), '#'),
00091       'class' => 'openid-link',
00092     );
00093     $items[] = array(
00094       'data' => l(t('Cancel OpenID login'), '#'),
00095       'class' => 'user-link',
00096     );
00097
00098     $form['openid_links'] = array(
00099       '#value' => theme('item_list', $items),
00100       '#weight' => 1,
00101     );
00102
00103     $form['links']['#weight'] = 2;
00104
00105     $form['openid_identifier'] = array(
00106       '#type' => 'textfield',
00107       '#title' => t('Log in using OpenID'),
00108       '#size' => ($form_id == 'user_login') ? 58 : 13,
00109       '#maxlength' => 255,
00110       '#weight' => -1,
00111       '#description' => l(t('What is OpenID?'), 'http://openid.net/', array('external' => TRUE)),
00112     );
00113     $form['openid.return_to'] = array('#type' => 'hidden', '#value' => url('openid/authenticate', array('absolute' => TRUE, 'query' => drupal_get_destination())));
00114   }
00115   elseif ($form_id == 'user_register' && isset($_SESSION['openid'])) {
00116     // We were unable to auto-register a new user. Prefill the registration
00117     // form with the values we have.
00118     $form['name']['#default_value'] = $_SESSION['openid']['values']['name'];
00119     $form['mail']['#default_value'] = $_SESSION['openid']['values']['mail'];
00120     // If user_email_verification is off, hide the password field and just fill
00121     // with random password to avoid confusion.
00122     if (!variable_get('user_email_verification', TRUE)) {
00123       $form['pass']['#type'] = 'hidden';
00124       $form['pass']['#value'] = user_password();
00125     }
00126     $form['auth_openid'] = array('#type' => 'hidden', '#value' => $_SESSION['openid']['values']['auth_openid']);
00127   }
00128   return $form;
00129 }
00130
00134 function openid_login_validate($form, &$form_state) {
00135   $return_to = $form_state['values']['openid.return_to'];
00136   if (empty($return_to)) {
00137     $return_to = url('', array('absolute' => TRUE));
00138   }
00139
00140   openid_begin($form_state['values']['openid_identifier'], $return_to, $form_state['values']);
00141 }
00142
00153 function openid_begin($claimed_id, $return_to = '', $form_values = array()) {
00154   module_load_include('inc', 'openid');
00155
00156   $claimed_id = _openid_normalize($claimed_id);
00157
00158   $services = openid_discovery($claimed_id);
00159   if (count($services) == 0) {
00160     form_set_error('openid_identifier', t('Sorry, that is not a valid OpenID. Please ensure you have spelled your ID correctly.'));
00161     return;
00162   }
00163
00164   // Store discovered information in the users' session so we don't have to rediscover.
00165   $_SESSION['openid']['service'] = $services[0];
00166   // Store the claimed id
00167   $_SESSION['openid']['claimed_id'] = $claimed_id;
00168   // Store the login form values so we can pass them to
00169   // user_exteral_login later.
00170   $_SESSION['openid']['user_login_values'] = $form_values;
00171
00172   $op_endpoint = $services[0]['uri'];
00173   // If bcmath is present, then create an association
00174   $assoc_handle = '';
00175   if (function_exists('bcadd')) {
00176     $assoc_handle = openid_association($op_endpoint);
00177   }
00178
00179   // Now that there is an association created, move on
00180   // to request authentication from the IdP
00181   // First check for LocalID. If not found, check for Delegate. Fall
00182   // back to $claimed_id if neither is found.
00183   if (!empty($services[0]['localid'])) {
00184     $identity = $services[0]['localid'];
00185   }
00186   else if (!empty($services[0]['delegate'])) {
00187     $identity = $services[0]['delegate'];
00188   }
00189   else {
00190     $identity = $claimed_id;
00191   }
00192
00193   if (isset($services[0]['types']) && is_array($services[0]['types']) && in_array(OPENID_NS_2_0 .'/server', $services[0]['types'])) {
00194     $identity = 'http://specs.openid.net/auth/2.0/identifier_select';
00195   }
00196   $authn_request = openid_authentication_request($claimed_id, $identity, $return_to, $assoc_handle, $services[0]['version']);
00197
00198   if ($services[0]['version'] == 2) {
00199     openid_redirect($op_endpoint, $authn_request);
00200   }
00201   else {
00202     openid_redirect_http($op_endpoint, $authn_request);
00203   }
00204 }
00205
00215 function openid_complete($response = array()) {
00216   module_load_include('inc', 'openid');
00217
00218   if (count($response) == 0) {
00219     $response = _openid_response();
00220   }
00221
00222   // Default to failed response
00223   $response['status'] = 'failed';
00224   if (isset($_SESSION['openid']['service']['uri']) && isset($_SESSION['openid']['claimed_id'])) {
00225     $service = $_SESSION['openid']['service'];
00226     $claimed_id = $_SESSION['openid']['claimed_id'];
00227     unset($_SESSION['openid']['service']);
00228     unset($_SESSION['openid']['claimed_id']);
00229     if (isset($response['openid.mode'])) {
00230       if ($response['openid.mode'] == 'cancel') {
00231         $response['status'] = 'cancel';
00232       }
00233       else {
00234         if (openid_verify_assertion($service['uri'], $response)) {
00235           // If the returned claimed_id is different from the session claimed_id,
00236           // then we need to do discovery and make sure the op_endpoint matches.
00237           if ($service['version'] == 2 && $response['openid.claimed_id'] != $claimed_id) {
00238             $disco = openid_discovery($response['openid.claimed_id']);
00239             if ($disco[0]['uri'] != $service['uri']) {
00240               return $response;
00241             }
00242           }
00243           else {
00244             $response['openid.claimed_id'] = $claimed_id;
00245           }
00246           $response['status'] = 'success';
00247         }
00248       }
00249     }
00250   }
00251   return $response;
00252 }
00253
00262 function openid_discovery($claimed_id) {
00263   module_load_include('inc', 'openid');
00264   module_load_include('inc', 'openid', 'xrds');
00265
00266   $services = array();
00267
00268   $xrds_url = $claimed_id;
00269   if (_openid_is_xri($claimed_id)) {
00270     $xrds_url = 'http://xri.net/'. $claimed_id;
00271   }
00272   $url = @parse_url($xrds_url);
00273   if ($url['scheme'] == 'http' || $url['scheme'] == 'https') {
00274     // For regular URLs, try Yadis resolution first, then HTML-based discovery
00275     $headers = array('Accept' => 'application/xrds+xml');
00276     $result = drupal_http_request($xrds_url, $headers);
00277
00278     if (!isset($result->error)) {
00279       if (isset($result->headers['Content-Type']) && preg_match("/application\/xrds\+xml/", $result->headers['Content-Type'])) {
00280         // Parse XML document to find URL
00281         $services = xrds_parse($result->data);
00282       }
00283       else {
00284         $xrds_url = NULL;
00285         if (isset($result->headers['X-XRDS-Location'])) {
00286           $xrds_url = $result->headers['X-XRDS-Location'];
00287         }
00288         else {
00289           // Look for meta http-equiv link in HTML head
00290           $xrds_url = _openid_meta_httpequiv('X-XRDS-Location', $result->data);
00291         }
00292         if (!empty($xrds_url)) {
00293           $headers = array('Accept' => 'application/xrds+xml');
00294           $xrds_result = drupal_http_request($xrds_url, $headers);
00295           if (!isset($xrds_result->error)) {
00296             $services = xrds_parse($xrds_result->data);
00297           }
00298         }
00299       }
00300
00301       // Check for HTML delegation
00302       if (count($services) == 0) {
00303         // Look for 2.0 links
00304         $uri = _openid_link_href('openid2.provider', $result->data);
00305         $delegate = _openid_link_href('openid2.local_id', $result->data);
00306         $version = 2;
00307
00308         // 1.0 links
00309         if (empty($uri)) {
00310           $uri = _openid_link_href('openid.server', $result->data);
00311           $delegate = _openid_link_href('openid.delegate', $result->data);
00312           $version = 1;
00313         }
00314         if (!empty($uri)) {
00315           $services[] = array('uri' => $uri, 'delegate' => $delegate, 'version' => $version);
00316         }
00317       }
00318     }
00319   }
00320   if (!$services) {
00321     module_invoke('system', 'check_http_request');
00322   }
00323   return $services;
00324 }
00325
00333 function openid_association($op_endpoint) {
00334   module_load_include('inc', 'openid');
00335
00336   // Remove Old Associations:
00337   db_query("DELETE FROM {openid_association} WHERE created + expires_in < %d", time());
00338
00339   // Check to see if we have an association for this IdP already
00340   $assoc_handle = db_result(db_query("SELECT assoc_handle FROM {openid_association} WHERE idp_endpoint_uri = '%s'", $op_endpoint));
00341   if (empty($assoc_handle)) {
00342     $mod = OPENID_DH_DEFAULT_MOD;
00343     $gen = OPENID_DH_DEFAULT_GEN;
00344     $r = _openid_dh_rand($mod);
00345     $private = bcadd($r, 1);
00346     $public = bcpowmod($gen, $private, $mod);
00347
00348     // If there is no existing association, then request one
00349     $assoc_request = openid_association_request($public);
00350     $assoc_message = _openid_encode_message(_openid_create_message($assoc_request));
00351     $assoc_headers = array('Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8');
00352     $assoc_result = drupal_http_request($op_endpoint, $assoc_headers, 'POST', $assoc_message);
00353     if (isset($assoc_result->error)) {
00354       module_invoke('system', 'check_http_request');
00355       return FALSE;
00356     }
00357
00358     $assoc_response = _openid_parse_message($assoc_result->data);
00359     if (isset($assoc_response['mode']) && $assoc_response['mode'] == 'error') {
00360       module_invoke('system', 'check_http_request');
00361       return FALSE;
00362     }
00363
00364     if ($assoc_response['session_type'] == 'DH-SHA1') {
00365       $spub = _openid_dh_base64_to_long($assoc_response['dh_server_public']);
00366       $enc_mac_key = base64_decode($assoc_response['enc_mac_key']);
00367       $shared = bcpowmod($spub, $private, $mod);
00368       $assoc_response['mac_key'] = base64_encode(_openid_dh_xorsecret($shared, $enc_mac_key));
00369     }
00370     db_query("INSERT INTO {openid_association} (idp_endpoint_uri, session_type, assoc_handle, assoc_type, expires_in, mac_key, created) VALUES('%s', '%s', '%s', '%s', %d, '%s', %d)",
00371              $op_endpoint, $assoc_response['session_type'], $assoc_response['assoc_handle'], $assoc_response['assoc_type'], $assoc_response['expires_in'], $assoc_response['mac_key'], time());
00372
00373     $assoc_handle = $assoc_response['assoc_handle'];
00374   }
00375
00376   return $assoc_handle;
00377 }
00378
00384 function openid_authentication($response) {
00385   module_load_include('inc', 'openid');
00386
00387   $identity = $response['openid.claimed_id'];
00388
00389   $account = user_external_load($identity);
00390   if (isset($account->uid)) {
00391     if (!variable_get('user_email_verification', TRUE) || $account->login) {
00392       user_external_login($account, $_SESSION['openid']['user_login_values']);
00393     }
00394     else {
00395       drupal_set_message(t('You must validate your email address for this account before logging in via OpenID'));
00396     }
00397   }
00398   elseif (variable_get('user_register', 1)) {
00399     // Register new user
00400     $form_state['redirect'] = NULL;
00401     $form_state['values']['name'] = (empty($response['openid.sreg.nickname'])) ? $identity : $response['openid.sreg.nickname'];
00402     $form_state['values']['mail'] = (empty($response['openid.sreg.email'])) ? '' : $response['openid.sreg.email'];
00403     $form_state['values']['pass']  = user_password();
00404     $form_state['values']['status'] = variable_get('user_register', 1) == 1;
00405     $form_state['values']['response'] = $response;
00406     $form_state['values']['auth_openid'] = $identity;
00407     $form = drupal_retrieve_form('user_register', $form_state);
00408     drupal_prepare_form('user_register', $form, $form_state);
00409     drupal_validate_form('user_register', $form, $form_state);
00410     if (form_get_errors()) {
00411       // We were unable to register a valid new user, redirect to standard
00412       // user/register and prefill with the values we received.
00413       drupal_set_message(t('OpenID registration failed for the reasons listed. You may register now, or if you already have an account you can <a href="@login">log in</a> now and add your OpenID under "My Account"', array('@login' => url('user/login'))), 'error');
00414       $_SESSION['openid']['values'] = $form_state['values'];
00415       // We'll want to redirect back to the same place.
00416       $destination = drupal_get_destination();
00417       unset($_REQUEST['destination']);
00418       drupal_goto('user/register', $destination);
00419     }
00420     else {
00421       unset($form_state['values']['response']);
00422       $account = user_save('', $form_state['values']);
00423       // Terminate if an error occured during user_save().
00424       if (!$account) {
00425         drupal_set_message(t("Error saving user account."), 'error');
00426         drupal_goto();
00427       }
00428       user_external_login($account);
00429     }
00430     drupal_redirect_form($form, $form_state['redirect']);
00431   }
00432   else {
00433     drupal_set_message(t('Only site administrators can create new user accounts.'), 'error');
00434   }
00435   drupal_goto();
00436 }
00437
00438 function openid_association_request($public) {
00439   module_load_include('inc', 'openid');
00440
00441   $request = array(
00442     'openid.ns' => OPENID_NS_2_0,
00443     'openid.mode' => 'associate',
00444     'openid.session_type' => 'DH-SHA1',
00445     'openid.assoc_type' => 'HMAC-SHA1'
00446   );
00447
00448   if ($request['openid.session_type'] == 'DH-SHA1' || $request['openid.session_type'] == 'DH-SHA256') {
00449     $cpub = _openid_dh_long_to_base64($public);
00450     $request['openid.dh_consumer_public'] = $cpub;
00451   }
00452
00453   return $request;
00454 }
00455
00456 function openid_authentication_request($claimed_id, $identity, $return_to = '', $assoc_handle = '', $version = 2) {
00457   module_load_include('inc', 'openid');
00458
00459   $ns = ($version == 2) ? OPENID_NS_2_0 : OPENID_NS_1_0;
00460   $request =  array(
00461     'openid.ns' => $ns,
00462     'openid.mode' => 'checkid_setup',
00463     'openid.identity' => $identity,
00464     'openid.claimed_id' => $claimed_id,
00465     'openid.assoc_handle' => $assoc_handle,
00466     'openid.return_to' => $return_to,
00467   );
00468
00469   if ($version == 2) {
00470     $request['openid.realm'] = url('', array('absolute' => TRUE));
00471   }
00472   else {
00473     $request['openid.trust_root'] = $realm;
00474   }
00475
00476   // Simple Registration
00477   $request['openid.sreg.required'] = 'nickname,email';
00478   $request['openid.ns.sreg'] = "http://openid.net/extensions/sreg/1.1";
00479
00480   $request = array_merge($request, module_invoke_all('openid', 'request', $request));
00481
00482   return $request;
00483 }
00484
00493 function openid_verify_assertion($op_endpoint, $response) {
00494   module_load_include('inc', 'openid');
00495
00496   $valid = FALSE;
00497
00498   $association = db_fetch_object(db_query("SELECT * FROM {openid_association} WHERE assoc_handle = '%s'", $response['openid.assoc_handle']));
00499   if ($association && isset($association->session_type)) {
00500     $keys_to_sign = explode(',', $response['openid.signed']);
00501     $self_sig = _openid_signature($association, $response, $keys_to_sign);
00502     if ($self_sig == $response['openid.sig']) {
00503       $valid = TRUE;
00504     }
00505     else {
00506       $valid = FALSE;
00507     }
00508   }
00509   else {
00510     $request = $response;
00511     $request['openid.mode'] = 'check_authentication';
00512     $message = _openid_create_message($request);
00513     $headers = array('Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8');
00514     $result = drupal_http_request($op_endpoint, $headers, 'POST', _openid_encode_message($message));
00515     if (!isset($result->error)) {
00516       $response = _openid_parse_message($result->data);
00517       if (strtolower(trim($response['is_valid'])) == 'true') {
00518         $valid = TRUE;
00519       }
00520       else {
00521         $valid = FALSE;
00522       }
00523     }
00524   }
00525   if (!$valid) {
00526     module_invoke('system', 'check_http_request');
00527   }
00528   return $valid;
00529 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/openid/openid.pages.inc Source File

modules » openid

openid.pages.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: openid.pages.inc,v 1.5 2008/01/30 22:11:22 goba Exp $
00003
00012 function openid_authentication_page() {
00013   $result = openid_complete();
00014   switch ($result['status']) {
00015     case 'success':
00016       return openid_authentication($result);
00017     case 'failed':
00018       drupal_set_message(t('OpenID login failed.'), 'error');
00019       break;
00020     case 'cancel':
00021       drupal_set_message(t('OpenID login cancelled.'));
00022       break;
00023   }
00024   drupal_goto();
00025 }
00026
00030 function openid_user_identities($account) {
00031   drupal_set_title(check_plain($account->name));
00032   drupal_add_css(drupal_get_path('module', 'openid') .'/openid.css', 'module');
00033
00034   // Check to see if we got a response
00035   $result = openid_complete();
00036   if ($result['status'] == 'success') {
00037     $identity = $result['openid.claimed_id'];
00038     db_query("INSERT INTO {authmap} (uid, authname, module) VALUES (%d, '%s','openid')", $account->uid, $identity);
00039     drupal_set_message(t('Successfully added %identity', array('%identity' => $identity)));
00040   }
00041
00042   $header = array(t('OpenID'), t('Operations'));
00043   $rows = array();
00044
00045   $result = db_query("SELECT * FROM {authmap} WHERE module='openid' AND uid=%d", $account->uid);
00046   while ($identity = db_fetch_object($result)) {
00047     $rows[] = array($identity->authname, l(t('Delete'), 'user/'. $account->uid .'/openid/delete/'. $identity->aid));
00048   }
00049
00050   $output = theme('table', $header, $rows);
00051   $output .= drupal_get_form('openid_user_add');
00052   return $output;
00053 }
00054
00061 function openid_user_add() {
00062   $form['openid_identifier'] = array(
00063     '#type' => 'textfield',
00064     '#title' => t('OpenID'),
00065   );
00066   $form['submit'] = array('#type' => 'submit', '#value' => t('Add an OpenID'));
00067   return $form;
00068 }
00069
00070 function openid_user_add_validate($form, &$form_state) {
00071   // Check for existing entries.
00072   $claimed_id = _openid_normalize($form_state['values']['openid_identifier']);
00073   if (db_result(db_query("SELECT authname FROM {authmap} WHERE authname='%s'", $claimed_id))) {
00074     form_set_error('openid_identifier', t('That OpenID is already in use on this site.'));
00075   }
00076   else {
00077     $return_to = url('user/'. arg(1) .'/openid', array('absolute' => TRUE));
00078     openid_begin($form_state['values']['openid_identifier'], $return_to);
00079   }
00080 }
00081
00085 function openid_user_delete($account, $aid = 0) {
00086   db_query("DELETE FROM {authmap} WHERE uid=%d AND aid=%d AND module='openid'", $account->uid, $aid);
00087   if (db_affected_rows()) {
00088     drupal_set_message(t('OpenID deleted.'));
00089   }
00090   drupal_goto('user/'. $account->uid .'/openid');
00091 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/page_example.module Source File

docs » examples

page_example.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: page_example.module,v 1.13 2007/10/17 19:38:36 litwol Exp $
00003
00018 function page_example_help($path, $arg) {
00019   switch ($path) {
00020     case 'foo':
00021       // Here is some help text for a custom page.
00022       return t('This sentence contains all the letters in the English alphabet.');
00023   }
00024 }
00025
00034 function page_example_perm() {
00035   return array('access foo', 'access baz');
00036 }
00037
00066 function page_example_menu() {
00067   // This is the minimum information you can provide for a menu item.
00068   $items['foo'] = array(
00069     'title' => 'Foo',
00070     'page callback' => 'page_example_foo',
00071     'access arguments' => array('access foo'),
00072   );
00073
00074   // By using the MENU_CALLBACK type, we can register the callback for this
00075   // path but not have the item show up in the menu; the admin is not allowed
00076   // to enable the item in the menu, either.
00077   //
00078   // Notice that the 'page arguments' is an array of numbers. These will be
00079   // replaced with the corresponding parts of the menu path. In this case a 0
00080   // would be replaced by 'bar', a 1 by 'baz', and like wise 2 and 3 will be
00081   // replaced by what ever the user provides. These will be passed as arguments
00082   // to the page_example_baz() function.
00083   $items['bar/baz/%/%'] = array(
00084     'title' => 'Baz',
00085     'page callback' => 'page_example_baz',
00086     'page arguments' => array(2, 3),
00087     'access arguments' => array('access baz'),
00088     'type' => MENU_CALLBACK,
00089   );
00090
00091   return $items;
00092 }
00093
00105 function page_example_foo() {
00106   return '<p>'. t('The quick brown fox jumps over the lazy dog.') .'</p>';
00107 }
00108
00116 function page_example_baz($alice, $bob) {
00117   // Make sure you don't trust the URL to be safe! Always check for exploits.
00118   if (!is_numeric($alice) || !is_numeric($bob)) {
00119     // We will just show a standard "access denied" page in this case.
00120     return drupal_access_denied();
00121   }
00122
00123   $list[] = t("Alice's number was @number.", array('@number' => $alice));
00124   $list[] = t("Bob's number was @number.", array('@number' => $bob));
00125   $list[] = t('The total was @number.', array('@number' => $alice + $bob));
00126
00127   return theme('item_list', $list);
00128 }
00129
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/pager.inc Source File

includes

pager.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: pager.inc,v 1.63 2007/12/06 09:58:30 goba Exp $
00003
00051 function pager_query($query, $limit = 10, $element = 0, $count_query = NULL) {
00052   global $pager_page_array, $pager_total, $pager_total_items;
00053   $page = isset($_GET['page']) ? $_GET['page'] : '';
00054
00055   // Substitute in query arguments.
00056   $args = func_get_args();
00057   $args = array_slice($args, 4);
00058   // Alternative syntax for '...'
00059   if (isset($args[0]) && is_array($args[0])) {
00060     $args = $args[0];
00061   }
00062
00063   // Construct a count query if none was given.
00064   if (!isset($count_query)) {
00065     $count_query = preg_replace(array('/SELECT.*?FROM /As', '/ORDER BY .*/'), array('SELECT COUNT(*) FROM ', ''), $query);
00066   }
00067
00068   // Convert comma-separated $page to an array, used by other functions.
00069   $pager_page_array = explode(',', $page);
00070
00071   // We calculate the total of pages as ceil(items / limit).
00072   $pager_total_items[$element] = db_result(db_query($count_query, $args));
00073   $pager_total[$element] = ceil($pager_total_items[$element] / $limit);
00074   $pager_page_array[$element] = max(0, min((int)$pager_page_array[$element], ((int)$pager_total[$element]) - 1));
00075   return db_query_range($query, $args, $pager_page_array[$element] * $limit, $limit);
00076 }
00077
00085 function pager_get_querystring() {
00086   static $string = NULL;
00087   if (!isset($string)) {
00088     $string = drupal_query_string_encode($_REQUEST, array_merge(array('q', 'page'), array_keys($_COOKIE)));
00089   }
00090   return $string;
00091 }
00092
00115 function theme_pager($tags = array(), $limit = 10, $element = 0, $parameters = array(), $quantity = 9) {
00116   global $pager_page_array, $pager_total;
00117
00118   // Calculate various markers within this pager piece:
00119   // Middle is used to "center" pages around the current page.
00120   $pager_middle = ceil($quantity / 2);
00121   // current is the page we are currently paged to
00122   $pager_current = $pager_page_array[$element] + 1;
00123   // first is the first page listed by this pager piece (re quantity)
00124   $pager_first = $pager_current - $pager_middle + 1;
00125   // last is the last page listed by this pager piece (re quantity)
00126   $pager_last = $pager_current + $quantity - $pager_middle;
00127   // max is the maximum page number
00128   $pager_max = $pager_total[$element];
00129   // End of marker calculations.
00130
00131   // Prepare for generation loop.
00132   $i = $pager_first;
00133   if ($pager_last > $pager_max) {
00134     // Adjust "center" if at end of query.
00135     $i = $i + ($pager_max - $pager_last);
00136     $pager_last = $pager_max;
00137   }
00138   if ($i <= 0) {
00139     // Adjust "center" if at start of query.
00140     $pager_last = $pager_last + (1 - $i);
00141     $i = 1;
00142   }
00143   // End of generation loop preparation.
00144
00145   $li_first = theme('pager_first', (isset($tags[0]) ? $tags[0] : t('« first')), $limit, $element, $parameters);
00146   $li_previous = theme('pager_previous', (isset($tags[1]) ? $tags[1] : t('‹ previous')), $limit, $element, 1, $parameters);
00147   $li_next = theme('pager_next', (isset($tags[3]) ? $tags[3] : t('next ›')), $limit, $element, 1, $parameters);
00148   $li_last = theme('pager_last', (isset($tags[4]) ? $tags[4] : t('last »')), $limit, $element, $parameters);
00149
00150   if ($pager_total[$element] > 1) {
00151     if ($li_first) {
00152       $items[] = array(
00153         'class' => 'pager-first',
00154         'data' => $li_first,
00155       );
00156     }
00157     if ($li_previous) {
00158       $items[] = array(
00159         'class' => 'pager-previous',
00160         'data' => $li_previous,
00161       );
00162     }
00163
00164     // When there is more than one page, create the pager list.
00165     if ($i != $pager_max) {
00166       if ($i > 1) {
00167         $items[] = array(
00168           'class' => 'pager-ellipsis',
00169           'data' => '…',
00170         );
00171       }
00172       // Now generate the actual pager piece.
00173       for (; $i <= $pager_last && $i <= $pager_max; $i++) {
00174         if ($i < $pager_current) {
00175           $items[] = array(
00176             'class' => 'pager-item',
00177             'data' => theme('pager_previous', $i, $limit, $element, ($pager_current - $i), $parameters),
00178           );
00179         }
00180         if ($i == $pager_current) {
00181           $items[] = array(
00182             'class' => 'pager-current',
00183             'data' => $i,
00184           );
00185         }
00186         if ($i > $pager_current) {
00187           $items[] = array(
00188             'class' => 'pager-item',
00189             'data' => theme('pager_next', $i, $limit, $element, ($i - $pager_current), $parameters),
00190           );
00191         }
00192       }
00193       if ($i < $pager_max) {
00194         $items[] = array(
00195           'class' => 'pager-ellipsis',
00196           'data' => '…',
00197         );
00198       }
00199     }
00200     // End generation.
00201     if ($li_next) {
00202       $items[] = array(
00203         'class' => 'pager-next',
00204         'data' => $li_next,
00205       );
00206     }
00207     if ($li_last) {
00208       $items[] = array(
00209         'class' => 'pager-last',
00210         'data' => $li_last,
00211       );
00212     }
00213     return theme('item_list', $items, NULL, 'ul', array('class' => 'pager'));
00214   }
00215 }
00216
00217
00241 function theme_pager_first($text, $limit, $element = 0, $parameters = array()) {
00242   global $pager_page_array;
00243   $output = '';
00244
00245   // If we are anywhere but the first page
00246   if ($pager_page_array[$element] > 0) {
00247     $output = theme('pager_link', $text, pager_load_array(0, $element, $pager_page_array), $element, $parameters);
00248   }
00249
00250   return $output;
00251 }
00252
00271 function theme_pager_previous($text, $limit, $element = 0, $interval = 1, $parameters = array()) {
00272   global $pager_page_array;
00273   $output = '';
00274
00275   // If we are anywhere but the first page
00276   if ($pager_page_array[$element] > 0) {
00277     $page_new = pager_load_array($pager_page_array[$element] - $interval, $element, $pager_page_array);
00278
00279     // If the previous page is the first page, mark the link as such.
00280     if ($page_new[$element] == 0) {
00281       $output = theme('pager_first', $text, $limit, $element, $parameters);
00282     }
00283     // The previous page is not the first page.
00284     else {
00285       $output = theme('pager_link', $text, $page_new, $element, $parameters);
00286     }
00287   }
00288
00289   return $output;
00290 }
00291
00310 function theme_pager_next($text, $limit, $element = 0, $interval = 1, $parameters = array()) {
00311   global $pager_page_array, $pager_total;
00312   $output = '';
00313
00314   // If we are anywhere but the last page
00315   if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
00316     $page_new = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array);
00317     // If the next page is the last page, mark the link as such.
00318     if ($page_new[$element] == ($pager_total[$element] - 1)) {
00319       $output = theme('pager_last', $text, $limit, $element, $parameters);
00320     }
00321     // The next page is not the last page.
00322     else {
00323       $output = theme('pager_link', $text, $page_new, $element, $parameters);
00324     }
00325   }
00326
00327   return $output;
00328 }
00329
00346 function theme_pager_last($text, $limit, $element = 0, $parameters = array()) {
00347   global $pager_page_array, $pager_total;
00348   $output = '';
00349
00350   // If we are anywhere but the last page
00351   if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
00352     $output = theme('pager_link', $text, pager_load_array($pager_total[$element] - 1, $element, $pager_page_array), $element, $parameters);
00353   }
00354
00355   return $output;
00356 }
00357
00358
00375 function theme_pager_link($text, $page_new, $element, $parameters = array(), $attributes = array()) {
00376   $page = isset($_GET['page']) ? $_GET['page'] : '';
00377   if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
00378     $parameters['page'] = $new_page;
00379   }
00380
00381   $query = array();
00382   if (count($parameters)) {
00383     $query[] = drupal_query_string_encode($parameters, array());
00384   }
00385   $querystring = pager_get_querystring();
00386   if ($querystring != '') {
00387     $query[] = $querystring;
00388   }
00389
00390   // Set each pager link title
00391   if (!isset($attributes['title'])) {
00392     static $titles = NULL;
00393     if (!isset($titles)) {
00394       $titles = array(
00395         t('« first') => t('Go to first page'),
00396         t('‹ previous') => t('Go to previous page'),
00397         t('next ›') => t('Go to next page'),
00398         t('last »') => t('Go to last page'),
00399       );
00400     }
00401     if (isset($titles[$text])) {
00402       $attributes['title'] = $titles[$text];
00403     }
00404     else if (is_numeric($text)) {
00405       $attributes['title'] = t('Go to page @number', array('@number' => $text));
00406     }
00407   }
00408
00409   return l($text, $_GET['q'], array('attributes' => $attributes, 'query' => count($query) ? implode('&', $query) : NULL));
00410 }
00411
00422 function pager_load_array($value, $element, $old_array) {
00423   $new_array = $old_array;
00424   // Look for empty elements.
00425   for ($i = 0; $i < $element; $i++) {
00426     if (!$new_array[$i]) {
00427       // Load found empty element with 0.
00428       $new_array[$i] = 0;
00429     }
00430   }
00431   // Update the changed element.
00432   $new_array[$element] = (int)$value;
00433   return $new_array;
00434 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: Page Index

Related Pages

Here is a list of all related documentation pages:
  • Todo List
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/path/path.admin.inc Source File

modules » path

path.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: path.admin.inc,v 1.7 2008/01/08 10:35:42 goba Exp $
00003
00014 function path_admin_overview($keys = NULL) {
00015   // Add the filter form above the overview table.
00016   $output = drupal_get_form('path_admin_filter_form', $keys);
00017   // Enable language column if locale is enabled or if we have any alias with language
00018   $count = db_result(db_query("SELECT COUNT(*) FROM {url_alias} WHERE language != ''"));
00019   $multilanguage = (module_exists('locale') || $count);
00020
00021   if ($keys) {
00022     // Replace wildcards with MySQL/PostgreSQL wildcards.
00023     $keys = preg_replace('!\*+!', '%', $keys);
00024     $sql = "SELECT * FROM {url_alias} WHERE dst LIKE '%%%s%%'";
00025   }
00026   else {
00027     $sql = 'SELECT * FROM {url_alias}';
00028   }
00029   $header = array(
00030     array('data' => t('Alias'), 'field' => 'dst', 'sort' => 'asc'),
00031     array('data' => t('System'), 'field' => 'src'),
00032     array('data' => t('Operations'), 'colspan' => '2')
00033   );
00034   if ($multilanguage) {
00035     $header[3] = $header[2];
00036     $header[2] = array('data' => t('Language'), 'field' => 'language');
00037   }
00038   $sql .= tablesort_sql($header);
00039   $result = pager_query($sql, 50, 0 , NULL, $keys);
00040
00041   $rows = array();
00042   $destination = drupal_get_destination();
00043   while ($data = db_fetch_object($result)) {
00044     $row = array(check_plain($data->dst), check_plain($data->src), l(t('edit'), "admin/build/path/edit/$data->pid", array('query' => $destination)), l(t('delete'), "admin/build/path/delete/$data->pid", array('query' => $destination)));
00045     if ($multilanguage) {
00046       $row[4] = $row[3];
00047       $row[3] = $row[2];
00048       $row[2] = module_invoke('locale', 'language_name', $data->language);
00049     }
00050     $rows[] = $row;
00051   }
00052
00053   if (empty($rows)) {
00054     $empty_message = $keys ? t('No URL aliases found.') : t('No URL aliases available.') ;
00055     $rows[] = array(array('data' => $empty_message, 'colspan' => ($multilanguage ? 5 : 4)));
00056   }
00057
00058   $output .= theme('table', $header, $rows);
00059   $output .= theme('pager', NULL, 50, 0);
00060
00061   return $output;
00062 }
00063
00067 function path_admin_edit($pid = 0) {
00068   if ($pid) {
00069     $alias = path_load($pid);
00070     drupal_set_title(check_plain($alias['dst']));
00071     $output = drupal_get_form('path_admin_form', $alias);
00072   }
00073   else {
00074     $output = drupal_get_form('path_admin_form');
00075   }
00076
00077   return $output;
00078 }
00079
00087 function path_admin_form(&$form_state, $edit = array('src' => '', 'dst' => '', 'language' => '', 'pid' => NULL)) {
00088
00089   $form['#alias'] = $edit;
00090
00091   $form['src'] = array(
00092     '#type' => 'textfield',
00093     '#title' => t('Existing system path'),
00094     '#default_value' => $edit['src'],
00095     '#maxlength' => 64,
00096     '#size' => 45,
00097     '#description' => t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1+2.'),
00098     '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
00099     '#required' => TRUE,
00100   );
00101   $form['dst'] = array(
00102     '#type' => 'textfield',
00103     '#title' => t('Path alias'),
00104     '#default_value' => $edit['dst'],
00105     '#maxlength' => 64,
00106     '#size' => 45,
00107     '#description' => t('Specify an alternative path by which this data can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
00108     '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
00109     '#required' => TRUE,
00110   );
00111   // This will be a hidden value unless locale module is enabled
00112   $form['language'] = array(
00113     '#type' => 'value',
00114     '#value' => $edit['language']
00115   );
00116   if ($edit['pid']) {
00117     $form['pid'] = array('#type' => 'hidden', '#value' => $edit['pid']);
00118     $form['submit'] = array('#type' => 'submit', '#value' => t('Update alias'));
00119   }
00120   else {
00121     $form['submit'] = array('#type' => 'submit', '#value' => t('Create new alias'));
00122   }
00123
00124   return $form;
00125 }
00126
00127
00131 function path_admin_form_validate($form, &$form_state) {
00132   $src = $form_state['values']['src'];
00133   $dst = $form_state['values']['dst'];
00134   $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0;
00135   // Language is only set if locale module is enabled, otherwise save for all languages.
00136   $language = isset($form_state['values']['language']) ? $form_state['values']['language'] : '';
00137
00138   if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE pid != %d AND dst = '%s' AND language = '%s'", $pid, $dst, $language))) {
00139     form_set_error('dst', t('The alias %alias is already in use in this language.', array('%alias' => $dst)));
00140   }
00141   $item = menu_get_item($src);
00142   if (!$item || !$item['access']) {
00143     form_set_error('src', t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $src)));
00144   }
00145 }
00146
00150 function path_admin_form_submit($form, &$form_state) {
00151   // Language is only set if locale module is enabled
00152   path_set_alias($form_state['values']['src'], $form_state['values']['dst'], isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0, isset($form_state['values']['language']) ? $form_state['values']['language'] : '');
00153
00154   drupal_set_message(t('The alias has been saved.'));
00155   $form_state['redirect'] = 'admin/build/path';
00156   return;
00157 }
00158
00162 function path_admin_delete_confirm($form_state, $pid) {
00163   $path = path_load($pid);
00164   if (user_access('administer url aliases')) {
00165     $form['pid'] = array('#type' => 'value', '#value' => $pid);
00166     $output = confirm_form($form,
00167       t('Are you sure you want to delete path alias %title?', array('%title' => $path['dst'])),
00168       isset($_GET['destination']) ? $_GET['destination'] : 'admin/build/path');
00169   }
00170   return $output;
00171 }
00172
00176 function path_admin_delete_confirm_submit($form, &$form_state) {
00177   if ($form_state['values']['confirm']) {
00178     path_admin_delete($form_state['values']['pid']);
00179     $form_state['redirect'] = 'admin/build/path';
00180     return;
00181   }
00182 }
00183
00184
00191 function path_admin_filter_form(&$form_state, $keys = '') {
00192   $form['#attributes'] = array('class' => 'search-form');
00193   $form['basic'] = array('#type' => 'fieldset',
00194     '#title' => t('Filter aliases')
00195   );
00196   $form['basic']['inline'] = array('#prefix' => '<div class="container-inline">', '#suffix' => '</div>');
00197   $form['basic']['inline']['filter'] = array(
00198     '#type' => 'textfield',
00199     '#title' => '',
00200     '#default_value' => $keys,
00201     '#maxlength' => 64,
00202     '#size' => 25,
00203   );
00204   $form['basic']['inline']['submit'] = array(
00205     '#type' => 'submit',
00206     '#value' => t('Filter'),
00207     '#submit' => array('path_admin_filter_form_submit_filter'),
00208     );
00209   if ($keys) {
00210     $form['basic']['inline']['reset'] = array(
00211       '#type' => 'submit',
00212       '#value' => t('Reset'),
00213       '#submit' => array('path_admin_filter_form_submit_reset'),
00214     );
00215   }
00216   return $form;
00217 }
00218
00222 function path_admin_filter_form_submit_filter($form, &$form_state) {
00223   $form_state['redirect'] = 'admin/build/path/list/'. trim($form_state['values']['filter']);
00224 }
00225
00229 function path_admin_filter_form_submit_reset($form, &$form_state) {
00230   $form_state['redirect'] = 'admin/build/path/list';
00231 }
00232
00233
00237 function path_admin_filter_get_keys() {
00238   // Extract keys as remainder of path
00239   $path = explode('/', $_GET['q'], 5);
00240   return count($path) == 5 ? $path[4] : '';
00241 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/path.inc Source File

includes

path.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: path.inc,v 1.19 2007/11/04 16:42:45 goba Exp $
00003
00016 function drupal_init_path() {
00017   if (!empty($_GET['q'])) {
00018     $_GET['q'] = drupal_get_normal_path(trim($_GET['q'], '/'));
00019   }
00020   else {
00021     $_GET['q'] = drupal_get_normal_path(variable_get('site_frontpage', 'node'));
00022   }
00023 }
00024
00046 function drupal_lookup_path($action, $path = '', $path_language = '') {
00047   global $language;
00048   // $map is an array with language keys, holding arrays of Drupal paths to alias relations
00049   static $map = array(), $no_src = array(), $count;
00050
00051   $path_language = $path_language ? $path_language : $language->language;
00052
00053   // Use $count to avoid looking up paths in subsequent calls if there simply are no aliases
00054   if (!isset($count)) {
00055     $count = db_result(db_query('SELECT COUNT(pid) FROM {url_alias}'));
00056   }
00057
00058   if ($action == 'wipe') {
00059     $map = array();
00060     $no_src = array();
00061   }
00062   elseif ($count > 0 && $path != '') {
00063     if ($action == 'alias') {
00064       if (isset($map[$path_language][$path])) {
00065         return $map[$path_language][$path];
00066       }
00067       // Get the most fitting result falling back with alias without language
00068       $alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s' AND language IN('%s', '') ORDER BY language DESC", $path, $path_language));
00069       $map[$path_language][$path] = $alias;
00070       return $alias;
00071     }
00072     // Check $no_src for this $path in case we've already determined that there
00073     // isn't a path that has this alias
00074     elseif ($action == 'source' && !isset($no_src[$path_language][$path])) {
00075       // Look for the value $path within the cached $map
00076       $src = '';
00077       if (!isset($map[$path_language]) || !($src = array_search($path, $map[$path_language]))) {
00078         // Get the most fitting result falling back with alias without language
00079         if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s' AND language IN('%s', '') ORDER BY language DESC", $path, $path_language))) {
00080           $map[$path_language][$src] = $path;
00081         }
00082         else {
00083           // We can't record anything into $map because we do not have a valid
00084           // index and there is no need because we have not learned anything
00085           // about any Drupal path. Thus cache to $no_src.
00086           $no_src[$path_language][$path] = TRUE;
00087         }
00088       }
00089       return $src;
00090     }
00091   }
00092
00093   return FALSE;
00094 }
00095
00108 function drupal_get_path_alias($path, $path_language = '') {
00109   $result = $path;
00110   if ($alias = drupal_lookup_path('alias', $path, $path_language)) {
00111     $result = $alias;
00112   }
00113   return $result;
00114 }
00115
00128 function drupal_get_normal_path($path, $path_language = '') {
00129   $result = $path;
00130   if ($src = drupal_lookup_path('source', $path, $path_language)) {
00131     $result = $src;
00132   }
00133   if (function_exists('custom_url_rewrite_inbound')) {
00134     // Modules may alter the inbound request path by reference.
00135     custom_url_rewrite_inbound($result, $path, $path_language);
00136   }
00137   return $result;
00138 }
00139
00159 function arg($index = NULL, $path = NULL) {
00160   static $arguments;
00161
00162   if (!isset($path)) {
00163     $path = $_GET['q'];
00164   }
00165   if (!isset($arguments[$path])) {
00166     $arguments[$path] = explode('/', $path);
00167   }
00168   if (!isset($index)) {
00169     return $arguments[$path];
00170   }
00171   if (isset($arguments[$path][$index])) {
00172     return $arguments[$path][$index];
00173   }
00174 }
00175
00182 function drupal_get_title() {
00183   $title = drupal_set_title();
00184
00185   // during a bootstrap, menu.inc is not included and thus we cannot provide a title
00186   if (!isset($title) && function_exists('menu_get_active_title')) {
00187     $title = check_plain(menu_get_active_title());
00188   }
00189
00190   return $title;
00191 }
00192
00203 function drupal_set_title($title = NULL) {
00204   static $stored_title;
00205
00206   if (isset($title)) {
00207     $stored_title = $title;
00208   }
00209   return $stored_title;
00210 }
00211
00218 function drupal_is_front_page() {
00219   // As drupal_init_path updates $_GET['q'] with the 'site_frontpage' path,
00220   // we can check it against the 'site_frontpage' variable.
00221   return $_GET['q'] == drupal_get_normal_path(variable_get('site_frontpage', 'node'));
00222 }
00223
00235 function drupal_match_path($path, $patterns) {
00236   static $regexps;
00237
00238   if (!isset($regexps[$patterns])) {
00239     $regexps[$patterns] = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote($patterns, '/')) .')$/';
00240   }
00241   return preg_match($regexps[$patterns], $path);
00242 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/path/path.module Source File

modules » path

path.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: path.module,v 1.138 2008/02/03 19:20:35 goba Exp $
00003
00012 function path_help($path, $arg) {
00013   switch ($path) {
00014     case 'admin/help#path':
00015       $output = '<p>'. t('The path module allows you to specify aliases for Drupal URLs. Such aliases improve readability of URLs for your users and may help internet search engines to index your content more effectively. More than one alias may be created for a given page.') .'</p>';
00016       $output .= t('<p>Some examples of URL aliases are:</p>
00017 <ul>
00018 <li>user/login =&gt; login</li>
00019 <li>image/tid/16 =&gt; store</li>
00020 <li>taxonomy/term/7+19+20+21 =&gt; store/products/whirlygigs</li>
00021 <li>node/3 =&gt; contact</li>
00022 </ul>
00023 ');
00024       $output .= '<p>'. t('The path module enables appropriately permissioned users to specify an optional alias in all node input and editing forms, and provides an interface to view and edit all URL aliases. The two permissions related to URL aliasing are <em>administer url aliases</em> and <em>create url aliases</em>. ') .'</p>';
00025       $output .= '<p>'. t('This module also provides user-defined mass URL aliasing capabilities, which is useful if you wish to uniformly use URLs different from the default. For example, you may want to have your URLs presented in a different language. Access to the Drupal source code on the web server is required to set up mass URL aliasing. ') .'</p>';
00026       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@path">Path module</a>.', array('@path' => 'http://drupal.org/handbook/modules/path/')) .'</p>';
00027       return $output;
00028     case 'admin/build/path':
00029       return '<p>'. t("Drupal provides complete control over URLs through aliasing, which is often used to make URLs more readable or easy to remember. For example, the alias 'about' may be mapped onto the post at the system path 'node/1', creating a more meaningful URL. Each system path can have multiple aliases.") .'</p>';
00030     case 'admin/build/path/add':
00031       return '<p>'. t('Enter the path you wish to create the alias for, followed by the name of the new alias.') .'</p>';
00032   }
00033 }
00034
00038 function path_menu() {
00039   $items['admin/build/path'] = array(
00040     'title' => 'URL aliases',
00041     'description' => "Change your site's URL paths by aliasing them.",
00042     'page callback' => 'path_admin_overview',
00043     'access arguments' => array('administer url aliases'),
00044     'file' => 'path.admin.inc',
00045   );
00046   $items['admin/build/path/edit'] = array(
00047     'title' => 'Edit alias',
00048     'page callback' => 'path_admin_edit',
00049     'type' => MENU_CALLBACK,
00050     'file' => 'path.admin.inc',
00051   );
00052   $items['admin/build/path/delete'] = array(
00053     'title' => 'Delete alias',
00054     'page callback' => 'drupal_get_form',
00055     'page arguments' => array('path_admin_delete_confirm'),
00056     'type' => MENU_CALLBACK,
00057     'file' => 'path.admin.inc',
00058   );
00059   $items['admin/build/path/list'] = array(
00060     'title' => 'List',
00061     'type' => MENU_DEFAULT_LOCAL_TASK,
00062     'weight' => -10,
00063   );
00064   $items['admin/build/path/add'] = array(
00065     'title' => 'Add alias',
00066     'page callback' => 'path_admin_edit',
00067     'access arguments' => array('administer url aliases'),
00068     'type' => MENU_LOCAL_TASK,
00069     'file' => 'path.admin.inc',
00070   );
00071
00072   return $items;
00073 }
00074
00078 function path_admin_delete($pid = 0) {
00079   db_query('DELETE FROM {url_alias} WHERE pid = %d', $pid);
00080   drupal_set_message(t('The alias has been deleted.'));
00081 }
00082
00086 function path_set_alias($path = NULL, $alias = NULL, $pid = NULL, $language = '') {
00087   $path = urldecode($path);
00088   $alias = urldecode($alias);
00089   // First we check if we deal with an existing alias and delete or modify it based on pid.
00090   if ($pid) {
00091     // An existing alias.
00092     if (!$path || !$alias) {
00093       // Delete the alias based on pid.
00094       db_query('DELETE FROM {url_alias} WHERE pid = %d', $pid);
00095     }
00096     else {
00097       // Update the existing alias.
00098       db_query("UPDATE {url_alias} SET src = '%s', dst = '%s', language = '%s' WHERE pid = %d", $path, $alias, $language, $pid);
00099     }
00100   }
00101   else if ($path && $alias) {
00102     // Check for existing aliases.
00103     if ($alias == drupal_get_path_alias($path, $language)) {
00104       // There is already such an alias, neutral or in this language.
00105       // Update the alias based on alias; setting the language if not yet done.
00106       db_query("UPDATE {url_alias} SET src = '%s', dst = '%s', language = '%s' WHERE dst = '%s'", $path, $alias, $language, $alias);
00107     }
00108     else {
00109       // A new alias. Add it to the database.
00110       db_query("INSERT INTO {url_alias} (src, dst, language) VALUES ('%s', '%s', '%s')", $path, $alias, $language);
00111     }
00112   }
00113   else {
00114     // Delete the alias.
00115     if ($alias) {
00116       db_query("DELETE FROM {url_alias} WHERE dst = '%s'", $alias);
00117     }
00118     else {
00119       db_query("DELETE FROM {url_alias} WHERE src = '%s'", $path);
00120     }
00121   }
00122   drupal_clear_path_cache();
00123 }
00124
00125
00132 function path_nodeapi(&$node, $op, $arg) {
00133   // Permissions are required for everything except node loading.
00134   if (user_access('create url aliases') || user_access('administer url aliases') || ($op == 'load')) {
00135     $language = isset($node->language) ? $node->language : '';
00136     switch ($op) {
00137       case 'validate':
00138         $node->path = trim($node->path);
00139         if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s' AND language = '%s'", $node->path, "node/$node->nid", $language))) {
00140           form_set_error('path', t('The path is already in use.'));
00141         }
00142         break;
00143
00144       case 'load':
00145         $path = 'node/'. $node->nid;
00146         $alias = drupal_get_path_alias($path, $language);
00147         if ($path != $alias) {
00148           $node->path = $alias;
00149         }
00150         break;
00151
00152       case 'insert':
00153         // Don't try to insert if path is NULL. We may have already set
00154         // the alias ahead of time.
00155         if (isset($node->path)) {
00156           path_set_alias('node/'. $node->nid, $node->path, NULL, $language);
00157         }
00158         break;
00159
00160       case 'update':
00161         path_set_alias('node/'. $node->nid, isset($node->path) ? $node->path : NULL, isset($node->pid) ? $node->pid : NULL, $language);
00162         break;
00163
00164       case 'delete':
00165         $path = 'node/'. $node->nid;
00166         if (drupal_get_path_alias($path) != $path) {
00167           path_set_alias($path);
00168         }
00169         break;
00170     }
00171   }
00172 }
00173
00177 function path_form_alter(&$form, $form_state, $form_id) {
00178   if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
00179     $path = isset($form['#node']->path) ? $form['#node']->path : NULL;
00180     $form['path'] = array(
00181       '#type' => 'fieldset',
00182       '#title' => t('URL path settings'),
00183       '#collapsible' => TRUE,
00184       '#collapsed' => empty($path),
00185       '#access' => user_access('create url aliases'),
00186       '#weight' => 30,
00187     );
00188     $form['path']['path'] = array(
00189       '#type' => 'textfield',
00190       '#default_value' => $path,
00191       '#maxlength' => 250,
00192       '#collapsible' => TRUE,
00193       '#collapsed' => TRUE,
00194       '#description' => t('Optionally specify an alternative URL by which this node can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
00195     );
00196     if ($path) {
00197       $form['path']['pid'] = array(
00198         '#type' => 'value',
00199         '#value' => db_result(db_query("SELECT pid FROM {url_alias} WHERE dst = '%s' AND language = '%s'", $path, $form['#node']->language))
00200       );
00201     }
00202   }
00203 }
00204
00208 function path_perm() {
00209   return array('create url aliases', 'administer url aliases');
00210 }
00211
00215 function path_load($pid) {
00216   return db_fetch_array(db_query('SELECT * FROM {url_alias} WHERE pid = %d', $pid));
00217 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/php/php.install Source File

modules » php

php.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: php.install,v 1.1 2007/04/24 10:54:34 dries Exp $
00003
00007 function php_install() {
00008   $format_exists = db_result(db_query("SELECT COUNT(*) FROM {filter_formats} WHERE name = 'PHP code'"));
00009   // Add a PHP code input format, if it does not exist. Do this only for the
00010   // first install (or if the format has been manually deleted) as there is no
00011   // reliable method to identify the format in an uninstall hook or in
00012   // subsequent clean installs.
00013   if (!$format_exists) {
00014     db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('PHP code', '', 0)");
00015     $format = db_result(db_query("SELECT MAX(format) FROM {filter_formats}"));
00016
00017     // Enable the PHP evaluator filter.
00018     db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, 'php', 0, 0)", $format);
00019
00020     drupal_set_message(t('A !php-code input format has been created.', array('!php-code' => l('PHP code', 'admin/settings/filters/'. $format))));
00021   }
00022 }
00023
00027 function php_disable() {
00028   drupal_set_message(t('The PHP module has been disabled. Please note that any existing content that was using the PHP filter will now be visible in plain text. This might pose a security risk by exposing sensitive information, if any, used in the PHP code.'));
00029 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/php/php.module Source File

modules » php

php.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: php.module,v 1.8.2.1 2008/02/05 09:29:50 goba Exp $
00003
00013 function php_help($path, $arg) {
00014   switch ($path) {
00015     case 'admin/help#php':
00016       $output = '<p>'. t('The PHP filter adds the ability to include PHP code in posts. PHP is a general-purpose scripting language widely-used for web development; the content management system used by this website has been developed using PHP.') .'</p>';
00017       $output .= '<p>'. t('Through the PHP filter, users with the proper permission may include custom PHP code within a page of the site. While this is a powerful and flexible feature if used by a trusted user with PHP experience, it is a significant and dangerous security risk in the hands of a malicious user. Even a trusted user may accidentally compromise the site by entering malformed or incorrect PHP code. Only the most trusted users should be granted permission to use the PHP filter, and all PHP code added through the PHP filter should be carefully examined before use.') .'</p>';
00018       $output .= '<p>'. t('<a href="@drupal">Drupal.org</a> offers <a href="@php-snippets">some example PHP snippets</a>, or you can create your own with some PHP experience and knowledge of the Drupal system.', array('@drupal' => url('http://drupal.org'), '@php-snippets' => url('http://drupal.org/handbook/customization/php-snippets'))) .'</p>';
00019       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@php">PHP module</a>.', array('@php' => 'http://drupal.org/handbook/modules/php/')) .'</p>';
00020       return $output;
00021   }
00022 }
00023
00027 function php_filter_tips($delta, $format, $long = false) {
00028   global $base_url;
00029   if ($delta == 0) {
00030     switch ($long) {
00031       case 0:
00032         return t('You may post PHP code. You should include &lt;?php ?&gt; tags.');
00033       case 1:
00034         $output = '<h4>'. t('Using custom PHP code') .'</h4>';
00035         $output .= '<p>'. t('Custom PHP code may be embedded in some types of site content, including posts and blocks. While embedding PHP code inside a post or block is a powerful and flexible feature when used by a trusted user with PHP experience, it is a significant and dangerous security risk when used improperly. Even a small mistake when posting PHP code may accidentally compromise your site.') .'</p>';
00036         $output .= '<p>'. t('If you are unfamiliar with PHP, SQL, or Drupal, avoid using custom PHP code within posts. Experimenting with PHP may corrupt your database, render your site inoperable, or significantly compromise security.') .'</p>';
00037         $output .= '<p>'. t('Notes:') .'</p>';
00038         $output .= '<ul><li>'. t('Remember to double-check each line for syntax and logic errors <strong>before</strong> saving.') .'</li>';
00039         $output .= '<li>'. t('Statements must be correctly terminated with semicolons.') .'</li>';
00040         $output .= '<li>'. t('Global variables used within your PHP code retain their values after your script executes.') .'</li>';
00041         $output .= '<li>'. t('<code>register_globals</code> is <strong>turned off</strong>. If you need to use forms, understand and use the functions in <a href="@formapi">the Drupal Form API</a>.', array('@formapi' => url('http://api.drupal.org/api/group/form_api/6'))) .'</li>';
00042         $output .= '<li>'. t('Use a <code>print</code> or <code>return</code> statement in your code to output content.') .'</li>';
00043         $output .= '<li>'. t('Develop and test your PHP code using a separate test script and sample database before deploying on a production site.') .'</li>';
00044         $output .= '<li>'. t('Consider including your custom PHP code within a site-specific module or <code>template.php</code> file rather than embedding it directly into a post or block.') .'</li>';
00045         $output .= '<li>'. t('Be aware that the ability to embed PHP code within content is provided by the PHP Filter module. If this module is disabled or deleted, then blocks and posts with embedded PHP may display, rather than execute, the PHP code.') .'</li></ul>';
00046         $output .= '<p>'. t('A basic example: <em>Creating a "Welcome" block that greets visitors with a simple message.</em>') .'</p>';
00047         $output .= '<ul><li>'. t('<p>Add a custom block to your site, named "Welcome". With its input format set to "PHP code" (or another format supporting PHP input), add the following in the Block body:</p>
00048 <pre>
00049 print t(\'Welcome visitor! Thank you for visiting.\');
00050 </pre>') .'</li>';
00051         $output .= '<li>'. t('<p>To display the name of a registered user, use this instead:</p>
00052 <pre>
00053 global $user;
00054 if ($user->uid) {
00055   print t(\'Welcome @name! Thank you for visiting.\', array(\'@name\' => $user->name));
00056 }
00057 else {
00058   print t(\'Welcome visitor! Thank you for visiting.\');
00059 }
00060 </pre>') .'</li></ul>';
00061         $output .= '<p>'. t('<a href="@drupal">Drupal.org</a> offers <a href="@php-snippets">some example PHP snippets</a>, or you can create your own with some PHP experience and knowledge of the Drupal system.', array('@drupal' => url('http://drupal.org'), '@php-snippets' => url('http://drupal.org/handbook/customization/php-snippets'))) .'</p>';
00062         return $output;
00063     }
00064   }
00065 }
00066
00072 function php_filter($op, $delta = 0, $format = -1, $text = '') {
00073   switch ($op) {
00074     case 'list':
00075       return array(0 => t('PHP evaluator'));
00076     case 'no cache':
00077       // No caching for the PHP evaluator.
00078       return $delta == 0;
00079     case 'description':
00080       return t('Executes a piece of PHP code. The usage of this filter should be restricted to administrators only!');
00081     case 'process':
00082       return drupal_eval($text);
00083     default:
00084       return $text;
00085   }
00086 }
00087
00088
00089
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/engines/phptemplate/phptemplate.engine Source File

themes » engines » phptemplate

phptemplate.engine

Go to the documentation of this file.
00001 <?php
00002 // $Id: phptemplate.engine,v 1.69 2007/10/02 16:19:23 dries Exp $
00003
00009 function phptemplate_init($template) {
00010   $file = dirname($template->filename) .'/template.php';
00011   if (file_exists($file)) {
00012     include_once "./$file";
00013   }
00014 }
00015
00022 function phptemplate_theme($existing, $type, $theme, $path) {
00023   $templates = drupal_find_theme_functions($existing, array('phptemplate', $theme));
00024   $templates += drupal_find_theme_templates($existing, '.tpl.php', $path);
00025   return $templates;
00026 }
00027
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/ping/ping.module Source File

modules » ping

ping.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: ping.module,v 1.52 2007/12/19 17:45:42 goba Exp $
00003
00012 function ping_help($path, $arg) {
00013   switch ($path) {
00014     case 'admin/help#ping':
00015       $output = '<p>'. t('The ping module is useful for notifying interested sites that your site has changed. It automatically sends notifications, or "pings", to the <a href="@external-http-pingomatic-com">pingomatic</a> service about new or updated content. In turn, <a href="@external-http-pingomatic-com">pingomatic</a> notifies other popular services, including weblogs.com, Technorati, blo.gs, BlogRolling, Feedster.com, and Moreover.', array('@external-http-pingomatic-com' => 'http://pingomatic.com/')) .'</p>';
00016       $output .= '<p>'. t('The ping module requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))) .'</p>';
00017       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@ping">Ping module</a>.', array('@ping' => 'http://drupal.org/handbook/modules/ping/')) .'</p>';
00018       return $output;
00019   }
00020 }
00021
00027 function ping_cron() {
00028   global $base_url;
00029
00030   if (variable_get('site_name', 0)) {
00031     if (db_result(db_query("SELECT COUNT(*) FROM {node} WHERE status = 1 AND (created > '". variable_get('cron_last', time()) ."' OR changed > '". variable_get('cron_last', time()) ."')"))) {
00032       _ping_notify(variable_get('site_name', ''), $base_url);
00033     }
00034   }
00035 }
00036
00041 function _ping_notify($name, $url) {
00042   module_invoke_all('ping', $name, $url);
00043 }
00044
00050 function ping_ping($name = '', $url = '') {
00051
00052   $result = xmlrpc('http://rpc.pingomatic.com', 'weblogUpdates.ping', $name, $url);
00053
00054   if ($result === FALSE) {
00055     watchdog('directory ping', 'Failed to notify pingomatic.com (site).', array(), WATCHDOG_WARNING);
00056   }
00057 }
00058
00059
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/poll/poll-bar-block.tpl.php Source File

modules » poll

poll-bar-block.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: poll-bar-block.tpl.php,v 1.2 2007/08/07 08:39:35 goba Exp $
00003
00018 ?>
00019
00020 <div class="text"><?php print $title; ?></div>
00021 <div class="bar">
00022   <div style="width: <?php print $percentage; ?>%;" class="foreground"></div>
00023 </div>
00024 <div class="percent">
00025   <?php print $percentage; ?>%
00026 </div>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/poll/poll-bar.tpl.php Source File

modules » poll

poll-bar.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: poll-bar.tpl.php,v 1.2 2007/08/07 08:39:35 goba Exp $
00003
00018 ?>
00019
00020 <div class="text"><?php print $title; ?></div>
00021 <div class="bar">
00022   <div style="width: <?php print $percentage; ?>%;" class="foreground"></div>
00023 </div>
00024 <div class="percent">
00025   <?php print $percentage; ?>% (<?php print format_plural($votes, '1 vote', '@count votes'); ?>)
00026 </div>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/poll/poll-results-block.tpl.php Source File

modules » poll

poll-results-block.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: poll-results-block.tpl.php,v 1.2 2007/08/02 20:08:53 dries Exp $
00020 ?>
00021
00022 <div class="poll">
00023   <div class="title"><?php print $title ?></div>
00024   <?php print $results ?>
00025   <div class="total">
00026     <?php print t('Total votes: @votes', array('@votes' => $votes)); ?>
00027   </div>
00028 </div>
00029 <div class="links"><?php print $links; ?></div>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/poll/poll-results.tpl.php Source File

modules » poll

poll-results.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: poll-results.tpl.php,v 1.2 2007/08/07 08:39:35 goba Exp $
00003
00020 ?>
00021 <div class="poll">
00022   <?php print $results; ?>
00023   <div class="total">
00024     <?php print t('Total votes: @votes', array('@votes' => $votes)); ?>
00025   </div>
00026   <?php if (!empty($cancel_form)): ?>
00027     <?php print $cancel_form; ?>
00028   <?php endif; ?>
00029 </div>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/poll/poll-vote.tpl.php Source File

modules » poll

poll-vote.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: poll-vote.tpl.php,v 1.2 2007/08/07 08:39:35 goba Exp $
00003
00017 ?>
00018 <div class="poll">
00019   <div class="vote-form">
00020     <div class="choices">
00021       <?php if ($block): ?>
00022         <div class="title"><?php print $title; ?>:</div>
00023       <?php endif; ?>
00024       <?php print $choice; ?>
00025     </div>
00026     <?php print $vote; ?>
00027   </div>
00028   <?php // This is the 'rest' of the form, in case items have been added. ?>
00029   <?php print $rest ?>
00030 </div>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/poll/poll.install Source File

modules » poll

poll.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: poll.install,v 1.13 2007/12/18 12:59:21 dries Exp $
00003
00007 function poll_install() {
00008   // Create tables.
00009   drupal_install_schema('poll');
00010 }
00011
00015 function poll_uninstall() {
00016   // Remove tables.
00017   drupal_uninstall_schema('poll');
00018 }
00019
00023 function poll_schema() {
00024   $schema['poll'] = array(
00025     'description' => t('Stores poll-specific information for poll nodes.'),
00026     'fields' => array(
00027       'nid'     => array(
00028         'type' => 'int',
00029         'unsigned' => TRUE,
00030         'not null' => TRUE,
00031         'default' => 0,
00032         'description' => t("The poll's {node}.nid.")
00033         ),
00034       'runtime' => array(
00035         'type' => 'int',
00036         'not null' => TRUE,
00037         'default' => 0,
00038         'description' => t('The number of seconds past {node}.created during which the poll is open.')
00039         ),
00040       'active'  => array(
00041         'type' => 'int',
00042         'unsigned' => TRUE,
00043         'not null' => TRUE,
00044         'default' => 0,
00045         'description' => t('Boolean indicating whether or not the poll is open.'),
00046         ),
00047       ),
00048     'primary key' => array('nid'),
00049     );
00050
00051   $schema['poll_choices'] = array(
00052     'description' => t('Stores information about all choices for all {poll}s.'),
00053     'fields' => array(
00054       'chid'    => array(
00055         'type' => 'serial',
00056         'unsigned' => TRUE,
00057         'not null' => TRUE,
00058         'description' => t('Unique identifier for a poll choice.'),
00059         ),
00060       'nid'     => array(
00061         'type' => 'int',
00062         'unsigned' => TRUE,
00063         'not null' => TRUE,
00064         'default' => 0,
00065         'description' => t('The {node}.nid this choice belongs to.'),
00066         ),
00067       'chtext'  => array(
00068         'type' => 'varchar',
00069         'length' => 128,
00070         'not null' => TRUE,
00071         'default' => '',
00072         'description' => t('The text for this choice.'),
00073         ),
00074       'chvotes' => array(
00075         'type' => 'int',
00076         'not null' => TRUE,
00077         'default' => 0,
00078         'description' => t('The total number of votes this choice has received by all users.'),
00079         ),
00080       'chorder' => array(
00081         'type' => 'int',
00082         'not null' => TRUE,
00083         'default' => 0,
00084         'description' => t('The sort order of this choice among all choices for the same node.'),
00085         )
00086       ),
00087     'indexes' => array(
00088       'nid' => array('nid')
00089       ),
00090     'primary key' => array('chid'),
00091     );
00092
00093   $schema['poll_votes'] = array(
00094     'description' => t('Stores per-{users} votes for each {poll}.'),
00095     'fields' => array(
00096       'nid'      => array(
00097         'type' => 'int',
00098         'unsigned' => TRUE,
00099         'not null' => TRUE,
00100         'description' => t('The {poll} node this vote is for.'),
00101         ),
00102       'uid'      => array(
00103         'type' => 'int',
00104         'unsigned' => TRUE,
00105         'not null' => TRUE,
00106         'default' => 0,
00107         'description' => t('The {users}.uid this vote is from unless the voter was anonymous.'),
00108         ),
00109       'chorder'  => array(
00110         'type' => 'int',
00111         'not null' => TRUE,
00112         'default' => -1,
00113         'description' => t("The {users}'s vote for this poll."),
00114         ),
00115       'hostname' => array(
00116         'type' => 'varchar',
00117         'length' => 128,
00118         'not null' => TRUE,
00119         'default' => '',
00120         'description' => t('The IP address this vote is from unless the voter was logged in.'),
00121         ),
00122       ),
00123     'primary key' => array('nid', 'uid', 'hostname'),
00124     'indexes' => array(
00125       'hostname' => array('hostname'),
00126       'uid'      => array('uid'),
00127       ),
00128     );
00129
00130   return $schema;
00131 }
00132
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/poll/poll.module Source File

modules » poll

poll.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: poll.module,v 1.263 2008/01/15 07:57:46 dries Exp $
00003
00013 function poll_help($path, $arg) {
00014   switch ($path) {
00015     case 'admin/help#poll':
00016       $output = '<p>'. t('The poll module can be used to create simple polls for site users. A poll is a simple, multiple choice questionnaire which displays the cumulative results of the answers to the poll. Having polls on the site is a good way to receive feedback from community members.') .'</p>';
00017       $output .= '<p>'. t('When creating a poll, enter the question being posed, as well as the potential choices (and beginning vote counts for each choice). The status and duration (length of time the poll remains active for new votes) can also be specified. Use the <a href="@poll">poll</a> menu item to view all current polls. To vote in or view the results of a specific poll, click on the poll itself.', array('@poll' => url('poll'))) .'</p>';
00018       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@poll">Poll module</a>.', array('@poll' => 'http://drupal.org/handbook/modules/poll/')) .'</p>';
00019       return $output;
00020   }
00021 }
00022
00026 function poll_init() {
00027   drupal_add_css(drupal_get_path('module', 'poll') .'/poll.css');
00028 }
00029
00033 function poll_theme() {
00034   return array(
00035     'poll_vote' => array(
00036       'template' => 'poll-vote',
00037       'arguments' => array('form' => NULL),
00038     ),
00039     'poll_choices' => array(
00040       'arguments' => array('form' => NULL),
00041     ),
00042     'poll_results' => array(
00043       'template' => 'poll-results',
00044       'arguments' => array('raw_title' => NULL, 'results' => NULL, 'votes' => NULL, 'raw_links' => NULL, 'block' => NULL, 'nid' => NULL, 'vote' => NULL),
00045     ),
00046     'poll_bar' => array(
00047       'template' => 'poll-bar',
00048       'arguments' => array('title' => NULL, 'votes' => NULL, 'total_votes' => NULL, 'vote' => NULL, 'block' => NULL),
00049     ),
00050   );
00051 }
00052
00056 function poll_perm() {
00057   return array('create poll content', 'delete own poll content', 'delete any poll content', 'edit any poll content', 'edit own poll content', 'vote on polls', 'cancel own vote', 'inspect all votes');
00058 }
00059
00063 function poll_access($op, $node, $account) {
00064   switch ($op) {
00065     case 'create':
00066       return user_access('create poll content', $account);
00067     case 'update':
00068       return user_access('edit any poll content', $account) || (user_access('edit own poll content', $account) && ($node->uid == $account->uid));
00069     case 'delete':
00070       return user_access('delete any poll content', $account) || (user_access('delete own poll content', $account) && ($node->uid == $account->uid));
00071   }
00072 }
00073
00077 function poll_menu() {
00078   $items['poll'] = array(
00079     'title' => 'Polls',
00080     'page callback' => 'poll_page',
00081     'access arguments' => array('access content'),
00082     'type' => MENU_SUGGESTED_ITEM,
00083     'file' => 'poll.pages.inc',
00084   );
00085
00086   $items['node/%node/votes'] = array(
00087     'title' => 'Votes',
00088     'page callback' => 'poll_votes',
00089     'page arguments' => array(1),
00090     'access callback' => '_poll_menu_access',
00091     'access arguments' => array(1, 'inspect all votes', FALSE),
00092     'weight' => 3,
00093     'type' => MENU_LOCAL_TASK,
00094     'file' => 'poll.pages.inc',
00095   );
00096
00097   $items['node/%node/results'] = array(
00098     'title' => 'Results',
00099     'page callback' => 'poll_results',
00100     'page arguments' => array(1),
00101     'access callback' => '_poll_menu_access',
00102     'access arguments' => array(1, 'access content', TRUE),
00103     'weight' => 3,
00104     'type' => MENU_LOCAL_TASK,
00105     'file' => 'poll.pages.inc',
00106   );
00107
00108   $items['poll/js'] = array(
00109     'title' => 'Javascript Choice Form',
00110     'page callback' => 'poll_choice_js',
00111     'access arguments' => array('access content'),
00112     'type' => MENU_CALLBACK,
00113   );
00114
00115   return $items;
00116 }
00117
00121 function _poll_menu_access($node, $perm, $inspect_allowvotes) {
00122   return user_access($perm) && ($node->type == 'poll') && ($node->allowvotes || !$inspect_allowvotes);
00123 }
00124
00130 function poll_block($op = 'list', $delta = 0) {
00131   if (user_access('access content')) {
00132     if ($op == 'list') {
00133       $blocks[0]['info'] = t('Most recent poll');
00134       return $blocks;
00135     }
00136     else if ($op == 'view') {
00137       // Retrieve the latest poll.
00138       $sql = db_rewrite_sql("SELECT MAX(n.created) FROM {node} n INNER JOIN {poll} p ON p.nid = n.nid WHERE n.status = 1 AND p.active = 1");
00139       $timestamp = db_result(db_query($sql));
00140       if ($timestamp) {
00141         $poll = node_load(array('type' => 'poll', 'created' => $timestamp, 'status' => 1));
00142
00143         if ($poll->nid) {
00144           $poll = poll_view($poll, TRUE, FALSE, TRUE);
00145         }
00146       }
00147       $block['subject'] = t('Poll');
00148       $block['content'] = drupal_render($poll->content);
00149       return $block;
00150     }
00151   }
00152 }
00153
00159 function poll_cron() {
00160   $result = db_query('SELECT p.nid FROM {poll} p INNER JOIN {node} n ON p.nid = n.nid WHERE (n.created + p.runtime) < '. time() .' AND p.active = 1 AND p.runtime != 0');
00161   while ($poll = db_fetch_object($result)) {
00162     db_query("UPDATE {poll} SET active = 0 WHERE nid = %d", $poll->nid);
00163   }
00164 }
00165
00169 function poll_node_info() {
00170   return array(
00171     'poll' => array(
00172       'name' => t('Poll'),
00173       'module' => 'poll',
00174       'description' => t('A <em>poll</em> is a question with a set of possible responses. A <em>poll</em>, once created, automatically provides a simple running count of the number of votes received for each response.'),
00175       'title_label' => t('Question'),
00176       'has_body' => FALSE,
00177     )
00178   );
00179 }
00180
00184 function poll_form(&$node, $form_state) {
00185   global $user;
00186
00187   $admin = user_access('administer nodes') || user_access('edit any poll content') || (user_access('edit own poll content') && $user->uid == $node->uid);
00188
00189   $type = node_get_types('type', $node);
00190
00191   $form = array(
00192     '#cache' => TRUE,
00193   );
00194
00195   $form['title'] = array(
00196     '#type' => 'textfield',
00197     '#title' => check_plain($type->title_label),
00198     '#required' => TRUE,
00199     '#default_value' => $node->title,
00200     '#weight' => -5,
00201   );
00202
00203   if (isset($form_state['choice_count'])) {
00204     $choice_count = $form_state['choice_count'];
00205   }
00206   else {
00207     $choice_count = max(2, empty($node->choice) ? 2 : count($node->choice));
00208   }
00209
00210   // Add a wrapper for the choices and more button.
00211   $form['choice_wrapper'] = array(
00212     '#tree' => FALSE,
00213     '#weight' => -4,
00214     '#prefix' => '<div class="clear-block" id="poll-choice-wrapper">',
00215     '#suffix' => '</div>',
00216   );
00217
00218   // Container for just the poll choices.
00219   $form['choice_wrapper']['choice'] = array(
00220     '#prefix' => '<div id="poll-choices">',
00221     '#suffix' => '</div>',
00222     '#theme' => 'poll_choices',
00223   );
00224
00225   // Add the current choices to the form.
00226   for ($delta = 0; $delta < $choice_count; $delta++) {
00227     $text = isset($node->choice[$delta]['chtext']) ? $node->choice[$delta]['chtext'] : '';
00228     $votes = isset($node->choice[$delta]['chvotes']) ? $node->choice[$delta]['chvotes'] : 0;
00229
00230     $form['choice_wrapper']['choice'][$delta] = _poll_choice_form($delta, $text, $votes);
00231   }
00232
00233   // We name our button 'poll_more' to avoid conflicts with other modules using
00234   // AHAH-enabled buttons with the id 'more'.
00235   $form['choice_wrapper']['poll_more'] = array(
00236     '#type' => 'submit',
00237     '#value' => t('More choices'),
00238     '#description' => t("If the amount of boxes above isn't enough, click here to add more choices."),
00239     '#weight' => 1,
00240     '#submit' => array('poll_more_choices_submit'), // If no javascript action.
00241     '#ahah' => array(
00242       'path' => 'poll/js',
00243       'wrapper' => 'poll-choices',
00244       'method' => 'replace',
00245       'effect' => 'fade',
00246     ),
00247   );
00248
00249   // Poll attributes
00250   $_duration = array(0 => t('Unlimited')) + drupal_map_assoc(array(86400, 172800, 345600, 604800, 1209600, 2419200, 4838400, 9676800, 31536000), "format_interval");
00251   $_active = array(0 => t('Closed'), 1 => t('Active'));
00252
00253   if ($admin) {
00254     $form['settings'] = array(
00255       '#type' => 'fieldset',
00256       '#collapsible' => TRUE,
00257       '#title' => t('Poll settings'),
00258       '#weight' => -3,
00259     );
00260
00261     $form['settings']['active'] = array(
00262       '#type' => 'radios',
00263       '#title' => t('Poll status'),
00264       '#default_value' => isset($node->active) ? $node->active : 1,
00265       '#options' => $_active,
00266       '#description' => t('When a poll is closed, visitors can no longer vote for it.')
00267     );
00268   }
00269   $form['settings']['runtime'] = array(
00270     '#type' => 'select',
00271     '#title' => t('Poll duration'),
00272     '#default_value' => isset($node->runtime) ? $node->runtime : 0,
00273     '#options' => $_duration,
00274     '#description' => t('After this period, the poll will be closed automatically.'),
00275   );
00276
00277   return $form;
00278 }
00279
00285 function poll_more_choices_submit($form, &$form_state) {
00286   // Set the form to rebuild and run submit handlers.
00287   node_form_submit_build_node($form, $form_state);
00288
00289   // Make the changes we want to the form state.
00290   if ($form_state['values']['poll_more']) {
00291     $form_state['choice_count'] = count($form_state['values']['choice']) + 5;
00292   }
00293 }
00294
00295 function _poll_choice_form($delta, $value = '', $votes = 0) {
00296   $admin = user_access('administer nodes');
00297
00298   $form = array(
00299     '#tree' => TRUE,
00300   );
00301
00302   // We'll manually set the #parents property of these fields so that
00303   // their values appear in the $form_state['values']['choice'] array.
00304   $form['chtext'] = array(
00305     '#type' => 'textfield',
00306     '#title' => t('Choice @n', array('@n' => ($delta + 1))),
00307     '#default_value' => $value,
00308     '#parents' => array('choice', $delta, 'chtext'),
00309   );
00310
00311   if ($admin) {
00312     $form['chvotes'] = array(
00313       '#type' => 'textfield',
00314       '#title' => t('Votes for choice @n', array('@n' => ($delta + 1))),
00315       '#default_value' => $votes,
00316       '#size' => 5,
00317       '#maxlength' => 7,
00318       '#parents' => array('choice', $delta, 'chvotes'),
00319     );
00320   }
00321
00322   return $form;
00323 }
00324
00328 function poll_choice_js() {
00329   $delta = count($_POST['choice']);
00330
00331   // Build our new form element.
00332   $form_element = _poll_choice_form($delta);
00333   drupal_alter('form', $form_element, array(), 'poll_choice_js');
00334
00335   // Build the new form.
00336   $form_state = array('submitted' => FALSE);
00337   $form_build_id = $_POST['form_build_id'];
00338   // Add the new element to the stored form. Without adding the element to the
00339   // form, Drupal is not aware of this new elements existence and will not
00340   // process it. We retreive the cached form, add the element, and resave.
00341   $form = form_get_cache($form_build_id, $form_state);
00342   $form['choice_wrapper']['choice'][$delta] = $form_element;
00343   form_set_cache($form_build_id, $form, $form_state);
00344   $form += array(
00345     '#post' => $_POST,
00346     '#programmed' => FALSE,
00347   );
00348
00349   // Rebuild the form.
00350   $form = form_builder('poll_node_form', $form, $form_state);
00351
00352   // Render the new output.
00353   $choice_form = $form['choice_wrapper']['choice'];
00354   unset($choice_form['#prefix'], $choice_form['#suffix']); // Prevent duplicate wrappers.
00355   $choice_form[$delta]['#attributes']['class'] = empty($choice_form[$delta]['#attributes']['class']) ? 'ahah-new-content' : $choice_form[$delta]['#attributes']['class'] .' ahah-new-content';
00356   $choice_form[$delta]['chvotes']['#value'] = 0;
00357   $output = theme('status_messages') . drupal_render($choice_form);
00358
00359   drupal_json(array('status' => TRUE, 'data' => $output));
00360 }
00361
00365 function poll_node_form_submit(&$form, &$form_state) {
00366   // Renumber fields
00367   $form_state['values']['choice'] = array_values($form_state['values']['choice']);
00368   $form_state['values']['teaser'] = poll_teaser((object)$form_state['values']);
00369 }
00370
00374 function poll_validate($node) {
00375   if (isset($node->title)) {
00376     // Check for at least two options and validate amount of votes:
00377     $realchoices = 0;
00378     // Renumber fields
00379     $node->choice = array_values($node->choice);
00380     foreach ($node->choice as $i => $choice) {
00381       if ($choice['chtext'] != '') {
00382         $realchoices++;
00383       }
00384       if (isset($choice['chvotes']) && $choice['chvotes'] < 0) {
00385         form_set_error("choice][$i][chvotes", t('Negative values are not allowed.'));
00386       }
00387     }
00388
00389     if ($realchoices < 2) {
00390       form_set_error("choice][$realchoices][chtext", t('You must fill in at least two choices.'));
00391     }
00392   }
00393 }
00394
00398 function poll_load($node) {
00399   global $user;
00400
00401   $poll = db_fetch_object(db_query("SELECT runtime, active FROM {poll} WHERE nid = %d", $node->nid));
00402
00403   // Load the appropriate choices into the $poll object.
00404   $result = db_query("SELECT chtext, chvotes, chorder FROM {poll_choices} WHERE nid = %d ORDER BY chorder", $node->nid);
00405   while ($choice = db_fetch_array($result)) {
00406     $poll->choice[$choice['chorder']] = $choice;
00407   }
00408
00409   // Determine whether or not this user is allowed to vote.
00410   $poll->allowvotes = FALSE;
00411   if (user_access('vote on polls') && $poll->active) {
00412     if ($user->uid) {
00413       $result = db_fetch_object(db_query('SELECT chorder FROM {poll_votes} WHERE nid = %d AND uid = %d', $node->nid, $user->uid));
00414     }
00415     else {
00416       $result = db_fetch_object(db_query("SELECT chorder FROM {poll_votes} WHERE nid = %d AND hostname = '%s'", $node->nid, ip_address()));
00417     }
00418     if (isset($result->chorder)) {
00419       $poll->vote = $result->chorder;
00420     }
00421     else {
00422       $poll->vote = -1;
00423       $poll->allowvotes = TRUE;
00424     }
00425   }
00426   return $poll;
00427 }
00428
00432 function poll_insert($node) {
00433   if (!user_access('administer nodes')) {
00434     // Make sure all votes are 0 initially
00435     foreach ($node->choice as $i => $choice) {
00436       $node->choice[$i]['chvotes'] = 0;
00437     }
00438     $node->active = 1;
00439   }
00440
00441   db_query("INSERT INTO {poll} (nid, runtime, active) VALUES (%d, %d, %d)", $node->nid, $node->runtime, $node->active);
00442
00443   $i = 0;
00444   foreach ($node->choice as $choice) {
00445     if ($choice['chtext'] != '') {
00446       db_query("INSERT INTO {poll_choices} (nid, chtext, chvotes, chorder) VALUES (%d, '%s', %d, %d)", $node->nid, $choice['chtext'], $choice['chvotes'], $i++);
00447     }
00448   }
00449 }
00450
00454 function poll_update($node) {
00455   // Update poll settings.
00456   db_query('UPDATE {poll} SET runtime = %d, active = %d WHERE nid = %d', $node->runtime, $node->active, $node->nid);
00457
00458   // Clean poll choices.
00459   db_query('DELETE FROM {poll_choices} WHERE nid = %d', $node->nid);
00460
00461   // Poll choices come in the same order with the same numbers as they are in
00462   // the database, but some might have an empty title, which signifies that
00463   // they should be removed. We remove all votes to the removed options, so
00464   // people who voted on them can vote again.
00465   $new_chorder = 0;
00466   foreach ($node->choice as $old_chorder => $choice) {
00467     $chvotes = isset($choice['chvotes']) ? (int)$choice['chvotes'] : 0;
00468     $chtext = $choice['chtext'];
00469
00470     if (!empty($chtext)) {
00471       db_query("INSERT INTO {poll_choices} (nid, chtext, chvotes, chorder) VALUES (%d, '%s', %d, %d)", $node->nid, $chtext, $chvotes, $new_chorder);
00472       if ($new_chorder != $old_chorder) {
00473         // We can only remove items in the middle, not add, so
00474         // new_chorder is always <= old_chorder, making this safe.
00475         db_query("UPDATE {poll_votes} SET chorder = %d WHERE nid = %d AND chorder = %d", $new_chorder, $node->nid, $old_chorder);
00476       }
00477       $new_chorder++;
00478     }
00479     else {
00480       db_query("DELETE FROM {poll_votes} WHERE nid = %d AND chorder = %d", $node->nid, $old_chorder);
00481     }
00482   }
00483 }
00484
00488 function poll_delete($node) {
00489   db_query("DELETE FROM {poll} WHERE nid = %d", $node->nid);
00490   db_query("DELETE FROM {poll_choices} WHERE nid = %d", $node->nid);
00491   db_query("DELETE FROM {poll_votes} WHERE nid = %d", $node->nid);
00492 }
00493
00501 function poll_view($node, $teaser = FALSE, $page = FALSE, $block = FALSE) {
00502   global $user;
00503   $output = '';
00504
00505   // Special display for side-block
00506   if ($block) {
00507     // No 'read more' link
00508     $node->readmore = FALSE;
00509
00510     $links = module_invoke_all('link', 'node', $node, 1);
00511     $links[] = array('title' => t('Older polls'), 'href' => 'poll', 'attributes' => array('title' => t('View the list of polls on this site.')));
00512     if ($node->allowvotes && $block) {
00513       $links[] = array('title' => t('Results'), 'href' => 'node/'. $node->nid .'/results', 'attributes' => array('title' => t('View the current poll results.')));
00514     }
00515
00516     $node->links = $links;
00517   }
00518
00519   if (!empty($node->allowvotes) && ($block || empty($node->show_results))) {
00520     $node->content['body'] = array(
00521       '#value' => drupal_get_form('poll_view_voting', $node, $block),
00522     );
00523   }
00524   else {
00525     $node->content['body'] = array(
00526       '#value' => poll_view_results($node, $teaser, $page, $block),
00527     );
00528   }
00529   return $node;
00530 }
00531
00537 function poll_teaser($node) {
00538   $teaser = NULL;
00539   if (is_array($node->choice)) {
00540     foreach ($node->choice as $k => $choice) {
00541       if ($choice['chtext'] != '') {
00542         $teaser .= '* '. check_plain($choice['chtext']) ."\n";
00543       }
00544     }
00545   }
00546   return $teaser;
00547 }
00548
00556 function poll_view_voting(&$form_state, $node, $block) {
00557   if ($node->choice) {
00558     $list = array();
00559     foreach ($node->choice as $i => $choice) {
00560       $list[$i] = check_plain($choice['chtext']);
00561     }
00562     $form['choice'] = array(
00563       '#type' => 'radios',
00564       '#default_value' => -1,
00565       '#options' => $list,
00566     );
00567   }
00568
00569   $form['vote'] = array(
00570     '#type' => 'submit',
00571     '#value' => t('Vote'),
00572     '#submit' => array('poll_vote'),
00573   );
00574
00575   // Store the node so we can get to it in submit functions.
00576   $form['#node'] = $node;
00577   $form['#block'] = $block;
00578
00579   // Set form caching because we could have multiple of these forms on
00580   // the same page, and we want to ensure the right one gets picked.
00581   $form['#cache'] = TRUE;
00582
00583   // Provide a more cleanly named voting form theme.
00584   $form['#theme'] = 'poll_vote';
00585   return $form;
00586 }
00587
00591 function poll_view_voting_validate($form, &$form_state) {
00592   if ($form_state['values']['choice'] == -1) {
00593     form_set_error( 'choice', t('Your vote could not be recorded because you did not select any of the choices.'));
00594   }
00595 }
00596
00600 function poll_vote($form, &$form_state) {
00601   $node = $form['#node'];
00602   $choice = $form_state['values']['choice'];
00603
00604   global $user;
00605   if ($user->uid) {
00606     db_query('INSERT INTO {poll_votes} (nid, chorder, uid) VALUES (%d, %d, %d)', $node->nid, $choice, $user->uid);
00607   }
00608   else {
00609     db_query("INSERT INTO {poll_votes} (nid, chorder, hostname) VALUES (%d, %d, '%s')", $node->nid, $choice, ip_address());
00610   }
00611
00612   // Add one to the votes.
00613   db_query("UPDATE {poll_choices} SET chvotes = chvotes + 1 WHERE nid = %d AND chorder = %d", $node->nid, $choice);
00614
00615   cache_clear_all();
00616   drupal_set_message(t('Your vote was recorded.'));
00617
00618   // Return the user to whatever page they voted from.
00619 }
00620
00626 function template_preprocess_poll_vote(&$variables) {
00627   $form = $variables['form'];
00628   $variables['choice'] = drupal_render($form['choice']);
00629   $variables['title'] = check_plain($form['#node']->title);
00630   $variables['vote'] = drupal_render($form['vote']);
00631   $variables['rest'] = drupal_render($form);
00632   $variables['block'] = $form['#block'];
00633   // If this is a block, allow a different tpl.php to be used.
00634   if ($variables['block']) {
00635     $variables['template_files'][] = 'poll-vote-block';
00636   }
00637 }
00638
00642 function poll_view_results(&$node, $teaser, $page, $block) {
00643   // Count the votes and find the maximum
00644   $total_votes = 0;
00645   $max_votes = 0;
00646   foreach ($node->choice as $choice) {
00647     if (isset($choice['chvotes'])) {
00648       $total_votes += $choice['chvotes'];
00649       $max_votes = max($max_votes, $choice['chvotes']);
00650     }
00651   }
00652
00653   $poll_results = '';
00654   foreach ($node->choice as $i => $choice) {
00655     if (!empty($choice['chtext'])) {
00656       $chvotes = isset($choice['chvotes']) ? $choice['chvotes'] : NULL;
00657       $poll_results .= theme('poll_bar', $choice['chtext'], $chvotes, $total_votes, isset($node->vote) && $node->vote == $i, $block);
00658     }
00659   }
00660
00661   return theme('poll_results', $node->title, $poll_results, $total_votes, isset($node->links) ? $node->links : array(), $block, $node->nid, isset($node->vote) ? $node->vote : NULL);
00662 }
00663
00664
00670 function theme_poll_choices($form) {
00671   // Change the button title to reflect the behavior when using JavaScript.
00672   drupal_add_js('if (Drupal.jsEnabled) { $(document).ready(function() { $("#edit-poll-more").val("'. t('Add another choice') .'"); }); }', 'inline');
00673
00674   $rows = array();
00675   $headers = array(
00676     t('Choice'),
00677     t('Vote count'),
00678   );
00679
00680   foreach (element_children($form) as $key) {
00681     // No need to print the field title every time.
00682     unset($form[$key]['chtext']['#title'], $form[$key]['chvotes']['#title']);
00683
00684     // Build the table row.
00685     $row = array(
00686       'data' => array(
00687         array('data' => drupal_render($form[$key]['chtext']), 'class' => 'poll-chtext'),
00688         array('data' => drupal_render($form[$key]['chvotes']), 'class' => 'poll-chvotes'),
00689       ),
00690     );
00691
00692     // Add additional attributes to the row, such as a class for this row.
00693     if (isset($form[$key]['#attributes'])) {
00694       $row = array_merge($row, $form[$key]['#attributes']);
00695     }
00696     $rows[] = $row;
00697   }
00698
00699   $output = theme('table', $headers, $rows);
00700   $output .= drupal_render($form);
00701   return $output;
00702 }
00703
00717 function template_preprocess_poll_results(&$variables) {
00718   $variables['links'] = theme('links', $variables['raw_links']);
00719   if (isset($variables['vote']) && $variables['vote'] > -1 && user_access('cancel own vote')) {
00720     $variables['cancel_form'] = drupal_get_form('poll_cancel_form', $variables['nid']);
00721   }
00722   $variables['title'] = check_plain($variables['raw_title']);
00723
00724   // If this is a block, allow a different tpl.php to be used.
00725   if ($variables['block']) {
00726     $variables['template_files'][] = 'poll-results-block';
00727   }
00728 }
00729
00739 function template_preprocess_poll_bar(&$variables) {
00740   if ($variables['block']) {
00741     $variables['template_files'][] = 'poll-bar-block';
00742   }
00743   $variables['title'] = check_plain($variables['title']);
00744   $variables['percentage'] = round($variables['votes'] * 100 / max($variables['total_votes'], 1));
00745 }
00746
00753 function poll_cancel_form(&$form_state, $nid) {
00754   // Store the nid so we can get to it in submit functions.
00755   $form['#nid'] = $nid;
00756
00757   $form['submit'] = array(
00758     '#type' => 'submit',
00759     '#value' => t('Cancel your vote'),
00760     '#submit' => array('poll_cancel')
00761   );
00762
00763   $form['#cache'] = TRUE;
00764
00765   return $form;
00766 }
00767
00771 function poll_cancel($form, &$form_state) {
00772   $node = node_load($form['#nid']);
00773   global $user;
00774
00775   if ($user->uid) {
00776     db_query('DELETE FROM {poll_votes} WHERE nid = %d and uid = %d', $node->nid, $user->uid);
00777   }
00778   else {
00779     db_query("DELETE FROM {poll_votes} WHERE nid = %d and hostname = '%s'", $node->nid, ip_address());
00780   }
00781
00782   // Subtract from the votes.
00783   db_query("UPDATE {poll_choices} SET chvotes = chvotes - 1 WHERE nid = %d AND chorder = %d", $node->nid, $node->vote);
00784 }
00785
00789 function poll_user($op, &$edit, &$user) {
00790   if ($op == 'delete') {
00791     db_query('UPDATE {poll_votes} SET uid = 0 WHERE uid = %d', $user->uid);
00792   }
00793 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/poll/poll.pages.inc Source File

modules » poll

poll.pages.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: poll.pages.inc,v 1.4 2007/12/14 09:50:41 goba Exp $
00003
00012 function poll_page() {
00013   // List all polls.
00014   $sql = db_rewrite_sql("SELECT n.nid, n.title, p.active, n.created, SUM(c.chvotes) AS votes FROM {node} n INNER JOIN {poll} p ON n.nid = p.nid INNER JOIN {poll_choices} c ON n.nid = c.nid WHERE n.status = 1 GROUP BY n.nid, n.title, p.active, n.created ORDER BY n.created DESC");
00015   // Count all polls for the pager.
00016   $count_sql = db_rewrite_sql('SELECT COUNT(*) FROM {node} n INNER JOIN {poll} p ON n.nid = p.nid WHERE n.status = 1');
00017   $result = pager_query($sql, 15, 0, $count_sql);
00018   $output = '<ul>';
00019   while ($node = db_fetch_object($result)) {
00020     $output .= '<li>'. l($node->title, "node/$node->nid") .' - '. format_plural($node->votes, '1 vote', '@count votes') .' - '. ($node->active ? t('open') : t('closed')) .'</li>';
00021   }
00022   $output .= '</ul>';
00023   $output .= theme("pager", NULL, 15);
00024   return $output;
00025 }
00026
00030 function poll_votes($node) {
00031   drupal_set_title(check_plain($node->title));
00032   $output = t('This table lists all the recorded votes for this poll. If anonymous users are allowed to vote, they will be identified by the IP address of the computer they used when they voted.');
00033
00034   $header[] = array('data' => t('Visitor'), 'field' => 'u.name');
00035   $header[] = array('data' => t('Vote'), 'field' => 'pv.chorder');
00036
00037   $result = pager_query("SELECT pv.chorder, pv.uid, pv.hostname, u.name FROM {poll_votes} pv LEFT JOIN {users} u ON pv.uid = u.uid WHERE pv.nid = %d". tablesort_sql($header), 20, 0, NULL, $node->nid);
00038   $rows = array();
00039   while ($vote = db_fetch_object($result)) {
00040     $rows[] = array(
00041       $vote->name ? theme('username', $vote) : check_plain($vote->hostname),
00042       check_plain($node->choice[$vote->chorder]['chtext']));
00043   }
00044   $output .= theme('table', $header, $rows);
00045   $output .= theme('pager', NULL, 20, 0);
00046   return $output;
00047 }
00048
00052 function poll_results($node) {
00053   drupal_set_title(check_plain($node->title));
00054   $node->show_results = TRUE;
00055   return node_show($node, 0);
00056 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/profile/profile-block.tpl.php Source File

modules » profile

profile-block.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: profile-block.tpl.php,v 1.2 2007/08/07 08:39:35 goba Exp $
00003
00032 ?>
00033 <?php print $picture; ?>
00034
00035 <?php foreach ($profile as $field) : ?>
00036   <p>
00037     <?php if ($field->type != 'checkbox') : ?>
00038       <strong><?php print $field->title; ?></strong><br />
00039     <?php endif; ?>
00040     <?php print $field->value; ?>
00041   </p>
00042 <?php endforeach; ?>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/profile/profile-listing.tpl.php Source File

modules » profile

profile-listing.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: profile-listing.tpl.php,v 1.2 2007/08/07 08:39:35 goba Exp $
00003
00038 ?>
00039 <div class="profile">
00040   <?php print $picture; ?>
00041
00042   <div class="name">
00043     <?php print $name; ?>
00044   </div>
00045
00046   <?php foreach ($profile as $field) : ?>
00047     <div class="field">
00048       <?php print $field->value; ?>
00049     </div>
00050   <?php endforeach; ?>
00051
00052 </div>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/profile/profile-wrapper.tpl.php Source File

modules » profile

profile-wrapper.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: profile-wrapper.tpl.php,v 1.2 2007/08/07 08:39:35 goba Exp $
00003
00022 ?>
00023 <div id="profile">
00024   <?php print $content; ?>
00025 </div>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/profile/profile.admin.inc Source File

modules » profile

profile.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: profile.admin.inc,v 1.8 2008/01/21 15:20:43 goba Exp $
00003
00015 function profile_admin_overview() {
00016   $result = db_query('SELECT title, name, type, category, fid, weight FROM {profile_fields} ORDER BY category, weight');
00017
00018   $form = array();
00019   $categories = array();
00020   while ($field = db_fetch_object($result)) {
00021     // Collect all category information
00022     $categories[] = $field->category;
00023
00024     // Save all field information
00025     $form[$field->fid]['name'] = array('#value' => check_plain($field->name));
00026     $form[$field->fid]['title'] = array('#value' => check_plain($field->title));
00027     $form[$field->fid]['type'] = array('#value' => $field->type);
00028     $form[$field->fid]['category'] = array('#type' => 'select', '#default_value' => $field->category, '#options' => array());
00029     $form[$field->fid]['weight'] = array('#type' => 'weight', '#default_value' => $field->weight);
00030     $form[$field->fid]['edit'] = array('#value' => l(t('edit'), "admin/user/profile/edit/$field->fid"));
00031     $form[$field->fid]['delete'] = array('#value' => l(t('delete'), "admin/user/profile/delete/$field->fid"));
00032   }
00033
00034   // Add the cateogory combo boxes
00035   $categories = array_unique($categories);
00036   foreach ($form as $fid => $field) {
00037     foreach ($categories as $cat => $category) {
00038       $form[$fid]['category']['#options'][$category] = $category;
00039     }
00040   }
00041
00042   // Display the submit button only when there's more than one field
00043   if (count($form) > 1) {
00044     $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
00045   }
00046   else {
00047     // Disable combo boxes when there isn't a submit button
00048     foreach ($form as $fid => $field) {
00049       unset($form[$fid]['weight']);
00050       $form[$fid]['category']['#type'] = 'value';
00051     }
00052   }
00053   $form['#tree'] = TRUE;
00054
00055   $addnewfields = '<h2>'. t('Add new field') .'</h2>';
00056   $addnewfields .= '<ul>';
00057   foreach (_profile_field_types() as $key => $value) {
00058     $addnewfields .= '<li>'. l($value, "admin/user/profile/add/$key") .'</li>';
00059   }
00060   $addnewfields .= '</ul>';
00061   $form['addnewfields'] = array('#value' => $addnewfields);
00062
00063   return $form;
00064 }
00065
00071 function profile_admin_overview_submit($form, &$form_state) {
00072   foreach (element_children($form_state['values']) as $fid) {
00073     if (is_numeric($fid)) {
00074       $weight = $form_state['values'][$fid]['weight'];
00075       $category = $form_state['values'][$fid]['category'];
00076       if ($weight != $form[$fid]['weight']['#default_value'] || $category != $form[$fid]['category']['#default_value']) {
00077         db_query("UPDATE {profile_fields} SET weight = %d, category = '%s' WHERE fid = %d", $weight, $category, $fid);
00078       }
00079     }
00080   }
00081
00082   drupal_set_message(t('Profile fields have been updated.'));
00083   cache_clear_all();
00084   menu_rebuild();
00085 }
00086
00093 function theme_profile_admin_overview($form) {
00094   drupal_add_css(drupal_get_path('module', 'profile') .'/profile.css');
00095   // Add javascript if there's more than one field.
00096   if (isset($form['submit'])) {
00097     drupal_add_js(drupal_get_path('module', 'profile') .'/profile.js');
00098   }
00099
00100   $rows = array();
00101   $categories = array();
00102   $category_number = 0;
00103   foreach (element_children($form) as $key) {
00104     // Don't take form control structures.
00105     if (array_key_exists('category', $form[$key])) {
00106       $field = &$form[$key];
00107       $category = $field['category']['#default_value'];
00108
00109       if (!isset($categories[$category])) {
00110         // Category classes are given numeric IDs because there's no guarantee
00111         // class names won't contain invalid characters.
00112         $categories[$category] = $category_number;
00113         $category_field['#attributes']['class'] = 'profile-category profile-category-'. $category_number;
00114         $rows[] = array(array('data' => $category, 'colspan' => 7, 'class' => 'category'));
00115         $rows[] = array('data' => array(array('data' => '<em>'. t('No fields in this category. If this category remains empty when saved, it will be removed.') .'</em>', 'colspan' => 7)), 'class' => 'category-'. $category_number .'-message category-message category-populated');
00116
00117         // Make it dragable only if there is more than one field
00118         if (isset($form['submit'])) {
00119           drupal_add_tabledrag('profile-fields', 'order', 'sibling', 'profile-weight', 'profile-weight-'. $category_number);
00120           drupal_add_tabledrag('profile-fields', 'match', 'sibling', 'profile-category', 'profile-category-'. $category_number);
00121         }
00122         $category_number++;
00123       }
00124
00125       // Add special drag and drop classes that group fields together.
00126       $field['weight']['#attributes']['class'] = 'profile-weight profile-weight-'. $categories[$category];
00127       $field['category']['#attributes']['class'] = 'profile-category profile-category-'. $categories[$category];
00128
00129       // Add the row
00130       $row = array();
00131       $row[] = drupal_render($field['title']);
00132       $row[] = drupal_render($field['name']);
00133       $row[] = drupal_render($field['type']);
00134       if (isset($form['submit'])) {
00135         $row[] = drupal_render($field['category']);
00136         $row[] = drupal_render($field['weight']);
00137       }
00138       $row[] = drupal_render($field['edit']);
00139       $row[] = drupal_render($field['delete']);
00140       $rows[] = array('data' => $row, 'class' => 'draggable');
00141     }
00142   }
00143   if (empty($rows)) {
00144     $rows[] = array(array('data' => t('No fields available.'), 'colspan' => 7));
00145   }
00146
00147   $header = array(t('Title'), t('Name'), t('Type'));
00148   if (isset($form['submit'])) {
00149     $header[] = t('Category');
00150     $header[] = t('Weight');
00151   }
00152   $header[] = array('data' => t('Operations'), 'colspan' => 2);
00153
00154   $output = theme('table', $header, $rows, array('id' => 'profile-fields'));
00155   $output .= drupal_render($form);
00156
00157   return $output;
00158 }
00159
00167 function profile_field_form(&$form_state, $arg = NULL) {
00168   if (arg(3) == 'edit') {
00169     if (is_numeric($arg)) {
00170       $fid = $arg;
00171
00172       $edit = db_fetch_array(db_query('SELECT * FROM {profile_fields} WHERE fid = %d', $fid));
00173
00174       if (!$edit) {
00175         drupal_not_found();
00176         return;
00177       }
00178       drupal_set_title(t('edit %title', array('%title' => $edit['title'])));
00179       $form['fid'] = array('#type' => 'value',
00180         '#value' => $fid,
00181       );
00182       $type = $edit['type'];
00183     }
00184     else {
00185       drupal_not_found();
00186       return;
00187     }
00188   }
00189   else {
00190     $types = _profile_field_types();
00191     if (!isset($types[$arg])) {
00192       drupal_not_found();
00193       return;
00194     }
00195     $type = $arg;
00196     drupal_set_title(t('add new %type', array('%type' => $types[$type])));
00197     $edit = array('name' => 'profile_');
00198     $form['type'] = array('#type' => 'value', '#value' => $type);
00199   }
00200   $edit += array(
00201     'category' => '',
00202     'title' => '',
00203     'explanation' => '',
00204     'weight' => 0,
00205     'page' => '',
00206     'autocomplete' => '',
00207     'required' => '',
00208     'register' => '',
00209   );
00210   $form['fields'] = array('#type' => 'fieldset',
00211     '#title' => t('Field settings'),
00212   );
00213   $form['fields']['category'] = array('#type' => 'textfield',
00214     '#title' => t('Category'),
00215     '#default_value' => $edit['category'],
00216     '#autocomplete_path' => 'admin/user/profile/autocomplete',
00217     '#description' => t('The category the new field should be part of. Categories are used to group fields logically. An example category is "Personal information".'),
00218     '#required' => TRUE,
00219   );
00220   $form['fields']['title'] = array('#type' => 'textfield',
00221     '#title' => t('Title'),
00222     '#default_value' => $edit['title'],
00223     '#description' => t('The title of the new field. The title will be shown to the user. An example title is "Favorite color".'),
00224     '#required' => TRUE,
00225   );
00226   $form['fields']['name'] = array('#type' => 'textfield',
00227     '#title' => t('Form name'),
00228     '#default_value' => $edit['name'],
00229     '#description' => t('The name of the field. The form name is not shown to the user but used internally in the HTML code and URLs.
00230 Unless you know what you are doing, it is highly recommended that you prefix the form name with <code>profile_</code> to avoid name clashes with other fields. Spaces or any other special characters except dash (-) and underscore (_) are not allowed. An example name is "profile_favorite_color" or perhaps just "profile_color".'),
00231     '#required' => TRUE,
00232   );
00233   $form['fields']['explanation'] = array('#type' => 'textarea',
00234     '#title' => t('Explanation'),
00235     '#default_value' => $edit['explanation'],
00236     '#description' => t('An optional explanation to go with the new field. The explanation will be shown to the user.'),
00237   );
00238   if ($type == 'selection') {
00239     $form['fields']['options'] = array('#type' => 'textarea',
00240       '#title' => t('Selection options'),
00241       '#default_value' => isset($edit['options']) ? $edit['options'] : '',
00242       '#description' => t('A list of all options. Put each option on a separate line. Example options are "red", "blue", "green", etc.'),
00243     );
00244   }
00245   $form['fields']['visibility'] = array('#type' => 'radios',
00246     '#title' => t('Visibility'),
00247     '#default_value' => isset($edit['visibility']) ? $edit['visibility'] : PROFILE_PUBLIC,
00248     '#options' => array(PROFILE_HIDDEN => t('Hidden profile field, only accessible by administrators, modules and themes.'), PROFILE_PRIVATE => t('Private field, content only available to privileged users.'), PROFILE_PUBLIC => t('Public field, content shown on profile page but not used on member list pages.'), PROFILE_PUBLIC_LISTINGS => t('Public field, content shown on profile page and on member list pages.')),
00249   );
00250   if ($type == 'selection' || $type == 'list' || $type == 'textfield') {
00251     $form['fields']['page'] = array('#type' => 'textfield',
00252       '#title' => t('Page title'),
00253       '#default_value' => $edit['page'],
00254       '#description' => t('To enable browsing this field by value, enter a title for the resulting page. The word <code>%value</code> will be substituted with the corresponding value. An example page title is "People whose favorite color is %value". This is only applicable for a public field.'),
00255     );
00256   }
00257   else if ($type == 'checkbox') {
00258     $form['fields']['page'] = array('#type' => 'textfield',
00259       '#title' => t('Page title'),
00260       '#default_value' => $edit['page'],
00261       '#description' => t('To enable browsing this field by value, enter a title for the resulting page. An example page title is "People who are employed". This is only applicable for a public field.'),
00262     );
00263   }
00264   $form['fields']['weight'] = array('#type' => 'weight',
00265     '#title' => t('Weight'),
00266     '#default_value' => $edit['weight'],
00267     '#description' => t('The weights define the order in which the form fields are shown. Lighter fields "float up" towards the top of the category.'),
00268   );
00269   $form['fields']['autocomplete'] = array('#type' => 'checkbox',
00270     '#title' => t('Form will auto-complete while user is typing.'),
00271     '#default_value' => $edit['autocomplete'],
00272   );
00273   $form['fields']['required'] = array('#type' => 'checkbox',
00274     '#title' => t('The user must enter a value.'),
00275     '#default_value' => $edit['required'],
00276   );
00277   $form['fields']['register'] = array('#type' => 'checkbox',
00278     '#title' => t('Visible in user registration form.'),
00279     '#default_value' => $edit['register'],
00280   );
00281   $form['submit'] = array('#type' => 'submit',
00282     '#value' => t('Save field'),
00283   );
00284   return $form;
00285 }
00286
00290 function profile_field_form_validate($form, &$form_state) {
00291   // Validate the 'field name':
00292   if (preg_match('/[^a-zA-Z0-9_-]/', $form_state['values']['name'])) {
00293     form_set_error('name', t('The specified form name contains one or more illegal characters. Spaces or any other special characters except dash (-) and underscore (_) are not allowed.'));
00294   }
00295
00296   if (in_array($form_state['values']['name'], user_fields())) {
00297     form_set_error('name', t('The specified form name is reserved for use by Drupal.'));
00298   }
00299   // Validate the category:
00300   if (!$form_state['values']['category']) {
00301     form_set_error('category', t('You must enter a category.'));
00302   }
00303   if (strtolower($form_state['values']['category']) == 'account') {
00304     form_set_error('category', t('The specified category name is reserved for use by Drupal.'));
00305   }
00306   $args1 = array($form_state['values']['title'], $form_state['values']['category']);
00307   $args2 = array($form_state['values']['name']);
00308   $query_suffix = '';
00309
00310   if (isset($form_state['values']['fid'])) {
00311     $args1[] = $args2[] = $form_state['values']['fid'];
00312     $query_suffix = ' AND fid != %d';
00313   }
00314
00315   if (db_result(db_query("SELECT fid FROM {profile_fields} WHERE title = '%s' AND category = '%s'". $query_suffix, $args1))) {
00316     form_set_error('title', t('The specified title is already in use.'));
00317   }
00318   if (db_result(db_query("SELECT fid FROM {profile_fields} WHERE name = '%s'". $query_suffix, $args2))) {
00319     form_set_error('name', t('The specified name is already in use.'));
00320   }
00321   if ($form_state['values']['visibility'] == PROFILE_HIDDEN) {
00322     if ($form_state['values']['required']) {
00323       form_set_error('required', t('A hidden field cannot be required.'));
00324     }
00325     if ($form_state['values']['register']) {
00326       form_set_error('register', t('A hidden field cannot be set to visible on the user registration form.'));
00327     }
00328   }
00329 }
00330
00334 function profile_field_form_submit($form, &$form_state) {
00335   if (!isset($form_state['values']['options'])) {
00336     $form_state['values']['options'] = '';
00337   }
00338   if (!isset($form_state['values']['page'])) {
00339     $form_state['values']['page'] = '';
00340   }
00341   if (!isset($form_state['values']['fid'])) {
00342     db_query("INSERT INTO {profile_fields} (title, name, explanation, category, type, weight, required, register, visibility, autocomplete, options, page) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, %d, '%s', '%s')", $form_state['values']['title'], $form_state['values']['name'], $form_state['values']['explanation'], $form_state['values']['category'], $form_state['values']['type'], $form_state['values']['weight'], $form_state['values']['required'], $form_state['values']['register'], $form_state['values']['visibility'], $form_state['values']['autocomplete'], $form_state['values']['options'], $form_state['values']['page']);
00343
00344     drupal_set_message(t('The field has been created.'));
00345     watchdog('profile', 'Profile field %field added under category %category.', array('%field' => $form_state['values']['title'], '%category' => $form_state['values']['category']), WATCHDOG_NOTICE, l(t('view'), 'admin/user/profile'));
00346   }
00347   else {
00348     db_query("UPDATE {profile_fields} SET title = '%s', name = '%s', explanation = '%s', category = '%s', weight = %d, required = %d, register = %d, visibility = %d, autocomplete = %d, options = '%s', page = '%s' WHERE fid = %d", $form_state['values']['title'], $form_state['values']['name'], $form_state['values']['explanation'], $form_state['values']['category'], $form_state['values']['weight'], $form_state['values']['required'], $form_state['values']['register'], $form_state['values']['visibility'], $form_state['values']['autocomplete'], $form_state['values']['options'], $form_state['values']['page'], $form_state['values']['fid']);
00349
00350     drupal_set_message(t('The field has been updated.'));
00351   }
00352   cache_clear_all();
00353   menu_rebuild();
00354
00355   $form_state['redirect'] = 'admin/user/profile';
00356   return;
00357 }
00358
00362 function profile_field_delete(&$form_state, $fid) {
00363   $field = db_fetch_object(db_query("SELECT title FROM {profile_fields} WHERE fid = %d", $fid));
00364   if (!$field) {
00365     drupal_not_found();
00366     return;
00367   }
00368   $form['fid'] = array('#type' => 'value', '#value' => $fid);
00369   $form['title'] = array('#type' => 'value', '#value' => $field->title);
00370
00371   return confirm_form($form,
00372     t('Are you sure you want to delete the field %field?', array('%field' => $field->title)), 'admin/user/profile',
00373     t('This action cannot be undone. If users have entered values into this field in their profile, these entries will also be deleted. If you want to keep the user-entered data, instead of deleting the field you may wish to <a href="@edit-field">edit this field</a> and change it to a hidden profile field so that it may only be accessed by administrators.', array('@edit-field' => url('admin/user/profile/edit/'. $fid))),
00374     t('Delete'), t('Cancel'));
00375 }
00376
00380 function profile_field_delete_submit($form, &$form_state) {
00381   db_query('DELETE FROM {profile_fields} WHERE fid = %d', $form_state['values']['fid']);
00382   db_query('DELETE FROM {profile_values} WHERE fid = %d', $form_state['values']['fid']);
00383
00384   cache_clear_all();
00385
00386   drupal_set_message(t('The field %field has been deleted.', array('%field' => $form_state['values']['title'])));
00387   watchdog('profile', 'Profile field %field deleted.', array('%field' => $form_state['values']['title']), WATCHDOG_NOTICE, l(t('view'), 'admin/user/profile'));
00388
00389   $form_state['redirect'] = 'admin/user/profile';
00390   return;
00391 }
00392
00396 function profile_admin_settings_autocomplete($string) {
00397   $matches = array();
00398   $result = db_query_range("SELECT category FROM {profile_fields} WHERE LOWER(category) LIKE LOWER('%s%%')", $string, 0, 10);
00399   while ($data = db_fetch_object($result)) {
00400     $matches[$data->category] = check_plain($data->category);
00401   }
00402   print drupal_to_js($matches);
00403   exit();
00404 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/profile/profile.install Source File

modules » profile

profile.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: profile.install,v 1.12 2007/12/18 12:59:22 dries Exp $
00003
00007 function profile_install() {
00008   // Create tables.
00009   drupal_install_schema('profile');
00010 }
00011
00015 function profile_uninstall() {
00016   // Remove tables
00017   drupal_uninstall_schema('profile');
00018
00019   variable_del('profile_block_author_fields');
00020 }
00021
00025 function profile_schema() {
00026   $schema['profile_fields'] = array(
00027     'description' => t('Stores profile field information.'),
00028     'fields' => array(
00029       'fid' => array(
00030         'type' => 'serial',
00031         'not null' => TRUE,
00032         'description' => t('Primary Key: Unique profile field ID.'),
00033       ),
00034       'title' => array(
00035         'type' => 'varchar',
00036         'length' => 255,
00037         'not null' => FALSE,
00038         'description' => t('Title of the field shown to the end user.'),
00039       ),
00040       'name' => array(
00041         'type' => 'varchar',
00042         'length' => 128,
00043         'not null' => TRUE,
00044         'default' => '',
00045         'description' => t('Internal name of the field used in the form HTML and URLs.'),
00046       ),
00047       'explanation' => array(
00048         'type' => 'text',
00049         'not null' => FALSE,
00050         'description' => t('Explanation of the field to end users.'),
00051       ),
00052       'category' => array(
00053         'type' => 'varchar',
00054         'length' => 255,
00055         'not null' => FALSE,
00056         'description' => t('Profile category that the field will be grouped under.'),
00057       ),
00058       'page' => array(
00059         'type' => 'varchar',
00060         'length' => 255,
00061         'not null' => FALSE,
00062         'description' => t("Title of page used for browsing by the field's value"),
00063       ),
00064       'type' => array(
00065         'type' => 'varchar',
00066         'length' => 128,
00067         'not null' => FALSE,
00068         'description' => t('Type of form field.'),
00069       ),
00070       'weight' => array(
00071         'type' => 'int',
00072         'not null' => TRUE,
00073         'default' => 0,
00074         'size' => 'tiny',
00075         'description' => t('Weight of field in relation to other profile fields.'),
00076       ),
00077       'required' => array(
00078         'type' => 'int',
00079         'not null' => TRUE,
00080         'default' => 0,
00081         'size' => 'tiny',
00082         'description' => t('Whether the user is required to enter a value. (0 = no, 1 = yes)'),
00083       ),
00084       'register' => array(
00085         'type' => 'int',
00086         'not null' => TRUE,
00087         'default' => 0,
00088         'size' => 'tiny',
00089         'description' => t('Whether the field is visible in the user registration form. (1 = yes, 0 = no)'),
00090       ),
00091       'visibility' => array(
00092         'type' => 'int',
00093         'not null' => TRUE,
00094         'default' => 0,
00095         'size' => 'tiny',
00096         'description' => t('The level of visibility for the field. (0 = hidden, 1 = private, 2 = public on profile but not member list pages, 3 = public on profile and list pages)'),
00097       ),
00098       'autocomplete' => array(
00099         'type' => 'int',
00100         'not null' => TRUE,
00101         'default' => 0,
00102         'size' => 'tiny',
00103         'description' => t('Whether form auto-completion is enabled. (0 = disabled, 1 = enabled)'),
00104       ),
00105       'options' => array(
00106         'type' => 'text',
00107         'not null' => FALSE,
00108         'description' => t('List of options to be used in a list selection field.'),
00109       ),
00110     ),
00111     'indexes' => array('category' => array('category')),
00112     'unique keys' => array('name' => array('name')),
00113     'primary key' => array('fid'),
00114   );
00115
00116   $schema['profile_values'] = array(
00117     'description' => t('Stores values for profile fields.'),
00118     'fields' => array(
00119       'fid' => array(
00120         'type' => 'int',
00121         'unsigned' => TRUE,
00122         'not null' => TRUE,
00123         'default' => 0,
00124         'description' => t('The {profile_fields}.fid of the field.'),
00125       ),
00126       'uid' => array(
00127         'type' => 'int',
00128         'unsigned' => TRUE,
00129         'not null' => TRUE,
00130         'default' => 0,
00131         'description' => t('The {users}.uid of the profile user.'),
00132       ),
00133       'value' => array(
00134         'type' => 'text',
00135         'not null' => FALSE,
00136         'description' => t('The value for the field.'),
00137       ),
00138     ),
00139     'primary key' => array('uid', 'fid'),
00140     'indexes' => array(
00141       'fid' => array('fid'),
00142     ),
00143   );
00144
00145   return $schema;
00146 }
00147
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/profile/profile.module Source File

modules » profile

profile.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: profile.module,v 1.236 2008/02/03 19:36:46 goba Exp $
00003
00012 define('PROFILE_PRIVATE', 1);
00013
00017 define('PROFILE_PUBLIC', 2);
00018
00022 define('PROFILE_PUBLIC_LISTINGS', 3);
00023
00027 define('PROFILE_HIDDEN', 4);
00028
00032 function profile_help($path, $arg) {
00033   switch ($path) {
00034     case 'admin/help#profile':
00035       $output = '<p>'. t('The profile module allows custom fields (such as country, full name, or age) to be defined and displayed in the <em>My Account</em> section. This permits users of a site to share more information about themselves, and can help community-based sites organize users around specific information.') .'</p>';
00036       $output .= '<p>'. t('The following types of fields can be added to a user profile:') .'</p>';
00037       $output .= '<ul><li>'. t('single-line textfield') .'</li>';
00038       $output .= '<li>'. t('multi-line textfield') .'</li>';
00039       $output .= '<li>'. t('checkbox') .'</li>';
00040       $output .= '<li>'. t('list selection') .'</li>';
00041       $output .= '<li>'. t('freeform list') .'</li>';
00042       $output .= '<li>'. t('URL') .'</li>';
00043       $output .= '<li>'. t('date') .'</li></ul>';
00044       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@profile">Profile module</a>.', array('@profile' => 'http://drupal.org/handbook/modules/profile/')) .'</p>';
00045       return $output;
00046     case 'admin/user/profile':
00047       return '<p>'. t("This page displays a list of the existing custom profile fields to be displayed on a user's <em>My Account</em> page. To provide structure, similar or related fields may be placed inside a category. To add a new category (or edit an existing one), edit a profile field and provide a new category name. To change the category of a field or the order of fields within a category, grab a drag-and-drop handle under the Title column and drag the field to a new location in the list. (Grab a handle by clicking and holding the mouse while hovering over a handle icon.) Remember that your changes will not be saved until you click the <em>Save configuration</em> button at the bottom of the page.") .'</p>';
00048   }
00049 }
00050
00054 function profile_theme() {
00055   return array(
00056     'profile_block' => array(
00057       'arguments' => array('account' => NULL, 'fields' => array()),
00058       'template' => 'profile-block',
00059     ),
00060     'profile_listing' => array(
00061       'arguments' => array('account' => NULL, 'fields' => array()),
00062       'template' => 'profile-listing',
00063     ),
00064     'profile_wrapper' => array(
00065       'arguments' => array('content' => NULL),
00066       'template' => 'profile-wrapper',
00067     ),
00068     'profile_admin_overview' => array(
00069       'arguments' => array('form' => NULL),
00070       'file' => 'profile.admin.inc',
00071     )
00072   );
00073 }
00074
00078 function profile_menu() {
00079   $items['profile'] = array(
00080     'title' => 'User list',
00081     'page callback' => 'profile_browse',
00082     'access arguments' => array('access user profiles'),
00083     'type' => MENU_SUGGESTED_ITEM,
00084     'file' => 'profile.pages.inc',
00085   );
00086   $items['admin/user/profile'] = array(
00087     'title' => 'Profiles',
00088     'description' => 'Create customizable fields for your users.',
00089     'page callback' => 'drupal_get_form',
00090     'page arguments' => array('profile_admin_overview'),
00091     'access arguments' => array('administer users'),
00092     'file' => 'profile.admin.inc',
00093   );
00094   $items['admin/user/profile/add'] = array(
00095     'title' => 'Add field',
00096     'page callback' => 'drupal_get_form',
00097     'page arguments' => array('profile_field_form'),
00098     'type' => MENU_CALLBACK,
00099     'file' => 'profile.admin.inc',
00100   );
00101   $items['admin/user/profile/autocomplete'] = array(
00102     'title' => 'Profile category autocomplete',
00103     'page callback' => 'profile_admin_settings_autocomplete',
00104     'type' => MENU_CALLBACK,
00105     'file' => 'profile.admin.inc',
00106   );
00107   $items['admin/user/profile/edit'] = array(
00108     'title' => 'Edit field',
00109     'page callback' => 'drupal_get_form',
00110     'page arguments' => array('profile_field_form'),
00111     'type' => MENU_CALLBACK,
00112     'file' => 'profile.admin.inc',
00113   );
00114   $items['admin/user/profile/delete'] = array(
00115     'title' => 'Delete field',
00116     'page callback' => 'drupal_get_form',
00117     'page arguments' => array('profile_field_delete'),
00118     'type' => MENU_CALLBACK,
00119     'file' => 'profile.admin.inc',
00120   );
00121   $items['profile/autocomplete'] = array(
00122     'title' => 'Profile autocomplete',
00123     'page callback' => 'profile_autocomplete',
00124     'access arguments' => array('access user profiles'),
00125     'type' => MENU_CALLBACK,
00126     'file' => 'profile.pages.inc',
00127   );
00128   return $items;
00129 }
00130
00134 function profile_block($op = 'list', $delta = 0, $edit = array()) {
00135
00136   if ($op == 'list') {
00137     $blocks[0]['info'] = t('Author information');
00138     $blocks[0]['cache'] = BLOCK_CACHE_PER_PAGE | BLOCK_CACHE_PER_ROLE;
00139     return $blocks;
00140   }
00141   else if ($op == 'configure' && $delta == 0) {
00142     // Compile a list of fields to show
00143     $fields = array();
00144     $result = db_query('SELECT name, title, weight, visibility FROM {profile_fields} WHERE visibility IN (%d, %d) ORDER BY weight', PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS);
00145     while ($record = db_fetch_object($result)) {
00146       $fields[$record->name] = check_plain($record->title);
00147     }
00148     $fields['user_profile'] = t('Link to full user profile');
00149     $form['profile_block_author_fields'] = array('#type' => 'checkboxes',
00150       '#title' => t('Profile fields to display'),
00151       '#default_value' => variable_get('profile_block_author_fields', NULL),
00152       '#options' => $fields,
00153       '#description' => t('Select which profile fields you wish to display in the block. Only fields designated as public in the <a href="@profile-admin">profile field configuration</a> are available.', array('@profile-admin' => url('admin/user/profile'))),
00154     );
00155     return $form;
00156   }
00157   else if ($op == 'save' && $delta == 0) {
00158     variable_set('profile_block_author_fields', $edit['profile_block_author_fields']);
00159   }
00160   else if ($op == 'view') {
00161     if (user_access('access user profiles')) {
00162       $output = '';
00163       if ((arg(0) == 'node') && is_numeric(arg(1)) && (arg(2) == NULL)) {
00164         $node = node_load(arg(1));
00165         $account = user_load(array('uid' => $node->uid));
00166
00167         if ($use_fields = variable_get('profile_block_author_fields', array())) {
00168           // Compile a list of fields to show.
00169           $fields = array();
00170           $result = db_query('SELECT name, title, type, visibility, weight FROM {profile_fields} WHERE visibility IN (%d, %d) ORDER BY weight', PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS);
00171           while ($record = db_fetch_object($result)) {
00172             // Ensure that field is displayed only if it is among the defined block fields and, if it is private, the user has appropriate permissions.
00173             if (isset($use_fields[$record->name]) && $use_fields[$record->name]) {
00174               $fields[] = $record;
00175             }
00176           }
00177         }
00178
00179         if (!empty($fields)) {
00180           $profile = _profile_update_user_fields($fields, $account);
00181           $output .= theme('profile_block', $account, $profile, TRUE);
00182         }
00183
00184         if (isset($use_fields['user_profile']) && $use_fields['user_profile']) {
00185           $output .= '<div>'. l(t('View full user profile'), 'user/'. $account->uid) .'</div>';
00186         }
00187       }
00188
00189       if ($output) {
00190         $block['subject'] = t('About %name', array('%name' => $account->name));
00191         $block['content'] = $output;
00192         return $block;
00193       }
00194     }
00195   }
00196 }
00197
00201 function profile_user($type, &$edit, &$user, $category = NULL) {
00202   switch ($type) {
00203     case 'load':
00204       return profile_load_profile($user);
00205     case 'register':
00206       return profile_form_profile($edit, $user, $category, TRUE);
00207     case 'update':
00208     return profile_save_profile($edit, $user, $category);
00209     case 'insert':
00210       return profile_save_profile($edit, $user, $category, TRUE);
00211     case 'view':
00212       return profile_view_profile($user);
00213     case 'form':
00214       return profile_form_profile($edit, $user, $category);
00215     case 'validate':
00216       return profile_validate_profile($edit, $category);
00217     case 'categories':
00218       return profile_categories();
00219     case 'delete':
00220       db_query('DELETE FROM {profile_values} WHERE uid = %d', $user->uid);
00221   }
00222 }
00223
00224 function profile_load_profile(&$user) {
00225   $result = db_query('SELECT f.name, f.type, v.value FROM {profile_fields} f INNER JOIN {profile_values} v ON f.fid = v.fid WHERE uid = %d', $user->uid);
00226   while ($field = db_fetch_object($result)) {
00227     if (empty($user->{$field->name})) {
00228       $user->{$field->name} = _profile_field_serialize($field->type) ? unserialize($field->value) : $field->value;
00229     }
00230   }
00231 }
00232
00233 function profile_save_profile(&$edit, &$user, $category, $register = FALSE) {
00234   $result = _profile_get_fields($category, $register);
00235   while ($field = db_fetch_object($result)) {
00236     if (_profile_field_serialize($field->type)) {
00237       $edit[$field->name] = serialize($edit[$field->name]);
00238     }
00239     db_query("DELETE FROM {profile_values} WHERE fid = %d AND uid = %d", $field->fid, $user->uid);
00240     db_query("INSERT INTO {profile_values} (fid, uid, value) VALUES (%d, %d, '%s')", $field->fid, $user->uid, $edit[$field->name]);
00241     // Mark field as handled (prevents saving to user->data).
00242     $edit[$field->name] = NULL;
00243   }
00244 }
00245
00246 function profile_view_field($user, $field) {
00247   // Only allow browsing of private fields for admins, if browsing is enabled,
00248   // and if a user has permission to view profiles. Note that this check is
00249   // necessary because a user may always see their own profile.
00250   $browse = user_access('access user profiles')
00251          && (user_access('administer users') || $field->visibility != PROFILE_PRIVATE)
00252          && !empty($field->page);
00253
00254   if (isset($user->{$field->name}) && $value = $user->{$field->name}) {
00255     switch ($field->type) {
00256       case 'textarea':
00257         return check_markup($value);
00258       case 'textfield':
00259       case 'selection':
00260         return $browse ? l($value, 'profile/'. $field->name .'/'. $value) : check_plain($value);
00261       case 'checkbox':
00262         return $browse ? l($field->title, 'profile/'. $field->name) : check_plain($field->title);
00263       case 'url':
00264         return '<a href="'. check_url($value) .'">'. check_plain($value) .'</a>';
00265       case 'date':
00266         $format = substr(variable_get('date_format_short', 'm/d/Y - H:i'), 0, 5);
00267         // Note: Avoid PHP's date() because it does not handle dates before
00268         // 1970 on Windows. This would make the date field useless for e.g.
00269         // birthdays.
00270         $replace = array(
00271           'd' => sprintf('%02d', $value['day']),
00272           'j' => $value['day'],
00273           'm' => sprintf('%02d', $value['month']),
00274           'M' => map_month($value['month']),
00275           'Y' => $value['year'],
00276           'H:i' => NULL,
00277           'g:ia' => NULL,
00278         );
00279         return strtr($format, $replace);
00280       case 'list':
00281         $values = split("[,\n\r]", $value);
00282         $fields = array();
00283         foreach ($values as $value) {
00284           if ($value = trim($value)) {
00285             $fields[] = $browse ? l($value, 'profile/'. $field->name .'/'. $value) : check_plain($value);
00286           }
00287         }
00288         return implode(', ', $fields);
00289     }
00290   }
00291 }
00292
00293 function profile_view_profile(&$user) {
00294
00295   profile_load_profile($user);
00296
00297   // Show private fields to administrators and people viewing their own account.
00298   if (user_access('administer users') || $GLOBALS['user']->uid == $user->uid) {
00299     $result = db_query('SELECT * FROM {profile_fields} WHERE visibility != %d ORDER BY category, weight', PROFILE_HIDDEN);
00300   }
00301   else {
00302     $result = db_query('SELECT * FROM {profile_fields} WHERE visibility != %d AND visibility != %d ORDER BY category, weight', PROFILE_PRIVATE, PROFILE_HIDDEN);
00303   }
00304
00305   $fields = array();
00306   while ($field = db_fetch_object($result)) {
00307     if ($value = profile_view_field($user, $field)) {
00308       $title = ($field->type != 'checkbox') ? check_plain($field->title) : NULL;
00309
00310       // Create a single fieldset for each category.
00311       if (!isset($user->content[$field->category])) {
00312         $user->content[$field->category] = array(
00313           '#type' => 'user_profile_category',
00314           '#title' => $field->category,
00315         );
00316       }
00317
00318       $user->content[$field->category][$field->name] = array(
00319         '#type' => 'user_profile_item',
00320         '#title' => $title,
00321         '#value' => $value,
00322         '#weight' => $field->weight,
00323         '#attributes' => array('class' => 'profile-'. $field->name),
00324       );
00325     }
00326   }
00327 }
00328
00329 function _profile_form_explanation($field) {
00330   $output = $field->explanation;
00331
00332   if ($field->type == 'list') {
00333     $output .= ' '. t('Put each item on a separate line or separate them by commas. No HTML allowed.');
00334   }
00335
00336   if ($field->visibility == PROFILE_PRIVATE) {
00337     $output .= ' '. t('The content of this field is kept private and will not be shown publicly.');
00338   }
00339
00340   return $output;
00341 }
00342
00343 function profile_form_profile($edit, $user, $category, $register = FALSE) {
00344   $result = _profile_get_fields($category, $register);
00345   $weight = 1;
00346   $fields = array();
00347   while ($field = db_fetch_object($result)) {
00348     $category = $field->category;
00349     if (!isset($fields[$category])) {
00350       $fields[$category] = array('#type' => 'fieldset', '#title' => check_plain($category), '#weight' => $weight++);
00351     }
00352     switch ($field->type) {
00353       case 'textfield':
00354       case 'url':
00355         $fields[$category][$field->name] = array('#type' => 'textfield',
00356           '#title' => check_plain($field->title),
00357           '#default_value' => isset($edit[$field->name]) ? $edit[$field->name] : '',
00358           '#maxlength' => 255,
00359           '#description' => _profile_form_explanation($field),
00360           '#required' => $field->required,
00361         );
00362         if ($field->autocomplete) {
00363           $fields[$category][$field->name]['#autocomplete_path'] = "profile/autocomplete/". $field->fid;
00364         }
00365         break;
00366       case 'textarea':
00367         $fields[$category][$field->name] = array('#type' => 'textarea',
00368           '#title' => check_plain($field->title),
00369           '#default_value' => isset($edit[$field->name]) ? $edit[$field->name] : '',
00370           '#description' => _profile_form_explanation($field),
00371           '#required' => $field->required,
00372         );
00373         break;
00374       case 'list':
00375         $fields[$category][$field->name] = array('#type' => 'textarea',
00376           '#title' => check_plain($field->title),
00377           '#default_value' => isset($edit[$field->name]) ? $edit[$field->name] : '',
00378           '#description' => _profile_form_explanation($field),
00379           '#required' => $field->required,
00380         );
00381         break;
00382       case 'checkbox':
00383         $fields[$category][$field->name] = array('#type' => 'checkbox',
00384           '#title' => check_plain($field->title),
00385           '#default_value' => isset($edit[$field->name]) ? $edit[$field->name] : '',
00386           '#description' => _profile_form_explanation($field),
00387           '#required' => $field->required,
00388         );
00389         break;
00390       case 'selection':
00391         $options = $field->required ? array() : array('--');
00392         $lines = split("[,\n\r]", $field->options);
00393         foreach ($lines as $line) {
00394           if ($line = trim($line)) {
00395             $options[$line] = $line;
00396           }
00397         }
00398         $fields[$category][$field->name] = array('#type' => 'select',
00399           '#title' => check_plain($field->title),
00400           '#default_value' => isset($edit[$field->name]) ? $edit[$field->name] : '',
00401           '#options' => $options,
00402           '#description' => _profile_form_explanation($field),
00403           '#required' => $field->required,
00404         );
00405         break;
00406       case 'date':
00407         $fields[$category][$field->name] = array('#type' => 'date',
00408           '#title' => check_plain($field->title),
00409           '#default_value' => isset($edit[$field->name]) ? $edit[$field->name] : '',
00410           '#description' => _profile_form_explanation($field),
00411           '#required' => $field->required,
00412         );
00413         break;
00414     }
00415   }
00416   return $fields;
00417 }
00418
00422 function _profile_update_user_fields($fields, $account) {
00423   foreach ($fields as $key => $field) {
00424     $fields[$key]->value = profile_view_field($account, $field);
00425   }
00426   return $fields;
00427 }
00428
00429 function profile_validate_profile($edit, $category) {
00430   $result = _profile_get_fields($category);
00431   while ($field = db_fetch_object($result)) {
00432     if ($edit[$field->name]) {
00433       if ($field->type == 'url') {
00434         if (!valid_url($edit[$field->name], TRUE)) {
00435           form_set_error($field->name, t('The value provided for %field is not a valid URL.', array('%field' => $field->title)));
00436         }
00437       }
00438     }
00439     else if ($field->required && !user_access('administer users')) {
00440       form_set_error($field->name, t('The field %field is required.', array('%field' => $field->title)));
00441     }
00442   }
00443
00444   return $edit;
00445 }
00446
00447 function profile_categories() {
00448   $result = db_query("SELECT DISTINCT(category) FROM {profile_fields}");
00449   $data = array();
00450   while ($category = db_fetch_object($result)) {
00451     $data[] = array(
00452       'name' => $category->category,
00453       'title' => $category->category,
00454       'weight' => 3,
00455       'access callback' => 'profile_category_access',
00456       'access arguments' => array($category->category)
00457     );
00458   }
00459   return $data;
00460 }
00461
00465 function profile_category_access($category) {
00466   if (user_access('administer users')) {
00467     return TRUE;
00468   }
00469   else {
00470     return db_result(db_query("SELECT COUNT(*) FROM {profile_fields} WHERE category = '%s' AND visibility <> %d", $category, PROFILE_HIDDEN));
00471   }
00472 }
00473
00483 function template_preprocess_profile_block(&$variables) {
00484
00485   $variables['picture'] = theme('user_picture', $variables['account']);
00486   $variables['profile'] = array();
00487   // Supply filtered version of $fields that have values.
00488   foreach ($variables['fields'] as $field) {
00489     if ($field->value) {
00490       $variables['profile'][$field->name]->title = check_plain($field->title);
00491       $variables['profile'][$field->name]->value = $field->value;
00492       $variables['profile'][$field->name]->type = $field->type;
00493     }
00494   }
00495
00496 }
00497
00507 function template_preprocess_profile_listing(&$variables) {
00508
00509   $variables['picture'] = theme('user_picture', $variables['account']);
00510   $variables['name'] = theme('username', $variables['account']);
00511   $variables['profile'] = array();
00512   // Supply filtered version of $fields that have values.
00513   foreach ($variables['fields'] as $field) {
00514     if ($field->value) {
00515       $variables['profile'][$field->name]->title = $field->title;
00516       $variables['profile'][$field->name]->value = $field->value;
00517       $variables['profile'][$field->name]->type = $field->type;
00518     }
00519   }
00520
00521 }
00522
00531 function template_preprocess_profile_wrapper(&$variables) {
00532   $variables['current_field'] = '';
00533   if ($field = arg(1)) {
00534     $variables['current_field'] = $field;
00535     // Supply an alternate template suggestion based on the browsable field.
00536     $variables['template_files'][] = 'profile-wrapper-'. $field;
00537   }
00538 }
00539
00540 function _profile_field_types($type = NULL) {
00541   $types = array('textfield' => t('single-line textfield'),
00542                  'textarea' => t('multi-line textfield'),
00543                  'checkbox' => t('checkbox'),
00544                  'selection' => t('list selection'),
00545                  'list' => t('freeform list'),
00546                  'url' => t('URL'),
00547                  'date' => t('date'));
00548   return isset($type) ? $types[$type] : $types;
00549 }
00550
00551 function _profile_field_serialize($type = NULL) {
00552   return $type == 'date';
00553 }
00554
00555 function _profile_get_fields($category, $register = FALSE) {
00556   $args = array();
00557   $sql = 'SELECT * FROM {profile_fields} WHERE ';
00558   $filters = array();
00559   if ($register) {
00560     $filters[] = 'register = 1';
00561   }
00562   else {
00563     // Use LOWER('%s') instead of PHP's strtolower() to avoid UTF-8 conversion issues.
00564     $filters[] = "LOWER(category) = LOWER('%s')";
00565     $args[] = $category;
00566   }
00567   if (!user_access('administer users')) {
00568     $filters[] = 'visibility != %d';
00569     $args[] = PROFILE_HIDDEN;
00570   }
00571   $sql .= implode(' AND ', $filters);
00572   $sql .= ' ORDER BY category, weight';
00573   return db_query($sql, $args);
00574 }
00575
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/profile/profile.pages.inc Source File

modules » profile

profile.pages.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: profile.pages.inc,v 1.2 2007/12/08 14:06:22 goba Exp $
00003
00012 function profile_browse() {
00013   // Ensure that the path is converted to 3 levels always.
00014   list(, $name, $value) = array_pad(explode('/', $_GET['q'], 3), 3, '');
00015
00016   $field = db_fetch_object(db_query("SELECT DISTINCT(fid), type, title, page, visibility FROM {profile_fields} WHERE name = '%s'", $name));
00017
00018   if ($name && $field->fid) {
00019     // Only allow browsing of fields that have a page title set.
00020     if (empty($field->page)) {
00021       drupal_not_found();
00022       return;
00023     }
00024     // Do not allow browsing of private and hidden fields by non-admins.
00025     if (!user_access('administer users') && ($field->visibility == PROFILE_PRIVATE || $field->visibility == PROFILE_HIDDEN)) {
00026       drupal_access_denied();
00027       return;
00028     }
00029
00030     // Compile a list of fields to show.
00031     $fields = array();
00032     $result = db_query('SELECT name, title, type, weight, page FROM {profile_fields} WHERE fid != %d AND visibility = %d ORDER BY weight', $field->fid, PROFILE_PUBLIC_LISTINGS);
00033     while ($record = db_fetch_object($result)) {
00034       $fields[] = $record;
00035     }
00036
00037     // Determine what query to use:
00038     $arguments = array($field->fid);
00039     switch ($field->type) {
00040       case 'checkbox':
00041         $query = 'v.value = 1';
00042         break;
00043       case 'textfield':
00044       case 'selection':
00045         $query = "v.value = '%s'";
00046         $arguments[] = $value;
00047         break;
00048       case 'list':
00049         $query = "v.value LIKE '%%%s%%'";
00050         $arguments[] = $value;
00051         break;
00052       default:
00053         drupal_not_found();
00054         return;
00055     }
00056
00057     // Extract the affected users:
00058     $result = pager_query("SELECT u.uid, u.access FROM {users} u INNER JOIN {profile_values} v ON u.uid = v.uid WHERE v.fid = %d AND $query AND u.access != 0 AND u.status != 0 ORDER BY u.access DESC", 20, 0, NULL, $arguments);
00059
00060     $content = '';
00061     while ($account = db_fetch_object($result)) {
00062       $account = user_load(array('uid' => $account->uid));
00063       $profile = _profile_update_user_fields($fields, $account);
00064       $content .= theme('profile_listing', $account, $profile);
00065     }
00066     $output = theme('profile_wrapper', $content);
00067     $output .= theme('pager', NULL, 20);
00068
00069     if ($field->type == 'selection' || $field->type == 'list' || $field->type == 'textfield') {
00070       $title = strtr(check_plain($field->page), array('%value' => theme('placeholder', $value)));
00071     }
00072     else {
00073       $title = check_plain($field->page);
00074     }
00075
00076     drupal_set_title($title);
00077     return $output;
00078   }
00079   else if ($name && !$field->fid) {
00080     drupal_not_found();
00081   }
00082   else {
00083     // Compile a list of fields to show.
00084     $fields = array();
00085     $result = db_query('SELECT name, title, type, weight, page FROM {profile_fields} WHERE visibility = %d ORDER BY category, weight', PROFILE_PUBLIC_LISTINGS);
00086     while ($record = db_fetch_object($result)) {
00087       $fields[] = $record;
00088     }
00089
00090     // Extract the affected users:
00091     $result = pager_query('SELECT uid, access FROM {users} WHERE uid > 0 AND status != 0 AND access != 0 ORDER BY access DESC', 20, 0, NULL);
00092
00093     $content = '';
00094     while ($account = db_fetch_object($result)) {
00095       $account = user_load(array('uid' => $account->uid));
00096       $profile = _profile_update_user_fields($fields, $account);
00097       $content .= theme('profile_listing', $account, $profile);
00098     }
00099     $output = theme('profile_wrapper', $content);
00100     $output .= theme('pager', NULL, 20);
00101
00102     drupal_set_title(t('User list'));
00103     return $output;
00104   }
00105 }
00106
00110 function profile_autocomplete($field, $string) {
00111   $matches = array();
00112   if (db_result(db_query("SELECT COUNT(*) FROM {profile_fields} WHERE fid = %d AND autocomplete = 1", $field))) {
00113     $result = db_query_range("SELECT value FROM {profile_values} WHERE fid = %d AND LOWER(value) LIKE LOWER('%s%%') GROUP BY value ORDER BY value ASC", $field, $string, 0, 10);
00114     while ($data = db_fetch_object($result)) {
00115       $matches[$data->value] = check_plain($data->value);
00116     }
00117   }
00118
00119   drupal_json($matches);
00120 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/search/search-block-form.tpl.php Source File

modules » search

search-block-form.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: search-block-form.tpl.php,v 1.1 2007/10/31 18:06:38 dries Exp $
00003
00034 ?>
00035 <div class="container-inline">
00036   <?php print $search_form; ?>
00037 </div>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/search/search-result.tpl.php Source File

modules » search

search-result.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: search-result.tpl.php,v 1.1 2007/10/31 18:06:38 dries Exp $
00003
00048 ?>
00049 <dt class="title">
00050   <a href="<?php print $url; ?>"><?php print $title; ?></a>
00051 </dt>
00052 <dd>
00053   <?php if ($snippet) : ?>
00054     <p class="search-snippet"><?php print $snippet; ?></p>
00055   <?php endif; ?>
00056   <?php if ($info) : ?>
00057   <p class="search-info"><?php print $info; ?></p>
00058   <?php endif; ?>
00059 </dd>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/search/search-results.tpl.php Source File

modules » search

search-results.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: search-results.tpl.php,v 1.1 2007/10/31 18:06:38 dries Exp $
00003
00023 ?>
00024 <dl class="search-results <?php print $type; ?>-results">
00025   <?php print $search_results; ?>
00026 </dl>
00027 <?php print $pager; ?>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/search/search-theme-form.tpl.php Source File

modules » search

search-theme-form.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: search-theme-form.tpl.php,v 1.1 2007/10/31 18:06:38 dries Exp $
00003
00035 ?>
00036 <div id="search" class="container-inline">
00037   <?php print $search_form; ?>
00038 </div>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/search/search.admin.inc Source File

modules » search

search.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: search.admin.inc,v 1.4 2008/01/08 10:35:42 goba Exp $
00003
00012 function search_wipe_confirm() {
00013   return confirm_form(array(), t('Are you sure you want to re-index the site?'),
00014                   'admin/settings/search', t(' The search index is not cleared but systematically updated to reflect the new settings. Searching will continue to work but new content won\'t be indexed until all existing content has been re-indexed. This action cannot be undone.'), t('Re-index site'), t('Cancel'));
00015 }
00016
00020 function search_wipe_confirm_submit(&$form, &$form_state) {
00021   if ($form['confirm']) {
00022     search_wipe();
00023     drupal_set_message(t('The index will be rebuilt.'));
00024     $form_state['redirect'] = 'admin/settings/search';
00025     return;
00026   }
00027 }
00028
00036 function search_admin_settings() {
00037   // Collect some stats
00038   $remaining = 0;
00039   $total = 0;
00040   foreach (module_list() as $module) {
00041     if (module_hook($module, 'search')) {
00042       $status = module_invoke($module, 'search', 'status');
00043       $remaining += $status['remaining'];
00044       $total += $status['total'];
00045     }
00046   }
00047   $count = format_plural($remaining, 'There is 1 item left to index.', 'There are @count items left to index.');
00048   $percentage = ((int)min(100, 100 * ($total - $remaining) / max(1, $total))) .'%';
00049   $status = '<p><strong>'. t('%percentage of the site has been indexed.', array('%percentage' => $percentage)) .' '. $count .'</strong></p>';
00050   $form['status'] = array('#type' => 'fieldset', '#title' => t('Indexing status'));
00051   $form['status']['status'] = array('#value' => $status);
00052   $form['status']['wipe'] = array('#type' => 'submit', '#value' => t('Re-index site'));
00053
00054   $items = drupal_map_assoc(array(10, 20, 50, 100, 200, 500));
00055
00056   // Indexing throttle:
00057   $form['indexing_throttle'] = array('#type' => 'fieldset', '#title' => t('Indexing throttle'));
00058   $form['indexing_throttle']['search_cron_limit'] = array('#type' => 'select', '#title' => t('Number of items to index per cron run'), '#default_value' => variable_get('search_cron_limit', 100), '#options' => $items, '#description' => t('The maximum number of items indexed in each pass of a <a href="@cron">cron maintenance task</a>. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing.', array('@cron' => url('admin/reports/status'))));
00059   // Indexing settings:
00060   $form['indexing_settings'] = array('#type' => 'fieldset', '#title' => t('Indexing settings'));
00061   $form['indexing_settings']['info'] = array('#value' => t('<p><em>Changing the settings below will cause the site index to be rebuilt. The search index is not cleared but systematically updated to reflect the new settings. Searching will continue to work but new content won\'t be indexed until all existing content has been re-indexed.</em></p><p><em>The default settings should be appropriate for the majority of sites.</em></p>'));
00062   $form['indexing_settings']['minimum_word_size'] = array('#type' => 'textfield', '#title' => t('Minimum word length to index'), '#default_value' => variable_get('minimum_word_size', 3), '#size' => 5, '#maxlength' => 3, '#description' => t('The number of characters a word has to be to be indexed. A lower setting means better search result ranking, but also a larger database. Each search query must contain at least one keyword that is this size (or longer).'));
00063   $form['indexing_settings']['overlap_cjk'] = array('#type' => 'checkbox', '#title' => t('Simple CJK handling'), '#default_value' => variable_get('overlap_cjk', TRUE), '#description' => t('Whether to apply a simple Chinese/Japanese/Korean tokenizer based on overlapping sequences. Turn this off if you want to use an external preprocessor for this instead. Does not affect other languages.'));
00064
00065   $form['#validate'] = array('search_admin_settings_validate');
00066
00067   // Per module settings
00068   $form = array_merge($form, module_invoke_all('search', 'admin'));
00069   return system_settings_form($form);
00070 }
00071
00075 function search_admin_settings_validate($form, &$form_state) {
00076   if ($form_state['values']['op'] == t('Re-index site')) {
00077     drupal_goto('admin/settings/search/wipe');
00078   }
00079   // If these settings change, the index needs to be rebuilt.
00080   if ((variable_get('minimum_word_size', 3) != $form_state['values']['minimum_word_size']) ||
00081       (variable_get('overlap_cjk', TRUE) != $form_state['values']['overlap_cjk'])) {
00082     drupal_set_message(t('The index will be rebuilt.'));
00083     search_wipe();
00084   }
00085 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/search/search.install Source File

modules » search

search.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: search.install,v 1.14 2007/12/28 10:53:27 dries Exp $
00003
00007 function search_install() {
00008   // Create tables.
00009   drupal_install_schema('search');
00010 }
00011
00015 function search_uninstall() {
00016   // Remove tables.
00017   drupal_uninstall_schema('search');
00018
00019   variable_del('minimum_word_size');
00020   variable_del('overlap_cjk');
00021   variable_del('search_cron_limit');
00022 }
00023
00027 function search_schema() {
00028   $schema['search_dataset'] = array(
00029     'description' => t('Stores items that will be searched.'),
00030     'fields' => array(
00031       'sid' => array(
00032         'type' => 'int',
00033         'unsigned' => TRUE,
00034         'not null' => TRUE,
00035         'default' => 0,
00036         'description' => t('Search item ID, e.g. node ID for nodes.'),
00037       ),
00038       'type' => array(
00039         'type' => 'varchar',
00040         'length' => 16,
00041         'not null' => FALSE,
00042         'description' => t('Type of item, e.g. node.'),
00043       ),
00044       'data' => array(
00045         'type' => 'text',
00046         'not null' => TRUE,
00047         'size' => 'big',
00048         'description' => t('List of space-separated words from the item.'),
00049       ),
00050       'reindex' => array(
00051         'type' => 'int',
00052         'unsigned' => TRUE,
00053         'not null' => TRUE,
00054         'default' => 0,
00055         'description' => t('Set to force node reindexing.'),
00056       ),
00057     ),
00058     'unique keys' => array('sid_type' => array('sid', 'type')),
00059   );
00060
00061   $schema['search_index'] = array(
00062     'description' => t('Stores the search index, associating words, items and scores.'),
00063     'fields' => array(
00064       'word' => array(
00065         'type' => 'varchar',
00066         'length' => 50,
00067         'not null' => TRUE,
00068         'default' => '',
00069         'description' => t('The {search_total}.word that is associated with the search item.'),
00070       ),
00071       'sid' => array(
00072         'type' => 'int',
00073         'unsigned' => TRUE,
00074         'not null' => TRUE,
00075         'default' => 0,
00076         'description' => t('The {search_dataset}.sid of the searchable item to which the word belongs.'),
00077       ),
00078       'type' => array(
00079         'type' => 'varchar',
00080         'length' => 16,
00081         'not null' => FALSE,
00082         'description' => t('The {search_dataset}.type of the searchable item to which the word belongs.'),
00083       ),
00084       'score' => array(
00085         'type' => 'float',
00086         'not null' => FALSE,
00087         'description' => t('The numeric score of the word, higher being more important.'),
00088       ),
00089     ),
00090     'indexes' => array(
00091       'sid_type' => array('sid', 'type'),
00092       'word' => array('word')
00093     ),
00094     'unique keys' => array('word_sid_type' => array('word', 'sid', 'type')),
00095   );
00096
00097   $schema['search_total'] = array(
00098     'description' => t('Stores search totals for words.'),
00099     'fields' => array(
00100       'word' => array(
00101         'description' => t('Primary Key: Unique word in the search index.'),
00102         'type' => 'varchar',
00103         'length' => 50,
00104         'not null' => TRUE,
00105         'default' => '',
00106       ),
00107       'count' => array(
00108         'description' => t("The count of the word in the index using Zipf's law to equalize the probability distribution."),
00109         'type' => 'float',
00110         'not null' => FALSE,
00111       ),
00112     ),
00113     'primary key' => array('word'),
00114   );
00115
00116   $schema['search_node_links'] = array(
00117     'description' => t('Stores items (like nodes) that link to other nodes, used to improve search scores for nodes that are frequently linked to.'),
00118     'fields' => array(
00119       'sid' => array(
00120         'type' => 'int',
00121         'unsigned' => TRUE,
00122         'not null' => TRUE,
00123         'default' => 0,
00124         'description' => t('The {search_dataset}.sid of the searchable item containing the link to the node.'),
00125       ),
00126       'type' => array(
00127         'type' => 'varchar',
00128         'length' => 16,
00129         'not null' => TRUE,
00130         'default' => '',
00131         'description' => t('The {search_dataset}.type of the searchable item containing the link to the node.'),
00132       ),
00133       'nid' => array(
00134         'type' => 'int',
00135         'unsigned' => TRUE,
00136         'not null' => TRUE,
00137         'default' => 0,
00138         'description' => t('The {node}.nid that this item links to.'),
00139       ),
00140       'caption' => array(
00141         'type' => 'text',
00142         'size' => 'big',
00143         'not null' => FALSE,
00144         'description' => t('The text used to link to the {node}.nid.'),
00145       ),
00146     ),
00147     'primary key' => array('sid', 'type', 'nid'),
00148     'indexes' => array('nid' => array('nid')),
00149   );
00150
00151   return $schema;
00152 }
00153
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/search/search.module Source File

modules » search

search.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: search.module,v 1.250.2.1 2008/02/07 16:42:03 goba Exp $
00003
00022 define('PREG_CLASS_SEARCH_EXCLUDE',
00023 '\x{0}-\x{2f}\x{3a}-\x{40}\x{5b}-\x{60}\x{7b}-\x{bf}\x{d7}\x{f7}\x{2b0}-'.
00024 '\x{385}\x{387}\x{3f6}\x{482}-\x{489}\x{559}-\x{55f}\x{589}-\x{5c7}\x{5f3}-'.
00025 '\x{61f}\x{640}\x{64b}-\x{65e}\x{66a}-\x{66d}\x{670}\x{6d4}\x{6d6}-\x{6ed}'.
00026 '\x{6fd}\x{6fe}\x{700}-\x{70f}\x{711}\x{730}-\x{74a}\x{7a6}-\x{7b0}\x{901}-'.
00027 '\x{903}\x{93c}\x{93e}-\x{94d}\x{951}-\x{954}\x{962}-\x{965}\x{970}\x{981}-'.
00028 '\x{983}\x{9bc}\x{9be}-\x{9cd}\x{9d7}\x{9e2}\x{9e3}\x{9f2}-\x{a03}\x{a3c}-'.
00029 '\x{a4d}\x{a70}\x{a71}\x{a81}-\x{a83}\x{abc}\x{abe}-\x{acd}\x{ae2}\x{ae3}'.
00030 '\x{af1}-\x{b03}\x{b3c}\x{b3e}-\x{b57}\x{b70}\x{b82}\x{bbe}-\x{bd7}\x{bf0}-'.
00031 '\x{c03}\x{c3e}-\x{c56}\x{c82}\x{c83}\x{cbc}\x{cbe}-\x{cd6}\x{d02}\x{d03}'.
00032 '\x{d3e}-\x{d57}\x{d82}\x{d83}\x{dca}-\x{df4}\x{e31}\x{e34}-\x{e3f}\x{e46}-'.
00033 '\x{e4f}\x{e5a}\x{e5b}\x{eb1}\x{eb4}-\x{ebc}\x{ec6}-\x{ecd}\x{f01}-\x{f1f}'.
00034 '\x{f2a}-\x{f3f}\x{f71}-\x{f87}\x{f90}-\x{fd1}\x{102c}-\x{1039}\x{104a}-'.
00035 '\x{104f}\x{1056}-\x{1059}\x{10fb}\x{10fc}\x{135f}-\x{137c}\x{1390}-\x{1399}'.
00036 '\x{166d}\x{166e}\x{1680}\x{169b}\x{169c}\x{16eb}-\x{16f0}\x{1712}-\x{1714}'.
00037 '\x{1732}-\x{1736}\x{1752}\x{1753}\x{1772}\x{1773}\x{17b4}-\x{17db}\x{17dd}'.
00038 '\x{17f0}-\x{180e}\x{1843}\x{18a9}\x{1920}-\x{1945}\x{19b0}-\x{19c0}\x{19c8}'.
00039 '\x{19c9}\x{19de}-\x{19ff}\x{1a17}-\x{1a1f}\x{1d2c}-\x{1d61}\x{1d78}\x{1d9b}-'.
00040 '\x{1dc3}\x{1fbd}\x{1fbf}-\x{1fc1}\x{1fcd}-\x{1fcf}\x{1fdd}-\x{1fdf}\x{1fed}-'.
00041 '\x{1fef}\x{1ffd}-\x{2070}\x{2074}-\x{207e}\x{2080}-\x{2101}\x{2103}-\x{2106}'.
00042 '\x{2108}\x{2109}\x{2114}\x{2116}-\x{2118}\x{211e}-\x{2123}\x{2125}\x{2127}'.
00043 '\x{2129}\x{212e}\x{2132}\x{213a}\x{213b}\x{2140}-\x{2144}\x{214a}-\x{2b13}'.
00044 '\x{2ce5}-\x{2cff}\x{2d6f}\x{2e00}-\x{3005}\x{3007}-\x{303b}\x{303d}-\x{303f}'.
00045 '\x{3099}-\x{309e}\x{30a0}\x{30fb}-\x{30fe}\x{3190}-\x{319f}\x{31c0}-\x{31cf}'.
00046 '\x{3200}-\x{33ff}\x{4dc0}-\x{4dff}\x{a015}\x{a490}-\x{a716}\x{a802}\x{a806}'.
00047 '\x{a80b}\x{a823}-\x{a82b}\x{d800}-\x{f8ff}\x{fb1e}\x{fb29}\x{fd3e}\x{fd3f}'.
00048 '\x{fdfc}-\x{fe6b}\x{feff}-\x{ff0f}\x{ff1a}-\x{ff20}\x{ff3b}-\x{ff40}\x{ff5b}-'.
00049 '\x{ff65}\x{ff70}\x{ff9e}\x{ff9f}\x{ffe0}-\x{fffd}');
00050
00054 define('PREG_CLASS_NUMBERS',
00055 '\x{30}-\x{39}\x{b2}\x{b3}\x{b9}\x{bc}-\x{be}\x{660}-\x{669}\x{6f0}-\x{6f9}'.
00056 '\x{966}-\x{96f}\x{9e6}-\x{9ef}\x{9f4}-\x{9f9}\x{a66}-\x{a6f}\x{ae6}-\x{aef}'.
00057 '\x{b66}-\x{b6f}\x{be7}-\x{bf2}\x{c66}-\x{c6f}\x{ce6}-\x{cef}\x{d66}-\x{d6f}'.
00058 '\x{e50}-\x{e59}\x{ed0}-\x{ed9}\x{f20}-\x{f33}\x{1040}-\x{1049}\x{1369}-'.
00059 '\x{137c}\x{16ee}-\x{16f0}\x{17e0}-\x{17e9}\x{17f0}-\x{17f9}\x{1810}-\x{1819}'.
00060 '\x{1946}-\x{194f}\x{2070}\x{2074}-\x{2079}\x{2080}-\x{2089}\x{2153}-\x{2183}'.
00061 '\x{2460}-\x{249b}\x{24ea}-\x{24ff}\x{2776}-\x{2793}\x{3007}\x{3021}-\x{3029}'.
00062 '\x{3038}-\x{303a}\x{3192}-\x{3195}\x{3220}-\x{3229}\x{3251}-\x{325f}\x{3280}-'.
00063 '\x{3289}\x{32b1}-\x{32bf}\x{ff10}-\x{ff19}');
00064
00068 define('PREG_CLASS_PUNCTUATION',
00069 '\x{21}-\x{23}\x{25}-\x{2a}\x{2c}-\x{2f}\x{3a}\x{3b}\x{3f}\x{40}\x{5b}-\x{5d}'.
00070 '\x{5f}\x{7b}\x{7d}\x{a1}\x{ab}\x{b7}\x{bb}\x{bf}\x{37e}\x{387}\x{55a}-\x{55f}'.
00071 '\x{589}\x{58a}\x{5be}\x{5c0}\x{5c3}\x{5f3}\x{5f4}\x{60c}\x{60d}\x{61b}\x{61f}'.
00072 '\x{66a}-\x{66d}\x{6d4}\x{700}-\x{70d}\x{964}\x{965}\x{970}\x{df4}\x{e4f}'.
00073 '\x{e5a}\x{e5b}\x{f04}-\x{f12}\x{f3a}-\x{f3d}\x{f85}\x{104a}-\x{104f}\x{10fb}'.
00074 '\x{1361}-\x{1368}\x{166d}\x{166e}\x{169b}\x{169c}\x{16eb}-\x{16ed}\x{1735}'.
00075 '\x{1736}\x{17d4}-\x{17d6}\x{17d8}-\x{17da}\x{1800}-\x{180a}\x{1944}\x{1945}'.
00076 '\x{2010}-\x{2027}\x{2030}-\x{2043}\x{2045}-\x{2051}\x{2053}\x{2054}\x{2057}'.
00077 '\x{207d}\x{207e}\x{208d}\x{208e}\x{2329}\x{232a}\x{23b4}-\x{23b6}\x{2768}-'.
00078 '\x{2775}\x{27e6}-\x{27eb}\x{2983}-\x{2998}\x{29d8}-\x{29db}\x{29fc}\x{29fd}'.
00079 '\x{3001}-\x{3003}\x{3008}-\x{3011}\x{3014}-\x{301f}\x{3030}\x{303d}\x{30a0}'.
00080 '\x{30fb}\x{fd3e}\x{fd3f}\x{fe30}-\x{fe52}\x{fe54}-\x{fe61}\x{fe63}\x{fe68}'.
00081 '\x{fe6a}\x{fe6b}\x{ff01}-\x{ff03}\x{ff05}-\x{ff0a}\x{ff0c}-\x{ff0f}\x{ff1a}'.
00082 '\x{ff1b}\x{ff1f}\x{ff20}\x{ff3b}-\x{ff3d}\x{ff3f}\x{ff5b}\x{ff5d}\x{ff5f}-'.
00083 '\x{ff65}');
00084
00090 define('PREG_CLASS_CJK', '\x{3041}-\x{30ff}\x{31f0}-\x{31ff}\x{3400}-\x{4db5}'.
00091 '\x{4e00}-\x{9fbb}\x{f900}-\x{fad9}');
00092
00096 function search_help($path, $arg) {
00097   switch ($path) {
00098     case 'admin/help#search':
00099       $output = '<p>'. t('The search module adds the ability to search for content by keywords. Search is often the only practical way to find content on a large site, and is useful for finding both users and posts.') .'</p>';
00100       $output .= '<p>'. t('To provide keyword searching, the search engine maintains an index of words found in your site\'s content. To build and maintain this index, a correctly configured <a href="@cron">cron maintenance task</a> is required. Indexing behavior can be adjusted using the <a href="@searchsettings">search settings page</a>; for example, the <em>Number of items to index per cron run</em> sets the maximum number of items indexed in each pass of a <a href="@cron">cron maintenance task</a>. If necessary, reduce this number to prevent timeouts and memory errors when indexing.', array('@cron' => url('admin/reports/status'), '@searchsettings' => url('admin/settings/search'))) .'</p>';
00101       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@search">Search module</a>.', array('@search' => 'http://drupal.org/handbook/modules/search/')) .'</p>';
00102       return $output;
00103     case 'admin/settings/search':
00104       return '<p>'. t('The search engine maintains an index of words found in your site\'s content. To build and maintain this index, a correctly configured <a href="@cron">cron maintenance task</a> is required. Indexing behavior can be adjusted using the settings below.', array('@cron' => url('admin/reports/status'))) .'</p>';
00105     case 'search#noresults':
00106       return t('<ul>
00107 <li>Check if your spelling is correct.</li>
00108 <li>Remove quotes around phrases to match each word individually: <em>"blue smurf"</em> will match less than <em>blue smurf</em>.</li>
00109 <li>Consider loosening your query with <em>OR</em>: <em>blue smurf</em> will match less than <em>blue OR smurf</em>.</li>
00110 </ul>');
00111   }
00112 }
00113
00117 function search_theme() {
00118   return array(
00119     'search_theme_form' => array(
00120       'arguments' => array('form' => NULL),
00121       'template' => 'search-theme-form',
00122     ),
00123     'search_block_form' => array(
00124       'arguments' => array('form' => NULL),
00125       'template' => 'search-block-form',
00126     ),
00127     'search_result' => array(
00128       'arguments' => array('result' => NULL, 'type' => NULL),
00129       'file' => 'search.pages.inc',
00130       'template' => 'search-result',
00131     ),
00132     'search_results' => array(
00133       'arguments' => array('results' => NULL, 'type' => NULL),
00134       'file' => 'search.pages.inc',
00135       'template' => 'search-results',
00136     ),
00137   );
00138 }
00139
00143 function search_perm() {
00144   return array('search content', 'use advanced search', 'administer search');
00145 }
00146
00150 function search_block($op = 'list', $delta = 0) {
00151   if ($op == 'list') {
00152     $blocks[0]['info'] = t('Search form');
00153     // Not worth caching.
00154     $blocks[0]['cache'] = BLOCK_NO_CACHE;
00155     return $blocks;
00156   }
00157   else if ($op == 'view' && user_access('search content')) {
00158     $block['content'] = drupal_get_form('search_block_form');
00159     $block['subject'] = t('Search');
00160     return $block;
00161   }
00162 }
00163
00167 function search_menu() {
00168   $items['search'] = array(
00169     'title' => 'Search',
00170     'page callback' => 'search_view',
00171     'access arguments' => array('search content'),
00172     'type' => MENU_SUGGESTED_ITEM,
00173     'file' => 'search.pages.inc',
00174   );
00175   $items['admin/settings/search'] = array(
00176     'title' => 'Search settings',
00177     'description' => 'Configure relevance settings for search and other indexing options',
00178     'page callback' => 'drupal_get_form',
00179     'page arguments' => array('search_admin_settings'),
00180     'access arguments' => array('administer search'),
00181     'type' => MENU_NORMAL_ITEM,
00182     'file' => 'search.admin.inc',
00183   );
00184   $items['admin/settings/search/wipe'] = array(
00185     'title' => 'Clear index',
00186     'page callback' => 'drupal_get_form',
00187     'page arguments' => array('search_wipe_confirm'),
00188     'access arguments' => array('administer search'),
00189     'type' => MENU_CALLBACK,
00190     'file' => 'search.admin.inc',
00191   );
00192   $items['admin/reports/search'] = array(
00193     'title' => 'Top search phrases',
00194     'description' => 'View most popular search phrases.',
00195     'page callback' => 'dblog_top',
00196     'page arguments' => array('search'),
00197     'file' => 'dblog.admin.inc',
00198     'file path' => drupal_get_path('module', 'dblog'),
00199   );
00200
00201   foreach (module_implements('search') as $name) {
00202     $items['search/'. $name .'/%menu_tail'] = array(
00203       'title callback' => 'module_invoke',
00204       'title arguments' => array($name, 'search', 'name', TRUE),
00205       'page callback' => 'search_view',
00206       'page arguments' => array($name),
00207       'access callback' => '_search_menu',
00208       'access arguments' => array($name),
00209       'type' => MENU_LOCAL_TASK,
00210       'parent' => 'search',
00211       'file' => 'search.pages.inc',
00212     );
00213   }
00214   return $items;
00215 }
00216
00217 function _search_menu($name) {
00218   return user_access('search content') && module_invoke($name, 'search', 'name');
00219 }
00220
00230 function search_wipe($sid = NULL, $type = NULL, $reindex = FALSE) {
00231   if ($type == NULL && $sid == NULL) {
00232     module_invoke_all('search', 'reset');
00233   }
00234   else {
00235     db_query("DELETE FROM {search_dataset} WHERE sid = %d AND type = '%s'", $sid, $type);
00236     db_query("DELETE FROM {search_index} WHERE sid = %d AND type = '%s'", $sid, $type);
00237     // Don't remove links if re-indexing.
00238     if (!$reindex) {
00239       db_query("DELETE FROM {search_node_links} WHERE sid = %d AND type = '%s'", $sid, $type);
00240     }
00241   }
00242 }
00243
00249 function search_dirty($word = NULL) {
00250   static $dirty = array();
00251   if ($word !== NULL) {
00252     $dirty[$word] = TRUE;
00253   }
00254   else {
00255     return $dirty;
00256   }
00257 }
00258
00265 function search_cron() {
00266   // We register a shutdown function to ensure that search_total is always up
00267   // to date.
00268   register_shutdown_function('search_update_totals');
00269
00270   // Update word index
00271   foreach (module_list() as $module) {
00272     module_invoke($module, 'update_index');
00273   }
00274 }
00275
00280 function search_update_totals() {
00281   // Update word IDF (Inverse Document Frequency) counts for new/changed words
00282   foreach (search_dirty() as $word => $dummy) {
00283     // Get total count
00284     $total = db_result(db_query("SELECT SUM(score) FROM {search_index} WHERE word = '%s'", $word));
00285     // Apply Zipf's law to equalize the probability distribution
00286     $total = log10(1 + 1/(max(1, $total)));
00287     db_query("UPDATE {search_total} SET count = %f WHERE word = '%s'", $total, $word);
00288     if (!db_affected_rows()) {
00289       db_query("INSERT INTO {search_total} (word, count) VALUES ('%s', %f)", $word, $total);
00290     }
00291   }
00292   // Find words that were deleted from search_index, but are still in
00293   // search_total. We use a LEFT JOIN between the two tables and keep only the
00294   // rows which fail to join.
00295   $result = db_query("SELECT t.word AS realword, i.word FROM {search_total} t LEFT JOIN {search_index} i ON t.word = i.word WHERE i.word IS NULL");
00296   while ($word = db_fetch_object($result)) {
00297     db_query("DELETE FROM {search_total} WHERE word = '%s'", $word->realword);
00298   }
00299 }
00300
00304 function search_simplify($text) {
00305   // Decode entities to UTF-8
00306   $text = decode_entities($text);
00307
00308   // Lowercase
00309   $text = drupal_strtolower($text);
00310
00311   // Call an external processor for word handling.
00312   search_invoke_preprocess($text);
00313
00314   // Simple CJK handling
00315   if (variable_get('overlap_cjk', TRUE)) {
00316     $text = preg_replace_callback('/['. PREG_CLASS_CJK .']+/u', 'search_expand_cjk', $text);
00317   }
00318
00319   // To improve searching for numerical data such as dates, IP addresses
00320   // or version numbers, we consider a group of numerical characters
00321   // separated only by punctuation characters to be one piece.
00322   // This also means that searching for e.g. '20/03/1984' also returns
00323   // results with '20-03-1984' in them.
00324   // Readable regexp: ([number]+)[punctuation]+(?=[number])
00325   $text = preg_replace('/(['. PREG_CLASS_NUMBERS .']+)['. PREG_CLASS_PUNCTUATION .']+(?=['. PREG_CLASS_NUMBERS .'])/u', '\1', $text);
00326
00327   // The dot, underscore and dash are simply removed. This allows meaningful
00328   // search behavior with acronyms and URLs.
00329   $text = preg_replace('/[._-]+/', '', $text);
00330
00331   // With the exception of the rules above, we consider all punctuation,
00332   // marks, spacers, etc, to be a word boundary.
00333   $text = preg_replace('/['. PREG_CLASS_SEARCH_EXCLUDE .']+/u', ' ', $text);
00334
00335   return $text;
00336 }
00337
00342 function search_expand_cjk($matches) {
00343   $min = variable_get('minimum_word_size', 3);
00344   $str = $matches[0];
00345   $l = drupal_strlen($str);
00346   // Passthrough short words
00347   if ($l <= $min) {
00348     return ' '. $str .' ';
00349   }
00350   $tokens = ' ';
00351   // FIFO queue of characters
00352   $chars = array();
00353   // Begin loop
00354   for ($i = 0; $i < $l; ++$i) {
00355     // Grab next character
00356     $current = drupal_substr($str, 0, 1);
00357     $str = substr($str, strlen($current));
00358     $chars[] = $current;
00359     if ($i >= $min - 1) {
00360       $tokens .= implode('', $chars) .' ';
00361       array_shift($chars);
00362     }
00363   }
00364   return $tokens;
00365 }
00366
00370 function search_index_split($text) {
00371   static $last = NULL;
00372   static $lastsplit = NULL;
00373
00374   if ($last == $text) {
00375     return $lastsplit;
00376   }
00377   // Process words
00378   $text = search_simplify($text);
00379   $words = explode(' ', $text);
00380   array_walk($words, '_search_index_truncate');
00381
00382   // Save last keyword result
00383   $last = $text;
00384   $lastsplit = $words;
00385
00386   return $words;
00387 }
00388
00392 function _search_index_truncate(&$text) {
00393   $text = truncate_utf8($text, 50);
00394 }
00395
00399 function search_invoke_preprocess(&$text) {
00400   foreach (module_implements('search_preprocess') as $module) {
00401     $text = module_invoke($module, 'search_preprocess', $text);
00402   }
00403 }
00404
00419 function search_index($sid, $type, $text) {
00420   $minimum_word_size = variable_get('minimum_word_size', 3);
00421
00422   // Link matching
00423   global $base_url;
00424   $node_regexp = '@href=[\'"]?(?:'. preg_quote($base_url, '@') .'/|'. preg_quote(base_path(), '@') .')(?:\?q=)?/?((?![a-z]+:)[^\'">]+)[\'">]@i';
00425
00426   // Multipliers for scores of words inside certain HTML tags.
00427   // Note: 'a' must be included for link ranking to work.
00428   $tags = array('h1' => 25,
00429                 'h2' => 18,
00430                 'h3' => 15,
00431                 'h4' => 12,
00432                 'h5' => 9,
00433                 'h6' => 6,
00434                 'u' => 3,
00435                 'b' => 3,
00436                 'i' => 3,
00437                 'strong' => 3,
00438                 'em' => 3,
00439                 'a' => 10);
00440
00441   // Strip off all ignored tags to speed up processing, but insert space before/after
00442   // them to keep word boundaries.
00443   $text = str_replace(array('<', '>'), array(' <', '> '), $text);
00444   $text = strip_tags($text, '<'. implode('><', array_keys($tags)) .'>');
00445
00446   // Split HTML tags from plain text.
00447   $split = preg_split('/\s*<([^>]+?)>\s*/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
00448   // Note: PHP ensures the array consists of alternating delimiters and literals
00449   // and begins and ends with a literal (inserting $null as required).
00450
00451   $tag = FALSE; // Odd/even counter. Tag or no tag.
00452   $link = FALSE; // State variable for link analyser
00453   $score = 1; // Starting score per word
00454   $accum = ' '; // Accumulator for cleaned up data
00455   $tagstack = array(); // Stack with open tags
00456   $tagwords = 0; // Counter for consecutive words
00457   $focus = 1; // Focus state
00458
00459   $results = array(0 => array()); // Accumulator for words for index
00460
00461   foreach ($split as $value) {
00462     if ($tag) {
00463       // Increase or decrease score per word based on tag
00464       list($tagname) = explode(' ', $value, 2);
00465       $tagname = drupal_strtolower($tagname);
00466       // Closing or opening tag?
00467       if ($tagname[0] == '/') {
00468         $tagname = substr($tagname, 1);
00469         // If we encounter unexpected tags, reset score to avoid incorrect boosting.
00470         if (!count($tagstack) || $tagstack[0] != $tagname) {
00471           $tagstack = array();
00472           $score = 1;
00473         }
00474         else {
00475           // Remove from tag stack and decrement score
00476           $score = max(1, $score - $tags[array_shift($tagstack)]);
00477         }
00478         if ($tagname == 'a') {
00479           $link = FALSE;
00480         }
00481       }
00482       else {
00483         if (isset($tagstack[0]) && $tagstack[0] == $tagname) {
00484           // None of the tags we look for make sense when nested identically.
00485           // If they are, it's probably broken HTML.
00486           $tagstack = array();
00487           $score = 1;
00488         }
00489         else {
00490           // Add to open tag stack and increment score
00491           array_unshift($tagstack, $tagname);
00492           $score += $tags[$tagname];
00493         }
00494         if ($tagname == 'a') {
00495           // Check if link points to a node on this site
00496           if (preg_match($node_regexp, $value, $match)) {
00497             $path = drupal_get_normal_path($match[1]);
00498             if (preg_match('!(?:node|book)/(?:view/)?([0-9]+)!i', $path, $match)) {
00499               $linknid = $match[1];
00500               if ($linknid > 0) {
00501                 // Note: ignore links to uncachable nodes to avoid redirect bugs.
00502                 $node = db_fetch_object(db_query('SELECT n.title, n.nid, n.vid, r.format FROM {node} n INNER JOIN {node_revisions} r ON n.vid = r.vid WHERE n.nid = %d', $linknid));
00503                 if (filter_format_allowcache($node->format)) {
00504                   $link = TRUE;
00505                   $linktitle = $node->title;
00506                 }
00507               }
00508             }
00509           }
00510         }
00511       }
00512       // A tag change occurred, reset counter.
00513       $tagwords = 0;
00514     }
00515     else {
00516       // Note: use of PREG_SPLIT_DELIM_CAPTURE above will introduce empty values
00517       if ($value != '') {
00518         if ($link) {
00519           // Check to see if the node link text is its URL. If so, we use the target node title instead.
00520           if (preg_match('!^https?://!i', $value)) {
00521             $value = $linktitle;
00522           }
00523         }
00524         $words = search_index_split($value);
00525         foreach ($words as $word) {
00526           // Add word to accumulator
00527           $accum .= $word .' ';
00528           $num = is_numeric($word);
00529           // Check wordlength
00530           if ($num || drupal_strlen($word) >= $minimum_word_size) {
00531             // Normalize numbers
00532             if ($num) {
00533               $word = (int)ltrim($word, '-0');
00534             }
00535
00536             // Links score mainly for the target.
00537             if ($link) {
00538               if (!isset($results[$linknid])) {
00539                 $results[$linknid] = array();
00540               }
00541               $results[$linknid][] = $word;
00542               // Reduce score of the link caption in the source.
00543               $focus *= 0.2;
00544             }
00545             // Fall-through
00546             if (!isset($results[0][$word])) {
00547               $results[0][$word] = 0;
00548             }
00549             $results[0][$word] += $score * $focus;
00550
00551             // Focus is a decaying value in terms of the amount of unique words up to this point.
00552             // From 100 words and more, it decays, to e.g. 0.5 at 500 words and 0.3 at 1000 words.
00553             $focus = min(1, .01 + 3.5 / (2 + count($results[0]) * .015));
00554           }
00555           $tagwords++;
00556           // Too many words inside a single tag probably mean a tag was accidentally left open.
00557           if (count($tagstack) && $tagwords >= 15) {
00558             $tagstack = array();
00559             $score = 1;
00560           }
00561         }
00562       }
00563     }
00564     $tag = !$tag;
00565   }
00566
00567   search_wipe($sid, $type, TRUE);
00568
00569   // Insert cleaned up data into dataset
00570   db_query("INSERT INTO {search_dataset} (sid, type, data, reindex) VALUES (%d, '%s', '%s', %d)", $sid, $type, $accum, 0);
00571
00572   // Insert results into search index
00573   foreach ($results[0] as $word => $score) {
00574     // The database will collate similar words (accented and non-accented forms, etc.),
00575     // and the score is additive, so first add and then insert.
00576     db_query("UPDATE {search_index} SET score = score + %d WHERE word = '%s' AND sid = '%d' AND type = '%s'", $score, $word, $sid, $type);
00577     if (!db_affected_rows()) {
00578       db_query("INSERT INTO {search_index} (word, sid, type, score) VALUES ('%s', %d, '%s', %f)", $word, $sid, $type, $score);
00579     }
00580     search_dirty($word);
00581   }
00582   unset($results[0]);
00583
00584   // Get all previous links from this item.
00585   $result = db_query("SELECT nid, caption FROM {search_node_links} WHERE sid = %d AND type = '%s'", $sid, $type);
00586   $links = array();
00587   while ($link = db_fetch_object($result)) {
00588     $links[$link->nid] = $link->caption;
00589   }
00590
00591   // Now store links to nodes.
00592   foreach ($results as $nid => $words) {
00593     $caption = implode(' ', $words);
00594     if (isset($links[$nid])) {
00595       if ($links[$nid] != $caption) {
00596         // Update the existing link and mark the node for reindexing.
00597         db_query("UPDATE {search_node_links} SET caption = '%s' WHERE sid = %d AND type = '%s' AND nid = %d", $caption, $sid, $type, $nid);
00598         search_touch_node($nid);
00599       }
00600       // Unset the link to mark it as processed.
00601       unset($links[$nid]);
00602     }
00603     else {
00604       // Insert the existing link and mark the node for reindexing.
00605       db_query("INSERT INTO {search_node_links} (caption, sid, type, nid) VALUES ('%s', %d, '%s', %d)", $caption, $sid, $type, $nid);
00606       search_touch_node($nid);
00607     }
00608   }
00609   // Any left-over links in $links no longer exist. Delete them and mark the nodes for reindexing.
00610   foreach ($links as $nid => $caption) {
00611     db_query("DELETE FROM {search_node_links} WHERE sid = %d AND type = '%s' AND nid = %d", $sid, $type, $nid);
00612     search_touch_node($nid);
00613   }
00614 }
00615
00622 function search_touch_node($nid) {
00623   db_query("UPDATE {search_dataset} SET reindex = %d WHERE sid = %d AND type = 'node'", time(), $nid);
00624 }
00625
00629 function search_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
00630   switch ($op) {
00631     // Transplant links to a node into the target node.
00632     case 'update index':
00633       $result = db_query("SELECT caption FROM {search_node_links} WHERE nid = %d", $node->nid);
00634       $output = array();
00635       while ($link = db_fetch_object($result)) {
00636         $output[] = $link->caption;
00637       }
00638       return '<a>('. implode(', ', $output) .')</a>';
00639     // Reindex the node when it is updated.  The node is automatically indexed
00640     // when it is added, simply by being added to the node table.
00641     case 'update':
00642       search_touch_node($node->nid);
00643       break;
00644   }
00645 }
00646
00650 function search_comment($a1, $op) {
00651   switch ($op) {
00652     // Reindex the node when comments are added or changed
00653     case 'insert':
00654     case 'update':
00655     case 'delete':
00656     case 'publish':
00657     case 'unpublish':
00658       search_touch_node(is_array($a1) ? $a1['nid'] : $a1->nid);
00659       break;
00660   }
00661 }
00662
00666 function search_query_extract($keys, $option) {
00667   if (preg_match('/(^| )'. $option .':([^ ]*)( |$)/i', $keys, $matches)) {
00668     return $matches[2];
00669   }
00670 }
00671
00676 function search_query_insert($keys, $option, $value = '') {
00677   if (search_query_extract($keys, $option)) {
00678     $keys = trim(preg_replace('/(^| )'. $option .':[^ ]*/i', '', $keys));
00679   }
00680   if ($value != '') {
00681     $keys .= ' '. $option .':'. $value;
00682   }
00683   return $keys;
00684 }
00685
00706 function search_parse_query($text) {
00707   $keys = array('positive' => array(), 'negative' => array());
00708
00709   // Tokenize query string
00710   preg_match_all('/ (-?)("[^"]+"|[^" ]+)/i', ' '. $text, $matches, PREG_SET_ORDER);
00711
00712   if (count($matches) < 1) {
00713     return NULL;
00714   }
00715
00716   // Classify tokens
00717   $or = FALSE;
00718   $warning = '';
00719   $simple = TRUE;
00720   foreach ($matches as $match) {
00721     $phrase = FALSE;
00722     // Strip off phrase quotes
00723     if ($match[2]{0} == '"') {
00724       $match[2] = substr($match[2], 1, -1);
00725       $phrase = TRUE;
00726       $simple = FALSE;
00727     }
00728     // Simplify keyword according to indexing rules and external preprocessors
00729     $words = search_simplify($match[2]);
00730     // Re-explode in case simplification added more words, except when matching a phrase
00731     $words = $phrase ? array($words) : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY);
00732     // Negative matches
00733     if ($match[1] == '-') {
00734       $keys['negative'] = array_merge($keys['negative'], $words);
00735     }
00736     // OR operator: instead of a single keyword, we store an array of all
00737     // OR'd keywords.
00738     elseif ($match[2] == 'OR' && count($keys['positive'])) {
00739       $last = array_pop($keys['positive']);
00740       // Starting a new OR?
00741       if (!is_array($last)) {
00742         $last = array($last);
00743       }
00744       $keys['positive'][] = $last;
00745       $or = TRUE;
00746       continue;
00747     }
00748     // AND operator: implied, so just ignore it
00749     elseif ($match[2] == 'AND' || $match[2] == 'and') {
00750       $warning = $match[2];
00751       continue;
00752     }
00753
00754     // Plain keyword
00755     else {
00756       if ($match[2] == 'or') {
00757         $warning = $match[2];
00758       }
00759       if ($or) {
00760         // Add to last element (which is an array)
00761         $keys['positive'][count($keys['positive']) - 1] = array_merge($keys['positive'][count($keys['positive']) - 1], $words);
00762       }
00763       else {
00764         $keys['positive'] = array_merge($keys['positive'], $words);
00765       }
00766     }
00767     $or = FALSE;
00768   }
00769
00770   // Convert keywords into SQL statements.
00771   $query = array();
00772   $query2 = array();
00773   $arguments = array();
00774   $arguments2 = array();
00775   $matches = 0;
00776   $simple_and = FALSE;
00777   $simple_or = FALSE;
00778   // Positive matches
00779   foreach ($keys['positive'] as $key) {
00780     // Group of ORed terms
00781     if (is_array($key) && count($key)) {
00782       $simple_or = TRUE;
00783       $queryor = array();
00784       $any = FALSE;
00785       foreach ($key as $or) {
00786         list($q, $num_new_scores) = _search_parse_query($or, $arguments2);
00787         $any |= $num_new_scores;
00788         if ($q) {
00789           $queryor[] = $q;
00790           $arguments[] = $or;
00791         }
00792       }
00793       if (count($queryor)) {
00794         $query[] = '('. implode(' OR ', $queryor) .')';
00795         // A group of OR keywords only needs to match once
00796         $matches += ($any > 0);
00797       }
00798     }
00799     // Single ANDed term
00800     else {
00801       $simple_and = TRUE;
00802       list($q, $num_new_scores, $num_valid_words) = _search_parse_query($key, $arguments2);
00803       if ($q) {
00804         $query[] = $q;
00805         $arguments[] = $key;
00806         if (!$num_valid_words) {
00807           $simple = FALSE;
00808         }
00809         // Each AND keyword needs to match at least once
00810         $matches += $num_new_scores;
00811       }
00812     }
00813   }
00814   if ($simple_and && $simple_or) {
00815     $simple = FALSE;
00816   }
00817   // Negative matches
00818   foreach ($keys['negative'] as $key) {
00819     list($q) = _search_parse_query($key, $arguments2, TRUE);
00820     if ($q) {
00821       $query[] = $q;
00822       $arguments[] = $key;
00823       $simple = FALSE;
00824     }
00825   }
00826   $query = implode(' AND ', $query);
00827
00828   // Build word-index conditions for the first pass
00829   $query2 = substr(str_repeat("i.word = '%s' OR ", count($arguments2)), 0, -4);
00830
00831   return array($query, $arguments, $query2, $arguments2, $matches, $simple, $warning);
00832 }
00833
00837 function _search_parse_query(&$word, &$scores, $not = FALSE) {
00838   $num_new_scores = 0;
00839   $num_valid_words = 0;
00840   // Determine the scorewords of this word/phrase
00841   if (!$not) {
00842     $split = explode(' ', $word);
00843     foreach ($split as $s) {
00844       $num = is_numeric($s);
00845       if ($num || drupal_strlen($s) >= variable_get('minimum_word_size', 3)) {
00846         $s = $num ? ((int)ltrim($s, '-0')) : $s;
00847         if (!isset($scores[$s])) {
00848           $scores[$s] = $s;
00849           $num_new_scores++;
00850         }
00851         $num_valid_words++;
00852       }
00853     }
00854   }
00855   // Return matching snippet and number of added words
00856   return array("d.data ". ($not ? 'NOT ' : '') ."LIKE '%% %s %%'", $num_new_scores, $num_valid_words);
00857 }
00858
00913 function do_search($keywords, $type, $join1 = '', $where1 = '1', $arguments1 = array(), $columns2 = 'i.relevance AS score', $join2 = '', $arguments2 = array(), $sort_parameters = 'ORDER BY score DESC') {
00914   $query = search_parse_query($keywords);
00915
00916   if ($query[2] == '') {
00917     form_set_error('keys', t('You must include at least one positive keyword with @count characters or more.', array('@count' => variable_get('minimum_word_size', 3))));
00918   }
00919   if ($query[6]) {
00920     if ($query[6] == 'or') {
00921       drupal_set_message(t('Search for either of the two terms with uppercase <strong>OR</strong>. For example, <strong>cats OR dogs</strong>.'));
00922     }
00923   }
00924   if ($query === NULL || $query[0] == '' || $query[2] == '') {
00925     return array();
00926   }
00927
00928   // Build query for keyword normalization.
00929   $conditions = "$where1 AND ($query[2]) AND i.type = '%s'";
00930   $arguments1 = array_merge($arguments1, $query[3], array($type));
00931   $join = "INNER JOIN {search_total} t ON i.word = t.word $join1";
00932   if (!$query[5]) {
00933     $conditions .= " AND ($query[0])";
00934     $arguments1 = array_merge($arguments1, $query[1]);
00935     $join .= " INNER JOIN {search_dataset} d ON i.sid = d.sid AND i.type = d.type";
00936   }
00937
00938   // Calculate maximum keyword relevance, to normalize it.
00939   $select = "SELECT SUM(i.score * t.count) AS score FROM {search_index} i $join WHERE $conditions GROUP BY i.type, i.sid HAVING COUNT(*) >= %d ORDER BY score DESC";
00940   $arguments = array_merge($arguments1, array($query[4]));
00941   $normalize = db_result(db_query_range($select, $arguments, 0, 1));
00942   if (!$normalize) {
00943     return array();
00944   }
00945   $columns2 = str_replace('i.relevance', '('. (1.0 / $normalize) .' * SUM(i.score * t.count))', $columns2);
00946
00947   // Build query to retrieve results.
00948   $select = "SELECT i.type, i.sid, $columns2 FROM {search_index} i $join $join2 WHERE $conditions GROUP BY i.type, i.sid HAVING COUNT(*) >= %d";
00949   $count_select =  "SELECT COUNT(*) FROM ($select) n1";
00950   $arguments = array_merge($arguments2, $arguments1, array($query[4]));
00951
00952   // Do actual search query
00953   $result = pager_query("$select $sort_parameters", 10, 0, $count_select, $arguments);
00954   $results = array();
00955   while ($item = db_fetch_object($result)) {
00956     $results[] = $item;
00957   }
00958   return $results;
00959 }
00960
00964 function search_get_keys() {
00965   static $return;
00966   if (!isset($return)) {
00967     // Extract keys as remainder of path
00968     // Note: support old GET format of searches for existing links.
00969     $path = explode('/', $_GET['q'], 3);
00970     $keys = empty($_REQUEST['keys']) ? '' : $_REQUEST['keys'];
00971     $return = count($path) == 3 ? $path[2] : $keys;
00972   }
00973   return $return;
00974 }
00975
01019 function search_form(&$form_state, $action = '', $keys = '', $type = NULL, $prompt = NULL) {
01020
01021   // Add CSS
01022   drupal_add_css(drupal_get_path('module', 'search') .'/search.css', 'module', 'all', FALSE);
01023
01024   if (!$action) {
01025     $action = url('search/'. $type);
01026   }
01027   if (is_null($prompt)) {
01028     $prompt = t('Enter your keywords');
01029   }
01030
01031   $form = array(
01032     '#action' => $action,
01033     '#attributes' => array('class' => 'search-form'),
01034   );
01035   $form['module'] = array('#type' => 'value', '#value' => $type);
01036   $form['basic'] = array('#type' => 'item', '#title' => $prompt);
01037   $form['basic']['inline'] = array('#prefix' => '<div class="container-inline">', '#suffix' => '</div>');
01038   $form['basic']['inline']['keys'] = array(
01039     '#type' => 'textfield',
01040     '#title' => '',
01041     '#default_value' => $keys,
01042     '#size' => $prompt ? 40 : 20,
01043     '#maxlength' => 255,
01044   );
01045   // processed_keys is used to coordinate keyword passing between other forms
01046   // that hook into the basic search form.
01047   $form['basic']['inline']['processed_keys'] = array('#type' => 'value', '#value' => array());
01048   $form['basic']['inline']['submit'] = array('#type' => 'submit', '#value' => t('Search'));
01049
01050   return $form;
01051 }
01052
01060 function search_box(&$form_state, $form_id) {
01061   $form[$form_id] = array(
01062     '#title' => t('Search this site'),
01063     '#type' => 'textfield',
01064     '#size' => 15,
01065     '#default_value' => '',
01066     '#attributes' => array('title' => t('Enter the terms you wish to search for.')),
01067   );
01068   $form['submit'] = array('#type' => 'submit', '#value' => t('Search'));
01069   $form['#submit'][] = 'search_box_form_submit';
01070   $form['#validate'][] = 'search_box_form_validate';
01071
01072   return $form;
01073 }
01074
01078 function search_box_form_submit($form, &$form_state) {
01079   $form_id = $form['form_id']['#value'];
01080   $form_state['redirect'] = 'search/node/'. trim($form_state['values'][$form_id]);
01081 }
01082
01091 function template_preprocess_search_theme_form(&$variables) {
01092   $variables['search'] = array();
01093   $hidden = array();
01094   // Provide variables named after form keys so themers can print each element independently.
01095   foreach (element_children($variables['form']) as $key) {
01096     $type = $variables['form'][$key]['#type'];
01097     if ($type == 'hidden' || $type == 'token') {
01098       $hidden[] = drupal_render($variables['form'][$key]);
01099     }
01100     else {
01101       $variables['search'][$key] = drupal_render($variables['form'][$key]);
01102     }
01103   }
01104   // Hidden form elements have no value to themers. No need for separation.
01105   $variables['search']['hidden'] = implode($hidden);
01106   // Collect all form elements to make it easier to print the whole form.
01107   $variables['search_form'] = implode($variables['search']);
01108 }
01109
01118 function template_preprocess_search_block_form(&$variables) {
01119   $variables['search'] = array();
01120   $hidden = array();
01121   // Provide variables named after form keys so themers can print each element independently.
01122   foreach (element_children($variables['form']) as $key) {
01123     $type = $variables['form'][$key]['#type'];
01124     if ($type == 'hidden' || $type == 'token') {
01125       $hidden[] = drupal_render($variables['form'][$key]);
01126     }
01127     else {
01128       $variables['search'][$key] = drupal_render($variables['form'][$key]);
01129     }
01130   }
01131   // Hidden form elements have no value to themers. No need for separation.
01132   $variables['search']['hidden'] = implode($hidden);
01133   // Collect all form elements to make it easier to print the whole form.
01134   $variables['search_form'] = implode($variables['search']);
01135 }
01136
01140 function search_data($keys = NULL, $type = 'node') {
01141
01142   if (isset($keys)) {
01143     if (module_hook($type, 'search')) {
01144       $results = module_invoke($type, 'search', 'search', $keys);
01145       if (isset($results) && is_array($results) && count($results)) {
01146         if (module_hook($type, 'search_page')) {
01147           return module_invoke($type, 'search_page', $results);
01148         }
01149         else {
01150           return theme('search_results', $results, $type);
01151         }
01152       }
01153     }
01154   }
01155 }
01156
01170 function search_excerpt($keys, $text) {
01171   // We highlight around non-indexable or CJK characters.
01172   $boundary = '(?:(?<=['. PREG_CLASS_SEARCH_EXCLUDE . PREG_CLASS_CJK .'])|(?=['. PREG_CLASS_SEARCH_EXCLUDE . PREG_CLASS_CJK .']))';
01173
01174   // Extract positive keywords and phrases
01175   preg_match_all('/ ("([^"]+)"|(?!OR)([^" ]+))/', ' '. $keys, $matches);
01176   $keys = array_merge($matches[2], $matches[3]);
01177
01178   // Prepare text
01179   $text = ' '. strip_tags(str_replace(array('<', '>'), array(' <', '> '), $text)) .' ';
01180   array_walk($keys, '_search_excerpt_replace');
01181   $workkeys = $keys;
01182
01183   // Extract a fragment per keyword for at most 4 keywords.
01184   // First we collect ranges of text around each keyword, starting/ending
01185   // at spaces.
01186   // If the sum of all fragments is too short, we look for second occurrences.
01187   $ranges = array();
01188   $included = array();
01189   $length = 0;
01190   while ($length < 256 && count($workkeys)) {
01191     foreach ($workkeys as $k => $key) {
01192       if (strlen($key) == 0) {
01193         unset($workkeys[$k]);
01194         unset($keys[$k]);
01195         continue;
01196       }
01197       if ($length >= 256) {
01198         break;
01199       }
01200       // Remember occurrence of key so we can skip over it if more occurrences
01201       // are desired.
01202       if (!isset($included[$key])) {
01203         $included[$key] = 0;
01204       }
01205       // Locate a keyword (position $p), then locate a space in front (position
01206       // $q) and behind it (position $s)
01207       if (preg_match('/'. $boundary . $key . $boundary .'/iu', $text, $match, PREG_OFFSET_CAPTURE, $included[$key])) {
01208         $p = $match[0][1];
01209         if (($q = strpos($text, ' ', max(0, $p - 60))) !== FALSE) {
01210           $end = substr($text, $p, 80);
01211           if (($s = strrpos($end, ' ')) !== FALSE) {
01212             $ranges[$q] = $p + $s;
01213             $length += $p + $s - $q;
01214             $included[$key] = $p + 1;
01215           }
01216           else {
01217             unset($workkeys[$k]);
01218           }
01219         }
01220         else {
01221           unset($workkeys[$k]);
01222         }
01223       }
01224       else {
01225         unset($workkeys[$k]);
01226       }
01227     }
01228   }
01229
01230   // If we didn't find anything, return the beginning.
01231   if (count($ranges) == 0) {
01232     return truncate_utf8($text, 256) .' ...';
01233   }
01234
01235   // Sort the text ranges by starting position.
01236   ksort($ranges);
01237
01238   // Now we collapse overlapping text ranges into one. The sorting makes it O(n).
01239   $newranges = array();
01240   foreach ($ranges as $from2 => $to2) {
01241     if (!isset($from1)) {
01242       $from1 = $from2;
01243       $to1 = $to2;
01244       continue;
01245     }
01246     if ($from2 <= $to1) {
01247       $to1 = max($to1, $to2);
01248     }
01249     else {
01250       $newranges[$from1] = $to1;
01251       $from1 = $from2;
01252       $to1 = $to2;
01253     }
01254   }
01255   $newranges[$from1] = $to1;
01256
01257   // Fetch text
01258   $out = array();
01259   foreach ($newranges as $from => $to) {
01260     $out[] = substr($text, $from, $to - $from);
01261   }
01262   $text = (isset($newranges[0]) ? '' : '... ') . implode(' ... ', $out) .' ...';
01263
01264   // Highlight keywords. Must be done at once to prevent conflicts ('strong' and '<strong>').
01265   $text = preg_replace('/'. $boundary .'('. implode('|', $keys) .')'. $boundary .'/iu', '<strong>\0</strong>', $text);
01266   return $text;
01267 }
01268
01276 function _search_excerpt_replace(&$text) {
01277   $text = preg_quote($text, '/');
01278 }
01279
01280 function search_forms() {
01281   $forms['search_theme_form']= array(
01282     'callback' => 'search_box',
01283     'callback arguments' => array('search_theme_form'),
01284   );
01285   $forms['search_block_form']= array(
01286     'callback' => 'search_box',
01287     'callback arguments' => array('search_block_form'),
01288   );
01289   return $forms;
01290 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/search/search.pages.inc Source File

modules » search

search.pages.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: search.pages.inc,v 1.4 2007/12/06 09:51:01 goba Exp $
00003
00012 function search_view($type = 'node') {
00013   // Search form submits with POST but redirects to GET. This way we can keep
00014   // the search query URL clean as a whistle:
00015   // search/type/keyword+keyword
00016   if (!isset($_POST['form_id'])) {
00017     if ($type == '') {
00018       // Note: search/node can not be a default tab because it would take on the
00019       // path of its parent (search). It would prevent remembering keywords when
00020       // switching tabs. This is why we drupal_goto to it from the parent instead.
00021       drupal_goto('search/node');
00022     }
00023
00024     $keys = search_get_keys();
00025     // Only perform search if there is non-whitespace search term:
00026     $results = '';
00027     if (trim($keys)) {
00028       // Log the search keys:
00029       watchdog('search', '%keys (@type).', array('%keys' => $keys, '@type' => module_invoke($type, 'search', 'name')), WATCHDOG_NOTICE, l(t('results'), 'search/'. $type .'/'. $keys));
00030
00031       // Collect the search results:
00032       $results = search_data($keys, $type);
00033
00034       if ($results) {
00035         $results = theme('box', t('Search results'), $results);
00036       }
00037       else {
00038         $results = theme('box', t('Your search yielded no results'), search_help('search#noresults', drupal_help_arg()));
00039       }
00040     }
00041
00042     // Construct the search form.
00043     $output = drupal_get_form('search_form', NULL, $keys, $type);
00044     $output .= $results;
00045
00046     return $output;
00047   }
00048
00049   return drupal_get_form('search_form', NULL, empty($keys) ? '' : $keys, $type);
00050 }
00051
00061 function template_preprocess_search_results(&$variables) {
00062   $variables['search_results'] = '';
00063   foreach ($variables['results'] as $result) {
00064     $variables['search_results'] .= theme('search_result', $result, $variables['type']);
00065   }
00066   $variables['pager'] = theme('pager', NULL, 10, 0);
00067   // Provide alternate search results template.
00068   $variables['template_files'][] = 'search-results-'. $variables['type'];
00069 }
00070
00080 function template_preprocess_search_result(&$variables) {
00081   $result = $variables['result'];
00082   $variables['url'] = check_url($result['link']);
00083   $variables['title'] = check_plain($result['title']);
00084
00085   $info = array();
00086   if (!empty($result['type'])) {
00087     $info['type'] = check_plain($result['type']);
00088   }
00089   if (!empty($result['user'])) {
00090     $info['user'] = $result['user'];
00091   }
00092   if (!empty($result['date'])) {
00093     $info['date'] = format_date($result['date'], 'small');
00094   }
00095   if (isset($result['extra']) && is_array($result['extra'])) {
00096     $info = array_merge($info, $result['extra']);
00097   }
00098   // Check for existence. User search does not include snippets.
00099   $variables['snippet'] = isset($result['snippet']) ? $result['snippet'] : '';
00100   // Provide separated and grouped meta information..
00101   $variables['info_split'] = $info;
00102   $variables['info'] = implode(' - ', $info);
00103   // Provide alternate search result template.
00104   $variables['template_files'][] = 'search-result-'. $variables['type'];
00105 }
00106
00113 function search_form_validate($form, &$form_state) {
00114   form_set_value($form['basic']['inline']['processed_keys'], trim($form_state['values']['keys']), $form_state);
00115 }
00116
00120 function search_form_submit($form, &$form_state) {
00121   $keys = $form_state['values']['processed_keys'];
00122   if ($keys == '') {
00123     form_set_error('keys', t('Please enter some keywords.'));
00124     // Fall through to the drupal_goto() call.
00125   }
00126
00127   $type = $form_state['values']['module'] ? $form_state['values']['module'] : 'node';
00128   $form_state['redirect'] = 'search/'. $type .'/'. $keys;
00129   return;
00130 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/session.inc Source File

includes

session.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: session.inc,v 1.44.2.1 2008/02/07 11:58:40 goba Exp $
00003
00009 function sess_open($save_path, $session_name) {
00010   return TRUE;
00011 }
00012
00013 function sess_close() {
00014   return TRUE;
00015 }
00016
00017 function sess_read($key) {
00018   global $user;
00019
00020   // Write and Close handlers are called after destructing objects since PHP 5.0.5
00021   // Thus destructors can use sessions but session handler can't use objects.
00022   // So we are moving session closure before destructing objects.
00023   register_shutdown_function('session_write_close');
00024
00025   // Handle the case of first time visitors and clients that don't store cookies (eg. web crawlers).
00026   if (!isset($_COOKIE[session_name()])) {
00027     $user = drupal_anonymous_user();
00028     return '';
00029   }
00030
00031   // Otherwise, if the session is still active, we have a record of the client's session in the database.
00032   $user = db_fetch_object(db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = '%s'", $key));
00033
00034   // We found the client's session record and they are an authenticated user
00035   if ($user && $user->uid > 0) {
00036     // This is done to unserialize the data member of $user
00037     $user = drupal_unpack($user);
00038
00039     // Add roles element to $user
00040     $user->roles = array();
00041     $user->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
00042     $result = db_query("SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d", $user->uid);
00043     while ($role = db_fetch_object($result)) {
00044       $user->roles[$role->rid] = $role->name;
00045     }
00046   }
00047   // We didn't find the client's record (session has expired), or they are an anonymous user.
00048   else {
00049     $session = isset($user->session) ? $user->session : '';
00050     $user = drupal_anonymous_user($session);
00051   }
00052
00053   return $user->session;
00054 }
00055
00056 function sess_write($key, $value) {
00057   global $user;
00058
00059   // If saving of session data is disabled or if the client doesn't have a session,
00060   // and one isn't being created ($value), do nothing.
00061   if (!session_save_session() || (empty($_COOKIE[session_name()]) && empty($value))) {
00062     return TRUE;
00063   }
00064
00065   $result = db_result(db_query("SELECT COUNT(*) FROM {sessions} WHERE sid = '%s'", $key));
00066
00067   if (!$result) {
00068     // Only save session data when when the browser sends a cookie. This keeps
00069     // crawlers out of session table. This reduces memory and server load,
00070     // and gives more useful statistics. We can't eliminate anonymous session
00071     // table rows without breaking throttle module and "Who's Online" block.
00072     if ($user->uid || $value || count($_COOKIE)) {
00073       db_query("INSERT INTO {sessions} (sid, uid, cache, hostname, session, timestamp) VALUES ('%s', %d, %d, '%s', '%s', %d)", $key, $user->uid, isset($user->cache) ? $user->cache : '', ip_address(), $value, time());
00074     }
00075   }
00076   else {
00077     db_query("UPDATE {sessions} SET uid = %d, cache = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, isset($user->cache) ? $user->cache : '', ip_address(), $value, time(), $key);
00078
00079     // Last access time is updated no more frequently than once every 180 seconds.
00080     // This reduces contention in the users table.
00081     if ($user->uid && time() - $user->access > variable_get('session_write_interval', 180)) {
00082       db_query("UPDATE {users} SET access = %d WHERE uid = %d", time(), $user->uid);
00083     }
00084   }
00085
00086   return TRUE;
00087 }
00088
00092 function sess_regenerate() {
00093   $old_session_id = session_id();
00094
00095   // We code around http://bugs.php.net/bug.php?id=32802 by destroying
00096   // the session cookie by setting expiration in the past (a negative
00097   // value).  This issue only arises in PHP versions before 4.4.0,
00098   // regardless of the Drupal configuration.
00099   // TODO: remove this when we require at least PHP 4.4.0
00100   if (isset($_COOKIE[session_name()])) {
00101     setcookie(session_name(), '', time() - 42000, '/');
00102   }
00103
00104   session_regenerate_id();
00105
00106   db_query("UPDATE {sessions} SET sid = '%s' WHERE sid = '%s'", session_id(), $old_session_id);
00107 }
00108
00122 function sess_count($timestamp = 0, $anonymous = true) {
00123   $query = $anonymous ? ' AND uid = 0' : ' AND uid > 0';
00124   return db_result(db_query('SELECT COUNT(sid) AS count FROM {sessions} WHERE timestamp >= %d'. $query, $timestamp));
00125 }
00126
00133 function sess_destroy_sid($sid) {
00134   db_query("DELETE FROM {sessions} WHERE sid = '%s'", $sid);
00135 }
00136
00143 function sess_destroy_uid($uid) {
00144   db_query('DELETE FROM {sessions} WHERE uid = %d', $uid);
00145 }
00146
00147 function sess_gc($lifetime) {
00148   // Be sure to adjust 'php_value session.gc_maxlifetime' to a large enough
00149   // value. For example, if you want user sessions to stay in your database
00150   // for three weeks before deleting them, you need to set gc_maxlifetime
00151   // to '1814400'. At that value, only after a user doesn't log in after
00152   // three weeks (1814400 seconds) will his/her session be removed.
00153   db_query("DELETE FROM {sessions} WHERE timestamp < %d", time() - $lifetime);
00154
00155   return TRUE;
00156 }
00157
00170 function session_save_session($status = NULL) {
00171   static $save_session = TRUE;
00172   if (isset($status)) {
00173     $save_session = $status;
00174   }
00175   return ($save_session);
00176 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/statistics/statistics.admin.inc Source File

modules » statistics

statistics.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: statistics.admin.inc,v 1.6 2008/01/08 10:35:42 goba Exp $
00003
00012 function statistics_recent_hits() {
00013   $header = array(
00014     array('data' => t('Timestamp'), 'field' => 'a.timestamp', 'sort' => 'desc'),
00015     array('data' => t('Page'), 'field' => 'a.path'),
00016     array('data' => t('User'), 'field' => 'u.name'),
00017     array('data' => t('Operations'))
00018   );
00019
00020   $sql = 'SELECT a.aid, a.path, a.title, a.uid, u.name, a.timestamp FROM {accesslog} a LEFT JOIN {users} u ON u.uid = a.uid'. tablesort_sql($header);
00021
00022   $result = pager_query($sql, 30);
00023   $rows = array();
00024   while ($log = db_fetch_object($result)) {
00025     $rows[] = array(
00026       array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'),
00027       _statistics_format_item($log->title, $log->path),
00028       theme('username', $log),
00029       l(t('details'), "admin/reports/access/$log->aid"));
00030   }
00031
00032   if (empty($rows)) {
00033     $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4));
00034   }
00035
00036   $output = theme('table', $header, $rows);
00037   $output .= theme('pager', NULL, 30, 0);
00038   return $output;
00039 }
00040
00044 function statistics_top_pages() {
00045   // MAX(title) avoids having empty node titles which otherwise causes duplicates in the top pages list
00046   $sql = "SELECT COUNT(path) AS hits, path, MAX(title) AS title, AVG(timer) AS average_time, SUM(timer) AS total_time FROM {accesslog} GROUP BY path";
00047   $sql_cnt = "SELECT COUNT(DISTINCT(path)) FROM {accesslog}";
00048
00049   $header = array(
00050     array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'),
00051     array('data' => t('Page'), 'field' => 'path'),
00052     array('data' => t('Average page generation time'), 'field' => 'average_time'),
00053     array('data' => t('Total page generation time'), 'field' => 'total_time')
00054   );
00055   $sql .= tablesort_sql($header);
00056   $result = pager_query($sql, 30, 0, $sql_cnt);
00057
00058   $rows = array();
00059   while ($page = db_fetch_object($result)) {
00060     $rows[] = array($page->hits, _statistics_format_item($page->title, $page->path), t('%time ms', array('%time' => round($page->average_time))), format_interval(round($page->total_time / 1000)));
00061   }
00062
00063   if (empty($rows)) {
00064     $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4));
00065   }
00066
00067   drupal_set_title(t('Top pages in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)))));
00068   $output = theme('table', $header, $rows);
00069   $output .= theme('pager', NULL, 30, 0);
00070   return $output;
00071 }
00072
00076 function statistics_top_visitors() {
00077
00078   $header = array(
00079     array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'),
00080     array('data' => t('Visitor'), 'field' => 'u.name'),
00081     array('data' => t('Total page generation time'), 'field' => 'total'),
00082     array('data' => t('Operations'))
00083   );
00084
00085   $sql = "SELECT COUNT(a.uid) AS hits, a.uid, u.name, a.hostname, SUM(a.timer) AS total, ac.aid FROM {accesslog} a LEFT JOIN {access} ac ON ac.type = 'host' AND LOWER(a.hostname) LIKE (ac.mask) LEFT JOIN {users} u ON a.uid = u.uid GROUP BY a.hostname, a.uid, u.name, ac.aid". tablesort_sql($header);
00086   $sql_cnt = "SELECT COUNT(DISTINCT(CONCAT(uid, hostname))) FROM {accesslog}";
00087   $result = pager_query($sql, 30, 0, $sql_cnt);
00088
00089   $rows = array();
00090   while ($account = db_fetch_object($result)) {
00091     $qs = drupal_get_destination();
00092     $ban_link = $account->aid ? l(t('unban'), "admin/user/rules/delete/$account->aid", array('query' => $qs)) : l(t('ban'), "admin/user/rules/add/$account->hostname/host", array('query' => $qs));
00093     $rows[] = array($account->hits, ($account->uid ? theme('username', $account) : $account->hostname), format_interval(round($account->total / 1000)), $ban_link);
00094   }
00095
00096   if (empty($rows)) {
00097     $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4));
00098   }
00099
00100   drupal_set_title(t('Top visitors in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)))));
00101   $output = theme('table', $header, $rows);
00102   $output .= theme('pager', NULL, 30, 0);
00103   return $output;
00104 }
00105
00109 function statistics_top_referrers() {
00110   $query = "SELECT url, COUNT(url) AS hits, MAX(timestamp) AS last FROM {accesslog} WHERE url NOT LIKE '%%%s%%' AND url <> '' GROUP BY url";
00111   $query_cnt = "SELECT COUNT(DISTINCT(url)) FROM {accesslog} WHERE url <> '' AND url NOT LIKE '%%%s%%'";
00112   drupal_set_title(t('Top referrers in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)))));
00113
00114   $header = array(
00115     array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'),
00116     array('data' => t('Url'), 'field' => 'url'),
00117     array('data' => t('Last visit'), 'field' => 'last'),
00118   );
00119
00120   $query .= tablesort_sql($header);
00121   $result = pager_query($query, 30, 0, $query_cnt, $_SERVER['HTTP_HOST']);
00122
00123   $rows = array();
00124   while ($referrer = db_fetch_object($result)) {
00125     $rows[] = array($referrer->hits, _statistics_link($referrer->url), t('@time ago', array('@time' => format_interval(time() - $referrer->last))));
00126   }
00127
00128   if (empty($rows)) {
00129     $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 3));
00130   }
00131
00132   $output = theme('table', $header, $rows);
00133   $output .= theme('pager', NULL, 30, 0);
00134   return $output;
00135 }
00136
00140 function statistics_access_log($aid) {
00141   $result = db_query('SELECT a.*, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE aid = %d', $aid);
00142   if ($access = db_fetch_object($result)) {
00143     $rows[] = array(
00144       array('data' => t('URL'), 'header' => TRUE),
00145       l(url($access->path, array('absolute' => TRUE)), $access->path)
00146     );
00147     // It is safe to avoid filtering $access->title through check_plain because
00148     // it comes from drupal_get_title().
00149     $rows[] = array(
00150       array('data' => t('Title'), 'header' => TRUE),
00151       $access->title
00152     );
00153     $rows[] = array(
00154       array('data' => t('Referrer'), 'header' => TRUE),
00155       ($access->url ? l($access->url, $access->url) : '')
00156     );
00157     $rows[] = array(
00158       array('data' => t('Date'), 'header' => TRUE),
00159       format_date($access->timestamp, 'large')
00160     );
00161     $rows[] = array(
00162       array('data' => t('User'), 'header' => TRUE),
00163       theme('username', $access)
00164     );
00165     $rows[] = array(
00166       array('data' => t('Hostname'), 'header' => TRUE),
00167       check_plain($access->hostname)
00168     );
00169
00170     return theme('table', array(), $rows);
00171   }
00172   else {
00173     drupal_not_found();
00174   }
00175 }
00176
00183 function statistics_access_logging_settings() {
00184   // Access log settings:
00185   $options = array('1' => t('Enabled'), '0' => t('Disabled'));
00186   $form['access'] = array(
00187     '#type' => 'fieldset',
00188     '#title' => t('Access log settings'));
00189   $form['access']['statistics_enable_access_log'] = array(
00190     '#type' => 'radios',
00191     '#title' => t('Enable access log'),
00192     '#default_value' => variable_get('statistics_enable_access_log', 0),
00193     '#options' => $options,
00194     '#description' => t('Log each page access. Required for referrer statistics.'));
00195   $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
00196   $form['access']['statistics_flush_accesslog_timer'] = array(
00197     '#type' => 'select',
00198     '#title' => t('Discard access logs older than'),
00199     '#default_value'   => variable_get('statistics_flush_accesslog_timer', 259200),
00200     '#options' => $period,
00201     '#description' => t('Older access log entries (including referrer statistics) will be automatically discarded. (Requires a correctly configured <a href="@cron">cron maintenance task</a>.)', array('@cron' => url('admin/reports/status'))));
00202
00203   // count content views settings
00204   $form['content'] = array(
00205     '#type' => 'fieldset',
00206     '#title' => t('Content viewing counter settings'));
00207   $form['content']['statistics_count_content_views'] = array(
00208     '#type' => 'radios',
00209     '#title' => t('Count content views'),
00210     '#default_value' => variable_get('statistics_count_content_views', 0),
00211     '#options' => $options,
00212     '#description' => t('Increment a counter each time content is viewed.'));
00213
00214   return system_settings_form($form);
00215 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/statistics/statistics.install Source File

modules » statistics

statistics.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: statistics.install,v 1.13 2007/12/18 12:59:22 dries Exp $
00003
00007 function statistics_install() {
00008   // Create tables.
00009   drupal_install_schema('statistics');
00010 }
00011
00015 function statistics_update_1000() {
00016   $ret = array();
00017
00018   switch ($GLOBALS['db_type']) {
00019     case 'mysql':
00020     case 'mysqli':
00021       $ret[] = update_sql("ALTER TABLE {accesslog} CHANGE COLUMN sid sid varchar(64) NOT NULL default ''");
00022       break;
00023     case 'pgsql':
00024       db_change_column($ret, 'accesslog', 'sid', 'sid', 'varchar(64)', array('not null' => TRUE, 'default' => "''"));
00025       break;
00026   }
00027
00028   return $ret;
00029 }
00030
00034 function statistics_uninstall() {
00035   // Remove tables.
00036   drupal_uninstall_schema('statistics');
00037
00038   variable_del('statistics_count_content_views');
00039   variable_del('statistics_enable_access_log');
00040   variable_del('statistics_flush_accesslog_timer');
00041   variable_del('statistics_day_timestamp');
00042   variable_del('statistics_block_top_day_num');
00043   variable_del('statistics_block_top_all_num');
00044   variable_del('statistics_block_top_last_num');
00045 }
00046
00050 function statistics_schema() {
00051   $schema['accesslog'] = array(
00052     'description' => t('Stores site access information for statistics.'),
00053     'fields' => array(
00054       'aid' => array(
00055         'type' => 'serial',
00056         'not null' => TRUE,
00057         'description' => t('Primary Key: Unique accesslog ID.'),
00058       ),
00059       'sid' => array(
00060         'type' => 'varchar',
00061         'length' => 64,
00062         'not null' => TRUE,
00063         'default' => '',
00064         'description' => t('Browser session ID of user that visited page.'),
00065       ),
00066       'title' => array(
00067         'type' => 'varchar',
00068         'length' => 255,
00069         'not null' => FALSE,
00070         'description' => t('Title of page visited.'),
00071       ),
00072       'path' => array(
00073         'type' => 'varchar',
00074         'length' => 255,
00075         'not null' => FALSE,
00076         'description' => t('Internal path to page visited (relative to Drupal root.)'),
00077       ),
00078       'url' => array(
00079         'type' => 'varchar',
00080         'length' => 255,
00081         'not null' => FALSE,
00082         'description' => t('Referrer URI.'),
00083       ),
00084       'hostname' => array(
00085         'type' => 'varchar',
00086         'length' => 128,
00087         'not null' => FALSE,
00088         'description' => t('Hostname of user that visited the page.'),
00089       ),
00090       'uid' => array(
00091         'type' => 'int',
00092         'unsigned' => TRUE,
00093         'not null' => FALSE,
00094         'default' => 0,
00095         'description' => t('User {users}.uid that visited the page.'),
00096       ),
00097       'timer' => array(
00098         'type' => 'int',
00099         'unsigned' => TRUE,
00100         'not null' => TRUE,
00101         'default' => 0,
00102         'description' => t('Time in milliseconds that the page took to load.'),
00103       ),
00104       'timestamp' => array(
00105         'type' => 'int',
00106         'unsigned' => TRUE,
00107         'not null' => TRUE,
00108         'default' => 0,
00109         'description' => t('Timestamp of when the page was visited.'),
00110       ),
00111     ),
00112     'indexes' => array(
00113       'accesslog_timestamp' => array('timestamp'),
00114       'uid' => array('uid'),
00115     ),
00116     'primary key' => array('aid'),
00117   );
00118
00119   return $schema;
00120 }
00121
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/statistics/statistics.module Source File

modules » statistics

statistics.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: statistics.module,v 1.272 2008/01/04 09:31:48 goba Exp $
00003
00012 function statistics_help($path, $arg) {
00013   switch ($path) {
00014     case 'admin/help#statistics':
00015       $output = '<p>'. t('The statistics module keeps track of numerous site usage statistics, including the number of times, and from where, each of your posts is viewed. These statistics are useful in determining how users are interacting with each other and with your site, and are required for the display of some Drupal blocks.') .'</p>';
00016       $output .= '<p>'. t('The statistics module provides:') .'</p>';
00017       $output .= '<ul><li>'. t('a counter for each post on your site that increments each time the post is viewed. (Enable <em>Count content views</em> on the <a href="@accesslog">access log settings page</a>, and determine if the post access counters should be visible to any user roles on the <a href="@permissions">permissions page</a>.)', array('@accesslog' => url('admin/reports/settings'), '@permissions' => url('admin/user/permissions'))) .'</li>';
00018       $output .= '<li>'. t('a <a href="@recent-hits">recent hits</a> log that displays information about the latest activity on your site, including the URL and title of the page accessed, the user name (if available) and IP address of the accessing party.', array('@recent-hits' => url('admin/reports/hits'))) .'</li>';
00019       $output .= '<li>'. t('a <a href="@top-referrers">top referrers</a> log that displays the referring parties for your site visits (where your visitors came from).', array('@top-referrers' => url('admin/reports/referrers'))) .'</li>';
00020       $output .= '<li>'. t('a <a href="@top-pages">top pages</a> log that displays site content in descending order by number of views.', array('@top-pages' => url('admin/reports/pages'))) .'</li>';
00021       $output .= '<li>'. t('a <a href="@top-visitors">top visitors</a> log that displays the most active users on your site.', array('@top-visitors' => url('admin/reports/visitors'))) .'</li>';
00022       $output .= '<li>'. t('a <em>Popular content</em> block that displays the day\'s most viewed content, the all-time most viewed content, and the last content viewed. (Enable the <em>Popular content</em> block on the <a href="@blocks">blocks administration page</a>.)', array('@blocks' => url('admin/build/block'))) .'</li></ul>';
00023       $output .= '<p>'. t('Configuring the statistics module') .'</p>';
00024       $output .= '<ul><li>'. t('When the <em>Enable access log</em> setting on the <a href="@accesslog">access log settings page</a> is enabled, data about every page accessed (including the remote host\'s IP address, referrer, node accessed, and user name) is stored in the access log. The access log must be enabled for the <a href="@recent-hits">recent hits</a>, <a href="@top-referrers">top referrers</a>, <a href="@top-pages">top pages</a>, and <a href="@top-visitors">top visitors</a> log pages to function. Enabling the access log adds one additional database call per page displayed by Drupal.', array('@accesslog' => url('admin/reports/settings'), '@recent-hits' => url('admin/reports/hits'), '@top-referrers' => url('admin/reports/referrers'), '@top-pages' => url('admin/reports/pages'), '@top-visitors' => url('admin/reports/visitors'))) .'</li>';
00025       $output .= '<li>'. t('The <em>Discard access logs older than</em> setting on the <a href="@accesslog">access log settings page</a> specifies the length of time entries are retained in the access log before they are deleted. Automatic access log entry deletion requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@accesslog' => url('admin/reports/settings'), '@cron' => url('admin/reports/status'))) .'</li>';
00026       $output .= '<li>'. t('The <em>Count content views</em> setting on the <a href="@accesslog">access log settings page</a> enables a counter for each post on your site that increments each time the post is viewed. This option must be enabled to provide post-specific access counts. Enabling this option adds one additional database call per each post displayed by Drupal.', array('@accesslog' => url('admin/reports/settings'))) .'</li></ul>';
00027       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@statistics">Statistics module</a>.', array('@statistics' => 'http://drupal.org/handbook/modules/statistics/')) .'</p>';
00028       return $output;
00029     case 'admin/reports/settings':
00030       return '<p>'. t('Settings for the statistical information that Drupal will keep about the site. See <a href="@statistics">site statistics</a> for the actual information.', array('@statistics' => url('admin/reports/hits'))) .'</p>';
00031     case 'admin/reports/hits':
00032       return '<p>'. t("This page displays the site's most recent hits.") .'</p>';
00033     case 'admin/reports/referrers':
00034       return '<p>'. t('This page displays all external referrers, or external references to your website.') .'</p>';
00035     case 'admin/reports/visitors':
00036       return '<p>'. t("When you ban a visitor, you prevent the visitor's IP address from accessing your site. Unlike blocking a user, banning a visitor works even for anonymous users. This is most commonly used to block resource-intensive bots or web crawlers.") .'</p>';
00037   }
00038 }
00039
00045 function statistics_exit() {
00046   global $user, $recent_activity;
00047
00048   drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
00049
00050   if (variable_get('statistics_count_content_views', 0)) {
00051     // We are counting content views.
00052     if ((arg(0) == 'node') && is_numeric(arg(1)) && arg(2) == '') {
00053       // A node has been viewed, so update the node's counters.
00054       db_query('UPDATE {node_counter} SET daycount = daycount + 1, totalcount = totalcount + 1, timestamp = %d WHERE nid = %d', time(), arg(1));
00055       // If we affected 0 rows, this is the first time viewing the node.
00056       if (!db_affected_rows()) {
00057         // We must create a new row to store counters for the new node.
00058         db_query('INSERT INTO {node_counter} (nid, daycount, totalcount, timestamp) VALUES (%d, 1, 1, %d)', arg(1), time());
00059       }
00060     }
00061   }
00062   if ((variable_get('statistics_enable_access_log', 0)) && (module_invoke('throttle', 'status') == 0)) {
00063     // Log this page access.
00064     db_query("INSERT INTO {accesslog} (title, path, url, hostname, uid, sid, timer, timestamp) values('%s', '%s', '%s', '%s', %d, '%s', %d, %d)", strip_tags(drupal_get_title()), $_GET['q'], referer_uri(), ip_address(), $user->uid, session_id(), timer_read('page'), time());
00065   }
00066 }
00067
00071 function statistics_perm() {
00072   return array('access statistics', 'view post access counter');
00073 }
00074
00078 function statistics_link($type, $node = NULL, $teaser = FALSE) {
00079   global $id;
00080   $links = array();
00081
00082   if ($type != 'comment' && user_access('view post access counter')) {
00083     $statistics = statistics_get($node->nid);
00084     if ($statistics) {
00085       $links['statistics_counter']['title'] = format_plural($statistics['totalcount'], '1 read', '@count reads');
00086     }
00087   }
00088
00089   return $links;
00090 }
00091
00095 function statistics_menu() {
00096   $items['admin/reports/hits'] = array(
00097     'title' => 'Recent hits',
00098     'description' => 'View pages that have recently been visited.',
00099     'page callback' => 'statistics_recent_hits',
00100     'access arguments' => array('access statistics'),
00101     'file' => 'statistics.admin.inc',
00102   );
00103   $items['admin/reports/pages'] = array(
00104     'title' => 'Top pages',
00105     'description' => 'View pages that have been hit frequently.',
00106     'page callback' => 'statistics_top_pages',
00107     'access arguments' => array('access statistics'),
00108     'weight' => 1,
00109     'file' => 'statistics.admin.inc',
00110   );
00111   $items['admin/reports/visitors'] = array(
00112     'title' => 'Top visitors',
00113     'description' => 'View visitors that hit many pages.',
00114     'page callback' => 'statistics_top_visitors',
00115     'access arguments' => array('access statistics'),
00116     'weight' => 2,
00117     'file' => 'statistics.admin.inc',
00118   );
00119   $items['admin/reports/referrers'] = array(
00120     'title' => 'Top referrers',
00121     'description' => 'View top referrers.',
00122     'page callback' => 'statistics_top_referrers',
00123     'access arguments' => array('access statistics'),
00124     'file' => 'statistics.admin.inc',
00125   );
00126   $items['admin/reports/access/%'] = array(
00127     'title' => 'Details',
00128     'description' => 'View access log.',
00129     'page callback' => 'statistics_access_log',
00130     'page arguments' => array(3),
00131     'access arguments' => array('access statistics'),
00132     'type' => MENU_CALLBACK,
00133     'file' => 'statistics.admin.inc',
00134   );
00135   $items['admin/reports/settings'] = array(
00136     'title' => 'Access log settings',
00137     'description' => 'Control details about what and how your site logs.',
00138     'page callback' => 'drupal_get_form',
00139     'page arguments' => array('statistics_access_logging_settings'),
00140     'access arguments' => array('administer site configuration'),
00141     'type' => MENU_NORMAL_ITEM,
00142     'weight' => 3,
00143     'file' => 'statistics.admin.inc',
00144   );
00145   $items['user/%user/track/navigation'] = array(
00146     'title' => 'Track page visits',
00147     'page callback' => 'statistics_user_tracker',
00148     'access callback' => 'user_access',
00149     'access arguments' => array('access statistics'),
00150     'type' => MENU_LOCAL_TASK,
00151     'weight' => 2,
00152     'file' => 'statistics.pages.inc',
00153   );
00154   $items['node/%node/track'] = array(
00155     'title' => 'Track',
00156     'page callback' => 'statistics_node_tracker',
00157     'access callback' => 'user_access',
00158     'access arguments' => array('access statistics'),
00159     'type' => MENU_LOCAL_TASK,
00160     'weight' => 2,
00161     'file' => 'statistics.pages.inc',
00162   );
00163
00164   return $items;
00165 }
00166
00170 function statistics_user($op, &$edit, &$user) {
00171   if ($op == 'delete') {
00172     db_query('UPDATE {accesslog} SET uid = 0 WHERE uid = %d', $user->uid);
00173   }
00174 }
00175
00179 function statistics_cron() {
00180   $statistics_timestamp = variable_get('statistics_day_timestamp', '');
00181
00182   if ((time() - $statistics_timestamp) >= 86400) {
00183     // Reset day counts.
00184     db_query('UPDATE {node_counter} SET daycount = 0');
00185     variable_set('statistics_day_timestamp', time());
00186   }
00187
00188   // Clean up expired access logs.
00189   db_query('DELETE FROM {accesslog} WHERE timestamp < %d', time() - variable_get('statistics_flush_accesslog_timer', 259200));
00190 }
00191
00208 function statistics_title_list($dbfield, $dbrows) {
00209   if (in_array($dbfield, array('totalcount', 'daycount', 'timestamp'))) {
00210     return db_query_range(db_rewrite_sql("SELECT n.nid, n.title, u.uid, u.name FROM {node} n INNER JOIN {node_counter} s ON n.nid = s.nid INNER JOIN {users} u ON n.uid = u.uid WHERE s.". $dbfield ." != 0 AND n.status = 1 ORDER BY s.". $dbfield ." DESC"), 0, $dbrows);
00211   }
00212   return FALSE;
00213 }
00214
00215
00229 function statistics_get($nid) {
00230
00231   if ($nid > 0) {
00232     // Retrieve an array with both totalcount and daycount.
00233     $statistics = db_fetch_array(db_query('SELECT totalcount, daycount, timestamp FROM {node_counter} WHERE nid = %d', $nid));
00234   }
00235
00236   return $statistics;
00237 }
00238
00242 function statistics_block($op = 'list', $delta = 0, $edit = array()) {
00243   switch ($op) {
00244     case 'list':
00245       if (variable_get('statistics_count_content_views', 0)) {
00246         $blocks[0]['info'] = t('Popular content');
00247         // Too dynamic to cache.
00248         $blocks[0]['cache'] = BLOCK_NO_CACHE;
00249         return $blocks;
00250       }
00251       break;
00252
00253     case 'configure':
00254       // Popular content block settings
00255       $numbers = array('0' => t('Disabled')) + drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40));
00256       $form['statistics_block_top_day_num'] = array('#type' => 'select', '#title' => t("Number of day's top views to display"), '#default_value' => variable_get('statistics_block_top_day_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "day" list.'));
00257       $form['statistics_block_top_all_num'] = array('#type' => 'select', '#title' => t('Number of all time views to display'), '#default_value' => variable_get('statistics_block_top_all_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "all time" list.'));
00258       $form['statistics_block_top_last_num'] = array('#type' => 'select', '#title' => t('Number of most recent views to display'), '#default_value' => variable_get('statistics_block_top_last_num', 0), '#options' => $numbers, '#description' => t('How many content items to display in "recently viewed" list.'));
00259       return $form;
00260
00261     case 'save':
00262       variable_set('statistics_block_top_day_num', $edit['statistics_block_top_day_num']);
00263       variable_set('statistics_block_top_all_num', $edit['statistics_block_top_all_num']);
00264       variable_set('statistics_block_top_last_num', $edit['statistics_block_top_last_num']);
00265       break;
00266
00267     case 'view':
00268       if (user_access('access content')) {
00269         $content = array();
00270
00271         $daytop = variable_get('statistics_block_top_day_num', 0);
00272         if ($daytop && ($result = statistics_title_list('daycount', $daytop)) && ($node_title_list = node_title_list($result, t("Today's:")))) {
00273           $content[] = $node_title_list;
00274         }
00275
00276         $alltimetop = variable_get('statistics_block_top_all_num', 0);
00277         if ($alltimetop && ($result = statistics_title_list('totalcount', $alltimetop)) && ($node_title_list = node_title_list($result, t('All time:')))) {
00278           $content[] = $node_title_list;
00279         }
00280
00281         $lasttop = variable_get('statistics_block_top_last_num', 0);
00282         if ($lasttop && ($result = statistics_title_list('timestamp', $lasttop)) && ($node_title_list = node_title_list($result, t('Last viewed:')))) {
00283           $content[] = $node_title_list;
00284         }
00285
00286         if (count($content)) {
00287           $block['content'] = implode('<br />', $content);
00288           $block['subject'] = t('Popular content');
00289           return $block;
00290         }
00291       }
00292   }
00293 }
00294
00299 function _statistics_link($path, $width = 35) {
00300   $title = drupal_get_path_alias($path);
00301   $title = truncate_utf8($title, $width, FALSE, TRUE);
00302   return l($title, $path);
00303 }
00304
00305 function _statistics_format_item($title, $path) {
00306   $path = ($path ? $path : '/');
00307   $output  = ($title ? "$title<br />" : '');
00308   $output .= _statistics_link($path);
00309   return $output;
00310 }
00311
00315 function statistics_nodeapi(&$node, $op, $arg = 0) {
00316   switch ($op) {
00317     case 'delete':
00318       // clean up statistics table when node is deleted
00319       db_query('DELETE FROM {node_counter} WHERE nid = %d', $node->nid);
00320   }
00321 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/statistics/statistics.pages.inc Source File

modules » statistics

statistics.pages.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: statistics.pages.inc,v 1.2 2007/10/20 21:57:50 goba Exp $
00003
00009 function statistics_node_tracker() {
00010   if ($node = node_load(arg(1))) {
00011
00012     $header = array(
00013         array('data' => t('Time'), 'field' => 'a.timestamp', 'sort' => 'desc'),
00014         array('data' => t('Referrer'), 'field' => 'a.url'),
00015         array('data' => t('User'), 'field' => 'u.name'),
00016         array('data' => t('Operations')));
00017
00018     $result = pager_query('SELECT a.aid, a.timestamp, a.url, a.uid, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE a.path LIKE \'node/%d%%\''. tablesort_sql($header), 30, 0, NULL, $node->nid);
00019     $rows = array();
00020     while ($log = db_fetch_object($result)) {
00021       $rows[] = array(
00022         array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'),
00023         _statistics_link($log->url),
00024         theme('username', $log),
00025         l(t('details'), "admin/reports/access/$log->aid"));
00026     }
00027
00028     if (empty($rows)) {
00029       $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 4));
00030     }
00031
00032     drupal_set_title(check_plain($node->title));
00033     $output = theme('table', $header, $rows);
00034     $output .= theme('pager', NULL, 30, 0);
00035     return $output;
00036   }
00037   else {
00038     drupal_not_found();
00039   }
00040 }
00041
00042 function statistics_user_tracker() {
00043   if ($account = user_load(array('uid' => arg(1)))) {
00044
00045     $header = array(
00046         array('data' => t('Timestamp'), 'field' => 'timestamp', 'sort' => 'desc'),
00047         array('data' => t('Page'), 'field' => 'path'),
00048         array('data' => t('Operations')));
00049
00050     $result = pager_query('SELECT aid, timestamp, path, title FROM {accesslog} WHERE uid = %d'. tablesort_sql($header), 30, 0, NULL, $account->uid);
00051     $rows = array();
00052     while ($log = db_fetch_object($result)) {
00053       $rows[] = array(
00054         array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'),
00055         _statistics_format_item($log->title, $log->path),
00056         l(t('details'), "admin/reports/access/$log->aid"));
00057     }
00058
00059     if (empty($rows)) {
00060       $rows[] = array(array('data' => t('No statistics available.'), 'colspan' => 3));
00061     }
00062
00063     drupal_set_title(check_plain($account->name));
00064     $output = theme('table', $header, $rows);
00065     $output .= theme('pager', NULL, 30, 0);
00066     return $output;
00067   }
00068   else {
00069     drupal_not_found();
00070   }
00071 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/syslog/syslog.module Source File

modules » syslog

syslog.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: syslog.module,v 1.14 2007/12/14 18:08:48 goba Exp $
00003
00009 if (defined('LOG_LOCAL0')) {
00010   define('DEFAULT_SYSLOG_FACILITY', LOG_LOCAL0);
00011 }
00012 else {
00013   define('DEFAULT_SYSLOG_FACILITY', LOG_USER);
00014 }
00015
00019 function syslog_help($path, $arg) {
00020   switch ($path) {
00021     case 'admin/help#syslog':
00022       $output = '<p>'. t("The syslog module enables Drupal to send messages to the operating system's logging facility.") .'</p>';
00023       $output .= '<p>'. t('Syslog is an operating system administrative logging tool, and provides valuable information for use in system management and security auditing. Most suited to medium and large sites, syslog provides filtering tools that allow messages to be routed by type and severity. On UNIX/Linux systems, the file /etc/syslog.conf defines this routing configuration; on Microsoft Windows, all messages are sent to the Event Log. For more information on syslog facilities, severity levels, and how to set up a syslog.conf file, see <a href="@syslog_conf">UNIX/Linux syslog.conf</a> and PHP\'s <a href="@php_openlog">openlog</a> and <a href="@php_syslog">syslog</a> functions.', array('@syslog_conf' => url('http://www.rt.com/man/syslog.5.html'), '@php_openlog' => url('http://www.php.net/manual/en/function.openlog.php'), '@php_syslog' => url('http://www.php.net/manual/en/function.syslog.php'))) .'</p>';
00024       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@syslog">Syslog module</a>.', array('@syslog' => 'http://drupal.org/handbook/modules/syslog')) .'</p>';
00025       return $output;
00026   }
00027 }
00028
00029 function syslog_menu() {
00030   $items['admin/settings/logging/syslog'] = array(
00031     'title'          => 'Syslog',
00032     'description'    => 'Settings for syslog logging. Syslog is an operating system administrative logging tool used in systems management and security auditing. Most suited to medium and large sites, syslog provides filtering tools that allow messages to be routed by type and severity.',
00033     'page callback'  => 'drupal_get_form',
00034     'page arguments' => array('syslog_admin_settings'),
00035   );
00036   return $items;
00037 }
00038
00039 function syslog_admin_settings() {
00040   $form['syslog_facility'] = array(
00041     '#type'          => 'select',
00042     '#title'         => t('Send events to this syslog facility'),
00043     '#default_value' => variable_get('syslog_facility', DEFAULT_SYSLOG_FACILITY),
00044     '#options'       => syslog_facility_list(),
00045     '#description'   => t('Select the syslog facility code under which Drupal\'s messages should be sent. On UNIX/Linux systems, Drupal can flag its messages with the code LOG_LOCAL0 through LOG_LOCAL7; for Microsoft Windows, all messages are flagged with the code LOG_USER. Depending on the system configuration, syslog and other logging tools use this code to identify or filter Drupal messages from within the entire system log. For more information on syslog, see <a href="@syslog_help">Syslog help</a>.', array(
00046       '@syslog_help' => url('admin/help/syslog'),
00047       '!php'         => l("PHP's syslog", 'http://www.php.net/manual/en/function.openlog.php', array('external' => TRUE)),
00048       '!syslog_conf' => l('UNIX/Linux syslog.conf', 'http://www.rt.com/man/syslog.5.html', array('external' => TRUE)))),
00049   );
00050   return system_settings_form($form);
00051 }
00052
00053 function syslog_facility_list() {
00054   $facility_list = array(
00055     LOG_USER   => t('LOG_USER - User level messages. Use this for Windows.'),
00056   );
00057   if (defined('LOG_LOCAL0')) {
00058     $facility_list += array(
00059       LOG_LOCAL0 => t('LOG_LOCAL0 - Local 0'),
00060       LOG_LOCAL1 => t('LOG_LOCAL1 - Local 1'),
00061       LOG_LOCAL2 => t('LOG_LOCAL2 - Local 2'),
00062       LOG_LOCAL3 => t('LOG_LOCAL3 - Local 3'),
00063       LOG_LOCAL4 => t('LOG_LOCAL4 - Local 4'),
00064       LOG_LOCAL5 => t('LOG_LOCAL5 - Local 5'),
00065       LOG_LOCAL6 => t('LOG_LOCAL6 - Local 6'),
00066       LOG_LOCAL7 => t('LOG_LOCAL7 - Local 7'),
00067     );
00068   }
00069   return $facility_list;
00070 }
00071
00072 function syslog_watchdog($entry) {
00073   static $log_init = FALSE;
00074
00075   if (!$log_init) {
00076     $log_init = TRUE;
00077     openlog('drupal', LOG_NDELAY, variable_get('syslog_facility', DEFAULT_SYSLOG_FACILITY));
00078   }
00079
00080   syslog($entry['severity'], theme('syslog_format', $entry));
00081 }
00082
00083 function syslog_theme() {
00084   return array(
00085     'syslog_format' => array(
00086       'arguments' => array('entry' => NULL),
00087     ),
00088   );
00089 }
00090
00096 function theme_syslog_format($entry) {
00097   global $base_url;
00098
00099   $message  = $base_url;
00100   $message .= '|'. $entry['timestamp'];
00101   $message .= '|'. $entry['type'];
00102   $message .= '|'. $entry['ip'];
00103   $message .= '|'. $entry['request_uri'];
00104   $message .= '|'. $entry['referer'];
00105   $message .= '|'. $entry['user']->uid;
00106   $message .= '|'. strip_tags($entry['link']);
00107   $message .= '|'. strip_tags(is_null($entry['variables']) ? $entry['message'] : strtr($entry['message'], $entry['variables']));
00108
00109   return $message;
00110 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/system/system.admin.inc Source File

modules » system

system.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: system.admin.inc,v 1.63 2008/02/04 12:35:48 goba Exp $
00003
00012 function system_main_admin_page($arg = NULL) {
00013   // If we received an argument, they probably meant some other page.
00014   // Let's 404 them since the menu system cannot be told we do not
00015   // accept arguments.
00016   if (isset($arg) && substr($arg, 0, 3) != 'by-') {
00017     return drupal_not_found();
00018   }
00019
00020   // Check for status report errors.
00021   if (system_status(TRUE) && user_access('administer site configuration')) {
00022     drupal_set_message(t('One or more problems were detected with your Drupal installation. Check the <a href="@status">status report</a> for more information.', array('@status' => url('admin/reports/status'))), 'error');
00023   }
00024   $blocks = array();
00025   if ($admin = db_fetch_array(db_query("SELECT menu_name, mlid FROM {menu_links} WHERE link_path = 'admin' AND module = 'system'"))) {
00026     $result = db_query("
00027       SELECT m.*, ml.*
00028       FROM {menu_links} ml
00029       INNER JOIN {menu_router} m ON ml.router_path = m.path
00030       WHERE ml.link_path != 'admin/help' AND menu_name = '%s' AND ml.plid = %d AND hidden = 0", $admin);
00031     while ($item = db_fetch_array($result)) {
00032       _menu_link_translate($item);
00033       if (!$item['access']) {
00034         continue;
00035       }
00036       // The link 'description' either derived from the hook_menu 'description'
00037       // or entered by the user via menu module is saved as the title attribute.
00038       if (!empty($item['localized_options']['attributes']['title'])) {
00039         $item['description'] = $item['localized_options']['attributes']['title'];
00040       }
00041       $block = $item;
00042       $block['content'] = '';
00043       if ($item['block_callback'] && function_exists($item['block_callback'])) {
00044         $function = $item['block_callback'];
00045         $block['content'] .= $function();
00046       }
00047       $block['content'] .= theme('admin_block_content', system_admin_menu_block($item));
00048       // Prepare for sorting as in function _menu_tree_check_access().
00049       // The weight is offset so it is always positive, with a uniform 5-digits.
00050       $blocks[(50000 + $item['weight']) .' '. $item['title'] .' '. $item['mlid']] = $block;
00051     }
00052   }
00053   if ($blocks) {
00054     ksort($blocks);
00055     return theme('admin_page', $blocks);
00056   }
00057   else {
00058     return t('You do not have any administrative items.');
00059   }
00060 }
00061
00062
00073 function system_admin_menu_block_page() {
00074   $item = menu_get_item();
00075   if ($content = system_admin_menu_block($item)) {
00076     $output = theme('admin_block_content', $content);
00077   }
00078   else {
00079     $output = t('You do not have any administrative items.');
00080   }
00081   return $output;
00082 }
00083
00090 function system_admin_compact_page($mode = 'off') {
00091   global $user;
00092   user_save($user, array('admin_compact_mode' => ($mode == 'on')));
00093   drupal_goto('admin');
00094 }
00095
00099 function system_admin_by_module() {
00100
00101   $modules = module_rebuild_cache();
00102   $menu_items = array();
00103   $help_arg = module_exists('help') ? drupal_help_arg() : FALSE;
00104
00105   foreach ($modules as $file) {
00106     $module = $file->name;
00107     if ($module == 'help') {
00108       continue;
00109     }
00110
00111     $admin_tasks = system_get_module_admin_tasks($module);
00112
00113     // Only display a section if there are any available tasks.
00114     if (count($admin_tasks)) {
00115
00116       // Check for help links.
00117       if ($help_arg && module_invoke($module, 'help', "admin/help#$module", $help_arg)) {
00118         $admin_tasks[100] = l(t('Get help'), "admin/help/$module");
00119       }
00120
00121       // Sort.
00122       ksort($admin_tasks);
00123
00124       $menu_items[$file->info['name']] = array($file->info['description'], $admin_tasks);
00125     }
00126   }
00127   return theme('system_admin_by_module', $menu_items);
00128 }
00129
00133 function system_settings_overview() {
00134   // Check database setup if necessary
00135   if (function_exists('db_check_setup') && empty($_POST)) {
00136     db_check_setup();
00137   }
00138
00139   $item = menu_get_item('admin/settings');
00140   $content = system_admin_menu_block($item);
00141
00142   $output = theme('admin_block_content', $content);
00143
00144   return $output;
00145 }
00146
00153 function system_admin_theme_settings() {
00154   $themes = system_theme_data();
00155
00156   uasort($themes, 'system_sort_modules_by_info_name');
00157
00158   $options[0] = '<'. t('System default') .'>';
00159   foreach ($themes as $theme) {
00160     $options[$theme->name] = $theme->info['name'];
00161   }
00162
00163   $form['admin_theme'] = array(
00164     '#type' => 'select',
00165     '#options' => $options,
00166     '#title' => t('Administration theme'),
00167     '#description' => t('Choose which theme the administration pages should display in. If you choose "System default" the administration pages will use the same theme as the rest of the site.'),
00168     '#default_value' => variable_get('admin_theme', '0'),
00169   );
00170
00171   $form['node_admin_theme'] = array(
00172     '#type' => 'checkbox',
00173     '#title' => t('Use administration theme for content editing'),
00174     '#description' => t('Use the administration theme when editing existing posts or creating new ones.'),
00175     '#default_value' => variable_get('node_admin_theme', '0'),
00176   );
00177
00178   $form['#submit'][] = 'system_admin_theme_submit';
00179   return system_settings_form($form);
00180 }
00181
00188 function system_themes_form() {
00189
00190   drupal_clear_css_cache();
00191   $themes = system_theme_data();
00192
00193   uasort($themes, 'system_sort_modules_by_info_name');
00194
00195   $status = array();
00196   $incompatible_core = array();
00197   $incompatible_php = array();
00198
00199   foreach ($themes as $theme) {
00200     $screenshot = NULL;
00201     $theme_key = $theme->name;
00202     while ($theme_key) {
00203       if (file_exists($themes[$theme_key]->info['screenshot'])) {
00204         $screenshot = $themes[$theme_key]->info['screenshot'];
00205         break;
00206       }
00207       $theme_key = isset($themes[$theme_key]->info['base theme']) ? $themes[$theme_key]->info['base theme'] : NULL;
00208     }
00209     $screenshot = $screenshot ? theme('image', $screenshot, t('Screenshot for %theme theme', array('%theme' => $theme->info['name'])), '', array('class' => 'screenshot'), FALSE) : t('no screenshot');
00210
00211     $form[$theme->name]['screenshot'] = array('#value' => $screenshot);
00212     $form[$theme->name]['info'] = array(
00213       '#type' => 'value',
00214       '#value' => $theme->info,
00215     );
00216     $options[$theme->name] = '';
00217
00218     if (!empty($theme->status) || $theme->name == variable_get('admin_theme', '0')) {
00219       $form[$theme->name]['operations'] = array('#value' => l(t('configure'), 'admin/build/themes/settings/'. $theme->name) );
00220     }
00221     else {
00222       // Dummy element for drupal_render. Cleaner than adding a check in the theme function.
00223       $form[$theme->name]['operations'] = array();
00224     }
00225     if (!empty($theme->status)) {
00226       $status[] = $theme->name;
00227     }
00228     else {
00229       // Ensure this theme is compatible with this version of core.
00230       if (!isset($theme->info['core']) || $theme->info['core'] != DRUPAL_CORE_COMPATIBILITY) {
00231         $incompatible_core[] = $theme->name;
00232       }
00233       if (version_compare(phpversion(), $theme->info['php']) < 0) {
00234         $incompatible_php[$theme->name] = $theme->info['php'];
00235       }
00236     }
00237   }
00238
00239   $form['status'] = array(
00240     '#type' => 'checkboxes',
00241     '#options' => $options,
00242     '#default_value' => $status,
00243     '#incompatible_themes_core' => drupal_map_assoc($incompatible_core),
00244     '#incompatible_themes_php' => $incompatible_php,
00245   );
00246   $form['theme_default'] = array(
00247     '#type' => 'radios',
00248     '#options' => $options,
00249     '#default_value' => variable_get('theme_default', 'garland'),
00250   );
00251   $form['buttons']['submit'] = array(
00252     '#type' => 'submit',
00253     '#value' => t('Save configuration'),
00254   );
00255   $form['buttons']['reset'] = array(
00256     '#type' => 'submit',
00257     '#value' => t('Reset to defaults'),
00258   );
00259   return $form;
00260 }
00261
00265 function system_themes_form_submit($form, &$form_state) {
00266
00267   // Store list of previously enabled themes and disable all themes
00268   $old_theme_list = $new_theme_list = array();
00269   foreach (list_themes() as $theme) {
00270     if ($theme->status) {
00271       $old_theme_list[] = $theme->name;
00272     }
00273   }
00274   db_query("UPDATE {system} SET status = 0 WHERE type = 'theme'");
00275
00276   if ($form_state['values']['op'] == t('Save configuration')) {
00277     if (is_array($form_state['values']['status'])) {
00278       foreach ($form_state['values']['status'] as $key => $choice) {
00279         // Always enable the default theme, despite its status checkbox being checked:
00280         if ($choice || $form_state['values']['theme_default'] == $key) {
00281           system_initialize_theme_blocks($key);
00282           $new_theme_list[] = $key;
00283           db_query("UPDATE {system} SET status = 1 WHERE type = 'theme' and name = '%s'", $key);
00284         }
00285       }
00286     }
00287     if (($admin_theme = variable_get('admin_theme', '0')) != '0' && $admin_theme != $form_state['values']['theme_default']) {
00288       drupal_set_message(t('Please note that the <a href="!admin_theme_page">administration theme</a> is still set to the %admin_theme theme; consequently, the theme on this page remains unchanged. All non-administrative sections of the site, however, will show the selected %selected_theme theme by default.', array(
00289         '!admin_theme_page' => url('admin/settings/admin'),
00290         '%admin_theme' => $admin_theme,
00291         '%selected_theme' => $form_state['values']['theme_default'],
00292       )));
00293     }
00294     variable_set('theme_default', $form_state['values']['theme_default']);
00295   }
00296   else {
00297     // Revert to defaults: only Garland is enabled.
00298     variable_del('theme_default');
00299     db_query("UPDATE {system} SET status = 1 WHERE type = 'theme' AND name = 'garland'");
00300     $new_theme_list = array('garland');
00301   }
00302
00303   list_themes(TRUE);
00304   menu_rebuild();
00305   drupal_rebuild_theme_registry();
00306   drupal_set_message(t('The configuration options have been saved.'));
00307   $form_state['redirect'] = 'admin/build/themes';
00308
00309   // Notify locale module about new themes being enabled, so translations can
00310   // be imported. This might start a batch, and only return to the redirect
00311   // path after that.
00312   module_invoke('locale', 'system_update', array_diff($new_theme_list, $old_theme_list));
00313
00314   return;
00315 }
00316
00327 function system_theme_settings(&$form_state, $key = '') {
00328   $directory_path = file_directory_path();
00329   file_check_directory($directory_path, FILE_CREATE_DIRECTORY, 'file_directory_path');
00330
00331   // Default settings are defined in theme_get_settings() in includes/theme.inc
00332   if ($key) {
00333     $settings = theme_get_settings($key);
00334     $var = str_replace('/', '_', 'theme_'. $key .'_settings');
00335     $themes = system_theme_data();
00336     $features = $themes[$key]->info['features'];
00337   }
00338   else {
00339     $settings = theme_get_settings('');
00340     $var = 'theme_settings';
00341   }
00342
00343   $form['var'] = array('#type' => 'hidden', '#value' => $var);
00344
00345   // Check for a new uploaded logo, and use that instead.
00346   if ($file = file_save_upload('logo_upload', array('file_validate_is_image' => array()))) {
00347     $parts = pathinfo($file->filename);
00348     $filename = ($key) ? str_replace('/', '_', $key) .'_logo.'. $parts['extension'] : 'logo.'. $parts['extension'];
00349
00350     // The image was saved using file_save_upload() and was added to the
00351     // files table as a temporary file. We'll make a copy and let the garbage
00352     // collector delete the original upload.
00353     if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) {
00354       $_POST['default_logo'] = 0;
00355       $_POST['logo_path'] = $file->filepath;
00356       $_POST['toggle_logo'] = 1;
00357     }
00358   }
00359
00360   // Check for a new uploaded favicon, and use that instead.
00361   if ($file = file_save_upload('favicon_upload')) {
00362     $parts = pathinfo($file->filename);
00363     $filename = ($key) ? str_replace('/', '_', $key) .'_favicon.'. $parts['extension'] : 'favicon.'. $parts['extension'];
00364
00365     // The image was saved using file_save_upload() and was added to the
00366     // files table as a temporary file. We'll make a copy and let the garbage
00367     // collector delete the original upload.
00368     if (file_copy($file, $filename)) {
00369       $_POST['default_favicon'] = 0;
00370       $_POST['favicon_path'] = $file->filepath;
00371       $_POST['toggle_favicon'] = 1;
00372     }
00373   }
00374
00375   // Toggle settings
00376   $toggles = array(
00377     'logo'                 => t('Logo'),
00378     'name'                 => t('Site name'),
00379     'slogan'               => t('Site slogan'),
00380     'mission'              => t('Mission statement'),
00381     'node_user_picture'    => t('User pictures in posts'),
00382     'comment_user_picture' => t('User pictures in comments'),
00383     'search'               => t('Search box'),
00384     'favicon'              => t('Shortcut icon'),
00385     'primary_links'        => t('Primary links'),
00386     'secondary_links'      => t('Secondary links'),
00387   );
00388
00389   // Some features are not always available
00390   $disabled = array();
00391   if (!variable_get('user_pictures', 0)) {
00392     $disabled['toggle_node_user_picture'] = TRUE;
00393     $disabled['toggle_comment_user_picture'] = TRUE;
00394   }
00395   if (!module_exists('search')) {
00396     $disabled['toggle_search'] = TRUE;
00397   }
00398
00399   $form['theme_settings'] = array(
00400     '#type' => 'fieldset',
00401     '#title' => t('Toggle display'),
00402     '#description' => t('Enable or disable the display of certain page elements.'),
00403   );
00404   foreach ($toggles as $name => $title) {
00405     if ((!$key) || in_array($name, $features)) {
00406       $form['theme_settings']['toggle_'. $name] = array('#type' => 'checkbox', '#title' => $title, '#default_value' => $settings['toggle_'. $name]);
00407       // Disable checkboxes for features not supported in the current configuration.
00408       if (isset($disabled['toggle_'. $name])) {
00409         $form['theme_settings']['toggle_'. $name]['#disabled'] = TRUE;
00410       }
00411     }
00412   }
00413
00414   // System wide only settings.
00415   if (!$key) {
00416     // Create neat 2-column layout for the toggles
00417     $form['theme_settings'] += array(
00418       '#prefix' => '<div class="theme-settings-left">',
00419       '#suffix' => '</div>',
00420     );
00421
00422     // Toggle node display.
00423     $node_types = node_get_types('names');
00424     if ($node_types) {
00425       $form['node_info'] = array(
00426         '#type' => 'fieldset',
00427         '#title' => t('Display post information on'),
00428         '#description' => t('Enable or disable the <em>submitted by Username on date</em> text when displaying posts of the following type.'),
00429         '#prefix' => '<div class="theme-settings-right">',
00430         '#suffix' => '</div>',
00431       );
00432       foreach ($node_types as $type => $name) {
00433         $form['node_info']["toggle_node_info_$type"] = array('#type' => 'checkbox', '#title' => check_plain($name), '#default_value' => $settings["toggle_node_info_$type"]);
00434       }
00435     }
00436   }
00437   elseif (!element_children($form['theme_settings'])) {
00438     // If there is no element in the theme settings fieldset then do not show
00439     // it -- but keep it in the form if another module wants to alter.
00440     $form['theme_settings']['#access'] = FALSE;
00441   }
00442
00443   // Logo settings
00444   if ((!$key) || in_array('logo', $features)) {
00445     $form['logo'] = array(
00446       '#type' => 'fieldset',
00447       '#title' => t('Logo image settings'),
00448       '#description' => t('If toggled on, the following logo will be displayed.'),
00449       '#attributes' => array('class' => 'theme-settings-bottom'),
00450     );
00451     $form['logo']["default_logo"] = array(
00452       '#type' => 'checkbox',
00453       '#title' => t('Use the default logo'),
00454       '#default_value' => $settings['default_logo'],
00455       '#tree' => FALSE,
00456       '#description' => t('Check here if you want the theme to use the logo supplied with it.')
00457     );
00458     $form['logo']['logo_path'] = array(
00459       '#type' => 'textfield',
00460       '#title' => t('Path to custom logo'),
00461       '#default_value' => $settings['logo_path'],
00462       '#description' => t('The path to the file you would like to use as your logo file instead of the default logo.'));
00463
00464     $form['logo']['logo_upload'] = array(
00465       '#type' => 'file',
00466       '#title' => t('Upload logo image'),
00467       '#maxlength' => 40,
00468       '#description' => t("If you don't have direct file access to the server, use this field to upload your logo.")
00469     );
00470   }
00471
00472   if ((!$key) || in_array('favicon', $features)) {
00473     $form['favicon'] = array(
00474       '#type' => 'fieldset',
00475       '#title' => t('Shortcut icon settings'),
00476       '#description' => t("Your shortcut icon, or 'favicon', is displayed in the address bar and bookmarks of most browsers.")
00477     );
00478     $form['favicon']['default_favicon'] = array(
00479       '#type' => 'checkbox',
00480       '#title' => t('Use the default shortcut icon.'),
00481       '#default_value' => $settings['default_favicon'],
00482       '#description' => t('Check here if you want the theme to use the default shortcut icon.')
00483     );
00484     $form['favicon']['favicon_path'] = array(
00485       '#type' => 'textfield',
00486       '#title' => t('Path to custom icon'),
00487       '#default_value' => $settings['favicon_path'],
00488       '#description' => t('The path to the image file you would like to use as your custom shortcut icon.')
00489     );
00490
00491     $form['favicon']['favicon_upload'] = array(
00492       '#type' => 'file',
00493       '#title' => t('Upload icon image'),
00494       '#description' => t("If you don't have direct file access to the server, use this field to upload your shortcut icon.")
00495     );
00496   }
00497
00498   if ($key) {
00499     // Include the theme's theme-settings.php file
00500     $filename = './'. str_replace("/$key.info", '', $themes[$key]->filename) .'/theme-settings.php';
00501     if (!file_exists($filename) and !empty($themes[$key]->info['base theme'])) {
00502       // If the theme doesn't have a theme-settings.php file, use the base theme's.
00503       $base = $themes[$key]->info['base theme'];
00504       $filename = './'. str_replace("/$base.info", '', $themes[$base]->filename) .'/theme-settings.php';
00505     }
00506     if (file_exists($filename)) {
00507       require_once $filename;
00508     }
00509
00510     // Call engine-specific settings.
00511     $function = $themes[$key]->prefix .'_engine_settings';
00512     if (function_exists($function)) {
00513       $group = $function($settings);
00514       if (!empty($group)) {
00515         $form['engine_specific'] = array('#type' => 'fieldset', '#title' => t('Theme-engine-specific settings'), '#description' => t('These settings only exist for all the templates and styles based on the %engine theme engine.', array('%engine' => $themes[$key]->prefix)));
00516         $form['engine_specific'] = array_merge($form['engine_specific'], $group);
00517       }
00518     }
00519     // Call theme-specific settings.
00520     $function = $key .'_settings';
00521     if (!function_exists($function)) {
00522       $function = $themes[$key]->prefix .'_settings';
00523     }
00524     if (function_exists($function)) {
00525       $group = $function($settings);
00526       if (!empty($group)) {
00527         $form['theme_specific'] = array('#type' => 'fieldset', '#title' => t('Theme-specific settings'), '#description' => t('These settings only exist for the %theme theme and all the styles based on it.', array('%theme' => $themes[$key]->info['name'])));
00528         $form['theme_specific'] = array_merge($form['theme_specific'], $group);
00529       }
00530     }
00531   }
00532   $form['#attributes'] = array('enctype' => 'multipart/form-data');
00533
00534   $form = system_settings_form($form);
00535   // We don't want to call system_settings_form_submit(), so change #submit.
00536   $form['#submit'] = array('system_theme_settings_submit');
00537   return $form;
00538 }
00539
00543 function system_theme_settings_submit($form, &$form_state) {
00544   $values = $form_state['values'];
00545   $key = $values['var'];
00546
00547   if ($values['op'] == t('Reset to defaults')) {
00548     variable_del($key);
00549     drupal_set_message(t('The configuration options have been reset to their default values.'));
00550   }
00551   else {
00552     // Exclude unnecessary elements before saving.
00553     unset($values['var'], $values['submit'], $values['reset'], $values['form_id'], $values['op'], $values['form_build_id'], $values['form_token']);
00554     variable_set($key, $values);
00555     drupal_set_message(t('The configuration options have been saved.'));
00556   }
00557
00558   cache_clear_all();
00559 }
00560
00573 function _system_is_incompatible(&$incompatible, $files, $file) {
00574   static $seen;
00575   // We need to protect ourselves in case of a circular dependency.
00576   if (isset($seen[$file->name])) {
00577     return isset($incompatible[$file->name]);
00578   }
00579   $seen[$file->name] = TRUE;
00580   if (isset($incompatible[$file->name])) {
00581     return TRUE;
00582   }
00583   // The 'dependencies' key in .info files was a string in Drupal 5, but changed
00584   // to an array in Drupal 6. If it is not an array, the module is not
00585   // compatible and we can skip the check below which requires an array.
00586   if (!is_array($file->info['dependencies'])) {
00587     $file->info['dependencies'] = array();
00588     $incompatible[$file->name] = TRUE;
00589     return TRUE;
00590   }
00591   // Recursively traverse the dependencies, looking for incompatible modules
00592   foreach ($file->info['dependencies'] as $dependency) {
00593     if (isset($files[$dependency]) && _system_is_incompatible($incompatible, $files, $files[$dependency])) {
00594       $incompatible[$file->name] = TRUE;
00595       return TRUE;
00596     }
00597   }
00598 }
00599
00620 function system_modules($form_state = array()) {
00621   drupal_rebuild_theme_registry();
00622   node_types_rebuild();
00623   menu_rebuild();
00624   cache_clear_all('schema', 'cache');
00625   // Get current list of modules.
00626   $files = module_rebuild_cache();
00627
00628   uasort($files, 'system_sort_modules_by_info_name');
00629
00630   if (!empty($form_state['storage'])) {
00631     return system_modules_confirm_form($files, $form_state['storage']);
00632   }
00633   $dependencies = array();
00634
00635   // Store module list for validation callback.
00636   $form['validation_modules'] = array('#type' => 'value', '#value' => $files);
00637
00638   // Create storage for disabled modules as browser will disable checkboxes.
00639   $form['disabled_modules'] = array('#type' => 'value', '#value' => array());
00640
00641   // Traverse the files, checking for compatibility
00642   $incompatible_core = array();
00643   $incompatible_php = array();
00644   foreach ($files as $filename => $file) {
00645     // Ensure this module is compatible with this version of core.
00646     if (!isset($file->info['core']) || $file->info['core'] != DRUPAL_CORE_COMPATIBILITY) {
00647       $incompatible_core[$file->name] = $file->name;
00648     }
00649     // Ensure this module is compatible with the currently installed version of PHP.
00650     if (version_compare(phpversion(), $file->info['php']) < 0) {
00651       $incompatible_php[$file->name] = $file->info['php'];
00652     }
00653   }
00654
00655   // Array for disabling checkboxes in callback system_module_disable.
00656   $disabled = array();
00657   $throttle = array();
00658   // Traverse the files retrieved and build the form.
00659   foreach ($files as $filename => $file) {
00660     $form['name'][$filename] = array('#value' => $file->info['name']);
00661     $form['version'][$filename] = array('#value' => $file->info['version']);
00662     $form['description'][$filename] = array('#value' => t($file->info['description']));
00663     $options[$filename] = '';
00664     // Ensure this module is compatible with this version of core and php.
00665     if (_system_is_incompatible($incompatible_core, $files, $file) || _system_is_incompatible($incompatible_php, $files, $file)) {
00666       $disabled[] = $file->name;
00667       // Nothing else in this loop matters, so move to the next module.
00668       continue;
00669     }
00670     if ($file->status) {
00671       $status[] = $file->name;
00672     }
00673     if ($file->throttle) {
00674       $throttle[] = $file->name;
00675     }
00676
00677     $dependencies = array();
00678     // Check for missing dependencies.
00679     if (is_array($file->info['dependencies'])) {
00680       foreach ($file->info['dependencies'] as $dependency) {
00681         if (!isset($files[$dependency]) || !$files[$dependency]->status) {
00682           if (isset($files[$dependency])) {
00683             $dependencies[] = $files[$dependency]->info['name'] . t(' (<span class="admin-disabled">disabled</span>)');
00684           }
00685           else {
00686             $dependencies[] = drupal_ucfirst($dependency) . t(' (<span class="admin-missing">missing</span>)');
00687             $disabled[] = $filename;
00688             $form['disabled_modules']['#value'][$filename] = FALSE;
00689           }
00690         }
00691         else {
00692           $dependencies[] = $files[$dependency]->info['name'] . t(' (<span class="admin-enabled">enabled</span>)');
00693         }
00694       }
00695
00696       // Add text for dependencies.
00697       if (!empty($dependencies)) {
00698         $form['description'][$filename]['dependencies'] = array(
00699           '#value' => t('Depends on: !dependencies', array('!dependencies' => implode(', ', $dependencies))),
00700           '#prefix' => '<div class="admin-dependencies">',
00701           '#suffix' => '</div>',
00702         );
00703       }
00704     }
00705
00706     // Mark dependents disabled so user can not remove modules being depended on.
00707     $dependents = array();
00708     foreach ($file->info['dependents'] as $dependent) {
00709       if ($files[$dependent]->status == 1) {
00710         $dependents[] = $files[$dependent]->info['name'] . t(' (<span class="admin-enabled">enabled</span>)');
00711         $disabled[] = $filename;
00712         $form['disabled_modules']['#value'][$filename] = TRUE;
00713       }
00714       else {
00715         $dependents[] = $files[$dependent]->info['name'] . t(' (<span class="admin-disabled">disabled</span>)');
00716       }
00717     }
00718
00719     // Add text for enabled dependents.
00720     if (!empty($dependents)) {
00721       $form['description'][$filename]['required'] = array(
00722         '#value' => t('Required by: !required', array('!required' => implode(', ', $dependents))),
00723         '#prefix' => '<div class="admin-required">',
00724         '#suffix' => '</div>',
00725       );
00726     }
00727   }
00728
00729   $modules_required = drupal_required_modules();
00730   // Merge in required modules.
00731   foreach ($modules_required as $required) {
00732     $disabled[] = $required;
00733     $form['disabled_modules']['#value'][$required] = TRUE;
00734   }
00735
00736   // Handle status checkboxes, including overriding
00737   // the generated checkboxes for required modules.
00738   $form['status'] = array(
00739     '#type' => 'checkboxes',
00740     '#default_value' => $status,
00741     '#options' => $options,
00742     '#process' => array(
00743       'expand_checkboxes',
00744       'system_modules_disable',
00745     ),
00746     '#disabled_modules' => $disabled,
00747     '#incompatible_modules_core' => $incompatible_core,
00748     '#incompatible_modules_php' => $incompatible_php,
00749   );
00750
00751   // Handle throttle checkboxes, including overriding the
00752   // generated checkboxes for required modules.
00753   if (module_exists('throttle')) {
00754     $form['throttle'] = array(
00755       '#type' => 'checkboxes',
00756       '#default_value' => $throttle,
00757       '#options' => $options,
00758       '#process' => array(
00759         'expand_checkboxes',
00760         'system_modules_disable',
00761       ),
00762       '#disabled_modules' => array_merge($modules_required, array('throttle')),
00763     );
00764   }
00765
00766   $form['buttons']['submit'] = array(
00767     '#type' => 'submit',
00768     '#value' => t('Save configuration'),
00769   );
00770   $form['#action'] = url('admin/build/modules/list/confirm');
00771
00772   return $form;
00773 }
00774
00778 function system_sort_modules_by_info_name($a, $b) {
00779   return strcasecmp($a->info['name'], $b->info['name']);
00780 }
00781
00793 function system_modules_disable($form, $edit) {
00794   foreach ($form['#disabled_modules'] as $key) {
00795     $form[$key]['#attributes']['disabled'] = 'disabled';
00796   }
00797   return $form;
00798 }
00799
00811 function system_modules_confirm_form($modules, $storage) {
00812   $form = array();
00813   $items = array();
00814
00815   list($dependencies, $status) = $storage;
00816   $form['validation_modules'] = array('#type' => 'value', '#value' => $modules);
00817   $form['status']['#tree'] = TRUE;
00818   // Remember list of modules selected on the module listing page already.
00819   foreach ($status as $key => $choice) {
00820     $form['status'][$key] = array('#type' => 'value', '#value' => $choice);
00821   }
00822   foreach ($dependencies as $name => $missing_dependencies) {
00823     $form['status'][$name] = array('#type' => 'hidden', '#value' => 1);
00824     foreach ($missing_dependencies as $k => $dependency) {
00825       $form['status'][$dependency] = array('#type' => 'hidden', '#value' => 1);
00826       $info = $modules[$dependency]->info;
00827       $missing_dependencies[$k] = $info['name'] ? $info['name'] : drupal_ucfirst($dependency);
00828     }
00829     $t_argument = array(
00830       '@module' => $modules[$name]->info['name'],
00831       '@dependencies' => implode(', ', $missing_dependencies),
00832     );
00833     $items[] = format_plural(count($missing_dependencies), 'You must enable the @dependencies module to install @module.', 'You must enable the @dependencies modules to install @module.', $t_argument);
00834   }
00835   $form['text'] = array('#value' => theme('item_list', $items));
00836
00837   if ($form) {
00838     // Set some default form values
00839     $form = confirm_form(
00840       $form,
00841       t('Some required modules must be enabled'),
00842       'admin/build/modules',
00843       t('Would you like to continue with enabling the above?'),
00844       t('Continue'),
00845       t('Cancel'));
00846     return $form;
00847   }
00848 }
00849
00853 function system_modules_submit($form, &$form_state) {
00854   include_once './includes/install.inc';
00855   $new_modules = array();
00856
00857   // If we are coming from the confirm form...
00858   if (!isset($form_state['storage'])) {
00859     // Merge in disabled active modules since they should be enabled.
00860     // They don't appear because disabled checkboxes are not submitted
00861     // by browsers.
00862     $form_state['values']['status'] = array_merge($form_state['values']['status'], $form_state['values']['disabled_modules']);
00863
00864     // Check values for dependency that we can't install.
00865     if ($dependencies = system_module_build_dependencies($form_state['values']['validation_modules'], $form_state['values'])) {
00866       // These are the modules that depend on existing modules.
00867       foreach (array_keys($dependencies) as $name) {
00868         $form_state['values']['status'][$name] = 0;
00869       }
00870     }
00871   }
00872   else {
00873     $dependencies = NULL;
00874   }
00875
00876   // Update throttle settings, if present
00877   if (isset($form_state['values']['throttle'])) {
00878     foreach ($form_state['values']['throttle'] as $key => $choice) {
00879       db_query("UPDATE {system} SET throttle = %d WHERE type = 'module' and name = '%s'", $choice ? 1 : 0, $key);
00880     }
00881   }
00882
00883   // If there where unmet dependencies and they haven't confirmed don't process
00884   // the submission yet. Store the form submission data needed later.
00885   if ($dependencies) {
00886     if (!isset($form_state['values']['confirm'])) {
00887       $form_state['storage'] = array($dependencies, $form_state['values']['status']);
00888       return;
00889     }
00890     else {
00891       $form_state['values']['status'] = array_merge($form_state['values']['status'], $form_storage[1]);
00892     }
00893   }
00894   // If we have no dependencies, or the dependencies are confirmed
00895   // to be installed, we don't need the temporary storage anymore.
00896   unset($form_state['storage']);
00897
00898   $enable_modules = array();
00899   $disable_modules = array();
00900   foreach ($form_state['values']['status'] as $key => $choice) {
00901     if ($choice) {
00902       if (drupal_get_installed_schema_version($key) == SCHEMA_UNINSTALLED) {
00903         $new_modules[] = $key;
00904       }
00905       else {
00906         $enable_modules[] = $key;
00907       }
00908     }
00909     else {
00910       $disable_modules[] = $key;
00911     }
00912   }
00913
00914   $old_module_list = module_list();
00915
00916   if (!empty($enable_modules)) {
00917     module_enable($enable_modules);
00918   }
00919   if (!empty($disable_modules)) {
00920     module_disable($disable_modules);
00921   }
00922
00923   // Install new modules.
00924   foreach ($new_modules as $key => $module) {
00925     if (!drupal_check_module($module)) {
00926       unset($new_modules[$key]);
00927     }
00928   }
00929   drupal_install_modules($new_modules);
00930
00931   $current_module_list = module_list(TRUE, FALSE);
00932   if ($old_module_list != $current_module_list) {
00933     drupal_set_message(t('The configuration options have been saved.'));
00934   }
00935
00936   drupal_clear_css_cache();
00937   drupal_clear_js_cache();
00938
00939   $form_state['redirect'] = 'admin/build/modules';
00940
00941   // Notify locale module about module changes, so translations can be
00942   // imported. This might start a batch, and only return to the redirect
00943   // path after that.
00944   module_invoke('locale', 'system_update', $new_modules);
00945
00946   // Synchronize to catch any actions that were added or removed.
00947   actions_synchronize();
00948
00949   return;
00950 }
00951
00952
00963 function system_module_build_dependencies($modules, $form_values) {
00964   static $dependencies;
00965
00966   if (!isset($dependencies) && isset($form_values)) {
00967     $dependencies = array();
00968     foreach ($modules as $name => $module) {
00969       // If the module is disabled, will be switched on and it has dependencies.
00970       if (!$module->status && $form_values['status'][$name] && isset($module->info['dependencies'])) {
00971         foreach ($module->info['dependencies'] as $dependency) {
00972           if (!$form_values['status'][$dependency] && isset($modules[$dependency])) {
00973             if (!isset($dependencies[$name])) {
00974               $dependencies[$name] = array();
00975             }
00976             $dependencies[$name][] = $dependency;
00977           }
00978         }
00979       }
00980     }
00981   }
00982   return $dependencies;
00983 }
00984
01000 function system_modules_uninstall($form_state = NULL) {
01001   // Make sure the install API is available.
01002   include_once './includes/install.inc';
01003
01004   // Display the confirm form if any modules have been submitted.
01005   if (isset($form_state) && $confirm_form = system_modules_uninstall_confirm_form($form_state['storage'])) {
01006     return $confirm_form;
01007   }
01008
01009   $form = array();
01010
01011   // Pull all disabled modules from the system table.
01012   $disabled_modules = db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' AND status = 0 AND schema_version > %d ORDER BY name", SCHEMA_UNINSTALLED);
01013   while ($module = db_fetch_object($disabled_modules)) {
01014
01015     // Grab the module info
01016     $info = unserialize($module->info);
01017
01018     // Load the .install file, and check for an uninstall hook.
01019     // If the hook exists, the module can be uninstalled.
01020     module_load_install($module->name);
01021     if (module_hook($module->name, 'uninstall')) {
01022       $form['modules'][$module->name]['name'] = array('#value' => $info['name'] ? $info['name'] : $module->name);
01023       $form['modules'][$module->name]['description'] = array('#value' => t($info['description']));
01024       $options[$module->name] = '';
01025     }
01026   }
01027
01028   // Only build the rest of the form if there are any modules available to uninstall.
01029   if (!empty($options)) {
01030     $form['uninstall'] = array(
01031       '#type' => 'checkboxes',
01032       '#options' => $options,
01033     );
01034     $form['buttons']['submit'] = array(
01035       '#type' => 'submit',
01036       '#value' => t('Uninstall'),
01037     );
01038     $form['#action'] = url('admin/build/modules/uninstall/confirm');
01039   }
01040   else {
01041     $form['modules'] = array();
01042   }
01043
01044   return $form;
01045 }
01046
01056 function system_modules_uninstall_confirm_form($storage) {
01057   // Nothing to build.
01058   if (!isset($storage)) {
01059     return;
01060   }
01061
01062   // Construct the hidden form elements and list items.
01063   foreach (array_filter($storage['uninstall']) as $module => $value) {
01064     $info = drupal_parse_info_file(dirname(drupal_get_filename('module', $module)) .'/'. $module .'.info');
01065     $uninstall[] = $info['name'];
01066     $form['uninstall'][$module] = array('#type' => 'hidden',
01067       '#value' => 1,
01068     );
01069   }
01070
01071   // Display a confirm form if modules have been selected.
01072   if (isset($uninstall)) {
01073     $form['#confirmed'] = TRUE;
01074     $form['uninstall']['#tree'] = TRUE;
01075     $form['modules'] = array('#value' => '<p>'. t('The following modules will be completely uninstalled from your site, and <em>all data from these modules will be lost</em>!') .'</p>'. theme('item_list', $uninstall));
01076     $form = confirm_form(
01077       $form,
01078       t('Confirm uninstall'),
01079       'admin/build/modules/uninstall',
01080       t('Would you like to continue with uninstalling the above?'),
01081       t('Uninstall'),
01082       t('Cancel'));
01083     return $form;
01084   }
01085 }
01086
01090 function system_modules_uninstall_validate($form, &$form_state) {
01091   // Form submitted, but no modules selected.
01092   if (!count(array_filter($form_state['values']['uninstall']))) {
01093     drupal_set_message(t('No modules selected.'), 'error');
01094     drupal_goto('admin/build/modules/uninstall');
01095   }
01096 }
01097
01101 function system_modules_uninstall_submit($form, &$form_state) {
01102   // Make sure the install API is available.
01103   include_once './includes/install.inc';
01104
01105   if (!empty($form['#confirmed'])) {
01106     // Call the uninstall routine for each selected module.
01107     foreach (array_filter($form_state['values']['uninstall']) as $module => $value) {
01108       drupal_uninstall_module($module);
01109     }
01110     drupal_set_message(t('The selected modules have been uninstalled.'));
01111
01112     unset($form_state['storage']);
01113     $form_state['redirect'] = 'admin/build/modules/uninstall';
01114   }
01115   else {
01116     $form_state['storage'] = $form_state['values'];
01117   }
01118 }
01119
01126 function system_site_information_settings() {
01127   $form['site_name'] = array(
01128     '#type' => 'textfield',
01129     '#title' => t('Name'),
01130     '#default_value' => variable_get('site_name', 'Drupal'),
01131     '#description' => t('The name of this website.'),
01132     '#required' => TRUE
01133   );
01134   $form['site_mail'] = array(
01135     '#type' => 'textfield',
01136     '#title' => t('E-mail address'),
01137     '#default_value' => variable_get('site_mail', ini_get('sendmail_from')),
01138     '#description' => t("The <em>From</em> address in automated e-mails sent during registration and new password requests, and other notifications. (Use an address ending in your site's domain to help prevent this e-mail being flagged as spam.)"),
01139     '#required' => TRUE,
01140   );
01141   $form['site_slogan'] = array(
01142     '#type' => 'textfield',
01143     '#title' => t('Slogan'),
01144     '#default_value' => variable_get('site_slogan', ''),
01145     '#description' => t("Your site's motto, tag line, or catchphrase (often displayed alongside the title of the site).")
01146   );
01147   $form['site_mission'] = array(
01148     '#type' => 'textarea',
01149     '#title' => t('Mission'),
01150     '#default_value' => variable_get('site_mission', ''),
01151     '#description' => t("Your site's mission or focus statement (often prominently displayed on the front page).")
01152   );
01153   $form['site_footer'] = array(
01154     '#type' => 'textarea',
01155     '#title' => t('Footer message'),
01156     '#default_value' => variable_get('site_footer', ''),
01157     '#description' => t('This text will be displayed at the bottom of each page. Useful for adding a copyright notice to your pages.')
01158   );
01159   $form['anonymous'] = array(
01160     '#type' => 'textfield',
01161     '#title' => t('Anonymous user'),
01162     '#default_value' => variable_get('anonymous', t('Anonymous')),
01163     '#description' => t('The name used to indicate anonymous users.'),
01164     '#required' => TRUE,
01165   );
01166   $form['site_frontpage'] = array(
01167     '#type' => 'textfield',
01168     '#title' => t('Default front page'),
01169     '#default_value' => variable_get('site_frontpage', 'node'),
01170     '#size' => 40,
01171     '#description' => t('The home page displays content from this relative URL. If unsure, specify "node".'),
01172     '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
01173     '#required' => TRUE,
01174   );
01175   $form['#validate'][] = 'system_site_information_settings_validate';
01176
01177   return system_settings_form($form);
01178 }
01179
01183 function system_site_information_settings_validate($form, &$form_state) {
01184   // Validate the e-mail address.
01185   if ($error = user_validate_mail($form_state['values']['site_mail'])) {
01186     form_set_error('site_mail', $error);
01187   }
01188   // Validate front page path.
01189   $item = array('link_path' => $form_state['values']['site_frontpage']);
01190   $normal_path = drupal_get_normal_path($item['link_path']);
01191   if ($item['link_path'] != $normal_path) {
01192     drupal_set_message(t('The menu system stores system paths only, but will use the URL alias for display. %link_path has been stored as %normal_path', array('%link_path' => $item['link_path'], '%normal_path' => $normal_path)));
01193     $item['link_path'] = $normal_path;
01194   }
01195   if (!empty($item) && !menu_valid_path($item)) {
01196     form_set_error('site_frontpage', t("The path '@path' is either invalid or you do not have access to it.", array('@path' => $item['link_path'])));
01197   }
01198 }
01199
01206 function system_error_reporting_settings() {
01207
01208   $form['site_403'] = array(
01209     '#type' => 'textfield',
01210     '#title' => t('Default 403 (access denied) page'),
01211     '#default_value' => variable_get('site_403', ''),
01212     '#size' => 40,
01213     '#description' => t('This page is displayed when the requested document is denied to the current user. If unsure, specify nothing.'),
01214     '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
01215   );
01216
01217   $form['site_404'] = array(
01218     '#type' => 'textfield',
01219     '#title' => t('Default 404 (not found) page'),
01220     '#default_value' => variable_get('site_404', ''),
01221     '#size' => 40,
01222     '#description' => t('This page is displayed when no other content matches the requested document. If unsure, specify nothing.'),
01223     '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')
01224   );
01225
01226   $form['error_level'] = array(
01227     '#type' => 'select', '#title' => t('Error reporting'), '#default_value' => variable_get('error_level', 1),
01228     '#options' => array(t('Write errors to the log'), t('Write errors to the log and to the screen')),
01229     '#description' => t('Specify where Drupal, PHP and SQL errors are logged. While it is recommended that a site running in a production environment write errors to the log only, in a development or testing environment it may be helpful to write errors both to the log and to the screen.')
01230   );
01231
01232   return system_settings_form($form);
01233 }
01234
01238 function system_logging_overview() {
01239   $item = menu_get_item('admin/settings/logging');
01240   $content = system_admin_menu_block($item);
01241
01242   $output = theme('admin_block_content', $content);
01243
01244   return $output;
01245 }
01246
01253 function system_performance_settings() {
01254
01255   $description = '<p>'. t("The normal cache mode is suitable for most sites and does not cause any side effects. The aggressive cache mode causes Drupal to skip the loading (boot) and unloading (exit) of enabled modules when serving a cached page. This results in an additional performance boost but can cause unwanted side effects.") .'</p>';
01256
01257   $problem_modules = array_unique(array_merge(module_implements('boot'), module_implements('exit')));
01258   sort($problem_modules);
01259
01260   if (count($problem_modules) > 0) {
01261     $description .= '<p>'. t('<strong class="error">The following enabled modules are incompatible with aggressive mode caching and will not function properly: %modules</strong>', array('%modules' => implode(', ', $problem_modules))) .'.</p>';
01262   }
01263   else {
01264     $description .= '<p>'. t('<strong class="ok">Currently, all enabled modules are compatible with the aggressive caching policy.</strong> Please note, if you use aggressive caching and enable new modules, you will need to check this page again to ensure compatibility.') .'</p>';
01265   }
01266   $form['page_cache'] = array(
01267     '#type' => 'fieldset',
01268     '#title' => t('Page cache'),
01269     '#description' => t('Enabling the page cache will offer a significant performance boost. Drupal can store and send compressed cached pages requested by <em>anonymous</em> users. By caching a web page, Drupal does not have to construct the page each time it is viewed.'),
01270   );
01271
01272   $form['page_cache']['cache'] = array(
01273     '#type' => 'radios',
01274     '#title' => t('Caching mode'),
01275     '#default_value' => variable_get('cache', CACHE_DISABLED),
01276     '#options' => array(CACHE_DISABLED => t('Disabled'), CACHE_NORMAL => t('Normal (recommended for production sites, no side effects)'), CACHE_AGGRESSIVE => t('Aggressive (experts only, possible side effects)')),
01277     '#description' => $description
01278   );
01279
01280   $period = drupal_map_assoc(array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400), 'format_interval');
01281   $period[0] = '<'. t('none') .'>';
01282   $form['page_cache']['cache_lifetime'] = array(
01283     '#type' => 'select',
01284     '#title' => t('Minimum cache lifetime'),
01285     '#default_value' => variable_get('cache_lifetime', 0),
01286     '#options' => $period,
01287     '#description' => t('On high-traffic sites, it may be necessary to enforce a minimum cache lifetime. The minimum cache lifetime is the minimum amount of time that will elapse before the cache is emptied and recreated, and is applied to both page and block caches. A larger minimum cache lifetime offers better performance, but users will not see new content for a longer period of time.')
01288   );
01289   $form['page_cache']['page_compression'] = array(
01290     '#type' => 'radios',
01291     '#title' => t('Page compression'),
01292     '#default_value' => variable_get('page_compression', TRUE),
01293     '#options' => array(t('Disabled'), t('Enabled')),
01294     '#description' => t("By default, Drupal compresses the pages it caches in order to save bandwidth and improve download times. This option should be disabled when using a webserver that performs compression."),
01295   );
01296
01297   $form['block_cache'] = array(
01298     '#type' => 'fieldset',
01299     '#title' => t('Block cache'),
01300     '#description' => t('Enabling the block cache can offer a performance increase for all users by preventing blocks from being reconstructed on each page load. If the page cache is also enabled, performance increases from enabling the block cache will mainly benefit authenticated users.'),
01301   );
01302
01303   $form['block_cache']['block_cache'] = array(
01304     '#type' => 'radios',
01305     '#title' => t('Block cache'),
01306     '#default_value' => variable_get('block_cache', CACHE_DISABLED),
01307     '#options' => array(CACHE_DISABLED => t('Disabled'), CACHE_NORMAL => t('Enabled (recommended)')),
01308     '#disabled' => count(module_implements('node_grants')),
01309     '#description' => t('Note that block caching is inactive when modules defining content access restrictions are enabled.'),
01310   );
01311
01312   $form['bandwidth_optimizations'] = array(
01313     '#type' => 'fieldset',
01314     '#title' => t('Bandwidth optimizations'),
01315     '#description' => t('<p>Drupal can automatically optimize external resources like CSS and JavaScript, which can reduce both the size and number of requests made to your website. CSS files can be aggregated and compressed into a single file, while JavaScript files are aggregated (but not compressed). These optional optimizations may reduce server load, bandwidth requirements, and page loading times.</p><p>These options are disabled if you have not set up your files directory, or if your download method is set to private.</p>')
01316   );
01317
01318   $directory = file_directory_path();
01319   $is_writable = is_dir($directory) && is_writable($directory) && (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC);
01320   $form['bandwidth_optimizations']['preprocess_css'] = array(
01321     '#type' => 'radios',
01322     '#title' => t('Optimize CSS files'),
01323     '#default_value' => intval(variable_get('preprocess_css', 0) && $is_writable),
01324     '#disabled' => !$is_writable,
01325     '#options' => array(t('Disabled'), t('Enabled')),
01326     '#description' => t('This option can interfere with theme development and should only be enabled in a production environment.'),
01327   );
01328   $form['bandwidth_optimizations']['preprocess_js'] = array(
01329     '#type' => 'radios',
01330     '#title' => t('Optimize JavaScript files'),
01331     '#default_value' => intval(variable_get('preprocess_js', 0) && $is_writable),
01332     '#disabled' => !$is_writable,
01333     '#options' => array(t('Disabled'), t('Enabled')),
01334     '#description' => t('This option can interfere with module development and should only be enabled in a production environment.'),
01335   );
01336
01337   $form['clear_cache'] = array(
01338     '#type' => 'fieldset',
01339     '#title' => t('Clear cached data'),
01340     '#description' => t('Caching data improves performance, but may cause problems while troubleshooting new modules, themes, or translations, if outdated information has been cached. To refresh all cached data on your site, click the button below. <em>Warning: high-traffic sites will experience performance slowdowns while cached data is rebuilt.</em>'),
01341   );
01342
01343   $form['clear_cache']['clear'] = array(
01344     '#type' => 'submit',
01345     '#value' => t('Clear cached data'),
01346     '#submit' => array('system_clear_cache_submit'),
01347   );
01348
01349   $form['#submit'][] = 'drupal_clear_css_cache';
01350   $form['#submit'][] = 'drupal_clear_js_cache';
01351
01352   return system_settings_form($form);
01353 }
01354
01360 function system_clear_cache_submit(&$form_state, $form) {
01361   drupal_flush_all_caches();
01362   drupal_set_message('Caches cleared.');
01363 }
01364
01371 function system_file_system_settings() {
01372
01373   $form['file_directory_path'] = array(
01374     '#type' => 'textfield',
01375     '#title' => t('File system path'),
01376     '#default_value' => file_directory_path(),
01377     '#maxlength' => 255,
01378     '#description' => t('A file system path where the files will be stored. This directory must exist and be writable by Drupal. If the download method is set to public, this directory must be relative to the Drupal installation directory and be accessible over the web. If the download method is set to private, this directory should not be accessible over the web. Changing this location will modify all download paths and may cause unexpected problems on an existing site.'),
01379     '#after_build' => array('system_check_directory'),
01380   );
01381
01382   $form['file_directory_temp'] = array(
01383     '#type' => 'textfield',
01384     '#title' => t('Temporary directory'),
01385     '#default_value' => file_directory_temp(),
01386     '#maxlength' => 255,
01387     '#description' => t('A file system path where uploaded files will be stored during previews.'),
01388     '#after_build' => array('system_check_directory'),
01389   );
01390
01391   $form['file_downloads'] = array(
01392     '#type' => 'radios',
01393     '#title' => t('Download method'),
01394     '#default_value' => variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC),
01395     '#options' => array(FILE_DOWNLOADS_PUBLIC => t('Public - files are available using HTTP directly.'), FILE_DOWNLOADS_PRIVATE => t('Private - files are transferred by Drupal.')),
01396     '#description' => t('Choose the <em>Public download</em> method unless you wish to enforce fine-grained access controls over file downloads. Changing the download method will modify all download paths and may cause unexpected problems on an existing site.')
01397   );
01398
01399   return system_settings_form($form);
01400 }
01401
01408 function system_image_toolkit_settings() {
01409   $toolkits_available = image_get_available_toolkits();
01410   if (count($toolkits_available) > 1) {
01411     $form['image_toolkit'] = array(
01412       '#type' => 'radios',
01413       '#title' => t('Select an image processing toolkit'),
01414       '#default_value' => variable_get('image_toolkit', image_get_toolkit()),
01415       '#options' => $toolkits_available
01416     );
01417   }
01418   elseif (count($toolkits_available) == 1) {
01419     variable_set('image_toolkit', key($toolkits_available));
01420   }
01421
01422   $form['image_toolkit_settings'] = image_toolkit_invoke('settings');
01423
01424   return system_settings_form($form);
01425 }
01426
01433 function system_rss_feeds_settings() {
01434
01435   $form['feed_default_items'] = array(
01436     '#type' => 'select',
01437     '#title' => t('Number of items in each feed'),
01438     '#default_value' => variable_get('feed_default_items', 10),
01439     '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
01440     '#description' => t('Default number of items to include in each feed.')
01441   );
01442   $form['feed_item_length'] = array(
01443     '#type' => 'select',
01444     '#title' => t('Feed content'),
01445     '#default_value' => variable_get('feed_item_length', 'teaser'),
01446     '#options' => array('title' => t('Titles only'), 'teaser' => t('Titles plus teaser'), 'fulltext' => t('Full text')),
01447     '#description' => t('Global setting for the default display of content items in each feed.')
01448   );
01449
01450   return system_settings_form($form);
01451 }
01452
01460 function system_date_time_settings() {
01461   drupal_add_js(drupal_get_path('module', 'system') .'/system.js', 'module');
01462   drupal_add_js(array('dateTime' => array('lookup' => url('admin/settings/date-time/lookup'))), 'setting');
01463
01464   // Date settings:
01465   $zones = _system_zonelist();
01466
01467   // Date settings: possible date formats
01468   $date_short = array('Y-m-d H:i', 'm/d/Y - H:i', 'd/m/Y - H:i', 'Y/m/d - H:i',
01469            'd.m.Y - H:i', 'm/d/Y - g:ia', 'd/m/Y - g:ia', 'Y/m/d - g:ia',
01470            'M j Y - H:i', 'j M Y - H:i', 'Y M j - H:i',
01471            'M j Y - g:ia', 'j M Y - g:ia', 'Y M j - g:ia');
01472   $date_medium = array('D, Y-m-d H:i', 'D, m/d/Y - H:i', 'D, d/m/Y - H:i',
01473           'D, Y/m/d - H:i', 'F j, Y - H:i', 'j F, Y - H:i', 'Y, F j - H:i',
01474           'D, m/d/Y - g:ia', 'D, d/m/Y - g:ia', 'D, Y/m/d - g:ia',
01475           'F j, Y - g:ia', 'j F Y - g:ia', 'Y, F j - g:ia', 'j. F Y - G:i');
01476   $date_long = array('l, F j, Y - H:i', 'l, j F, Y - H:i', 'l, Y, F j - H:i',
01477         'l, F j, Y - g:ia', 'l, j F Y - g:ia', 'l, Y, F j - g:ia', 'l, j. F Y - G:i');
01478
01479   // Date settings: construct choices for user
01480   foreach ($date_short as $f) {
01481     $date_short_choices[$f] = format_date(time(), 'custom', $f);
01482   }
01483   foreach ($date_medium as $f) {
01484     $date_medium_choices[$f] = format_date(time(), 'custom', $f);
01485   }
01486   foreach ($date_long as $f) {
01487     $date_long_choices[$f] = format_date(time(), 'custom', $f);
01488   }
01489
01490   $date_long_choices['custom'] = $date_medium_choices['custom'] = $date_short_choices['custom'] = t('Custom format');
01491
01492   $form['locale'] = array(
01493     '#type' => 'fieldset',
01494     '#title' => t('Locale settings'),
01495   );
01496
01497   $form['locale']['date_default_timezone'] = array(
01498     '#type' => 'select',
01499     '#title' => t('Default time zone'),
01500     '#default_value' => variable_get('date_default_timezone', 0),
01501     '#options' => $zones,
01502     '#description' => t('Select the default site time zone.')
01503   );
01504
01505   $form['locale']['configurable_timezones'] = array(
01506     '#type' => 'radios',
01507     '#title' => t('User-configurable time zones'),
01508     '#default_value' => variable_get('configurable_timezones', 1),
01509     '#options' => array(t('Disabled'), t('Enabled')),
01510     '#description' => t('When enabled, users can set their own time zone and dates will be displayed accordingly.')
01511   );
01512
01513   $form['locale']['date_first_day'] = array(
01514     '#type' => 'select',
01515     '#title' => t('First day of week'),
01516     '#default_value' => variable_get('date_first_day', 0),
01517     '#options' => array(0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'), 3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday')),
01518     '#description' => t('The first day of the week for calendar views.')
01519   );
01520
01521   $form['date_formats'] = array(
01522     '#type' => 'fieldset',
01523     '#title' => t('Formatting'),
01524   );
01525
01526   $date_format_short = variable_get('date_format_short', $date_short[1]);
01527   $form['date_formats']['date_format_short'] = array(
01528     '#prefix' => '<div class="date-container"><div class="select-container">',
01529     '#suffix' => '</div>',
01530     '#type' => 'select',
01531     '#title' => t('Short date format'),
01532     '#attributes' => array('class' => 'date-format'),
01533     '#default_value' => (isset($date_short_choices[$date_format_short]) ? $date_format_short : 'custom'),
01534     '#options' => $date_short_choices,
01535     '#description' => t('The short format of date display.'),
01536   );
01537
01538   $default_short_custom = variable_get('date_format_short_custom', (isset($date_short_choices[$date_format_short]) ? $date_format_short : ''));
01539   $form['date_formats']['date_format_short_custom'] = array(
01540     '#prefix' => '<div class="custom-container">',
01541     '#suffix' => '</div></div>',
01542     '#type' => 'textfield',
01543     '#title' => t('Custom short date format'),
01544     '#attributes' => array('class' => 'custom-format'),
01545     '#default_value' => $default_short_custom,
01546     '#description' => t('A user-defined short date format. See the <a href="@url">PHP manual</a> for available options. This format is currently set to display as <span>%date</span>.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(time(), 'custom', $default_short_custom))),
01547   );
01548
01549   $date_format_medium = variable_get('date_format_medium', $date_medium[1]);
01550   $form['date_formats']['date_format_medium'] = array(
01551     '#prefix' => '<div class="date-container"><div class="select-container">',
01552     '#suffix' => '</div>',
01553     '#type' => 'select',
01554     '#title' => t('Medium date format'),
01555     '#attributes' => array('class' => 'date-format'),
01556     '#default_value' => (isset($date_medium_choices[$date_format_medium]) ? $date_format_medium : 'custom'),
01557     '#options' => $date_medium_choices,
01558     '#description' => t('The medium sized date display.'),
01559   );
01560
01561   $default_medium_custom = variable_get('date_format_medium_custom', (isset($date_medium_choices[$date_format_medium]) ? $date_format_medium : ''));
01562   $form['date_formats']['date_format_medium_custom'] = array(
01563     '#prefix' => '<div class="custom-container">',
01564     '#suffix' => '</div></div>',
01565     '#type' => 'textfield',
01566     '#title' => t('Custom medium date format'),
01567     '#attributes' => array('class' => 'custom-format'),
01568     '#default_value' => $default_medium_custom,
01569     '#description' => t('A user-defined medium date format. See the <a href="@url">PHP manual</a> for available options. This format is currently set to display as <span>%date</span>.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(time(), 'custom', $default_medium_custom))),
01570   );
01571
01572   $date_format_long = variable_get('date_format_long', $date_long[0]);
01573   $form['date_formats']['date_format_long'] = array(
01574     '#prefix' => '<div class="date-container"><div class="select-container">',
01575     '#suffix' => '</div>',
01576     '#type' => 'select',
01577     '#title' => t('Long date format'),
01578     '#attributes' => array('class' => 'date-format'),
01579     '#default_value' => (isset($date_long_choices[$date_format_long]) ? $date_format_long : 'custom'),
01580     '#options' => $date_long_choices,
01581     '#description' => t('Longer date format used for detailed display.')
01582   );
01583
01584   $default_long_custom = variable_get('date_format_long_custom', (isset($date_long_choices[$date_format_long]) ? $date_format_long : ''));
01585   $form['date_formats']['date_format_long_custom'] = array(
01586     '#prefix' => '<div class="custom-container">',
01587     '#suffix' => '</div></div>',
01588     '#type' => 'textfield',
01589     '#title' => t('Custom long date format'),
01590     '#attributes' => array('class' => 'custom-format'),
01591     '#default_value' => $default_long_custom,
01592     '#description' => t('A user-defined long date format. See the <a href="@url">PHP manual</a> for available options. This format is currently set to display as <span>%date</span>.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(time(), 'custom', $default_long_custom))),
01593   );
01594
01595   $form = system_settings_form($form);
01596   // We will call system_settings_form_submit() manually, so remove it for now.
01597   unset($form['#submit']);
01598   return $form;
01599 }
01600
01604 function system_date_time_settings_submit($form, &$form_state) {
01605   if ($form_state['values']['date_format_short'] == 'custom') {
01606     $form_state['values']['date_format_short'] = $form_state['values']['date_format_short_custom'];
01607   }
01608   if ($form_state['values']['date_format_medium'] == 'custom') {
01609     $form_state['values']['date_format_medium'] = $form_state['values']['date_format_medium_custom'];
01610   }
01611   if ($form_state['values']['date_format_long'] == 'custom') {
01612     $form_state['values']['date_format_long'] = $form_state['values']['date_format_long_custom'];
01613   }
01614   return system_settings_form_submit($form, $form_state);
01615 }
01616
01620 function system_date_time_lookup() {
01621   $result = format_date(time(), 'custom', $_GET['format']);
01622   echo drupal_to_js($result);
01623   exit;
01624 }
01625
01632 function system_site_maintenance_settings() {
01633
01634   $form['site_offline'] = array(
01635     '#type' => 'radios',
01636     '#title' => t('Site status'),
01637     '#default_value' => variable_get('site_offline', 0),
01638     '#options' => array(t('Online'), t('Off-line')),
01639     '#description' => t('When set to "Online", all visitors will be able to browse your site normally. When set to "Off-line", only users with the "administer site configuration" permission will be able to access your site to perform maintenance; all other visitors will see the site off-line message configured below. Authorized users can log in during "Off-line" mode directly via the <a href="@user-login">user login</a> page.', array('@user-login' => url('user'))),
01640   );
01641
01642   $form['site_offline_message'] = array(
01643     '#type' => 'textarea',
01644     '#title' => t('Site off-line message'),
01645     '#default_value' => variable_get('site_offline_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))),
01646     '#description' => t('Message to show visitors when the site is in off-line mode.')
01647   );
01648
01649   return system_settings_form($form);
01650 }
01651
01658 function system_clean_url_settings() {
01659   $form['clean_url'] = array(
01660     '#type' => 'radios',
01661     '#title' => t('Clean URLs'),
01662     '#default_value' => variable_get('clean_url', 0),
01663     '#options' => array(t('Disabled'), t('Enabled')),
01664     '#description' => t('This option makes Drupal emit "clean" URLs (i.e. without <code>?q=</code> in the URL).'),
01665   );
01666
01667   if (!variable_get('clean_url', 0)) {
01668     if (strpos(request_uri(), '?q=') !== FALSE) {
01669       drupal_add_js(drupal_get_path('module', 'system') .'/system.js', 'module');
01670
01671       $form['clean_url']['#description'] .= ' <span>'. t('Before enabling clean URLs, you must perform a test to determine if your server is properly configured. If you are able to see this page again after clicking the "Run the clean URL test" link, the test has succeeded and the radio buttons above will be available. If instead you are directed to a "Page not found" error, you will need to change the configuration of your server. The <a href="@handbook">handbook page on Clean URLs</a> has additional troubleshooting information.', array('@handbook' => 'http://drupal.org/node/15365')) .'</span>';
01672
01673       $form['clean_url']['#disabled'] = TRUE;
01674       $form['clean_url']['#prefix'] = '<div id="clean-url">';
01675       $form['clean_url']['#suffix'] = '<p>'. t('<a href="@clean_url">Run the clean url test</a>.', array('@clean_url' => base_path() .'admin/settings/clean-urls')) .'</p></div>';
01676     }
01677     else {
01678       $form['clean_url']['#description'] .= ' <div class="ok">'. t('Your server has been successfully tested to support this feature.') .'</div>';
01679     }
01680   }
01681
01682   return system_settings_form($form);
01683 }
01684
01691 function system_status($check = FALSE) {
01692   // Load .install files
01693   include_once './includes/install.inc';
01694   drupal_load_updates();
01695
01696   // Check run-time requirements and status information.
01697   $requirements = module_invoke_all('requirements', 'runtime');
01698   usort($requirements, '_system_sort_requirements');
01699
01700   if ($check) {
01701     return drupal_requirements_severity($requirements) == REQUIREMENT_ERROR;
01702   }
01703   // MySQL import might have set the uid of the anonymous user to autoincrement
01704   // value. Let's try fixing it. See http://drupal.org/node/204411
01705   db_query("UPDATE {users} SET uid = uid - uid WHERE name = '' AND pass = '' AND status = 0");
01706
01707   return theme('status_report', $requirements);
01708 }
01709
01713 function system_run_cron() {
01714   // Run cron manually
01715   if (drupal_cron_run()) {
01716     drupal_set_message(t('Cron ran successfully.'));
01717   }
01718   else {
01719     drupal_set_message(t('Cron run failed.'), 'error');
01720   }
01721
01722   drupal_goto('admin/reports/status');
01723 }
01724
01728 function system_php() {
01729   phpinfo(INFO_GENERAL | INFO_CONFIGURATION);
01730   exit();
01731 }
01732
01743 function _system_sql($data, $keys) {
01744   $rows = array();
01745   foreach ($keys as $key => $explanation) {
01746     if (isset($data[$key])) {
01747       $rows[] = array(check_plain($key), check_plain($data[$key]), $explanation);
01748     }
01749   }
01750
01751   return theme('table', array(t('Variable'), t('Value'), t('Description')), $rows);
01752 }
01753
01757 function system_sql() {
01758
01759   $result = db_query("SHOW STATUS");
01760   while ($entry = db_fetch_object($result)) {
01761     // 'SHOW STATUS' returns fields named 'Variable_name' and 'Value',
01762     // case is important.
01763     $data[$entry->Variable_name] = $entry->Value;
01764   }
01765
01766   $output  = '<h2>'. t('Command counters') .'</h2>';
01767   $output .= _system_sql($data, array(
01768    'Com_select' => t('The number of <code>SELECT</code>-statements.'),
01769    'Com_insert' => t('The number of <code>INSERT</code>-statements.'),
01770    'Com_update' => t('The number of <code>UPDATE</code>-statements.'),
01771    'Com_delete' => t('The number of <code>DELETE</code>-statements.'),
01772    'Com_lock_tables' => t('The number of table locks.'),
01773    'Com_unlock_tables' => t('The number of table unlocks.')
01774   ));
01775
01776   $output .= '<h2>'. t('Query performance') .'</h2>';
01777   $output .= _system_sql($data, array(
01778    'Select_full_join' => t('The number of joins without an index; should be zero.'),
01779    'Select_range_check' => t('The number of joins without keys that check for key usage after each row; should be zero.'),
01780    'Sort_scan' => t('The number of sorts done without using an index; should be zero.'),
01781    'Table_locks_immediate' => t('The number of times a lock could be acquired immediately.'),
01782    'Table_locks_waited' => t('The number of times the server had to wait for a lock.')
01783   ));
01784
01785   $output .= '<h2>'. t('Query cache information') .'</h2>';
01786   $output .= '<p>'. t('The MySQL query cache can improve performance of your site by storing the result of queries. Then, if an identical query is received later, the MySQL server retrieves the result from the query cache rather than parsing and executing the statement again.') .'</p>';
01787   $output .= _system_sql($data, array(
01788    'Qcache_queries_in_cache' => t('The number of queries in the query cache.'),
01789    'Qcache_hits' => t('The number of times MySQL found previous results in the cache.'),
01790    'Qcache_inserts' => t('The number of times MySQL added a query to the cache (misses).'),
01791    'Qcache_lowmem_prunes' => t('The number of times MySQL had to remove queries from the cache because it ran out of memory. Ideally should be zero.')
01792   ));
01793
01794   return $output;
01795 }
01796
01800 function system_batch_page() {
01801   require_once './includes/batch.inc';
01802   $output = _batch_page();
01803   if ($output === FALSE) {
01804     drupal_access_denied();
01805   }
01806   elseif (isset($output)) {
01807     // Force a page without blocks or messages to
01808     // display a list of collected messages later.
01809     print theme('page', $output, FALSE, FALSE);
01810   }
01811 }
01812
01821 function theme_admin_block($block) {
01822   // Don't display the block if it has no content to display.
01823   if (empty($block['content'])) {
01824     return '';
01825   }
01826
01827   $output = <<< EOT
01828   <div class="admin-panel">
01829     <h3>
01830       $block[title]
01831     </h3>
01832     <div class="body">
01833       <p class="description">
01834         $block[description]
01835       </p>
01836       $block[content]
01837     </div>
01838   </div>
01839 EOT;
01840   return $output;
01841 }
01842
01851 function theme_admin_block_content($content) {
01852   if (!$content) {
01853     return '';
01854   }
01855
01856   if (system_admin_compact_mode()) {
01857     $output = '<ul class="menu">';
01858     foreach ($content as $item) {
01859       $output .= '<li class="leaf">'. l($item['title'], $item['href'], $item['localized_options']) .'</li>';
01860     }
01861     $output .= '</ul>';
01862   }
01863   else {
01864     $output = '<dl class="admin-list">';
01865     foreach ($content as $item) {
01866       $output .= '<dt>'. l($item['title'], $item['href'], $item['localized_options']) .'</dt>';
01867       $output .= '<dd>'. $item['description'] .'</dd>';
01868     }
01869     $output .= '</dl>';
01870   }
01871   return $output;
01872 }
01873
01884 function theme_admin_page($blocks) {
01885   $stripe = 0;
01886   $container = array();
01887
01888   foreach ($blocks as $block) {
01889     if ($block_output = theme('admin_block', $block)) {
01890       if (empty($block['position'])) {
01891         // perform automatic striping.
01892         $block['position'] = ++$stripe % 2 ? 'left' : 'right';
01893       }
01894       if (!isset($container[$block['position']])) {
01895         $container[$block['position']] = '';
01896       }
01897       $container[$block['position']] .= $block_output;
01898     }
01899   }
01900
01901   $output = '<div class="admin clear-block">';
01902   $output .= '<div class="compact-link">';
01903   if (system_admin_compact_mode()) {
01904     $output .= l(t('Show descriptions'), 'admin/compact/off', array('title' => t('Expand layout to include descriptions.')));
01905   }
01906   else {
01907     $output .= l(t('Hide descriptions'), 'admin/compact/on', array('title' => t('Compress layout by hiding descriptions.')));
01908   }
01909   $output .= '</div>';
01910
01911   foreach ($container as $id => $data) {
01912     $output .= '<div class="'. $id .' clear-block">';
01913     $output .= $data;
01914     $output .= '</div>';
01915   }
01916   $output .= '</div>';
01917   return $output;
01918 }
01919
01927 function theme_system_admin_by_module($menu_items) {
01928   $stripe = 0;
01929   $output = '';
01930   $container = array('left' => '', 'right' => '');
01931   $flip = array('left' => 'right', 'right' => 'left');
01932   $position = 'left';
01933
01934   // Iterate over all modules
01935   foreach ($menu_items as $module => $block) {
01936     list($description, $items) = $block;
01937
01938     // Output links
01939     if (count($items)) {
01940       $block = array();
01941       $block['title'] = $module;
01942       $block['content'] = theme('item_list', $items);
01943       $block['description'] = t($description);
01944
01945       if ($block_output = theme('admin_block', $block)) {
01946         if (!isset($block['position'])) {
01947           // Perform automatic striping.
01948           $block['position'] = $position;
01949           $position = $flip[$position];
01950         }
01951         $container[$block['position']] .= $block_output;
01952       }
01953     }
01954   }
01955
01956   $output = '<div class="admin clear-block">';
01957   foreach ($container as $id => $data) {
01958     $output .= '<div class="'. $id .' clear-block">';
01959     $output .= $data;
01960     $output .= '</div>';
01961   }
01962   $output .= '</div>';
01963
01964   return $output;
01965 }
01966
01974 function theme_status_report(&$requirements) {
01975   $i = 0;
01976   $output = '<table class="system-status-report">';
01977   foreach ($requirements as $requirement) {
01978     if (empty($requirement['#type'])) {
01979       $class = ++$i % 2 == 0 ? 'even' : 'odd';
01980
01981       $classes = array(
01982         REQUIREMENT_INFO => 'info',
01983         REQUIREMENT_OK => 'ok',
01984         REQUIREMENT_WARNING => 'warning',
01985         REQUIREMENT_ERROR => 'error',
01986       );
01987       $class = $classes[isset($requirement['severity']) ? (int)$requirement['severity'] : 0] .' '. $class;
01988
01989       // Output table row(s)
01990       if (!empty($requirement['description'])) {
01991         $output .= '<tr class="'. $class .' merge-down"><th>'. $requirement['title'] .'</th><td>'. $requirement['value'] .'</td></tr>';
01992         $output .= '<tr class="'. $class .' merge-up"><td colspan="2">'. $requirement['description'] .'</td></tr>';
01993       }
01994       else {
01995         $output .= '<tr class="'. $class .'"><th>'. $requirement['title'] .'</th><td>'. $requirement['value'] .'</td></tr>';
01996       }
01997     }
01998   }
01999
02000   $output .= '</table>';
02001   return $output;
02002 }
02003
02011 function theme_system_modules($form) {
02012   if (isset($form['confirm'])) {
02013     return drupal_render($form);
02014   }
02015
02016   // Individual table headers.
02017   $header = array();
02018   $header[] = array('data' => t('Enabled'), 'class' => 'checkbox');
02019   if (module_exists('throttle')) {
02020     $header[] = array('data' => t('Throttle'), 'class' => 'checkbox');
02021   }
02022   $header[] = t('Name');
02023   $header[] = t('Version');
02024   $header[] = t('Description');
02025
02026   // Pull package information from module list and start grouping modules.
02027   $modules = $form['validation_modules']['#value'];
02028   foreach ($modules as $module) {
02029     if (!isset($module->info['package']) || !$module->info['package']) {
02030       $module->info['package'] = t('Other');
02031     }
02032     $packages[$module->info['package']][$module->name] = $module->info;
02033   }
02034   ksort($packages);
02035
02036   // Display packages.
02037   $output = '';
02038   foreach ($packages as $package => $modules) {
02039     $rows = array();
02040     foreach ($modules as $key => $module) {
02041       $row = array();
02042       $description = drupal_render($form['description'][$key]);
02043       if (isset($form['status']['#incompatible_modules_core'][$key])) {
02044         unset($form['status'][$key]);
02045         $status = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of Drupal core'));
02046         $description .= '<div class="incompatible">'. t('This version is incompatible with the !core_version version of Drupal core.', array('!core_version' => VERSION)) .'</div>';
02047       }
02048       elseif (isset($form['status']['#incompatible_modules_php'][$key])) {
02049         unset($form['status'][$key]);
02050         $status = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of PHP'));
02051         $php_required = $form['status']['#incompatible_modules_php'][$key];
02052         if (substr_count($php_required, '.') < 2) {
02053           $php_required .= '.*';
02054         }
02055         $description .= '<div class="incompatible">'. t('This module requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $php_required, '!php_version' => phpversion())) .'</div>';
02056       }
02057       else {
02058         $status = drupal_render($form['status'][$key]);
02059       }
02060       $row[] = array('data' => $status, 'class' => 'checkbox');
02061       if (module_exists('throttle')) {
02062         $row[] = array('data' => drupal_render($form['throttle'][$key]), 'class' => 'checkbox');
02063       }
02064
02065       // Add labels only when there is also a checkbox.
02066       if (isset($form['status'][$key])) {
02067         $row[] = '<strong><label for="'. $form['status'][$key]['#id'] .'">'. drupal_render($form['name'][$key]) .'</label></strong>';
02068       }
02069       else {
02070         $row[] = '<strong>'. drupal_render($form['name'][$key]) .'</strong>';
02071       }
02072
02073       $row[] = drupal_render($form['version'][$key]);
02074       $row[] = array('data' => $description, 'class' => 'description');
02075       $rows[] = $row;
02076     }
02077     $fieldset = array(
02078       '#title' => t($package),
02079       '#collapsible' => TRUE,
02080       '#collapsed' => ($package == 'Core - required'),
02081       '#value' => theme('table', $header, $rows, array('class' => 'package')),
02082     );
02083     $output .= theme('fieldset', $fieldset);
02084   }
02085
02086   $output .= drupal_render($form);
02087   return $output;
02088 }
02089
02099 function theme_system_modules_uninstall($form) {
02100   // No theming for the confirm form.
02101   if (isset($form['confirm'])) {
02102     return drupal_render($form);
02103   }
02104
02105   // Table headers.
02106   $header = array(t('Uninstall'),
02107     t('Name'),
02108     t('Description'),
02109   );
02110
02111   // Display table.
02112   $rows = array();
02113   foreach (element_children($form['modules']) as $module) {
02114     $rows[] = array(
02115       array('data' => drupal_render($form['uninstall'][$module]), 'align' => 'center'),
02116       '<strong>'. drupal_render($form['modules'][$module]['name']) .'</strong>',
02117       array('data' => drupal_render($form['modules'][$module]['description']), 'class' => 'description'),
02118     );
02119   }
02120
02121   // Only display table if there are modules that can be uninstalled.
02122   if (empty($rows)) {
02123     $rows[] = array(array('data' => t('No modules are available to uninstall.'), 'colspan' => '3', 'align' => 'center', 'class' => 'message'));
02124   }
02125
02126   $output  = theme('table', $header, $rows);
02127   $output .= drupal_render($form);
02128
02129   return $output;
02130 }
02131
02138 function theme_system_theme_select_form($form) {
02139   foreach (element_children($form) as $key) {
02140     $row = array();
02141     if (isset($form[$key]['description']) && is_array($form[$key]['description'])) {
02142       $row[] = drupal_render($form[$key]['screenshot']);
02143       $row[] = drupal_render($form[$key]['description']);
02144       $row[] = drupal_render($form['theme'][$key]);
02145     }
02146     $rows[] = $row;
02147   }
02148
02149   $header = array(t('Screenshot'), t('Name'), t('Selected'));
02150   $output = theme('table', $header, $rows);
02151   return $output;
02152 }
02153
02161 function theme_system_themes_form($form) {
02162   foreach (element_children($form) as $key) {
02163     // Only look for themes
02164     if (!isset($form[$key]['info'])) {
02165       continue;
02166     }
02167
02168     // Fetch info
02169     $info = $form[$key]['info']['#value'];
02170     // Localize theme description.
02171     $description = t($info['description']);
02172     // Make sure it is compatible and render the checkbox if so.
02173     if (isset($form['status']['#incompatible_themes_core'][$key])) {
02174       unset($form['status'][$key]);
02175       $status = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of Drupal core'));
02176       $description .= '<div class="incompatible">'. t('This version is incompatible with the !core_version version of Drupal core.', array('!core_version' => VERSION)) .'</div>';
02177     }
02178     elseif (isset($form['status']['#incompatible_themes_php'][$key])) {
02179       unset($form['status'][$key]);
02180       $status = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of PHP'));
02181       $php_required = $form['status']['#incompatible_themes_php'][$key];
02182       if (substr_count($php_required, '.') < 2) {
02183         $php_required .= '.*';
02184       }
02185       $description .= '<div class="incompatible">'. t('This theme requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $php_required, '!php_version' => phpversion())) .'</div>';
02186     }
02187     else {
02188       $status = drupal_render($form['status'][$key]);
02189     }
02190
02191     // Style theme info
02192     $theme = '<div class="theme-info"><h2>'. $info['name'] .'</h2><div class="description">'. $description .'</div></div>';
02193
02194     // Build rows
02195     $row = array();
02196     $row[] = drupal_render($form[$key]['screenshot']);
02197     $row[] = $theme;
02198     $row[] = isset($info['version']) ? $info['version'] : '';
02199     $row[] = array('data' => $status, 'align' => 'center');
02200     if ($form['theme_default']) {
02201       $row[] = array('data' => drupal_render($form['theme_default'][$key]), 'align' => 'center');
02202       $row[] = array('data' => drupal_render($form[$key]['operations']), 'align' => 'center');
02203     }
02204     $rows[] = $row;
02205   }
02206
02207   $header = array(t('Screenshot'), t('Name'), t('Version'), t('Enabled'), t('Default'), t('Operations'));
02208   $output = theme('table', $header, $rows);
02209   $output .= drupal_render($form);
02210   return $output;
02211 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/system/system.install Source File

modules » system

system.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: system.install,v 1.238.2.1 2008/02/08 17:07:55 goba Exp $
00003
00012 function system_requirements($phase) {
00013   $requirements = array();
00014   // Ensure translations don't break at install time
00015   $t = get_t();
00016
00017   // Report Drupal version
00018   if ($phase == 'runtime') {
00019     $requirements['drupal'] = array(
00020       'title' => $t('Drupal'),
00021       'value' => VERSION,
00022       'severity' => REQUIREMENT_INFO,
00023       'weight' => -10,
00024     );
00025   }
00026
00027   // Web server information.
00028   $software = $_SERVER['SERVER_SOFTWARE'];
00029   $requirements['webserver'] = array(
00030     'title' => $t('Web server'),
00031     'value' => $software,
00032   );
00033
00034   // Test PHP version
00035   $requirements['php'] = array(
00036     'title' => $t('PHP'),
00037     'value' => ($phase == 'runtime') ? l(phpversion(), 'admin/reports/status/php') : phpversion(),
00038   );
00039   if (version_compare(phpversion(), DRUPAL_MINIMUM_PHP) < 0) {
00040     $requirements['php']['description'] = $t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => DRUPAL_MINIMUM_PHP));
00041     $requirements['php']['severity'] = REQUIREMENT_ERROR;
00042   }
00043
00044   // Test PHP register_globals setting.
00045   $requirements['php_register_globals'] = array(
00046     'title' => $t('PHP register globals'),
00047   );
00048   $register_globals = trim(ini_get('register_globals'));
00049   // Unfortunately, ini_get() may return many different values, and we can't
00050   // be certain which values mean 'on', so we instead check for 'not off'
00051   // since we never want to tell the user that their site is secure
00052   // (register_globals off), when it is in fact on. We can only guarantee
00053   // register_globals is off if the value returned is 'off', '', or 0.
00054   if (!empty($register_globals) && strtolower($register_globals) != 'off') {
00055     $requirements['php_register_globals']['description'] = $t('<em>register_globals</em> is enabled. Drupal requires this configuration directive to be disabled. Your site may not be secure when <em>register_globals</em> is enabled. The PHP manual has instructions for <a href="http://php.net/configuration.changes">how to change configuration settings</a>.');
00056     $requirements['php_register_globals']['severity'] = REQUIREMENT_ERROR;
00057     $requirements['php_register_globals']['value'] = $t("Enabled ('@value')", array('@value' => $register_globals));
00058   }
00059   else {
00060     $requirements['php_register_globals']['value'] = $t('Disabled');
00061   }
00062
00063   // Test PHP memory_limit
00064   $memory_limit = ini_get('memory_limit');
00065   $requirements['php_memory_limit'] = array(
00066     'title' => $t('PHP memory limit'),
00067     'value' => $memory_limit,
00068   );
00069
00070   if ($memory_limit && parse_size($memory_limit) < parse_size(DRUPAL_MINIMUM_PHP_MEMORY_LIMIT)) {
00071     $description = '';
00072     if ($phase == 'install') {
00073       $description = $t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the installation process.', array('%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT));
00074     }
00075     elseif ($phase == 'update') {
00076       $description = $t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the update process.', array('%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT));
00077     }
00078     elseif ($phase == 'runtime') {
00079       $description = $t('Depending on your configuration, Drupal can run with a %memory_limit PHP memory limit. However, a %memory_minimum_limit PHP memory limit or above is recommended, especially if your site uses additional custom or contributed modules.', array('%memory_limit' => $memory_limit, '%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT));
00080     }
00081
00082     if (!empty($description)) {
00083       if ($php_ini_path = get_cfg_var('cfg_file_path')) {
00084         $description .= ' '. $t('Increase the memory limit by editing the memory_limit parameter in the file %configuration-file and then restart your web server (or contact your system administrator or hosting provider for assistance).', array('%configuration-file' => $php_ini_path));
00085       }
00086       else {
00087         $description .= ' '. $t('Contact your system administrator or hosting provider for assistance with increasing your PHP memory limit.');
00088       }
00089
00090       $requirements['php_memory_limit']['description'] = $description .' '. $t('See the <a href="@url">Drupal requirements</a> for more information.', array('@url' => 'http://drupal.org/requirements'));
00091       $requirements['php_memory_limit']['severity'] = REQUIREMENT_WARNING;
00092     }
00093   }
00094
00095   // Test DB version
00096   global $db_type;
00097   if (function_exists('db_status_report')) {
00098     $requirements += db_status_report($phase);
00099   }
00100
00101   // Test settings.php file writability
00102   if ($phase == 'runtime') {
00103     $conf_dir = drupal_verify_install_file(conf_path(), FILE_NOT_WRITABLE, 'dir');
00104     $conf_file = drupal_verify_install_file(conf_path() .'/settings.php', FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE);
00105     if (!$conf_dir || !$conf_file) {
00106       $requirements['settings.php'] = array(
00107         'value' => $t('Not protected'),
00108         'severity' => REQUIREMENT_ERROR,
00109         'description' => '',
00110       );
00111       if (!$conf_dir) {
00112         $requirements['settings.php']['description'] .= $t('The directory %file is not protected from modifications and poses a security risk. You must change the directory\'s permissions to be non-writable. ', array('%file' => conf_path()));
00113       }
00114       if (!$conf_file) {
00115         $requirements['settings.php']['description'] .= $t('The file %file is not protected from modifications and poses a security risk. You must change the file\'s permissions to be non-writable.', array('%file' => conf_path() .'/settings.php'));
00116       }
00117     }
00118     else {
00119       $requirements['settings.php'] = array(
00120         'value' => $t('Protected'),
00121       );
00122     }
00123     $requirements['settings.php']['title'] = $t('Configuration file');
00124   }
00125
00126   // Report cron status.
00127   if ($phase == 'runtime') {
00128     // Cron warning threshold defaults to two days.
00129     $threshold_warning = variable_get('cron_threshold_warning', 172800);
00130     // Cron error threshold defaults to two weeks.
00131     $threshold_error = variable_get('cron_threshold_error', 1209600);
00132     // Cron configuration help text.
00133     $help = $t('For more information, see the online handbook entry for <a href="@cron-handbook">configuring cron jobs</a>.', array('@cron-handbook' => 'http://drupal.org/cron'));
00134
00135     // Determine when cron last ran. If never, use the install time to
00136     // determine the warning or error status.
00137     $cron_last = variable_get('cron_last', NULL);
00138     $never_run = FALSE;
00139     if (!is_numeric($cron_last)) {
00140       $never_run = TRUE;
00141       $cron_last = variable_get('install_time', 0);
00142     }
00143
00144     // Determine severity based on time since cron last ran.
00145     $severity = REQUIREMENT_OK;
00146     if (time() - $cron_last > $threshold_error) {
00147       $severity = REQUIREMENT_ERROR;
00148     }
00149     else if ($never_run || (time() - $cron_last > $threshold_warning)) {
00150       $severity = REQUIREMENT_WARNING;
00151     }
00152
00153     // If cron hasn't been run, and the user is viewing the main
00154     // administration page, instead of an error, we display a helpful reminder
00155     // to configure cron jobs.
00156     if ($never_run && $severity != REQUIREMENT_ERROR && $_GET['q'] == 'admin' && user_access('administer site configuration')) {
00157       drupal_set_message($t('Cron has not run. Please visit the <a href="@status">status report</a> for more information.', array('@status' => url('admin/reports/status'))));
00158     }
00159
00160     // Set summary and description based on values determined above.
00161     if ($never_run) {
00162       $summary = $t('Never run');
00163       $description = $t('Cron has not run.') .' '. $help;
00164     }
00165     else {
00166       $summary = $t('Last run !time ago', array('!time' => format_interval(time() - $cron_last)));
00167       $description = '';
00168       if ($severity != REQUIREMENT_OK) {
00169         $description = $t('Cron has not run recently.') .' '. $help;
00170       }
00171     }
00172
00173     $requirements['cron'] = array(
00174       'title' => $t('Cron maintenance tasks'),
00175       'severity' => $severity,
00176       'value' => $summary,
00177       'description' => $description .' '. $t('You can <a href="@cron">run cron manually</a>.', array('@cron' => url('admin/reports/status/run-cron'))),
00178     );
00179   }
00180
00181   // Test files directory
00182   $directory = file_directory_path();
00183   $requirements['file system'] = array(
00184     'title' => $t('File system'),
00185   );
00186
00187   // For installer, create the directory if possible.
00188   if ($phase == 'install' && !is_dir($directory) && @mkdir($directory)) {
00189     @chmod($directory, 0775); // Necessary for non-webserver users.
00190   }
00191
00192   $is_writable = is_writable($directory);
00193   $is_directory = is_dir($directory);
00194   if (!$is_writable || !$is_directory) {
00195     $description = '';
00196     $requirements['file system']['value'] = $t('Not writable');
00197     if (!$is_directory) {
00198       $error = $t('The directory %directory does not exist.', array('%directory' => $directory));
00199     }
00200     else {
00201       $error = $t('The directory %directory is not writable.', array('%directory' => $directory));
00202     }
00203     // The files directory requirement check is done only during install and runtime.
00204     if ($phase == 'runtime') {
00205       $description = $error .' '. $t('You may need to set the correct directory at the <a href="@admin-file-system">file system settings page</a> or change the current directory\'s permissions so that it is writable.', array('@admin-file-system' => url('admin/settings/file-system')));
00206     }
00207     elseif ($phase == 'install') {
00208       // For the installer UI, we need different wording. 'value' will
00209       // be treated as version, so provide none there.
00210       $description = $error .' '. $t('An automated attempt to create this directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually, or ensure that the installer has the permissions to create it automatically. For more information, please see INSTALL.txt or the <a href="@handbook_url">on-line handbook</a>.', array('@handbook_url' => 'http://drupal.org/server-permissions'));
00211       $requirements['file system']['value'] = '';
00212     }
00213     if (!empty($description)) {
00214       $requirements['file system']['description'] = $description;
00215       $requirements['file system']['severity'] = REQUIREMENT_ERROR;
00216     }
00217   }
00218   else {
00219     if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC) {
00220       $requirements['file system']['value'] = $t('Writable (<em>public</em> download method)');
00221     }
00222     else {
00223       $requirements['file system']['value'] = $t('Writable (<em>private</em> download method)');
00224     }
00225   }
00226
00227   // See if updates are available in update.php.
00228   if ($phase == 'runtime') {
00229     $requirements['update'] = array(
00230       'title' => $t('Database updates'),
00231       'severity' => REQUIREMENT_OK,
00232       'value' => $t('Up to date'),
00233     );
00234
00235     // Check installed modules.
00236     foreach (module_list() as $module) {
00237       $updates = drupal_get_schema_versions($module);
00238       if ($updates !== FALSE) {
00239         $default = drupal_get_installed_schema_version($module);
00240         if (max($updates) > $default) {
00241           $requirements['update']['severity'] = REQUIREMENT_ERROR;
00242           $requirements['update']['value'] = $t('Out of date');
00243           $requirements['update']['description'] = $t('Some modules have database schema updates to install. You should run the <a href="@update">database update script</a> immediately.', array('@update' => base_path() .'update.php'));
00244           break;
00245         }
00246       }
00247     }
00248   }
00249
00250   // Verify the update.php access setting
00251   if ($phase == 'runtime') {
00252     if (!empty($GLOBALS['update_free_access'])) {
00253       $requirements['update access'] = array(
00254         'value' => $t('Not protected'),
00255         'severity' => REQUIREMENT_ERROR,
00256         'description' => $t('The update.php script is accessible to everyone without authentication check, which is a security risk. You must change the $update_free_access value in your settings.php back to FALSE.'),
00257       );
00258     }
00259     else {
00260       $requirements['update access'] = array(
00261         'value' => $t('Protected'),
00262       );
00263     }
00264     $requirements['update access']['title'] = $t('Access to update.php');
00265   }
00266
00267   // Test Unicode library
00268   include_once './includes/unicode.inc';
00269   $requirements = array_merge($requirements, unicode_requirements());
00270
00271   // Check for update status module.
00272   if ($phase == 'runtime') {
00273     if (!module_exists('update')) {
00274       $requirements['update status'] = array(
00275         'value' => $t('Not enabled'),
00276         'severity' => REQUIREMENT_ERROR,
00277         'description' => $t('Update notifications are not enabled. It is <strong>highly recommended</strong> that you enable the update status module from the <a href="@module">module administration page</a> in order to stay up-to-date on new releases. For more information please read the <a href="@update">Update status handbook page</a>.', array('@update' => 'http://drupal.org/handbook/modules/update', '@module' => url('admin/build/modules'))),
00278       );
00279     }
00280     else {
00281       $requirements['update status'] = array(
00282         'value' => $t('Enabled'),
00283       );
00284       if (variable_get('drupal_http_request_fails', FALSE)) {
00285         $requirements['http requests'] = array(
00286           'title' => $t('HTTP request status'),
00287           'value' => $t('Fails'),
00288           'severity' => REQUIREMENT_ERROR,
00289           'description' => $t('Your system or network configuration does not allow Drupal to access web pages, resulting in reduced functionality. This could be due to your webserver configuration or PHP settings, and should be resolved in order to download information about available updates, fetch aggregator feeds, sign in via OpenID, or use other network-dependent services.'),
00290         );
00291       }
00292     }
00293     $requirements['update status']['title'] = $t('Update notifications');
00294   }
00295
00296   return $requirements;
00297 }
00298
00302 function system_install() {
00303   if ($GLOBALS['db_type'] == 'pgsql') {
00304     // Create unsigned types.
00305     db_query("CREATE DOMAIN int_unsigned integer CHECK (VALUE >= 0)");
00306     db_query("CREATE DOMAIN smallint_unsigned smallint CHECK (VALUE >= 0)");
00307     db_query("CREATE DOMAIN bigint_unsigned bigint CHECK (VALUE >= 0)");
00308
00309     // Create functions.
00310     db_query('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric) RETURNS numeric AS
00311       \'SELECT CASE WHEN (($1 > $2) OR ($2 IS NULL)) THEN $1 ELSE $2 END;\'
00312       LANGUAGE \'sql\''
00313     );
00314     db_query('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric, numeric) RETURNS numeric AS
00315       \'SELECT greatest($1, greatest($2, $3));\'
00316       LANGUAGE \'sql\''
00317     );
00318     if (!db_result(db_query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'rand'"))) {
00319       db_query('CREATE OR REPLACE FUNCTION "rand"() RETURNS float AS
00320         \'SELECT random();\'
00321         LANGUAGE \'sql\''
00322       );
00323     }
00324
00325     if (!db_result(db_query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'concat'"))) {
00326       db_query('CREATE OR REPLACE FUNCTION "concat"(text, text) RETURNS text AS
00327         \'SELECT $1 || $2;\'
00328         LANGUAGE \'sql\''
00329       );
00330     }
00331     db_query('CREATE OR REPLACE FUNCTION "if"(boolean, text, text) RETURNS text AS
00332       \'SELECT CASE WHEN $1 THEN $2 ELSE $3 END;\'
00333       LANGUAGE \'sql\''
00334     );
00335     db_query('CREATE OR REPLACE FUNCTION "if"(boolean, integer, integer) RETURNS integer AS
00336       \'SELECT CASE WHEN $1 THEN $2 ELSE $3 END;\'
00337       LANGUAGE \'sql\''
00338     );
00339   }
00340
00341   // Create tables.
00342   $modules = array('system', 'filter', 'block', 'user', 'node', 'comment', 'taxonomy');
00343   foreach ($modules as $module) {
00344     drupal_install_schema($module);
00345   }
00346
00347   // Load system theme data appropriately.
00348   system_theme_data();
00349
00350   // Inserting uid 0 here confuses MySQL -- the next user might be created as
00351   // uid 2 which is not what we want. So we insert the first user here, the
00352   // anonymous user. uid is 1 here for now, but very soon it will be changed
00353   // to 0.
00354   db_query("INSERT INTO {users} (name, mail) VALUES('%s', '%s')", '', '');
00355   // We need some placeholders here as name and mail are uniques and data is
00356   // presumed to be a serialized array. Install will change uid 1 immediately
00357   // anyways. So we insert the superuser here, the uid is 2 here for now, but
00358   // very soon it will be changed to 1.
00359   db_query("INSERT INTO {users} (name, mail, created, data) VALUES('%s', '%s', %d, '%s')", 'placeholder-for-uid-1', 'placeholder-for-uid-1', time(), serialize(array()));
00360   // This sets the above two users uid 0 (anonymous). We avoid an explicit 0
00361   // otherwise MySQL might insert the next auto_increment value.
00362   db_query("UPDATE {users} SET uid = uid - uid WHERE name = '%s'", '');
00363   // This sets uid 1 (superuser). We skip uid 2 but that's not a big problem.
00364   db_query("UPDATE {users} SET uid = 1 WHERE name = '%s'", 'placeholder-for-uid-1');
00365
00366   db_query("INSERT INTO {role} (name) VALUES ('%s')", 'anonymous user');
00367   db_query("INSERT INTO {role} (name) VALUES ('%s')", 'authenticated user');
00368
00369   db_query("INSERT INTO {permission} (rid, perm, tid) VALUES (%d, '%s', %d)", 1, 'access content', 0);
00370   db_query("INSERT INTO {permission} (rid, perm, tid) VALUES (%d, '%s', %d)", 2, 'access comments, access content, post comments, post comments without approval', 0);
00371
00372   db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", 'theme_default', 's:7:"garland";');
00373   db_query("UPDATE {system} SET status = %d WHERE type = '%s' AND name = '%s'", 1, 'theme', 'garland');
00374   db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', '0', 'garland', 1, 0, 'left', '', -1);
00375   db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', '1', 'garland', 1, 0, 'left', '', -1);
00376   db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', '0', 'garland', 1, 10, 'footer', '', -1);
00377
00378   db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) VALUES (%d, %d, '%s', %d, %d, %d)", 0, 0, 'all', 1, 0, 0);
00379
00380   // Add input formats.
00381   db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('%s', '%s', %d)", 'Filtered HTML', ',1,2,', 1);
00382   db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('%s', '%s', %d)", 'Full HTML', '', 1);
00383
00384   // Enable filters for each input format.
00385
00386   // Filtered HTML:
00387   // URL filter.
00388   db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 1, 'filter', 2, 0);
00389   // HTML filter.
00390   db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 1, 'filter', 0, 1);
00391   // Line break filter.
00392   db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 1, 'filter', 1, 2);
00393   // HTML corrector filter.
00394   db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 1, 'filter', 3, 10);
00395
00396   // Full HTML:
00397   // URL filter.
00398   db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 2, 'filter', 2, 0);
00399   // Line break filter.
00400   db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 2, 'filter', 1, 1);
00401   // HTML corrector filter.
00402   db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 2, 'filter', 3, 10);
00403
00404   db_query("INSERT INTO {variable} (name, value) VALUES ('%s','%s')", 'filter_html_1', 'i:1;');
00405
00406   db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", 'node_options_forum', 'a:1:{i:0;s:6:"status";}');
00407 }
00408
00412 function system_schema() {
00413   // NOTE: {variable} needs to be created before all other tables, as
00414   // some database drivers, e.g. Oracle and DB2, will require variable_get()
00415   // and variable_set() for overcoming some database specific limitations.
00416   $schema['variable'] = array(
00417     'description' => t('Named variable/value pairs created by Drupal core or any other module or theme. All variables are cached in memory at the start of every Drupal request so developers should not be careless about what is stored here.'),
00418     'fields' => array(
00419       'name' => array(
00420         'description' => t('The name of the variable.'),
00421         'type' => 'varchar',
00422         'length' => 128,
00423         'not null' => TRUE,
00424         'default' => ''),
00425       'value' => array(
00426         'description' => t('The value of the variable.'),
00427         'type' => 'text',
00428         'not null' => TRUE,
00429         'size' => 'big'),
00430       ),
00431     'primary key' => array('name'),
00432     );
00433
00434   $schema['actions'] = array(
00435     'description' => t('Stores action information.'),
00436     'fields' => array(
00437       'aid' => array(
00438         'description' => t('Primary Key: Unique actions ID.'),
00439         'type' => 'varchar',
00440         'length' => 255,
00441         'not null' => TRUE,
00442         'default' => '0'),
00443       'type' => array(
00444         'description' => t('The object that that action acts on (node, user, comment, system or custom types.)'),
00445         'type' => 'varchar',
00446         'length' => 32,
00447         'not null' => TRUE,
00448         'default' => ''),
00449       'callback' => array(
00450         'description' => t('The callback function that executes when the action runs.'),
00451         'type' => 'varchar',
00452         'length' => 255,
00453         'not null' => TRUE,
00454         'default' => ''),
00455       'parameters' => array(
00456         'description' => t('Parameters to be passed to the callback function.'),
00457         'type' => 'text',
00458         'not null' => TRUE,
00459         'size' => 'big'),
00460       'description' => array(
00461         'description' => t('Description of the action.'),
00462         'type' => 'varchar',
00463         'length' => 255,
00464         'not null' => TRUE,
00465         'default' => '0'),
00466       ),
00467     'primary key' => array('aid'),
00468     );
00469
00470   $schema['actions_aid'] = array(
00471     'description' => t('Stores action IDs for non-default actions.'),
00472     'fields' => array(
00473       'aid' => array(
00474         'description' => t('Primary Key: Unique actions ID.'),
00475         'type' => 'serial',
00476         'unsigned' => TRUE,
00477         'not null' => TRUE),
00478       ),
00479     'primary key' => array('aid'),
00480     );
00481
00482   $schema['batch'] = array(
00483     'description' => t('Stores details about batches (processes that run in multiple HTTP requests).'),
00484     'fields' => array(
00485       'bid' => array(
00486         'description' => t('Primary Key: Unique batch ID.'),
00487         'type' => 'serial',
00488         'unsigned' => TRUE,
00489         'not null' => TRUE),
00490       'token' => array(
00491         'description' => t("A string token generated against the current user's session id and the batch id, used to ensure that only the user who submitted the batch can effectively access it."),
00492         'type' => 'varchar',
00493         'length' => 64,
00494         'not null' => TRUE),
00495       'timestamp' => array(
00496         'description' => t('A Unix timestamp indicating when this batch was submitted for processing. Stale batches are purged at cron time.'),
00497         'type' => 'int',
00498         'not null' => TRUE),
00499       'batch' => array(
00500         'description' => t('A serialized array containing the processing data for the batch.'),
00501         'type' => 'text',
00502         'not null' => FALSE,
00503         'size' => 'big')
00504       ),
00505     'primary key' => array('bid'),
00506     'indexes' => array('token' => array('token')),
00507     );
00508
00509   $schema['cache'] = array(
00510     'description' => t('Generic cache table for caching things not separated out into their own tables. Contributed modules may also use this to store cached items.'),
00511     'fields' => array(
00512       'cid' => array(
00513         'description' => t('Primary Key: Unique cache ID.'),
00514         'type' => 'varchar',
00515         'length' => 255,
00516         'not null' => TRUE,
00517         'default' => ''),
00518       'data' => array(
00519         'description' => t('A collection of data to cache.'),
00520         'type' => 'blob',
00521         'not null' => FALSE,
00522         'size' => 'big'),
00523       'expire' => array(
00524         'description' => t('A Unix timestamp indicating when the cache entry should expire, or 0 for never.'),
00525         'type' => 'int',
00526         'not null' => TRUE,
00527         'default' => 0),
00528       'created' => array(
00529         'description' => t('A Unix timestamp indicating when the cache entry was created.'),
00530         'type' => 'int',
00531         'not null' => TRUE,
00532         'default' => 0),
00533       'headers' => array(
00534         'description' => t('Any custom HTTP headers to be added to cached data.'),
00535         'type' => 'text',
00536         'not null' => FALSE),
00537       'serialized' => array(
00538         'description' => t('A flag to indicate whether content is serialized (1) or not (0).'),
00539         'type' => 'int',
00540         'size' => 'small',
00541         'not null' => TRUE,
00542         'default' => 0)
00543       ),
00544     'indexes' => array('expire' => array('expire')),
00545     'primary key' => array('cid'),
00546     );
00547
00548   $schema['cache_form'] = $schema['cache'];
00549   $schema['cache_form']['description'] = t('Cache table for the form system to store recently built forms and their storage data, to be used in subsequent page requests.');
00550   $schema['cache_page'] = $schema['cache'];
00551   $schema['cache_page']['description'] = t('Cache table used to store compressed pages for anonymous users, if page caching is enabled.');
00552   $schema['cache_menu'] = $schema['cache'];
00553   $schema['cache_menu']['description'] = t('Cache table for the menu system to store router information as well as generated link trees for various menu/page/user combinations.');
00554
00555   $schema['files'] = array(
00556     'description' => t('Stores information for uploaded files.'),
00557     'fields' => array(
00558       'fid' => array(
00559         'description' => t('Primary Key: Unique files ID.'),
00560         'type' => 'serial',
00561         'unsigned' => TRUE,
00562         'not null' => TRUE),
00563       'uid' => array(
00564         'description' => t('The {users}.uid of the user who is associated with the file.'),
00565         'type' => 'int',
00566         'unsigned' => TRUE,
00567         'not null' => TRUE,
00568         'default' => 0),
00569       'filename' => array(
00570         'description' => t('Name of the file.'),
00571         'type' => 'varchar',
00572         'length' => 255,
00573         'not null' => TRUE,
00574         'default' => ''),
00575       'filepath' => array(
00576         'description' => t('Path of the file relative to Drupal root.'),
00577         'type' => 'varchar',
00578         'length' => 255,
00579         'not null' => TRUE,
00580         'default' => ''),
00581       'filemime' => array(
00582         'description' => t('The file MIME type.'),
00583         'type' => 'varchar',
00584         'length' => 255,
00585         'not null' => TRUE,
00586         'default' => ''),
00587       'filesize' => array(
00588         'description' => t('The size of the file in bytes.'),
00589         'type' => 'int',
00590         'unsigned' => TRUE,
00591         'not null' => TRUE,
00592         'default' => 0),
00593       'status' => array(
00594         'description' => t('A flag indicating whether file is temporary (1) or permanent (0).'),
00595         'type' => 'int',
00596         'not null' => TRUE,
00597         'default' => 0),
00598       'timestamp' => array(
00599         'description' => t('UNIX timestamp for when the file was added.'),
00600         'type' => 'int',
00601         'unsigned' => TRUE,
00602         'not null' => TRUE,
00603         'default' => 0),
00604       ),
00605     'indexes' => array(
00606       'uid' => array('uid'),
00607       'status' => array('status'),
00608       'timestamp' => array('timestamp'),
00609       ),
00610     'primary key' => array('fid'),
00611     );
00612
00613   $schema['flood'] = array(
00614     'description' => t('Flood controls the threshold of events, such as the number of contact attempts.'),
00615     'fields' => array(
00616       'fid' => array(
00617         'description' => t('Unique flood event ID.'),
00618         'type' => 'serial',
00619         'not null' => TRUE),
00620       'event' => array(
00621         'description' => t('Name of event (e.g. contact).'),
00622         'type' => 'varchar',
00623         'length' => 64,
00624         'not null' => TRUE,
00625         'default' => ''),
00626       'hostname' => array(
00627         'description' => t('Hostname of the visitor.'),
00628         'type' => 'varchar',
00629         'length' => 128,
00630         'not null' => TRUE,
00631         'default' => ''),
00632       'timestamp' => array(
00633         'description' => t('Timestamp of the event.'),
00634         'type' => 'int',
00635         'not null' => TRUE,
00636         'default' => 0)
00637       ),
00638     'primary key' => array('fid'),
00639     'indexes' => array(
00640       'allow' => array('event', 'hostname', 'timestamp'),
00641     ),
00642     );
00643
00644   $schema['history'] = array(
00645     'description' => t('A record of which {users} have read which {node}s.'),
00646     'fields' => array(
00647       'uid' => array(
00648         'description' => t('The {users}.uid that read the {node} nid.'),
00649         'type' => 'int',
00650         'not null' => TRUE,
00651         'default' => 0),
00652       'nid' => array(
00653         'description' => t('The {node}.nid that was read.'),
00654         'type' => 'int',
00655         'not null' => TRUE,
00656         'default' => 0),
00657       'timestamp' => array(
00658         'description' => t('The Unix timestamp at which the read occurred.'),
00659         'type' => 'int',
00660         'not null' => TRUE,
00661         'default' => 0)
00662       ),
00663     'primary key' => array('uid', 'nid'),
00664     'indexes' => array(
00665       'nid' => array('nid'),
00666     ),
00667     );
00668   $schema['menu_router'] = array(
00669     'description' => t('Maps paths to various callbacks (access, page and title)'),
00670     'fields' => array(
00671       'path' => array(
00672         'description' => t('Primary Key: the Drupal path this entry describes'),
00673         'type' => 'varchar',
00674         'length' => 255,
00675         'not null' => TRUE,
00676         'default' => ''),
00677       'load_functions' => array(
00678         'description' => t('A serialized array of function names (like node_load) to be called to load an object corresponding to a part of the current path.'),
00679         'type' => 'varchar',
00680         'length' => 255,
00681         'not null' => TRUE,
00682         'default' => ''),
00683       'to_arg_functions' => array(
00684         'description' => t('A serialized array of function names (like user_current_to_arg) to be called to replace a part of the router path with another string.'),
00685         'type' => 'varchar',
00686         'length' => 255,
00687         'not null' => TRUE,
00688         'default' => ''),
00689       'access_callback' => array(
00690         'description' => t('The callback which determines the access to this router path. Defaults to user_access.'),
00691         'type' => 'varchar',
00692         'length' => 255,
00693         'not null' => TRUE,
00694         'default' => ''),
00695       'access_arguments' => array(
00696         'description' => t('A serialized array of arguments for the access callback.'),
00697         'type' => 'text',
00698         'not null' => FALSE),
00699       'page_callback' => array(
00700         'description' => t('The name of the function that renders the page.'),
00701         'type' => 'varchar',
00702         'length' => 255,
00703         'not null' => TRUE,
00704         'default' => ''),
00705       'page_arguments' => array(
00706         'description' => t('A serialized array of arguments for the page callback.'),
00707         'type' => 'text',
00708         'not null' => FALSE),
00709       'fit' => array(
00710         'description' => t('A numeric representation of how specific the path is.'),
00711         'type' => 'int',
00712         'not null' => TRUE,
00713         'default' => 0),
00714       'number_parts' => array(
00715         'description' => t('Number of parts in this router path.'),
00716         'type' => 'int',
00717         'not null' => TRUE,
00718         'default' => 0,
00719         'size' => 'small'),
00720       'tab_parent' => array(
00721         'description' => t('Only for local tasks (tabs) - the router path of the parent page (which may also be a local task).'),
00722         'type' => 'varchar',
00723         'length' => 255,
00724         'not null' => TRUE,
00725         'default' => ''),
00726       'tab_root' => array(
00727         'description' => t('Router path of the closest non-tab parent page. For pages that are not local tasks, this will be the same as the path.'),
00728         'type' => 'varchar',
00729         'length' => 255,
00730         'not null' => TRUE,
00731         'default' => ''),
00732       'title' => array(
00733         'description' => t('The title for the current page, or the title for the tab if this is a local task.'),
00734         'type' => 'varchar',
00735         'length' => 255,
00736         'not null' => TRUE,
00737         'default' => ''),
00738       'title_callback' => array(
00739         'description' => t('A function which will alter the title. Defaults to t()'),
00740         'type' => 'varchar',
00741         'length' => 255,
00742         'not null' => TRUE,
00743         'default' => ''),
00744       'title_arguments' => array(
00745         'description' => t('A serialized array of arguments for the title callback. If empty, the title will be used as the sole argument for the title callback.'),
00746         'type' => 'varchar',
00747         'length' => 255,
00748         'not null' => TRUE,
00749         'default' => ''),
00750       'type' => array(
00751         'description' => t('Numeric representation of the type of the menu item, like MENU_LOCAL_TASK.'),
00752         'type' => 'int',
00753         'not null' => TRUE,
00754         'default' => 0),
00755       'block_callback' => array(
00756         'description' => t('Name of a function used to render the block on the system administration page for this item.'),
00757         'type' => 'varchar',
00758         'length' => 255,
00759         'not null' => TRUE,
00760         'default' => ''),
00761       'description' => array(
00762         'description' => t('A description of this item.'),
00763         'type' => 'text',
00764         'not null' => TRUE),
00765       'position' => array(
00766         'description' => t('The position of the block (left or right) on the system administration page for this item.'),
00767         'type' => 'varchar',
00768         'length' => 255,
00769         'not null' => TRUE,
00770         'default' => ''),
00771       'weight' => array(
00772         'description' => t('Weight of the element. Lighter weights are higher up, heavier weights go down.'),
00773         'type' => 'int',
00774         'not null' => TRUE,
00775         'default' => 0),
00776       'file' => array(
00777         'description' => t('The file to include for this element, usually the page callback function lives in this file.'),
00778         'type' => 'text',
00779         'size' => 'medium')
00780       ),
00781     'indexes' => array(
00782       'fit' => array('fit'),
00783       'tab_parent' => array('tab_parent')
00784       ),
00785     'primary key' => array('path'),
00786     );
00787
00788   $schema['menu_links'] = array(
00789     'description' => t('Contains the individual links within a menu.'),
00790     'fields' => array(
00791      'menu_name' => array(
00792         'description' => t("The menu name. All links with the same menu name (such as 'navigation') are part of the same menu."),
00793         'type' => 'varchar',
00794         'length' => 32,
00795         'not null' => TRUE,
00796         'default' => ''),
00797       'mlid' => array(
00798         'description' => t('The menu link ID (mlid) is the integer primary key.'),
00799         'type' => 'serial',
00800         'unsigned' => TRUE,
00801         'not null' => TRUE),
00802       'plid' => array(
00803         'description' => t('The parent link ID (plid) is the mlid of the link above in the hierarchy, or zero if the link is at the top level in its menu.'),
00804         'type' => 'int',
00805         'unsigned' => TRUE,
00806         'not null' => TRUE,
00807         'default' => 0),
00808       'link_path' => array(
00809         'description' => t('The Drupal path or external path this link points to.'),
00810         'type' => 'varchar',
00811         'length' => 255,
00812         'not null' => TRUE,
00813         'default' => ''),
00814       'router_path' => array(
00815         'description' => t('For links corresponding to a Drupal path (external = 0), this connects the link to a {menu_router}.path for joins.'),
00816         'type' => 'varchar',
00817         'length' => 255,
00818         'not null' => TRUE,
00819         'default' => ''),
00820       'link_title' => array(
00821       'description' => t('The text displayed for the link, which may be modified by a title callback stored in {menu_router}.'),
00822         'type' => 'varchar',
00823         'length' => 255,
00824         'not null' => TRUE,
00825         'default' => ''),
00826       'options' => array(
00827         'description' => t('A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.'),
00828         'type' => 'text',
00829         'not null' => FALSE),
00830       'module' => array(
00831         'description' => t('The name of the module that generated this link.'),
00832         'type' => 'varchar',
00833         'length' => 255,
00834         'not null' => TRUE,
00835         'default' => 'system'),
00836       'hidden' => array(
00837         'description' => t('A flag for whether the link should be rendered in menus. (1 = a disabled menu item that may be shown on admin screens, -1 = a menu callback, 0 = a normal, visible link)'),
00838         'type' => 'int',
00839         'not null' => TRUE,
00840         'default' => 0,
00841         'size' => 'small'),
00842       'external' => array(
00843         'description' => t('A flag to indicate if the link points to a full URL starting with a protocol, like http:// (1 = external, 0 = internal).'),
00844         'type' => 'int',
00845         'not null' => TRUE,
00846         'default' => 0,
00847         'size' => 'small'),
00848       'has_children' => array(
00849         'description' => t('Flag indicating whether any links have this link as a parent (1 = children exist, 0 = no children).'),
00850         'type' => 'int',
00851         'not null' => TRUE,
00852         'default' => 0,
00853         'size' => 'small'),
00854       'expanded' => array(
00855         'description' => t('Flag for whether this link should be rendered as expanded in menus - expanded links always have their child links displayed, instead of only when the link is in the active trail (1 = expanded, 0 = not expanded)'),
00856         'type' => 'int',
00857         'not null' => TRUE,
00858         'default' => 0,
00859         'size' => 'small'),
00860       'weight' => array(
00861         'description' => t('Link weight among links in the same menu at the same depth.'),
00862         'type' => 'int',
00863         'not null' => TRUE,
00864         'default' => 0),
00865       'depth' => array(
00866         'description' => t('The depth relative to the top level. A link with plid == 0 will have depth == 1.'),
00867         'type' => 'int',
00868         'not null' => TRUE,
00869         'default' => 0,
00870         'size' => 'small'),
00871       'customized' => array(
00872         'description' => t('A flag to indicate that the user has manually created or edited the link (1 = customized, 0 = not customized).'),
00873         'type' => 'int',
00874         'not null' => TRUE,
00875         'default' => 0,
00876         'size' => 'small'),
00877       'p1' => array(
00878         'description' => t('The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the plid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.'),
00879         'type' => 'int',
00880         'unsigned' => TRUE,
00881         'not null' => TRUE,
00882         'default' => 0),
00883       'p2' => array(
00884         'description' => t('The second mlid in the materialized path. See p1.'),
00885         'type' => 'int',
00886         'unsigned' => TRUE,
00887         'not null' => TRUE,
00888         'default' => 0),
00889       'p3' => array(
00890         'description' => t('The third mlid in the materialized path. See p1.'),
00891         'type' => 'int',
00892         'unsigned' => TRUE,
00893         'not null' => TRUE,
00894         'default' => 0),
00895       'p4' => array(
00896         'description' => t('The fourth mlid in the materialized path. See p1.'),
00897         'type' => 'int',
00898         'unsigned' => TRUE,
00899         'not null' => TRUE,
00900         'default' => 0),
00901       'p5' => array(
00902         'description' => t('The fifth mlid in the materialized path. See p1.'),
00903         'type' => 'int',
00904         'unsigned' => TRUE,
00905         'not null' => TRUE,
00906         'default' => 0),
00907       'p6' => array(
00908         'description' => t('The sixth mlid in the materialized path. See p1.'),
00909         'type' => 'int',
00910         'unsigned' => TRUE,
00911         'not null' => TRUE,
00912         'default' => 0),
00913       'p7' => array(
00914         'description' => t('The seventh mlid in the materialized path. See p1.'),
00915         'type' => 'int',
00916         'unsigned' => TRUE,
00917         'not null' => TRUE,
00918         'default' => 0),
00919       'p8' => array(
00920         'description' => t('The eighth mlid in the materialized path. See p1.'),
00921         'type' => 'int',
00922         'unsigned' => TRUE,
00923         'not null' => TRUE,
00924         'default' => 0),
00925       'p9' => array(
00926         'description' => t('The ninth mlid in the materialized path. See p1.'),
00927         'type' => 'int',
00928         'unsigned' => TRUE,
00929         'not null' => TRUE,
00930         'default' => 0),
00931       'updated' => array(
00932         'description' => t('Flag that indicates that this link was generated during the update from Drupal 5.'),
00933         'type' => 'int',
00934         'not null' => TRUE,
00935         'default' => 0,
00936         'size' => 'small'),
00937       ),
00938     'indexes' => array(
00939       'path_menu' => array(array('link_path', 128), 'menu_name'),
00940       'menu_plid_expand_child' => array(
00941         'menu_name', 'plid', 'expanded', 'has_children'),
00942       'menu_parents' => array(
00943         'menu_name', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9'),
00944       'router_path' => array(array('router_path', 128)),
00945       ),
00946     'primary key' => array('mlid'),
00947     );
00948
00949   $schema['sessions'] = array(
00950     'description' => t("Drupal's session handlers read and write into the sessions table. Each record represents a user session, either anonymous or authenticated."),
00951     'fields' => array(
00952       'uid' => array(
00953         'description' => t('The {users}.uid corresponding to a session, or 0 for anonymous user.'),
00954         'type' => 'int',
00955         'unsigned' => TRUE,
00956         'not null' => TRUE),
00957       'sid' => array(
00958         'description' => t("Primary key: A session ID. The value is generated by PHP's Session API."),
00959         'type' => 'varchar',
00960         'length' => 64,
00961         'not null' => TRUE,
00962         'default' => ''),
00963       'hostname' => array(
00964         'description' => t('The IP address that last used this session ID (sid).'),
00965         'type' => 'varchar',
00966         'length' => 128,
00967         'not null' => TRUE,
00968         'default' => ''),
00969       'timestamp' => array(
00970         'description' => t('The Unix timestamp when this session last requested a page. Old records are purged by PHP automatically.'),
00971         'type' => 'int',
00972         'not null' => TRUE,
00973         'default' => 0),
00974       'cache' => array(
00975         'description' => t("The time of this user's last post. This is used when the site has specified a minimum_cache_lifetime. See cache_get()."),
00976         'type' => 'int',
00977         'not null' => TRUE,
00978         'default' => 0),
00979       'session' => array(
00980         'description' => t('The serialized contents of $_SESSION, an array of name/value pairs that persists across page requests by this session ID. Drupal loads $_SESSION from here at the start of each request and saves it at the end.'),
00981         'type' => 'text',
00982         'not null' => FALSE,
00983         'size' => 'big')
00984       ),
00985     'primary key' => array('sid'),
00986     'indexes' => array(
00987       'timestamp' => array('timestamp'),
00988       'uid' => array('uid')
00989       ),
00990     );
00991
00992   $schema['system'] = array(
00993     'description' => t("A list of all modules, themes, and theme engines that are or have been installed in Drupal's file system."),
00994     'fields' => array(
00995       'filename' => array(
00996         'description' => t('The path of the primary file for this item, relative to the Drupal root; e.g. modules/node/node.module.'),
00997         'type' => 'varchar',
00998         'length' => 255,
00999         'not null' => TRUE,
01000         'default' => ''),
01001       'name' => array(
01002         'description' => t('The name of the item; e.g. node.'),
01003         'type' => 'varchar',
01004         'length' => 255,
01005         'not null' => TRUE,
01006         'default' => ''),
01007       'type' => array(
01008         'description' => t('The type of the item, either module, theme, or theme_engine.'),
01009         'type' => 'varchar',
01010         'length' => 255,
01011         'not null' => TRUE,
01012         'default' => ''),
01013       'owner' => array(
01014         'description' => t("A theme's 'parent'. Can be either a theme or an engine."),
01015         'type' => 'varchar',
01016         'length' => 255,
01017         'not null' => TRUE,
01018         'default' => ''),
01019       'status' => array(
01020         'description' => t('Boolean indicating whether or not this item is enabled.'),
01021         'type' => 'int',
01022         'not null' => TRUE,
01023         'default' => 0),
01024       'throttle' => array(
01025         'description' => t('Boolean indicating whether this item is disabled when the throttle.module disables throttleable items.'),
01026         'type' => 'int',
01027         'not null' => TRUE,
01028         'default' => 0,
01029         'size' => 'tiny'),
01030       'bootstrap' => array(
01031         'description' => t("Boolean indicating whether this module is loaded during Drupal's early bootstrapping phase (e.g. even before the page cache is consulted)."),
01032         'type' => 'int',
01033         'not null' => TRUE,
01034         'default' => 0),
01035       'schema_version' => array(
01036         'description' => t("The module's database schema version number. -1 if the module is not installed (its tables do not exist); 0 or the largest N of the module's hook_update_N() function that has either been run or existed when the module was first installed."),
01037         'type' => 'int',
01038         'not null' => TRUE,
01039         'default' => -1,
01040         'size' => 'small'),
01041       'weight' => array(
01042         'description' => t("The order in which this module's hooks should be invoked relative to other modules. Equal-weighted modules are ordered by name."),
01043         'type' => 'int',
01044         'not null' => TRUE,
01045         'default' => 0),
01046       'info' => array(
01047         'description' => t("A serialized array containing information from the module's .info file; keys can include name, description, package, version, core, dependencies, dependents, and php."),
01048         'type' => 'text',
01049         'not null' => FALSE)
01050       ),
01051     'primary key' => array('filename'),
01052     'indexes' =>
01053       array(
01054         'modules' => array(array('type', 12), 'status', 'weight', 'filename'),
01055         'bootstrap' => array(array('type', 12), 'status', 'bootstrap', 'weight', 'filename'),
01056       ),
01057     );
01058
01059   $schema['url_alias'] = array(
01060     'description' => t('A list of URL aliases for Drupal paths; a user may visit either the source or destination path.'),
01061     'fields' => array(
01062       'pid' => array(
01063         'description' => t('A unique path alias identifier.'),
01064         'type' => 'serial',
01065         'unsigned' => TRUE,
01066         'not null' => TRUE),
01067       'src' => array(
01068         'description' => t('The Drupal path this alias is for; e.g. node/12.'),
01069         'type' => 'varchar',
01070         'length' => 128,
01071         'not null' => TRUE,
01072         'default' => ''),
01073       'dst' => array(
01074         'description' => t('The alias for this path; e.g. title-of-the-story.'),
01075         'type' => 'varchar',
01076         'length' => 128,
01077         'not null' => TRUE,
01078         'default' => ''),
01079       'language' => array(
01080         'description' => t('The language this alias is for; if blank, the alias will be used for unknown languages. Each Drupal path can have an alias for each supported language.'),
01081         'type' => 'varchar',
01082         'length' => 12,
01083         'not null' => TRUE,
01084         'default' => '')
01085       ),
01086     'unique keys' => array('dst_language' => array('dst', 'language')),
01087     'primary key' => array('pid'),
01088     'indexes' => array('src' => array('src')),
01089     );
01090
01091   return $schema;
01092 }
01093
01094 // Updates for core.
01095
01096 function system_update_last_removed() {
01097   return 1021;
01098 }
01099
01108 function system_update_1022() {
01109   $ret = array();
01110   db_add_index($ret, 'users', 'created', array('created'));
01111   // Also appears as system_update_6004(). Ensure we don't update twice.
01112   variable_set('system_update_1022', TRUE);
01113   return $ret;
01114 }
01115
01129 function system_update_6000() {
01130   $ret = array();
01131   switch ($GLOBALS['db_type']) {
01132     case 'mysql':
01133     case 'mysqli':
01134       $max = (int)db_result(db_query('SELECT MAX(bid) FROM {boxes}'));
01135       $ret[] = update_sql('ALTER TABLE {boxes} CHANGE COLUMN bid bid int NOT NULL');
01136       $ret[] = update_sql("REPLACE INTO {sequences} VALUES ('{boxes}_bid', $max)");
01137       break;
01138   }
01139   return $ret;
01140 }
01141
01145 function system_update_6001() {
01146   $ret = array();
01147
01148   // Add vid to term-node relation.  The schema says it is unsigned.
01149   db_add_field($ret, 'term_node', 'vid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
01150   db_drop_primary_key($ret, 'term_node');
01151   db_add_primary_key($ret, 'term_node', array('vid', 'tid', 'nid'));
01152   db_add_index($ret, 'term_node', 'vid', array('vid'));
01153
01154   db_query('UPDATE {term_node} t SET vid = (SELECT vid FROM {node} n WHERE t.nid = n.nid)');
01155   return $ret;
01156 }
01157
01161 function system_update_6002() {
01162   $ret = array();
01163   db_drop_primary_key($ret, 'variable');
01164   db_change_field($ret, 'variable', 'name', 'name', array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''));
01165   db_add_primary_key($ret, 'variable', array('name'));
01166   return $ret;
01167 }
01168
01172 function system_update_6003() {
01173   $ret = array();
01174   db_add_index($ret, 'comments', 'status', array('status'));
01175   return $ret;
01176 }
01177
01189 function system_update_6004() {
01190   return array();
01191 }
01192
01196 function system_update_6005() {
01197   $ret = array();
01198   switch ($GLOBALS['db_type']) {
01199     case 'pgsql':
01200       db_add_column($ret, 'url_alias', 'language', 'varchar(12)', array('default' => "''", 'not null' => TRUE));
01201
01202       // As of system.install:1.85 (before the new language
01203       // subsystem), new installs got a unique key named
01204       // url_alias_dst_key on url_alias.dst.  Unfortunately,
01205       // system_update_162 created a unique key inconsistently named
01206       // url_alias_dst_idx on url_alias.dst (keys should have the _key
01207       // suffix, indexes the _idx suffix).  Therefore, sites installed
01208       // before system_update_162 have a unique key with a different
01209       // name than sites installed after system_update_162().  Now, we
01210       // want to drop the unique key on dst which may have either one
01211       // of two names and create a new unique key on (dst, language).
01212       // There is no way to know which key name exists so we have to
01213       // drop both, causing an SQL error.  Thus, we just hide the
01214       // error and only report the update_sql results that work.
01215       $err = error_reporting(0);
01216       $ret1 = update_sql('DROP INDEX {url_alias}_dst_idx');
01217       if ($ret1['success']) {
01218   $ret[] = $ret1;
01219       }
01220       $ret1 = array();
01221       db_drop_unique_key($ret, 'url_alias', 'dst');
01222       foreach ($ret1 as $r) {
01223   if ($r['success']) {
01224     $ret[] = $r;
01225   }
01226       }
01227       error_reporting($err);
01228
01229       $ret[] = update_sql('CREATE UNIQUE INDEX {url_alias}_dst_language_idx ON {url_alias}(dst, language)');
01230       break;
01231     case 'mysql':
01232     case 'mysqli':
01233       $ret[] = update_sql("ALTER TABLE {url_alias} ADD language varchar(12) NOT NULL default ''");
01234       $ret[] = update_sql("ALTER TABLE {url_alias} DROP INDEX dst");
01235       $ret[] = update_sql("ALTER TABLE {url_alias} ADD UNIQUE dst_language (dst, language)");
01236       break;
01237   }
01238   return $ret;
01239 }
01240
01244 function system_update_6006() {
01245   $ret = array();
01246   switch ($GLOBALS['db_type']) {
01247     case 'pgsql':
01248       $ret[] = update_sql('DROP INDEX {node_counter}_daycount_idx');
01249       $ret[] = update_sql('DROP INDEX {node_counter}_totalcount_idx');
01250       $ret[] = update_sql('DROP INDEX {node_counter}_timestamp_idx');
01251       break;
01252     case 'mysql':
01253     case 'mysqli':
01254       $ret[] = update_sql("ALTER TABLE {node_counter} DROP INDEX daycount");
01255       $ret[] = update_sql("ALTER TABLE {node_counter} DROP INDEX totalcount");
01256       $ret[] = update_sql("ALTER TABLE {node_counter} DROP INDEX timestamp");
01257       break;
01258   }
01259   return $ret;
01260 }
01261
01265 function system_update_6007() {
01266   $ret = array();
01267   $ret[] = update_sql("UPDATE {watchdog} SET severity = ". WATCHDOG_NOTICE ." WHERE severity = 0");
01268   $ret[] = update_sql("UPDATE {watchdog} SET severity = ". WATCHDOG_WARNING ." WHERE severity = 1");
01269   $ret[] = update_sql("UPDATE {watchdog} SET severity = ". WATCHDOG_ERROR ." WHERE severity = 2");
01270   return $ret;
01271 }
01272
01279 function system_update_6008() {
01280   $ret = array();
01281   $ret[] = update_sql('UPDATE {system} SET owner = description');
01282   db_drop_field($ret, 'system', 'description');
01283
01284   // Rebuild system table contents.
01285   module_rebuild_cache();
01286   system_theme_data();
01287
01288   return $ret;
01289 }
01290
01294 function system_update_6009() {
01295   $ret = array();
01296
01297   // If any input format used the Drupal 5 PHP filter.
01298   if (db_result(db_query("SELECT COUNT(format) FROM {filters} WHERE module = 'filter' AND delta = 1"))) {
01299     // Enable the PHP filter module.
01300     $ret[] = update_sql("UPDATE {system} SET status = 1 WHERE name = 'php' AND type = 'module'");
01301     // Update the input filters.
01302     $ret[] = update_sql("UPDATE {filters} SET delta = 0, module = 'php' WHERE module = 'filter' AND delta = 1");
01303   }
01304
01305   // With the removal of the PHP evaluator filter, the deltas of the line break
01306   // and URL filter have changed.
01307   $ret[] = update_sql("UPDATE {filters} SET delta = 1 WHERE module = 'filter' AND delta = 2");
01308   $ret[] = update_sql("UPDATE {filters} SET delta = 2 WHERE module = 'filter' AND delta = 3");
01309
01310   return $ret;
01311 }
01312
01321 function system_update_6010() {
01322   $ret = array();
01323   db_add_field($ret, 'watchdog', 'variables', array('type' => 'text', 'size' => 'big', 'not null' => TRUE, 'initial' => 'N;'));
01324   return $ret;
01325 }
01326
01330 function system_update_6011() {
01331   $ret = array();
01332   switch ($GLOBALS['db_type']) {
01333     case 'pgsql':
01334       db_add_column($ret, 'node', 'language', 'varchar(12)', array('default' => "''", 'not null' => TRUE));
01335       break;
01336     case 'mysql':
01337     case 'mysqli':
01338       $ret[] = update_sql("ALTER TABLE {node} ADD language varchar(12) NOT NULL default ''");
01339       break;
01340   }
01341   return $ret;
01342 }
01343
01348 function system_update_6012() {
01349   return array();
01350 }
01351
01355 function system_update_6013() {
01356   // Rebuild system table contents.
01357   module_rebuild_cache();
01358   system_theme_data();
01359
01360   return array(array('success' => TRUE, 'query' => 'Cache rebuilt.'));
01361 }
01362
01367 function system_update_6014() {
01368   variable_set('install_task', 'done');
01369
01370   return array(array('success' => TRUE, 'query' => "variable_set('install_task')"));
01371 }
01372
01376 function system_update_6015() {
01377   $ret = array();
01378
01379   switch ($GLOBALS['db_type']) {
01380     case 'pgsql':
01381       $ret[] = update_sql("CREATE TABLE {cache_form} (
01382         cid varchar(255) NOT NULL default '',
01383         data bytea,
01384         expire int NOT NULL default '0',
01385         created int NOT NULL default '0',
01386         headers text,
01387         serialized smallint NOT NULL default '0',
01388         PRIMARY KEY (cid)
01389     )");
01390       $ret[] = update_sql("CREATE INDEX {cache_form}_expire_idx ON {cache_form} (expire)");
01391       break;
01392     case 'mysql':
01393     case 'mysqli':
01394       $ret[] = update_sql("CREATE TABLE {cache_form} (
01395         cid varchar(255) NOT NULL default '',
01396         data longblob,
01397         expire int NOT NULL default '0',
01398         created int NOT NULL default '0',
01399         headers text,
01400         serialized int(1) NOT NULL default '0',
01401         PRIMARY KEY (cid),
01402         INDEX expire (expire)
01403       ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
01404       break;
01405   }
01406
01407   return $ret;
01408 }
01409
01414 function system_update_6016() {
01415   $ret = array();
01416
01417   switch ($GLOBALS['db_type']) {
01418     case 'pgsql':
01419       $ret[] = update_sql("ALTER TABLE {node} ADD CONSTRAINT {node}_nid_vid_key UNIQUE (nid, vid)");
01420       db_add_column($ret, 'blocks', 'bid', 'serial');
01421       $ret[] = update_sql("ALTER TABLE {blocks} ADD PRIMARY KEY (bid)");
01422       db_add_column($ret, 'filters', 'fid', 'serial');
01423       $ret[] = update_sql("ALTER TABLE {filters} ADD PRIMARY KEY (fid)");
01424       db_add_column($ret, 'flood', 'fid', 'serial');
01425       $ret[] = update_sql("ALTER TABLE {flood} ADD PRIMARY KEY (fid)");
01426       db_add_column($ret, 'permission', 'pid', 'serial');
01427       $ret[] = update_sql("ALTER TABLE {permission} ADD PRIMARY KEY (pid)");
01428       db_add_column($ret, 'term_relation', 'trid', 'serial');
01429       $ret[] = update_sql("ALTER TABLE {term_relation} ADD PRIMARY KEY (trid)");
01430       db_add_column($ret, 'term_synonym', 'tsid', 'serial');
01431       $ret[] = update_sql("ALTER TABLE {term_synonym} ADD PRIMARY KEY (tsid)");
01432       break;
01433     case 'mysql':
01434     case 'mysqli':
01435       $ret[] = update_sql('ALTER TABLE {node} ADD UNIQUE KEY nid_vid (nid, vid)');
01436       $ret[] = update_sql("ALTER TABLE {blocks} ADD bid int NOT NULL AUTO_INCREMENT PRIMARY KEY");
01437       $ret[] = update_sql("ALTER TABLE {filters} ADD fid int NOT NULL AUTO_INCREMENT PRIMARY KEY");
01438       $ret[] = update_sql("ALTER TABLE {flood} ADD fid int NOT NULL AUTO_INCREMENT PRIMARY KEY");
01439       $ret[] = update_sql("ALTER TABLE {permission} ADD pid int NOT NULL AUTO_INCREMENT PRIMARY KEY");
01440       $ret[] = update_sql("ALTER TABLE {term_relation} ADD trid int NOT NULL AUTO_INCREMENT PRIMARY KEY");
01441       $ret[] = update_sql("ALTER TABLE {term_synonym} ADD tsid int NOT NULL AUTO_INCREMENT PRIMARY KEY");
01442       break;
01443   }
01444
01445   return $ret;
01446 }
01447
01451 function system_update_6017() {
01452   $ret = array();
01453   // Maps old names to new ones.
01454   $var_names = array(
01455     'admin'    => 'register_admin_created',
01456     'approval' => 'register_pending_approval',
01457     'welcome'  => 'register_no_approval_required',
01458     'pass'     => 'password_reset',
01459   );
01460   foreach ($var_names as $old => $new) {
01461     foreach (array('_subject', '_body') as $suffix) {
01462       $old_name = 'user_mail_'. $old . $suffix;
01463       $new_name = 'user_mail_'. $new . $suffix;
01464       if ($old_val = variable_get($old_name, FALSE)) {
01465         variable_set($new_name, $old_val);
01466         variable_del($old_name);
01467         $ret[] = array('success' => TRUE, 'query' => "variable_set($new_name)");
01468         $ret[] = array('success' => TRUE, 'query' => "variable_del($old_name)");
01469         if ($old_name == 'user_mail_approval_body') {
01470           drupal_set_message('Saving an old value of the welcome message body for users that are pending administrator approval. However, you should consider modifying this text, since Drupal can now be configured to automatically notify users and send them their login information when their accounts are approved. See the <a href="'. url('admin/user/settings') .'">User settings</a> page for details.');
01471         }
01472       }
01473     }
01474   }
01475   return $ret;
01476 }
01477
01481 function system_update_6018() {
01482   $ret = array();
01483
01484   // Disable htmlcorrector.module, if it exists and replace its filter.
01485   if (module_exists('htmlcorrector')) {
01486     module_disable(array('htmlcorrector'));
01487     $ret[] = update_sql("UPDATE {filter_formats} SET module = 'filter', delta = 3 WHERE module = 'htmlcorrector'");
01488     $ret[] = array('success' => TRUE, 'query' => 'HTML Corrector module was disabled; this functionality has now been added to core.');
01489     return $ret;
01490   }
01491
01492   // Otherwise, find any format with 'HTML' in its name and add the filter at the end.
01493   $result = db_query("SELECT format, name FROM {filter_formats} WHERE name LIKE '%HTML%'");
01494   while ($format = db_fetch_object($result)) {
01495     $weight = db_result(db_query("SELECT MAX(weight) FROM {filters} WHERE format = %d", $format->format));
01496     db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", $format->format, 'filter', 3, max(10, $weight + 1));
01497     $ret[] = array('success' => TRUE, 'query' => "HTML corrector filter added to the '". $format->name ."' input format.");
01498   }
01499
01500   return $ret;
01501 }
01502
01517 function system_update_6019() {
01518   $ret = array();
01519
01520   switch ($GLOBALS['db_type']) {
01521     case 'pgsql':
01522       // Remove default ''.
01523       if (db_table_exists('aggregator_feed')) {
01524         db_field_set_no_default($ret, 'aggregator_feed', 'description');
01525         db_field_set_no_default($ret, 'aggregator_feed', 'image');
01526       }
01527       db_field_set_no_default($ret, 'blocks', 'pages');
01528       if (db_table_exists('contact')) {
01529         db_field_set_no_default($ret, 'contact', 'recipients');
01530         db_field_set_no_default($ret, 'contact', 'reply');
01531       }
01532       db_field_set_no_default($ret, 'watchdog', 'location');
01533       db_field_set_no_default($ret, 'node_revisions', 'body');
01534       db_field_set_no_default($ret, 'node_revisions', 'teaser');
01535       db_field_set_no_default($ret, 'node_revisions', 'log');
01536
01537       // Update from pgsql 'float' (which means 'double precision') to
01538       // schema 'float' (which in pgsql means 'real').
01539       if (db_table_exists('search_index')) {
01540         db_change_field($ret, 'search_index', 'score', 'score', array('type' => 'float'));
01541       }
01542       if (db_table_exists('search_total')) {
01543         db_change_field($ret, 'search_total', 'count', 'count', array('type' => 'float'));
01544       }
01545
01546       // Replace unique index dst_language with a unique constraint.  The
01547       // result is the same but the unique key fits our current schema
01548       // structure.  Also, the postgres documentation implies that
01549       // unique constraints are preferable to unique indexes.  See
01550       // http://www.postgresql.org/docs/8.2/interactive/indexes-unique.html.
01551       if (db_table_exists('url_alias')) {
01552         db_drop_index($ret, 'url_alias', 'dst_language');
01553         db_add_unique_key($ret, 'url_alias', 'dst_language',
01554           array('dst', 'language'));
01555       }
01556
01557       // Fix term_node pkey: mysql and pgsql code had different orders.
01558       if (db_table_exists('term_node')) {
01559         db_drop_primary_key($ret, 'term_node');
01560         db_add_primary_key($ret, 'term_node', array('vid', 'tid', 'nid'));
01561       }
01562
01563       // Make boxes.bid unsigned.
01564       db_drop_primary_key($ret, 'boxes');
01565       db_change_field($ret, 'boxes', 'bid', 'bid', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array('bid')));
01566
01567       // Fix primary key
01568       db_drop_primary_key($ret, 'node');
01569       db_add_primary_key($ret, 'node', array('nid'));
01570
01571       break;
01572
01573     case 'mysql':
01574     case 'mysqli':
01575       // Rename key 'link' to 'url'.
01576       if (db_table_exists('aggregator_feed')) {
01577         db_drop_unique_key($ret, 'aggregator_feed', 'link');
01578         db_add_unique_key($ret, 'aggregator_feed', 'url', array('url'));
01579       }
01580
01581       // Change to size => small.
01582       if (db_table_exists('boxes')) {
01583         db_change_field($ret, 'boxes', 'format', 'format', array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0));
01584       }
01585
01586       // Change to size => small.
01587       // Rename index 'lid' to 'nid'.
01588       if (db_table_exists('comments')) {
01589         db_change_field($ret, 'comments', 'format', 'format', array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0));
01590         db_drop_index($ret, 'comments', 'lid');
01591         db_add_index($ret, 'comments', 'nid', array('nid'));
01592       }
01593
01594       // Change to size => small.
01595       db_change_field($ret, 'cache', 'serialized', 'serialized', array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0));
01596       db_change_field($ret, 'cache_filter', 'serialized', 'serialized', array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0));
01597       db_change_field($ret, 'cache_page', 'serialized', 'serialized', array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0));
01598       db_change_field($ret, 'cache_form', 'serialized', 'serialized', array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0));
01599
01600       // Remove default => 0, set auto increment.
01601       $new_uid = 1 + db_result(db_query('SELECT MAX(uid) FROM {users}'));
01602       $ret[] = update_sql('UPDATE {users} SET uid = '. $new_uid .' WHERE uid = 0');
01603       db_drop_primary_key($ret, 'users');
01604       db_change_field($ret, 'users', 'uid', 'uid', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array('uid')));
01605       $ret[] = update_sql('UPDATE {users} SET uid = 0 WHERE uid = '. $new_uid);
01606
01607       // Special field names.
01608       $map = array('node_revisions' => 'vid');
01609       // Make sure these tables have proper auto_increment fields.
01610       foreach (array('boxes', 'files', 'node', 'node_revisions') as $table) {
01611         $field = isset($map[$table]) ? $map[$table] : $table[0] .'id';
01612         db_drop_primary_key($ret, $table);
01613         db_change_field($ret, $table, $field, $field, array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array($field)));
01614       }
01615
01616       break;
01617   }
01618
01619   return $ret;
01620 }
01621
01625 function system_update_6020() {
01626   $ret = array();
01627
01628   $schema['menu_router'] = array(
01629     'fields' => array(
01630       'path'             => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
01631       'load_functions'   => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
01632       'to_arg_functions' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
01633       'access_callback'  => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
01634       'access_arguments' => array('type' => 'text', 'not null' => FALSE),
01635       'page_callback'    => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
01636       'page_arguments'   => array('type' => 'text', 'not null' => FALSE),
01637       'fit'              => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
01638       'number_parts'     => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
01639       'tab_parent'       => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
01640       'tab_root'         => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
01641       'title'            => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
01642       'title_callback'   => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
01643       'title_arguments'  => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
01644       'type'             => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
01645       'block_callback'   => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
01646       'description'      => array('type' => 'text', 'not null' => TRUE),
01647       'position'         => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
01648       'weight'           => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
01649       'file'             => array('type' => 'text', 'size' => 'medium')
01650     ),
01651     'indexes' => array(
01652       'fit'        => array('fit'),
01653       'tab_parent' => array('tab_parent')
01654     ),
01655     'primary key' => array('path'),
01656   );
01657
01658   $schema['menu_links'] = array(
01659     'fields' => array(
01660       'menu_name'    => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''),
01661       'mlid'         => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
01662       'plid'         => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
01663       'link_path'    => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
01664       'router_path'  => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
01665       'link_title'   => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
01666       'options'      => array('type' => 'text', 'not null' => FALSE),
01667       'module'       => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'system'),
01668       'hidden'       => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
01669       'external'     => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
01670       'has_children' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
01671       'expanded'     => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
01672       'weight'       => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
01673       'depth'        => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
01674       'customized'   => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
01675       'p1'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
01676       'p2'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
01677       'p3'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
01678       'p4'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
01679       'p5'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
01680       'p6'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
01681       'p7'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
01682       'p8'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
01683       'p9'           => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
01684       'updated'      => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small'),
01685     ),
01686     'indexes' => array(
01687       'path_menu'              => array(array('link_path', 128), 'menu_name'),
01688       'menu_plid_expand_child' => array('menu_name', 'plid', 'expanded', 'has_children'),
01689       'menu_parents'           => array('menu_name', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9'),
01690       'router_path'            => array(array('router_path', 128)),
01691     ),
01692     'primary key' => array('mlid'),
01693   );
01694
01695   foreach ($schema as $name => $table) {
01696     db_create_table($ret, $name, $table);
01697   }
01698   return $ret;
01699 }
01700
01704 function system_update_6021() {
01705   $ret = array('#finished' => 0);
01706   $menus = array(
01707     'navigation' => array(
01708       'menu_name' => 'navigation',
01709       'title' => 'Navigation',
01710       'description' => 'The navigation menu is provided by Drupal and is the main interactive menu for any site. It is usually the only menu that contains personalized links for authenticated users, and is often not even visible to anonymous users.',
01711     ),
01712     'primary-links' => array(
01713       'menu_name' => 'primary-links',
01714       'title' => 'Primary links',
01715       'description' => 'Primary links are often used at the theme layer to show the major sections of a site. A typical representation for primary links would be tabs along the top.',
01716     ),
01717     'secondary-links' => array(
01718       'menu_name' => 'secondary-links',
01719       'title' => 'Secondary links',
01720       'description' => 'Secondary links are often used for pages like legal notices, contact details, and other secondary navigation items that play a lesser role than primary links',
01721     ),
01722   );
01723   // Multi-part update
01724   if (!isset($_SESSION['system_update_6021'])) {
01725     db_add_field($ret, 'menu', 'converted', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'));
01726     $_SESSION['system_update_6021_max'] = db_result(db_query('SELECT COUNT(*) FROM {menu}'));
01727     $_SESSION['menu_menu_map'] = array(1 => 'navigation');
01728     // 0 => FALSE is for new menus, 1 => FALSE is for the navigation.
01729     $_SESSION['menu_item_map'] = array(0 => FALSE, 1 => FALSE);
01730     $table = array(
01731       'fields' => array(
01732         'menu_name'   => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''),
01733         'title'       => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
01734         'description' => array('type' => 'text', 'not null' => FALSE),
01735       ),
01736       'primary key' => array('menu_name'),
01737     );
01738     db_create_table($ret, 'menu_custom', $table);
01739     db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", $menus['navigation']);
01740     $_SESSION['system_update_6021'] = 0;
01741   }
01742
01743   $limit = 50;
01744   while ($limit-- && ($item = db_fetch_array(db_query_range('SELECT * FROM {menu} WHERE converted = 0', 0, 1)))) {
01745     // If it's not a menu...
01746     if ($item['pid']) {
01747       // Let's climb up until we find an item with a converted parent.
01748       $item_original = $item;
01749       while ($item && !isset($_SESSION['menu_item_map'][$item['pid']])) {
01750         $item = db_fetch_array(db_query('SELECT * FROM {menu} WHERE mid = %d', $item['pid']));
01751       }
01752       // This can only occur if the menu entry is a leftover in the menu table.
01753       // These do not appear in Drupal 5 anyways, so we skip them.
01754       if (!$item) {
01755         db_query('UPDATE {menu} SET converted = %d WHERE mid = %d', 1, $item_original['mid']);
01756         $_SESSION['system_update_6021']++;
01757         continue;
01758       }
01759     }
01760     // We need to recheck because item might have changed.
01761     if ($item['pid']) {
01762       // Fill the new fields.
01763       $item['link_title'] = $item['title'];
01764       $item['link_path'] = drupal_get_normal_path($item['path']);
01765       // We know the parent is already set. If it's not FALSE then it's an item.
01766       if ($_SESSION['menu_item_map'][$item['pid']]) {
01767         // The new menu system parent link id.
01768         $item['plid'] = $_SESSION['menu_item_map'][$item['pid']]['mlid'];
01769         // The new menu system menu name.
01770         $item['menu_name'] = $_SESSION['menu_item_map'][$item['pid']]['menu_name'];
01771       }
01772       else {
01773         // This a top level element.
01774         $item['plid'] = 0;
01775         // The menu name is stored among the menus.
01776         $item['menu_name'] = $_SESSION['menu_menu_map'][$item['pid']];
01777       }
01778       // Is the element visible in the menu block?
01779       $item['hidden'] = !($item['type'] & MENU_VISIBLE_IN_TREE);
01780       // Is it a custom(ized) element?
01781       if ($item['type'] & (MENU_CREATED_BY_ADMIN | MENU_MODIFIED_BY_ADMIN)) {
01782         $item['customized'] = TRUE;
01783       }
01784       // Items created via the menu module need to be assigned to it.
01785       if ($item['type'] & MENU_CREATED_BY_ADMIN) {
01786         $item['module'] = 'menu';
01787         $item['router_path'] = '';
01788         $item['updated'] = TRUE;
01789       }
01790       else {
01791         $item['module'] = 'system';
01792         $item['router_path'] = $item['path'];
01793         $item['updated'] = FALSE;
01794       }
01795       // Save the link.
01796       menu_link_save($item);
01797       $_SESSION['menu_item_map'][$item['mid']] = array('mlid' => $item['mlid'], 'menu_name' => $item['menu_name']);
01798     }
01799     elseif (!isset($_SESSION['menu_menu_map'][$item['mid']])) {
01800       $item['menu_name'] = 'menu-'. preg_replace('/[^a-zA-Z0-9]/', '-', strtolower($item['title']));
01801       $item['menu_name'] = substr($item['menu_name'], 0, 20);
01802       $original_menu_name = $item['menu_name'];
01803       $i = 0;
01804       while (db_result(db_query("SELECT menu_name FROM {menu_custom} WHERE menu_name = '%s'", $item['menu_name']))) {
01805         $item['menu_name'] = $original_menu_name . ($i++);
01806       }
01807       if ($item['path']) {
01808         // Another bunch of bogus entries. Apparently, these are leftovers
01809         // from Drupal 4.7 .
01810         $_SESSION['menu_bogus_menus'][] = $item['menu_name'];
01811       }
01812       else {
01813         // Add this menu to the list of custom menus.
01814         db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '')", $item['menu_name'], $item['title']);
01815       }
01816       $_SESSION['menu_menu_map'][$item['mid']] = $item['menu_name'];
01817       $_SESSION['menu_item_map'][$item['mid']] = FALSE;
01818     }
01819     db_query('UPDATE {menu} SET converted = %d WHERE mid = %d', 1, $item['mid']);
01820     $_SESSION['system_update_6021']++;
01821   }
01822
01823   if ($_SESSION['system_update_6021'] >= $_SESSION['system_update_6021_max']) {
01824     if (!empty($_SESSION['menu_bogus_menus'])) {
01825       // Remove entries in bogus menus. This is secure because we deleted
01826       // every non-alpanumeric character from the menu name.
01827       $ret[] = update_sql("DELETE FROM {menu_links} WHERE menu_name IN ('". implode("', '", $_SESSION['menu_bogus_menus']) ."')");
01828     }
01829
01830     $menu_primary_menu = variable_get('menu_primary_menu', 0);
01831     // Ensure that we wind up with a system menu named 'primary-links'.
01832     if (isset($_SESSION['menu_menu_map'][2])) {
01833       // The primary links menu that ships with Drupal 5 has mid = 2.  If this
01834       // menu hasn't been deleted by the site admin, we use that.
01835       $updated_primary_links_menu = 2;
01836     }
01837     elseif (isset($_SESSION['menu_menu_map'][$menu_primary_menu]) && $menu_primary_menu > 1) {
01838       // Otherwise, we use the menu that is currently assigned to the primary
01839       // links region of the theme, as long as it exists and isn't the
01840       // Navigation menu.
01841       $updated_primary_links_menu = $menu_primary_menu;
01842     }
01843     else {
01844       // As a last resort, create 'primary-links' as a new menu.
01845       $updated_primary_links_menu = 0;
01846       db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", $menus['primary-links']);
01847     }
01848
01849     if ($updated_primary_links_menu) {
01850       // Change the existing menu name to 'primary-links'.
01851       $replace = array('%new_name' => 'primary-links', '%desc' => $menus['primary-links']['description'], '%old_name' => $_SESSION['menu_menu_map'][$updated_primary_links_menu]);
01852       $ret[] = update_sql(strtr("UPDATE {menu_custom} SET menu_name = '%new_name', description = '%desc' WHERE menu_name = '%old_name'", $replace));
01853       $ret[] = update_sql("UPDATE {menu_links} SET menu_name = 'primary-links' WHERE menu_name = '". $_SESSION['menu_menu_map'][$updated_primary_links_menu] ."'");
01854       $_SESSION['menu_menu_map'][$updated_primary_links_menu] = 'primary-links';
01855     }
01856
01857     $menu_secondary_menu = variable_get('menu_secondary_menu', 0);
01858     // Ensure that we wind up with a system menu named 'secondary-links'.
01859     if (isset($_SESSION['menu_menu_map'][$menu_secondary_menu]) && $menu_secondary_menu > 1 && $menu_secondary_menu != $updated_primary_links_menu) {
01860       // We use the menu that is currently assigned to the secondary links
01861       // region of the theme, as long as (a) it exists, (b) it isn't the
01862       // Navigation menu, (c) it isn't the same menu we assigned as the
01863       // system 'primary-links' menu above, and (d) it isn't the same menu
01864       // assigned to the primary links region of the theme.
01865       $updated_secondary_links_menu = $menu_secondary_menu;
01866     }
01867     else {
01868       // Otherwise, create 'secondary-links' as a new menu.
01869       $updated_secondary_links_menu = 0;
01870       db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", $menus['secondary-links']);
01871     }
01872
01873     if ($updated_secondary_links_menu) {
01874       // Change the existing menu name to 'secondary-links'.
01875       $replace = array('%new_name' => 'secondary-links', '%desc' => $menus['secondary-links']['description'], '%old_name' => $_SESSION['menu_menu_map'][$updated_secondary_links_menu]);
01876       $ret[] = update_sql(strtr("UPDATE {menu_custom} SET menu_name = '%new_name', description = '%desc' WHERE menu_name = '%old_name'", $replace));
01877       $ret[] = update_sql("UPDATE {menu_links} SET menu_name = 'secondary-links' WHERE menu_name = '". $_SESSION['menu_menu_map'][$updated_secondary_links_menu] ."'");
01878       $_SESSION['menu_menu_map'][$updated_secondary_links_menu] = 'secondary-links';
01879     }
01880
01881     // Update menu OTF preferences.
01882     $mid = variable_get('menu_parent_items', 0);
01883     $menu_name = ($mid && isset($_SESSION['menu_menu_map'][$mid])) ? $_SESSION['menu_menu_map'][$mid] : 'navigation';
01884     variable_set('menu_default_node_menu', $menu_name);
01885     variable_del('menu_parent_items');
01886
01887     // Update the source of the primary and secondary links.
01888     $menu_name = ($menu_primary_menu && isset($_SESSION['menu_menu_map'][$menu_primary_menu])) ? $_SESSION['menu_menu_map'][$menu_primary_menu] : '';
01889     variable_set('menu_primary_links_source', $menu_name);
01890     variable_del('menu_primary_menu');
01891
01892     $menu_name = ($menu_secondary_menu && isset($_SESSION['menu_menu_map'][$menu_secondary_menu])) ? $_SESSION['menu_menu_map'][$menu_secondary_menu] : '';
01893     variable_set('menu_secondary_links_source', $menu_name);
01894     variable_del('menu_secondary_menu');
01895
01896     // Skip the navigation menu - it is handled by the user module.
01897     unset($_SESSION['menu_menu_map'][1]);
01898     // Update the deltas for all menu module blocks.
01899     foreach ($_SESSION['menu_menu_map'] as $mid => $menu_name) {
01900       // This is again secure because we deleted every non-alpanumeric
01901       // character from the menu name.
01902       $ret[] = update_sql("UPDATE {blocks} SET delta = '". $menu_name ."' WHERE module = 'menu' AND delta = '". $mid ."'");
01903       $ret[] = update_sql("UPDATE {blocks_roles} SET delta = '". $menu_name ."' WHERE module = 'menu' AND delta = '". $mid ."'");
01904     }
01905     $ret[] = array('success' => TRUE, 'query' => 'Relocated '. $_SESSION['system_update_6021'] .' existing items to the new menu system.');
01906     $ret[] = update_sql("DROP TABLE {menu}");
01907     unset($_SESSION['system_update_6021'], $_SESSION['system_update_6021_max'], $_SESSION['menu_menu_map'], $_SESSION['menu_item_map'], $_SESSION['menu_bogus_menus']);
01908     // Create the menu overview links - also calls menu_rebuild(). If menu is
01909     // disabled, then just call menu_rebuild.
01910     if (function_exists('menu_enable')) {
01911       menu_enable();
01912     }
01913     else {
01914       menu_rebuild();
01915     }
01916     $ret['#finished'] = 1;
01917   }
01918   else {
01919     $ret['#finished'] = $_SESSION['system_update_6021'] / $_SESSION['system_update_6021_max'];
01920   }
01921   return $ret;
01922 }
01923
01929 function system_update_6022() {
01930   $ret = array();
01931
01932   // Rename the nid field to vid, add status and timestamp fields, and indexes.
01933   db_drop_index($ret, 'files', 'nid');
01934   db_change_field($ret, 'files', 'nid', 'uid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
01935   db_add_field($ret, 'files', 'status', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
01936   db_add_field($ret, 'files', 'timestamp', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
01937   db_add_index($ret, 'files', 'uid', array('uid'));
01938   db_add_index($ret, 'files', 'status', array('status'));
01939   db_add_index($ret, 'files', 'timestamp', array('timestamp'));
01940
01941   // Rename the file_revisions table to upload then add nid column. Since we're
01942   // changing the table name we need to drop and re-add the indexes and
01943   // the primary key so both mysql and pgsql end up with the correct index
01944   // names.
01945   db_drop_primary_key($ret, 'file_revisions');
01946   db_drop_index($ret, 'file_revisions', 'vid');
01947   db_rename_table($ret, 'file_revisions', 'upload');
01948   db_add_field($ret, 'upload', 'nid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
01949   db_add_index($ret, 'upload', 'nid', array('nid'));
01950   db_add_primary_key($ret, 'upload', array('vid', 'fid'));
01951   db_add_index($ret, 'upload', 'fid', array('fid'));
01952
01953   // The nid column was renamed to uid. Use the old nid to find the node's uid.
01954   update_sql('UPDATE {files} SET uid = (SELECT n.uid FROM {node} n WHERE {files}.uid = n.nid)');
01955   update_sql('UPDATE {upload} SET nid = (SELECT r.nid FROM {node_revisions} r WHERE {upload}.vid = r.vid)');
01956
01957   // Mark all existing files as FILE_STATUS_PERMANENT.
01958   $ret[] = update_sql('UPDATE {files} SET status = 1');
01959
01960   return $ret;
01961 }
01962
01963 function system_update_6023() {
01964   $ret = array();
01965
01966   // nid is DEFAULT 0
01967   db_drop_index($ret, 'node_revisions', 'nid');
01968   db_change_field($ret, 'node_revisions', 'nid', 'nid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
01969   db_add_index($ret, 'node_revisions', 'nid', array('nid'));
01970   return $ret;
01971 }
01972
01976 function system_update_6024() {
01977   $ret = array();
01978   db_add_field($ret, 'node', 'tnid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
01979   db_add_field($ret, 'node', 'translate', array('type' => 'int', 'not null' => TRUE, 'default' => 0));
01980   db_add_index($ret, 'node', 'tnid', array('tnid'));
01981   db_add_index($ret, 'node', 'translate', array('translate'));
01982   return $ret;
01983 }
01984
01988 function system_update_6025() {
01989   $ret = array();
01990   db_drop_index($ret, 'node', 'node_title_type');
01991   db_change_field($ret, 'node', 'title', 'title', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
01992   db_add_index($ret, 'node', 'node_title_type', array('title', array('type', 4)));
01993   db_change_field($ret, 'node_revisions', 'title', 'title', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
01994   return $ret;
01995 }
01996
02000 function system_update_6026() {
02001   $ret = array();
02002
02003   // Notify user that new update module exists.
02004   drupal_set_message('Drupal can check periodically for important bug fixes and security releases using the new update status module. This module can be turned on from the <a href="'. url('admin/build/modules') .'">modules administration page</a>. For more information please read the <a href="http://drupal.org/handbook/modules/update">Update status handbook page</a>.');
02005
02006   return $ret;
02007 }
02008
02012 function system_update_6027() {
02013   $ret = array();
02014
02015   // Create the blocks.cache column.
02016   db_add_field($ret, 'blocks', 'cache', array('type' => 'int', 'not null' => TRUE, 'default' => 1, 'size' => 'tiny'));
02017
02018   // The cache_block table is created in update_fix_d6_requirements() since
02019   // calls to cache_clear_all() would otherwise cause warnings.
02020
02021   // Fill in the values for the new 'cache' column in the {blocks} table.
02022   foreach (module_list() as $module) {
02023     if ($module_blocks = module_invoke($module, 'block', 'list')) {
02024       foreach ($module_blocks as $delta => $block) {
02025         if (isset($block['cache'])) {
02026           db_query("UPDATE {blocks} SET cache = %d WHERE module = '%s' AND delta = %d", $block['cache'], $module, $delta);
02027         }
02028       }
02029     }
02030   }
02031
02032   return $ret;
02033 }
02034
02038 function system_update_6028() {
02039   // Removed node_load cache to discuss it more for Drupal 7.
02040   return array();
02041 }
02042
02047 function system_update_6029() {
02048   // The watchdog table is now owned by dblog, which is not yet
02049   // "installed" according to the system table, but the table already
02050   // exists.  We set the module as "installed" here to avoid an error
02051   // later.
02052   //
02053   // Although not the case for the initial D6 release, it is likely
02054   // that dblog.install will have its own update functions eventually.
02055   // However, dblog did not exist in D5 and this update is part of the
02056   // initial D6 release, so we know that dblog is not installed yet.
02057   // It is therefore correct to install it as version 0.  If
02058   // dblog updates exist, the next run of update.php will get them.
02059   drupal_set_installed_schema_version('dblog', 0);
02060   module_enable(array('dblog'));
02061   menu_rebuild();
02062   return array(array('success' => TRUE, 'query' => "'dblog' module enabled."));
02063 }
02064
02068 function system_update_6030() {
02069   $ret = array();
02070
02071   // Rename the old contrib actions table if it exists so the contrib version
02072   // of the module can do something with the old data.
02073   if (db_table_exists('actions')) {
02074     db_rename_table($ret, 'actions', 'actions_old_contrib');
02075   }
02076
02077   $schema['actions'] = array(
02078     'fields' => array(
02079       'aid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '0'),
02080       'type' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => ''),
02081       'callback' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
02082       'parameters' => array('type' => 'text', 'not null' => TRUE, 'size' => 'big'),
02083       'description' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '0'),
02084     ),
02085     'primary key' => array('aid'),
02086   );
02087
02088   $schema['actions_aid'] = array(
02089     'fields' => array(
02090       'aid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
02091     ),
02092     'primary key' => array('aid'),
02093   );
02094
02095   db_create_table($ret, 'actions', $schema['actions']);
02096   db_create_table($ret, 'actions_aid', $schema['actions_aid']);
02097
02098   return $ret;
02099 }
02100
02105 function system_update_6031() {
02106   return array();
02107 }
02108
02113 function system_update_6032() {
02114   $ret = array();
02115   if (db_table_exists('profile_fields')) {
02116     db_drop_unique_key($ret, 'profile_fields', 'name');
02117     db_change_field($ret, 'profile_fields', 'name', 'name', array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''));
02118     db_add_unique_key($ret, 'profile_fields', 'name', array('name'));
02119   }
02120   return $ret;
02121 }
02122
02126 function system_update_6033() {
02127   $ret = array();
02128   if (db_table_exists('node_comment_statistics')) {
02129     // On pgsql but not mysql, db_change_field() drops all keys
02130     // involving the changed field, which in this case is the primary
02131     // key.  The normal approach is explicitly drop the pkey, change the
02132     // field, and re-create the pkey.
02133     //
02134     // Unfortunately, in this case that won't work on mysql; we CANNOT
02135     // drop the pkey because on mysql auto-increment fields must be
02136     // included in at least one key or index.
02137     //
02138     // Since we cannot drop the pkey before db_change_field(), after
02139     // db_change_field() we may or may not still have a pkey.  The
02140     // simple way out is to re-create the pkey only when using pgsql.
02141     // Realistic requirements trump idealistic purity.
02142     db_change_field($ret, 'node_comment_statistics', 'nid', 'nid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
02143     if ($GLOBALS['db_type'] == 'pgsql') {
02144       db_add_primary_key($ret, 'node_comment_statistics', array('nid'));
02145     }
02146   }
02147   return $ret;
02148 }
02149
02153 function system_update_6034() {
02154   $ret = array();
02155   $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
02156   while ($role = db_fetch_object($result)) {
02157     $renamed_permission = preg_replace('/administer access control/', 'administer permissions', $role->perm);
02158     if ($renamed_permission != $role->perm) {
02159       $ret[] = update_sql("UPDATE {permission} SET perm = '$renamed_permission' WHERE rid = $role->rid");
02160     }
02161   }
02162   return $ret;
02163 }
02164
02168 function system_update_6035() {
02169   $ret = array();
02170   db_drop_index($ret, 'system', 'weight');
02171   db_add_index($ret, 'system', 'modules', array(array('type', 12), 'status', 'weight', 'filename'));
02172   db_add_index($ret, 'system', 'bootstrap', array(array('type', 12), 'status', 'bootstrap', 'weight', 'filename'));
02173   return $ret;
02174 }
02175
02184 function system_update_6036() {
02185   $ret = array();
02186   if (db_table_exists('search_index')) {
02187     // Create the search_dataset.reindex column.
02188     db_add_field($ret, 'search_dataset', 'reindex', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
02189
02190     // Drop the search_index.from fields which are no longer used.
02191     db_drop_index($ret, 'search_index', 'from_sid_type');
02192     db_drop_field($ret, 'search_index', 'fromsid');
02193     db_drop_field($ret, 'search_index', 'fromtype');
02194
02195     // Drop the search_dataset.sid_type index, so that it can be made unique.
02196     db_drop_index($ret, 'search_dataset', 'sid_type');
02197
02198     // Create the search_node_links Table.
02199     $search_node_links_schema = array(
02200       'fields' => array(
02201         'sid'      => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
02202         'type'     => array('type' => 'varchar', 'length' => 16, 'not null' => TRUE, 'default' => ''),
02203         'nid'      => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
02204         'caption'    => array('type' => 'text', 'size' => 'big', 'not null' => FALSE),
02205       ),
02206       'primary key' => array('sid', 'type', 'nid'),
02207       'indexes' => array('nid' => array('nid')),
02208     );
02209     db_create_table($ret, 'search_node_links', $search_node_links_schema);
02210
02211     // with the change to search_dataset.reindex, the search queue is handled differently,
02212     // and this is no longer needed
02213     variable_del('node_cron_last');
02214
02215     // Add a unique index for the search_index.
02216     if ($GLOBALS['db_type'] == 'mysql' || $GLOBALS['db_type'] == 'mysqli') {
02217       // Since it's possible that some existing sites have duplicates,
02218       // create the index using the IGNORE keyword, which ignores duplicate errors.
02219       // However, pgsql doesn't support it
02220       $ret[] = update_sql("ALTER IGNORE TABLE {search_index} ADD UNIQUE KEY word_sid_type (word, sid, type)");
02221       $ret[] = update_sql("ALTER IGNORE TABLE {search_dataset} ADD UNIQUE KEY sid_type (sid, type)");
02222
02223       // Everything needs to be reindexed.
02224       $ret[] = update_sql("UPDATE {search_dataset} SET reindex = 1");
02225     }
02226     else {
02227       // Delete the existing tables if there are duplicate values
02228       if (db_result(db_query("SELECT sid FROM {search_dataset} GROUP BY sid, type HAVING COUNT(*) > 1")) || db_result(db_query("SELECT sid FROM {search_index} GROUP BY word, sid, type HAVING COUNT(*) > 1"))) {
02229         $ret[] = update_sql('DELETE FROM {search_dataset}');
02230         $ret[] = update_sql('DELETE FROM {search_index}');
02231         $ret[] = update_sql('DELETE FROM {search_total}');
02232       }
02233       else {
02234         // Everything needs to be reindexed.
02235         $ret[] = update_sql("UPDATE {search_dataset} SET reindex = 1");
02236       }
02237
02238       // create the new indexes
02239       db_add_unique_key($ret, 'search_index', 'word_sid_type', array('word', 'sid', 'type'));
02240       db_add_unique_key($ret, 'search_dataset', 'sid_type', array('sid', 'type'));
02241     }
02242   }
02243   return $ret;
02244 }
02245
02249 function system_update_6037() {
02250   $ret = array();
02251   db_change_field($ret, 'blocks', 'region', 'region', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''));
02252   $ret[] = update_sql("UPDATE {blocks} SET region = '' WHERE status = 0");
02253   return $ret;
02254 }
02255
02259 function system_update_6038() {
02260   $ret = array();
02261   if (db_table_exists('profile_fields')) {
02262     $ret[] = update_sql("UPDATE {profile_fields} SET category = 'Account settings' WHERE LOWER(category) = 'account'");
02263     if ($affectedrows = db_affected_rows()) {
02264       drupal_set_message('There were '. $affectedrows .' profile fields that used a reserved category name. They have been assigned to the category "Account settings".');
02265     }
02266   }
02267   return $ret;
02268 }
02269
02275 function system_update_6039() {
02276   $ret = array();
02277   $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
02278   while ($role = db_fetch_object($result)) {
02279     $renamed_permission = preg_replace('/(?<=^|,\ )edit\ ([a-zA-Z0-9_\-]+)\ content(?=,|$)/', 'edit any $1 content', $role->perm);
02280     $renamed_permission = preg_replace('/(?<=^|,\ )create\ polls(?=,|$)/', 'create poll content', $renamed_permission);
02281     if ($renamed_permission != $role->perm) {
02282       $ret[] = update_sql("UPDATE {permission} SET perm = '$renamed_permission' WHERE rid = $role->rid");
02283     }
02284   }
02285   return $ret;
02286 }
02287
02291 function system_update_6040() {
02292   $ret = array();
02293   if (db_table_exists('upload')) {
02294     db_add_field($ret, 'upload', 'weight', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny'));
02295   }
02296   return $ret;
02297 }
02298
02302 function system_update_6041() {
02303   $weight = intval((db_result(db_query("SELECT weight FROM {system} WHERE name = 'taxonomy'"))) + 1);
02304   $ret = array();
02305   $vid = intval(variable_get('forum_nav_vocabulary', ''));
02306   if (db_table_exists('vocabulary') && $vid) {
02307     $ret[] = update_sql("UPDATE {vocabulary} SET required = 0 WHERE vid = " . $vid);
02308     $ret[] = update_sql("UPDATE {system} SET weight = ". $weight ." WHERE name = 'forum'");
02309   }
02310   return $ret;
02311 }
02312
02316 function system_update_6042() {
02317   foreach (list_themes() as $theme) {
02318     $stylesheet = variable_get('color_'. $theme->name .'_stylesheet', NULL);
02319     if (!empty($stylesheet)) {
02320       variable_set('color_'. $theme->name .'_stylesheets', array($stylesheet));
02321       variable_del('color_'. $theme->name .'_stylesheet');
02322     }
02323   }
02324   return array();
02325 }
02326
02330 function system_update_6043() {
02331   $ret = array();
02332   // Required modules first.
02333   // Add new system module indexes.
02334   db_add_index($ret, 'flood', 'allow', array('event', 'hostname', 'timestamp'));
02335   db_add_index($ret, 'history', 'nid', array('nid'));
02336   // Change length of theme field in {blocks} to be consistent with module, and
02337   // to avoid a MySQL error regarding a too-long index.  Also add new indices.
02338   db_change_field($ret, 'blocks', 'theme', 'theme', array('type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => ''),array(
02339                   'unique keys' => array('tmd' => array('theme', 'module', 'delta'),),
02340                   'indexes' => array('list' => array('theme', 'status', 'region', 'weight', 'module'),),));
02341   db_add_index($ret, 'blocks_roles', 'rid', array('rid'));
02342   // Improve filter module indices.
02343   db_drop_index($ret, 'filters', 'weight');
02344   db_add_unique_key($ret, 'filters', 'fmd', array('format', 'module', 'delta'));
02345   db_add_index($ret, 'filters', 'list', array('format', 'weight', 'module', 'delta'));
02346   // Drop unneeded keys form the node table.
02347   db_drop_index($ret, 'node', 'status');
02348   db_drop_unique_key($ret, 'node', 'nid_vid');
02349   // Improve user module indices.
02350   db_add_index($ret, 'users', 'mail', array('mail'));
02351   db_add_index($ret, 'users_roles', 'rid', array('rid'));
02352
02353   // Optional modules - need to check if the tables exist.
02354   // Alter aggregator module's tables primary keys to make them more useful.
02355   if (db_table_exists('aggregator_category_feed')) {
02356     db_drop_primary_key($ret, 'aggregator_category_feed');
02357     db_add_primary_key($ret, 'aggregator_category_feed', array('cid', 'fid'));
02358     db_add_index($ret, 'aggregator_category_feed', 'fid', array('fid'));
02359   }
02360   if (db_table_exists('aggregator_category_item')) {
02361     db_drop_primary_key($ret, 'aggregator_category_item');
02362     db_add_primary_key($ret, 'aggregator_category_item', array('cid', 'iid'));
02363     db_add_index($ret, 'aggregator_category_item', 'iid', array('iid'));
02364   }
02365   // Alter contact module's table to add an index.
02366   if (db_table_exists('contact')) {
02367     db_add_index($ret, 'contact', 'list', array('weight', 'category'));
02368   }
02369   // Alter locale table to add a primary key, drop an index.
02370   if (db_table_exists('locales_target')) {
02371     db_add_primary_key($ret, 'locales_target', array('language', 'lid', 'plural'));
02372   }
02373   // Alter a poll module table to add a primary key.
02374   if (db_table_exists('poll_votes')) {
02375     db_drop_index($ret, 'poll_votes', 'nid');
02376     db_add_primary_key($ret, 'poll_votes', array('nid', 'uid', 'hostname'));
02377   }
02378   // Alter a profile module table to add a primary key.
02379   if (db_table_exists('profile_values')) {
02380     db_drop_index($ret, 'profile_values', 'uid');
02381     db_drop_index($ret, 'profile_values', 'fid');
02382     db_change_field($ret,'profile_values' ,'fid', 'fid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0,), array('indexes' => array('fid' => array('fid'),)));
02383     db_change_field($ret,'profile_values' ,'uid', 'uid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0,));
02384     db_add_primary_key($ret, 'profile_values', array('uid', 'fid'));
02385   }
02386   // Alter a statistics module table to add an index.
02387   if (db_table_exists('accesslog')) {
02388     db_add_index($ret, 'accesslog', 'uid', array('uid'));
02389   }
02390   // Alter taxonomy module's tables.
02391   if (db_table_exists('term_data')) {
02392     db_drop_index($ret, 'term_data', 'vid');
02393     db_add_index($ret, 'term_data', 'vid_name', array('vid', 'name'));
02394     db_add_index($ret, 'term_data', 'taxonomy_tree', array('vid', 'weight', 'name'));
02395   }
02396   if (db_table_exists('term_node')) {
02397     db_drop_primary_key($ret, 'term_node');
02398     db_drop_index($ret, 'term_node', 'tid');
02399     db_add_primary_key($ret, 'term_node', array('tid', 'vid'));
02400   }
02401   if (db_table_exists('term_relation')) {
02402     db_drop_index($ret, 'term_relation', 'tid1');
02403     db_add_unique_key($ret, 'term_relation', 'tid1_tid2', array('tid1', 'tid2'));
02404   }
02405   if (db_table_exists('term_synonym')) {
02406     db_drop_index($ret, 'term_synonym', 'name');
02407     db_add_index($ret, 'term_synonym', 'name_tid', array('name', 'tid'));
02408   }
02409   if (db_table_exists('vocabulary')) {
02410     db_add_index($ret, 'vocabulary', 'list', array('weight', 'name'));
02411   }
02412   if (db_table_exists('vocabulary_node_types')) {
02413     db_drop_primary_key($ret, 'vocabulary_node_types');
02414     db_add_primary_key($ret, 'vocabulary_node_types', array('type', 'vid'));
02415     db_add_index($ret, 'vocabulary_node_types', 'vid', array('vid'));
02416   }
02417   // If we updated in RC1 or before ensure we don't update twice.
02418   variable_set('system_update_6043_RC2', TRUE);
02419
02420   return $ret;
02421 }
02422
02426 function system_update_6044() {
02427   $ret = array();
02428
02429   // Delete invalid entries in {term_node} after system_update_6001.
02430   $ret[] = update_sql("DELETE FROM {term_node} WHERE vid = 0");
02431
02432   // Only execute the rest of this function if 6043 was run in RC1 or before.
02433   if (variable_get('system_update_6043_RC2', FALSE)) {
02434     variable_del('system_update_6043_RC2');
02435     return $ret;
02436   }
02437
02438   // User module indices.
02439   db_drop_unique_key($ret, 'users', 'mail');
02440   db_add_index($ret, 'users', 'mail', array('mail'));
02441
02442   // Optional modules - need to check if the tables exist.
02443   // Alter taxonomy module's tables.
02444   if (db_table_exists('term_data')) {
02445     db_drop_unique_key($ret, 'term_data', 'vid_name');
02446     db_add_index($ret, 'term_data', 'vid_name', array('vid', 'name'));
02447   }
02448   if (db_table_exists('term_synonym')) {
02449     db_drop_unique_key($ret, 'term_synonym', 'name_tid', array('name', 'tid'));
02450     db_add_index($ret, 'term_synonym', 'name_tid', array('name', 'tid'));
02451   }
02452
02453   return $ret;
02454 }
02455
02472 function system_update_6045() {
02473   $ret = array();
02474   $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
02475   while ($role = db_fetch_object($result)) {
02476     $renamed_permission = preg_replace('/(?<=^|,\ )edit\ own\ blog(?=,|$)/', 'create blog entries, edit own blog entries', $role->perm);
02477     $renamed_permission = preg_replace('/(?<=^|,\ )edit\ book\ content(?=,|$)/', 'edit any book content', $renamed_permission);
02478     $renamed_permission = preg_replace('/(?<=^|,\ )administer\ locales(?=,|$)/', 'administer languages, translate interface', $renamed_permission);
02479     if ($renamed_permission != $role->perm) {
02480       $ret[] = update_sql("UPDATE {permission} SET perm = '$renamed_permission' WHERE rid = $role->rid");
02481     }
02482   }
02483
02484   // Notify user that delete permissions may have been changed. This was in
02485   // effect since system_update_6039(), but there was no user notice.
02486   drupal_set_message('Drupal now has separate edit and delete permissions. Previously, users who were able to edit content were automatically allowed to delete it. For added security, delete permissions for individual core content types have been <strong>removed</strong> from all roles on your site (only roles with the "administer nodes" permission can now delete these types of content). If you would like to reenable any individual delete permissions, you can do this at the <a href="'. url('admin/user/permissions', array('fragment' => 'module-node')) .'">permissions page</a>.');
02487   return $ret;
02488 }
02489
02495 function system_update_6046() {
02496   $ret = array();
02497   if (!variable_get('file_directory_path', FALSE)) {
02498     variable_set('file_directory_path', 'files');
02499     $ret[] = array('success' => TRUE, 'query' => "variable_set('file_directory_path')");
02500   }
02501   return $ret;
02502 }
02503
02507 function system_update_6047() {
02508   $ret = array();
02509   $ret[] = update_sql("UPDATE {blocks} SET cache = -1 WHERE module = 'user' AND delta IN ('0', '1')");
02510   $ret[] = update_sql("UPDATE {blocks} SET cache = -1 WHERE module = 'system' AND delta = '0'");
02511   return $ret;
02512 }
02513
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/system/system.module Source File

modules » system

system.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: system.module,v 1.585.2.4 2008/02/08 23:23:19 goba Exp $
00003
00012 define('VERSION', '6.0-dev');
00013
00017 define('DRUPAL_CORE_COMPATIBILITY', '6.x');
00018
00022 define('DRUPAL_MINIMUM_PHP',    '4.3.5');
00023
00027 define('DRUPAL_MINIMUM_PHP_MEMORY_LIMIT',    '16M');
00028
00032 define('DRUPAL_MINIMUM_MYSQL',  '4.1.1');
00033
00037 define('DRUPAL_MINIMUM_PGSQL',  '7.4');
00038
00042 define('DRUPAL_MAXIMUM_TEMP_FILE_AGE', 1440);
00043
00047 function system_help($path, $arg) {
00048   global $base_url;
00049
00050   switch ($path) {
00051     case 'admin/help#system':
00052       $output = '<p>'. t('The system module is at the foundation of your Drupal website, and provides basic but extensible functionality for use by other modules and themes. Some integral elements of Drupal are contained in and managed by the system module, including caching, enabling or disabling of modules and themes, preparing and displaying the administrative page, and configuring fundamental site settings. A number of key system maintenance operations are also part of the system module.') .'</p>';
00053       $output .= '<p>'. t('The system module provides:') .'</p>';
00054       $output .= '<ul><li>'. t('support for enabling and disabling <a href="@modules">modules</a>. Drupal comes packaged with a number of core modules; each module provides a discrete set of features and may be enabled depending on the needs of your site. A wide array of additional modules contributed by members of the Drupal community are available for download at the <a href="@drupal-modules">Drupal.org module page</a>.', array('@modules' => url('admin/build/modules'), '@drupal-modules' => 'http://drupal.org/project/modules')) .'</li>';
00055       $output .= '<li>'. t('support for enabling and disabling <a href="@themes">themes</a>, which determine the design and presentation of your site. Drupal comes packaged with several core themes and additional contributed themes are available at the <a href="@drupal-themes">Drupal.org theme page</a>.', array('@themes' => url('admin/build/themes'), '@drupal-themes' => 'http://drupal.org/project/themes')) .'</li>';
00056       $output .= '<li>'. t('a robust <a href="@cache-settings">caching system</a> that allows the efficient re-use of previously-constructed web pages and web page components. Drupal stores the pages requested by anonymous users in a compressed format; depending on your site configuration and the amount of your web traffic tied to anonymous visitors, Drupal\'s caching system may significantly increase the speed of your site.', array('@cache-settings' => url('admin/settings/performance'))) .'</li>';
00057       $output .= '<li>'. t('a set of routine administrative operations that rely on a correctly-configured <a href="@cron">cron maintenance task</a> to run automatically. A number of other modules, including the feed aggregator, ping module and search also rely on <a href="@cron">cron maintenance tasks</a>. For more information, see the online handbook entry for <a href="@handbook">configuring cron jobs</a>.', array('@cron' => url('admin/reports/status'), '@handbook' => 'http://drupal.org/cron')) .'</li>';
00058       $output .= '<li>'. t('basic configuration options for your site, including <a href="@date-settings">date and time settings</a>, <a href="@file-system">file system settings</a>, <a href="@clean-url">clean URL support</a>, <a href="@site-info">site name and other information</a>, and a <a href="@site-maintenance">site maintenance</a> function for taking your site temporarily off-line.', array('@date-settings' => url('admin/settings/date-time'), '@file-system' => url('admin/settings/file-system'), '@clean-url' => url('admin/settings/clean-urls'), '@site-info' => url('admin/settings/site-information'), '@site-maintenance' => url('admin/settings/site-maintenance'))) .'</li></ul>';
00059       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@system">System module</a>.', array('@system' => 'http://drupal.org/handbook/modules/system/')) .'</p>';
00060       return $output;
00061     case 'admin':
00062       return '<p>'. t('Welcome to the administration section. Here you may control how your site functions.') .'</p>';
00063     case 'admin/by-module':
00064       return '<p>'. t('This page shows you all available administration tasks for each module.') .'</p>';
00065     case 'admin/build/themes':
00066       $output = '<p>'. t('Select which themes are available to your users and specify the default theme. To configure site-wide display settings, click the "configure" task above. Alternatively, to override these settings in a specific theme, click the "configure" link for that theme. Note that different themes may have different regions available for displaying content; for consistency in presentation, you may wish to enable only one theme.') .'</p>';
00067       $output .= '<p>'. t('To change the appearance of your site, a number of <a href="@themes">contributed themes</a> are available.', array('@themes' => 'http://drupal.org/project/themes')) .'</p>';
00068       return $output;
00069     case 'admin/build/themes/settings/'. $arg[4]:
00070       $reference = explode('.', $arg[4], 2);
00071       $theme = array_pop($reference);
00072       return '<p>'. t('These options control the display settings for the <code>%template</code> theme. When your site is displayed using this theme, these settings will be used. By clicking "Reset to defaults," you can choose to use the <a href="@global">global settings</a> for this theme.', array('%template' => $theme, '@global' => url('admin/build/themes/settings'))) .'</p>';
00073     case 'admin/build/themes/settings':
00074       return '<p>'. t('These options control the default display settings for your entire site, across all themes. Unless they have been overridden by a specific theme, these settings will be used.') .'</p>';
00075     case 'admin/build/modules':
00076       $output = '<p>'. t('Modules are plugins that extend Drupal\'s core functionality. Enable modules by selecting the <em>Enabled</em> checkboxes below and clicking the <em>Save configuration</em> button. Once a module is enabled, new <a href="@permissions">permissions</a> may be available. To reduce server load, modules with their <em>Throttle</em> checkbox selected are temporarily disabled when your site becomes extremely busy. (Note that the <em>Throttle</em> checkbox is only available if the Throttle module is enabled.)', array('@permissions' => url('admin/user/permissions')));
00077       if (module_exists('throttle')) {
00078         $output .= ' '. t('The auto-throttle functionality must be enabled on the <a href="@throttle">throttle configuration page</a> after having enabled the throttle module.', array('@throttle' => url('admin/settings/throttle')));
00079       }
00080       $output .= '</p>';
00081       $output .= '<p>'. t('It is important that <a href="@update-php">update.php</a> is run every time a module is updated to a newer version.', array('@update-php' => $base_url .'/update.php')) .'</p>';
00082       $output .= '<p>'. t('You can find all administration tasks belonging to a particular module on the <a href="@by-module">administration by module page</a>.', array('@by-module' => url('admin/by-module'))) .'</p>';
00083       $output .= '<p>'. t('To extend the functionality of your site, a number of <a href="@modules">contributed modules</a> are available.', array('@modules' => 'http://drupal.org/project/modules')) .'</p>';
00084       return $output;
00085     case 'admin/build/modules/uninstall':
00086       return '<p>'. t('The uninstall process removes all data related to a module. To uninstall a module, you must first disable it. Not all modules support this feature.') .'</p>';
00087     case 'admin/build/block/configure':
00088       if ($arg[4] == 'system' && $arg[5] == 0) {
00089         return '<p>'. t('The <em>Powered by Drupal</em> block is an optional link to the home page of the Drupal project. While there is absolutely no requirement that sites feature this link, it may be used to show support for Drupal.') .'</p>';
00090       }
00091       break;
00092     case 'admin/settings/actions':
00093     case 'admin/settings/actions/manage':
00094       $output = '<p>'. t('Actions are individual tasks that the system can do, such as unpublishing a piece of content or banning a user. Modules, such as the trigger module, can fire these actions when certain system events happen; for example, when a new post is added or when a user logs in. Modules may also provide additional actions.') .'</p>';
00095       $output .= '<p>'. t('There are two types of actions: simple and advanced. Simple actions do not require any additional configuration, and are listed here automatically. Advanced actions can do more than simple actions; for example, send an e-mail to a specified address, or check for certain words within a piece of content. These actions need to be created and configured first before they may be used. To create an advanced action, select the action from the drop-down below and click the <em>Create</em> button.') .'</p>';
00096       if (module_exists('trigger')) {
00097         $output .= '<p>'. t('You may proceed to the <a href="@url">Triggers</a> page to assign these actions to system events.', array('@url' => url('admin/build/trigger'))) .'</p>';
00098       }
00099       return $output;
00100     case 'admin/settings/actions/configure':
00101       return t('An advanced action offers additional configuration options which may be filled out below. Changing the <em>Description</em> field is recommended, in order to better identify the precise action taking place. This description will be displayed in modules such as the trigger module when assigning actions to system events, so it is best if it is as descriptive as possible (for example, "Send e-mail to Moderation Team" rather than simply "Send e-mail").');
00102     case 'admin/reports/status':
00103       return '<p>'. t("Here you can find a short overview of your site's parameters as well as any problems detected with your installation. It may be useful to copy and paste this information into support requests filed on drupal.org's support forums and project issue queues.") .'</p>';
00104   }
00105 }
00106
00110 function system_theme() {
00111   return array_merge(drupal_common_theme(), array(
00112     'system_theme_select_form' => array(
00113       'arguments' => array('form' => NULL),
00114       'file' => 'system.admin.inc',
00115     ),
00116     'system_themes_form' => array(
00117       'arguments' => array('form' => NULL),
00118       'file' => 'system.admin.inc',
00119     ),
00120     'system_modules' => array(
00121       'arguments' => array('form' => NULL),
00122       'file' => 'system.admin.inc',
00123     ),
00124     'system_modules_uninstall' => array(
00125       'arguments' => array('form' => NULL),
00126       'file' => 'system.admin.inc',
00127     ),
00128     'status_report' => array(
00129       'arguments' => array('requirements' => NULL),
00130       'file' => 'system.admin.inc',
00131     ),
00132     'admin_page' => array(
00133       'arguments' => array('blocks' => NULL),
00134       'file' => 'system.admin.inc',
00135     ),
00136     'admin_block' => array(
00137       'arguments' => array('block' => NULL),
00138       'file' => 'system.admin.inc',
00139     ),
00140     'admin_block_content' => array(
00141       'arguments' => array('content' => NULL),
00142       'file' => 'system.admin.inc',
00143     ),
00144     'system_admin_by_module' => array(
00145       'arguments' => array('menu_items' => NULL),
00146       'file' => 'system.admin.inc',
00147     ),
00148     'system_powered_by' => array(
00149       'arguments' => array('image_path' => NULL),
00150     ),
00151   ));
00152 }
00153
00157 function system_perm() {
00158   return array('administer site configuration', 'access administration pages', 'administer actions', 'access site reports', 'select different theme', 'administer files');
00159 }
00160
00164 function system_elements() {
00165   // Top level form
00166   $type['form'] = array('#method' => 'post', '#action' => request_uri());
00167
00168   // Inputs
00169   $type['submit'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => TRUE, '#process' => array('form_expand_ahah'));
00170   $type['button'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => FALSE, '#process' => array('form_expand_ahah'));
00171   $type['image_button'] = array('#input' => TRUE, '#button_type' => 'submit', '#executes_submit_callback' => TRUE, '#process' => array('form_expand_ahah'), '#return_value' => TRUE, '#has_garbage_value' => TRUE, '#src' => NULL);
00172   $type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE, '#process' => array('form_expand_ahah'));
00173   $type['password'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#process' => array('form_expand_ahah'));
00174   $type['password_confirm'] = array('#input' => TRUE, '#process' => array('expand_password_confirm'));
00175   $type['textarea'] = array('#input' => TRUE, '#cols' => 60, '#rows' => 5, '#resizable' => TRUE, '#process' => array('form_expand_ahah'));
00176   $type['radios'] = array('#input' => TRUE, '#process' => array('expand_radios'));
00177   $type['radio'] = array('#input' => TRUE, '#default_value' => NULL, '#process' => array('form_expand_ahah'));
00178   $type['checkboxes'] = array('#input' => TRUE, '#process' => array('expand_checkboxes'), '#tree' => TRUE);
00179   $type['checkbox'] = array('#input' => TRUE, '#return_value' => 1, '#process' => array('form_expand_ahah'));
00180   $type['select'] = array('#input' => TRUE, '#size' => 0, '#multiple' => FALSE, '#process' => array('form_expand_ahah'));
00181   $type['weight'] = array('#input' => TRUE, '#delta' => 10, '#default_value' => 0, '#process' => array('process_weight', 'form_expand_ahah'));
00182   $type['date'] = array('#input' => TRUE, '#process' => array('expand_date'), '#element_validate' => array('date_validate'));
00183   $type['file'] = array('#input' => TRUE, '#size' => 60);
00184
00185   // Form structure
00186   $type['item'] = array('#value' => '');
00187   $type['hidden'] = array('#input' => TRUE, '#process' => array('form_expand_ahah'));
00188   $type['value'] = array('#input' => TRUE);
00189   $type['markup'] = array('#prefix' => '', '#suffix' => '');
00190   $type['fieldset'] = array('#collapsible' => FALSE, '#collapsed' => FALSE, '#value' => NULL, '#process' => array('form_expand_ahah'));
00191   $type['token'] = array('#input' => TRUE);
00192   return $type;
00193 }
00194
00198 function system_menu() {
00199   $items['system/files'] = array(
00200     'title' => 'File download',
00201     'page callback' => 'file_download',
00202     'access callback' => TRUE,
00203     'type' => MENU_CALLBACK,
00204   );
00205   $items['admin'] = array(
00206     'title' => 'Administer',
00207     'access arguments' => array('access administration pages'),
00208     'page callback' => 'system_main_admin_page',
00209     'weight' => 9,
00210     'file' => 'system.admin.inc',
00211   );
00212   $items['admin/compact'] = array(
00213     'title' => 'Compact mode',
00214     'page callback' => 'system_admin_compact_page',
00215     'type' => MENU_CALLBACK,
00216     'file' => 'system.admin.inc',
00217   );
00218   $items['admin/by-task'] = array(
00219     'title' => 'By task',
00220     'page callback' => 'system_main_admin_page',
00221     'file' => 'system.admin.inc',
00222     'type' => MENU_DEFAULT_LOCAL_TASK,
00223   );
00224   $items['admin/by-module'] = array(
00225     'title' => 'By module',
00226     'page callback' => 'system_admin_by_module',
00227     'file' => 'system.admin.inc',
00228     'type' => MENU_LOCAL_TASK,
00229     'weight' => 2,
00230   );
00231   $items['admin/content'] = array(
00232     'title' => 'Content management',
00233     'description' => "Manage your site's content.",
00234     'position' => 'left',
00235     'weight' => -10,
00236     'page callback' => 'system_admin_menu_block_page',
00237     'file' => 'system.admin.inc',
00238   );
00239
00240   // menu items that are basically just menu blocks
00241   $items['admin/settings'] = array(
00242     'title' => 'Site configuration',
00243     'description' => 'Adjust basic site configuration options.',
00244     'position' => 'right',
00245     'weight' => -5,
00246     'page callback' => 'system_settings_overview',
00247     'file' => 'system.admin.inc',
00248   );
00249   $items['admin/build'] = array(
00250     'title' => 'Site building',
00251     'description' => 'Control how your site looks and feels.',
00252     'position' => 'right',
00253     'weight' => -10,
00254     'page callback' => 'system_admin_menu_block_page',
00255     'file' => 'system.admin.inc',
00256   );
00257   $items['admin/settings/admin'] = array(
00258     'title' => 'Administration theme',
00259     'description' => 'Settings for how your administrative pages should look.',
00260     'position' => 'left',
00261     'page callback' => 'drupal_get_form',
00262     'page arguments' => array('system_admin_theme_settings'),
00263     'access arguments' => array('administer site configuration'),
00264     'block callback' => 'system_admin_theme_settings',
00265     'file' => 'system.admin.inc',
00266   );
00267   // Themes:
00268   $items['admin/build/themes'] = array(
00269     'title' => 'Themes',
00270     'description' => 'Change which theme your site uses or allows users to set.',
00271     'page callback' => 'drupal_get_form',
00272     'page arguments' => array('system_themes_form', NULL),
00273     'access arguments' => array('administer site configuration'),
00274     'file' => 'system.admin.inc',
00275   );
00276   $items['admin/build/themes/select'] = array(
00277     'title' => 'List',
00278     'description' => 'Select the default theme.',
00279     'type' => MENU_DEFAULT_LOCAL_TASK,
00280     'weight' => -1,
00281   );
00282   $items['admin/build/themes/settings'] = array(
00283     'title' => 'Configure',
00284     'page arguments' => array('system_theme_settings'),
00285     'type' => MENU_LOCAL_TASK,
00286   );
00287   // Theme configuration subtabs
00288   $items['admin/build/themes/settings/global'] = array(
00289     'title' => 'Global settings',
00290     'type' => MENU_DEFAULT_LOCAL_TASK,
00291     'weight' => -1,
00292   );
00293
00294   foreach (list_themes() as $theme) {
00295     $items['admin/build/themes/settings/'. $theme->name] = array(
00296       'title' => $theme->info['name'],
00297       'page arguments' => array('system_theme_settings', $theme->name),
00298       'type' => MENU_LOCAL_TASK,
00299       'access callback' => '_system_themes_access',
00300       'access arguments' => array($theme),
00301     );
00302   }
00303
00304   // Modules:
00305   $items['admin/build/modules'] = array(
00306     'title' => 'Modules',
00307     'description' => 'Enable or disable add-on modules for your site.',
00308     'page callback' => 'drupal_get_form',
00309     'page arguments' => array('system_modules'),
00310     'access arguments' => array('administer site configuration'),
00311     'file' => 'system.admin.inc',
00312   );
00313   $items['admin/build/modules/list'] = array(
00314     'title' => 'List',
00315     'type' => MENU_DEFAULT_LOCAL_TASK,
00316   );
00317   $items['admin/build/modules/list/confirm'] = array(
00318     'title' => 'List',
00319     'type' => MENU_CALLBACK,
00320   );
00321   $items['admin/build/modules/uninstall'] = array(
00322     'title' => 'Uninstall',
00323     'page arguments' => array('system_modules_uninstall'),
00324     'type' => MENU_LOCAL_TASK,
00325   );
00326   $items['admin/build/modules/uninstall/confirm'] = array(
00327     'title' => 'Uninstall',
00328     'type' => MENU_CALLBACK,
00329   );
00330
00331   // Actions:
00332   $items['admin/settings/actions'] = array(
00333     'title' => 'Actions',
00334     'description' => 'Manage the actions defined for your site.',
00335     'access arguments' => array('administer actions'),
00336     'page callback' => 'system_actions_manage'
00337   );
00338   $items['admin/settings/actions/manage'] = array(
00339     'title' => 'Manage actions',
00340     'description' => 'Manage the actions defined for your site.',
00341     'page callback' => 'system_actions_manage',
00342     'type' => MENU_DEFAULT_LOCAL_TASK,
00343     'weight' => -2,
00344   );
00345   $items['admin/settings/actions/configure'] = array(
00346     'title' => 'Configure an advanced action',
00347     'page callback' => 'drupal_get_form',
00348     'page arguments' => array('system_actions_configure'),
00349     'type' => MENU_CALLBACK,
00350   );
00351   $items['admin/settings/actions/delete/%actions'] = array(
00352     'title' => 'Delete action',
00353     'description' => 'Delete an action.',
00354     'page callback' => 'drupal_get_form',
00355     'page arguments' => array('system_actions_delete_form', 4),
00356     'type' => MENU_CALLBACK,
00357   );
00358   $items['admin/settings/actions/orphan'] = array(
00359     'title' => 'Remove orphans',
00360     'page callback' => 'system_actions_remove_orphans',
00361     'type' => MENU_CALLBACK,
00362   );
00363
00364   // Settings:
00365   $items['admin/settings/site-information'] = array(
00366     'title' => 'Site information',
00367     'description' => 'Change basic site information, such as the site name, slogan, e-mail address, mission, front page and more.',
00368     'page callback' => 'drupal_get_form',
00369     'page arguments' => array('system_site_information_settings'),
00370     'access arguments' => array('administer site configuration'),
00371     'file' => 'system.admin.inc',
00372   );
00373   $items['admin/settings/error-reporting'] = array(
00374     'title' => 'Error reporting',
00375     'description' => 'Control how Drupal deals with errors including 403/404 errors as well as PHP error reporting.',
00376     'page callback' => 'drupal_get_form',
00377     'page arguments' => array('system_error_reporting_settings'),
00378     'access arguments' => array('administer site configuration'),
00379     'file' => 'system.admin.inc',
00380   );
00381   $items['admin/settings/logging'] = array(
00382     'title' => 'Logging and alerts',
00383     'description' => "Settings for logging and alerts modules. Various modules can route Drupal's system events to different destination, such as syslog, database, email, ...etc.",
00384     'page callback' => 'system_logging_overview',
00385     'access arguments' => array('administer site configuration'),
00386     'file' => 'system.admin.inc',
00387   );
00388   $items['admin/settings/performance'] = array(
00389     'title' => 'Performance',
00390     'description' => 'Enable or disable page caching for anonymous users and set CSS and JS bandwidth optimization options.',
00391     'page callback' => 'drupal_get_form',
00392     'page arguments' => array('system_performance_settings'),
00393     'access arguments' => array('administer site configuration'),
00394     'file' => 'system.admin.inc',
00395   );
00396   $items['admin/settings/file-system'] = array(
00397     'title' => 'File system',
00398     'description' => 'Tell Drupal where to store uploaded files and how they are accessed.',
00399     'page callback' => 'drupal_get_form',
00400     'page arguments' => array('system_file_system_settings'),
00401     'access arguments' => array('administer site configuration'),
00402     'file' => 'system.admin.inc',
00403   );
00404   $items['admin/settings/image-toolkit'] = array(
00405     'title' => 'Image toolkit',
00406     'description' => 'Choose which image toolkit to use if you have installed optional toolkits.',
00407     'page callback' => 'drupal_get_form',
00408     'page arguments' => array('system_image_toolkit_settings'),
00409     'access arguments' => array('administer site configuration'),
00410     'file' => 'system.admin.inc',
00411   );
00412   $items['admin/content/rss-publishing'] = array(
00413     'title' => 'RSS publishing',
00414     'description' => 'Configure the number of items per feed and whether feeds should be titles/teasers/full-text.',
00415     'page callback' => 'drupal_get_form',
00416     'page arguments' => array('system_rss_feeds_settings'),
00417     'access arguments' => array('administer site configuration'),
00418     'file' => 'system.admin.inc',
00419   );
00420   $items['admin/settings/date-time'] = array(
00421     'title' => 'Date and time',
00422     'description' => "Settings for how Drupal displays date and time, as well as the system's default timezone.",
00423     'page callback' => 'drupal_get_form',
00424     'page arguments' => array('system_date_time_settings'),
00425     'access arguments' => array('administer site configuration'),
00426     'file' => 'system.admin.inc',
00427   );
00428   $items['admin/settings/date-time/lookup'] = array(
00429     'title' => 'Date and time lookup',
00430     'type' => MENU_CALLBACK,
00431     'page callback' => 'system_date_time_lookup',
00432     'file' => 'system.admin.inc',
00433   );
00434   $items['admin/settings/site-maintenance'] = array(
00435     'title' => 'Site maintenance',
00436     'description' => 'Take the site off-line for maintenance or bring it back online.',
00437     'page callback' => 'drupal_get_form',
00438     'page arguments' => array('system_site_maintenance_settings'),
00439     'access arguments' => array('administer site configuration'),
00440     'file' => 'system.admin.inc',
00441   );
00442   $items['admin/settings/clean-urls'] = array(
00443     'title' => 'Clean URLs',
00444     'description' => 'Enable or disable clean URLs for your site.',
00445     'page callback' => 'drupal_get_form',
00446     'page arguments' => array('system_clean_url_settings'),
00447     'access arguments' => array('administer site configuration'),
00448     'file' => 'system.admin.inc',
00449   );
00450   $items['admin/settings/clean-urls/check'] = array(
00451     'title' => 'Clean URL check',
00452     'page callback' => 'drupal_json',
00453     'page arguments' => array(array('status' => TRUE)),
00454     'access callback' => TRUE,
00455     'type' => MENU_CALLBACK,
00456   );
00457   // Menu handler to test that drupal_http_request() works locally.
00458   // @see system_check_http_request()
00459   $items['admin/reports/request-test'] = array(
00460     'title' => 'Request test',
00461     'page callback' => 'printf',
00462     'page arguments' => array('request test'),
00463     'access callback' => TRUE,
00464     'type' => MENU_CALLBACK,
00465   );
00466
00467   // Reports:
00468   $items['admin/reports'] = array(
00469     'title' => 'Reports',
00470     'description' => 'View reports from system logs and other status information.',
00471     'page callback' => 'system_admin_menu_block_page',
00472     'access arguments' => array('access site reports'),
00473     'weight' => 5,
00474     'position' => 'left',
00475     'file' => 'system.admin.inc',
00476   );
00477   $items['admin/reports/status'] = array(
00478     'title' => 'Status report',
00479     'description' => "Get a status report about your site's operation and any detected problems.",
00480     'page callback' => 'system_status',
00481     'weight' => 10,
00482     'access arguments' => array('administer site configuration'),
00483     'file' => 'system.admin.inc',
00484   );
00485   $items['admin/reports/status/run-cron'] = array(
00486     'title' => 'Run cron',
00487     'page callback' => 'system_run_cron',
00488     'type' => MENU_CALLBACK,
00489     'file' => 'system.admin.inc',
00490   );
00491   $items['admin/reports/status/php'] = array(
00492     'title' => 'PHP',
00493     'page callback' => 'system_php',
00494     'type' => MENU_CALLBACK,
00495     'file' => 'system.admin.inc',
00496   );
00497   $items['admin/reports/status/sql'] = array(
00498     'title' => 'SQL',
00499     'page callback' => 'system_sql',
00500     'type' => MENU_CALLBACK,
00501     'file' => 'system.admin.inc',
00502   );
00503   // Default page for batch operations
00504   $items['batch'] = array(
00505     'page callback' => 'system_batch_page',
00506     'access callback' => TRUE,
00507     'type' => MENU_CALLBACK,
00508     'file' => 'system.admin.inc',
00509   );
00510   return $items;
00511 }
00512
00516 function _system_themes_access($theme) {
00517   return $theme->status || $theme->name == variable_get('admin_theme', '0');
00518 }
00519
00523 function system_init() {
00524   // Use the administrative theme if the user is looking at a page in the admin/* path.
00525   if (arg(0) == 'admin' || (variable_get('node_admin_theme', '0') && arg(0) == 'node' && (arg(1) == 'add' || arg(2) == 'edit'))) {
00526     global $custom_theme;
00527     $custom_theme = variable_get('admin_theme', '0');
00528     drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'module');
00529   }
00530
00531   // Add the CSS for this module.
00532   drupal_add_css(drupal_get_path('module', 'system') .'/defaults.css', 'module');
00533   drupal_add_css(drupal_get_path('module', 'system') .'/system.css', 'module');
00534   drupal_add_css(drupal_get_path('module', 'system') .'/system-menus.css', 'module');
00535 }
00536
00542 function system_user($type, $edit, &$user, $category = NULL) {
00543   if ($type == 'form' && $category == 'account') {
00544     $form['theme_select'] = system_theme_select_form(t('Selecting a different theme will change the look and feel of the site.'), isset($edit['theme']) ? $edit['theme'] : NULL, 2);
00545
00546     if (variable_get('configurable_timezones', 1)) {
00547       $zones = _system_zonelist();
00548       $form['timezone'] = array(
00549         '#type' => 'fieldset',
00550         '#title' => t('Locale settings'),
00551         '#weight' => 6,
00552         '#collapsible' => TRUE,
00553       );
00554       $form['timezone']['timezone'] = array(
00555         '#type' => 'select',
00556         '#title' => t('Time zone'),
00557         '#default_value' => strlen($edit['timezone']) ? $edit['timezone'] : variable_get('date_default_timezone', 0),
00558         '#options' => $zones,
00559         '#description' => t('Select your current local time. Dates and times throughout this site will be displayed using this time zone.'),
00560       );
00561     }
00562
00563     return $form;
00564   }
00565 }
00566
00572 function system_block($op = 'list', $delta = 0, $edit = NULL) {
00573   switch ($op) {
00574     case 'list':
00575       $blocks[0] = array(
00576         'info' => t('Powered by Drupal'),
00577         'weight' => '10',
00578          // Not worth caching.
00579         'cache' => BLOCK_NO_CACHE,
00580       );
00581       return $blocks;
00582     case 'configure':
00583       // Compile a list of fields to show
00584       $form['wrapper']['color'] = array(
00585         '#type' => 'select',
00586         '#title' => t('Badge color'),
00587         '#default_value' => variable_get('drupal_badge_color', 'powered-blue'),
00588         '#options' => array('powered-black' => t('Black'), 'powered-blue' => t('Blue'), 'powered-gray' => t('Gray')),
00589       );
00590       $form['wrapper']['size'] = array(
00591         '#type' => 'select',
00592         '#title' => t('Badge size'),
00593         '#default_value' => variable_get('drupal_badge_size', '80x15'),
00594         '#options' => array('80x15' => t('Small'), '88x31' => t('Medium'), '135x42' => t('Large')),
00595       );
00596       return $form;
00597     case 'save':
00598       variable_set('drupal_badge_color', $edit['color']);
00599       variable_set('drupal_badge_size', $edit['size']);
00600       break;
00601     case 'view':
00602       $image_path = 'misc/'. variable_get('drupal_badge_color', 'powered-blue') .'-'. variable_get('drupal_badge_size', '80x15') .'.png';
00603       $block['subject'] = NULL; // Don't display a title
00604       $block['content'] = theme('system_powered_by', $image_path);
00605       return $block;
00606   }
00607 }
00608
00615 function system_admin_menu_block($item) {
00616   $content = array();
00617   if (!isset($item['mlid'])) {
00618     $item += db_fetch_array(db_query("SELECT mlid, menu_name FROM {menu_links} ml WHERE ml.router_path = '%s' AND module = 'system'", $item['path']));
00619   }
00620   $result = db_query("
00621     SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*
00622     FROM {menu_links} ml
00623     LEFT JOIN {menu_router} m ON ml.router_path = m.path
00624     WHERE ml.plid = %d AND ml.menu_name = '%s' AND hidden = 0", $item['mlid'], $item['menu_name']);
00625   while ($item = db_fetch_array($result)) {
00626     _menu_link_translate($item);
00627     if (!$item['access']) {
00628       continue;
00629     }
00630     // The link 'description' either derived from the hook_menu 'description' or
00631     // entered by the user via menu module is saved as the title attribute.
00632     if (!empty($item['localized_options']['attributes']['title'])) {
00633       $item['description'] = $item['localized_options']['attributes']['title'];
00634     }
00635     // Prepare for sorting as in function _menu_tree_check_access().
00636     // The weight is offset so it is always positive, with a uniform 5-digits.
00637     $content[(50000 + $item['weight']) .' '. $item['title'] .' '. $item['mlid']] = $item;
00638   }
00639   ksort($content);
00640   return $content;
00641 }
00642
00646 function system_admin_theme_submit($form, &$form_state) {
00647   // If we're changing themes, make sure the theme has its blocks initialized.
00648   if ($form_state['values']['admin_theme'] && $form_state['values']['admin_theme'] != variable_get('admin_theme', '0')) {
00649     $result = db_result(db_query("SELECT COUNT(*) FROM {blocks} WHERE theme = '%s'", $form_state['values']['admin_theme']));
00650     if (!$result) {
00651       system_initialize_theme_blocks($form_state['values']['admin_theme']);
00652     }
00653   }
00654 }
00655
00668 function system_theme_select_form($description = '', $default_value = '', $weight = 0) {
00669   if (user_access('select different theme')) {
00670     $enabled = array();
00671     $themes = list_themes();
00672
00673     foreach ($themes as $theme) {
00674       if ($theme->status) {
00675         $enabled[] = $theme;
00676       }
00677     }
00678
00679     if (count($enabled) > 1) {
00680       ksort($enabled);
00681
00682       $form['themes'] = array(
00683         '#type' => 'fieldset',
00684         '#title' => t('Theme configuration'),
00685         '#description' => $description,
00686         '#collapsible' => TRUE,
00687         '#theme' => 'system_theme_select_form'
00688       );
00689
00690       foreach ($enabled as $info) {
00691         // For the default theme, revert to an empty string so the user's theme updates when the site theme is changed.
00692         $info->key = $info->name == variable_get('theme_default', 'garland') ? '' : $info->name;
00693
00694         $screenshot = NULL;
00695         $theme_key = $info->name;
00696         while ($theme_key) {
00697           if (file_exists($themes[$theme_key]->info['screenshot'])) {
00698             $screenshot = $themes[$theme_key]->info['screenshot'];
00699             break;
00700           }
00701           $theme_key = isset($themes[$theme_key]->info['base theme']) ? $themes[$theme_key]->info['base theme'] : NULL;
00702         }
00703
00704         $screenshot = $screenshot ? theme('image', $screenshot, t('Screenshot for %theme theme', array('%theme' => $info->name)), '', array('class' => 'screenshot'), FALSE) : t('no screenshot');
00705
00706         $form['themes'][$info->key]['screenshot'] = array('#value' => $screenshot);
00707         $form['themes'][$info->key]['description'] = array('#type' => 'item', '#title' => $info->name, '#value' => dirname($info->filename) . ($info->name == variable_get('theme_default', 'garland') ? '<br /> <em>'. t('(site default theme)') .'</em>' : ''));
00708         $options[$info->key] = '';
00709       }
00710
00711       $form['themes']['theme'] = array('#type' => 'radios', '#options' => $options, '#default_value' => $default_value ? $default_value : '');
00712       $form['#weight'] = $weight;
00713       return $form;
00714     }
00715   }
00716 }
00717
00728 function system_check_directory($form_element) {
00729   file_check_directory($form_element['#value'], FILE_CREATE_DIRECTORY, $form_element['#parents'][0]);
00730   return $form_element;
00731 }
00732
00741 function system_get_files_database(&$files, $type) {
00742   // Extract current files from database.
00743   $result = db_query("SELECT filename, name, type, status, throttle, schema_version FROM {system} WHERE type = '%s'", $type);
00744   while ($file = db_fetch_object($result)) {
00745     if (isset($files[$file->name]) && is_object($files[$file->name])) {
00746       $file->old_filename = $file->filename;
00747       foreach ($file as $key => $value) {
00748         if (!isset($files[$file->name]) || !isset($files[$file->name]->$key)) {
00749           $files[$file->name]->$key = $value;
00750         }
00751       }
00752     }
00753   }
00754 }
00755
00762 function system_theme_default() {
00763   return array(
00764     'regions' => array(
00765       'left' => 'Left sidebar',
00766       'right' => 'Right sidebar',
00767       'content' => 'Content',
00768       'header' => 'Header',
00769       'footer' => 'Footer',
00770     ),
00771     'description' => '',
00772     'features' => array(
00773       'comment_user_picture',
00774       'favicon',
00775       'mission',
00776       'logo',
00777       'name',
00778       'node_user_picture',
00779       'search',
00780       'slogan',
00781       'primary_links',
00782       'secondary_links',
00783     ),
00784     'stylesheets' => array(
00785       'all' => array('style.css')
00786     ),
00787     'scripts' => array('script.js'),
00788     'screenshot' => 'screenshot.png',
00789     'php' => DRUPAL_MINIMUM_PHP,
00790   );
00791 }
00792
00799 function system_theme_data() {
00800   // Scan the installation theme .info files and their engines.
00801   $themes = _system_theme_data();
00802
00803   // Extract current files from database.
00804   system_get_files_database($themes, 'theme');
00805
00806   db_query("DELETE FROM {system} WHERE type = 'theme'");
00807
00808   foreach ($themes as $theme) {
00809     if (!isset($theme->owner)) {
00810       $theme->owner = '';
00811     }
00812
00813     db_query("INSERT INTO {system} (name, owner, info, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d)", $theme->name, $theme->owner, serialize($theme->info), 'theme', $theme->filename, isset($theme->status) ? $theme->status : 0, 0, 0);
00814   }
00815
00816   return $themes;
00817 }
00818
00825 function _system_theme_data() {
00826   static $themes_info = array();
00827
00828   if (empty($theme_info)) {
00829     // Find themes
00830     $themes = drupal_system_listing('\.info$', 'themes');
00831     // Find theme engines
00832     $engines = drupal_system_listing('\.engine$', 'themes/engines');
00833
00834     $defaults = system_theme_default();
00835
00836     $sub_themes = array();
00837     // Read info files for each theme
00838     foreach ($themes as $key => $theme) {
00839       $themes[$key]->info = drupal_parse_info_file($theme->filename) + $defaults;
00840
00841       // Invoke hook_system_info_alter() to give installed modules a chance to
00842       // modify the data in the .info files if necessary.
00843       drupal_alter('system_info', $themes[$key]->info, $themes[$key]);
00844
00845       if (!empty($themes[$key]->info['base theme'])) {
00846         $sub_themes[] = $key;
00847       }
00848       if (empty($themes[$key]->info['engine'])) {
00849         $filename = dirname($themes[$key]->filename) .'/'. $themes[$key]->name .'.theme';
00850         if (file_exists($filename)) {
00851           $themes[$key]->owner = $filename;
00852           $themes[$key]->prefix = $key;
00853         }
00854       }
00855       else {
00856         $engine = $themes[$key]->info['engine'];
00857         if (isset($engines[$engine])) {
00858           $themes[$key]->owner = $engines[$engine]->filename;
00859           $themes[$key]->prefix = $engines[$engine]->name;
00860           $themes[$key]->template = TRUE;
00861         }
00862       }
00863
00864       // Give the stylesheets proper path information.
00865       $pathed_stylesheets = array();
00866       foreach ($themes[$key]->info['stylesheets'] as $media => $stylesheets) {
00867         foreach ($stylesheets as $stylesheet) {
00868           $pathed_stylesheets[$media][$stylesheet] = dirname($themes[$key]->filename) .'/'. $stylesheet;
00869         }
00870       }
00871       $themes[$key]->info['stylesheets'] = $pathed_stylesheets;
00872
00873       // Give the scripts proper path information.
00874       $scripts = array();
00875       foreach ($themes[$key]->info['scripts'] as $script) {
00876         $scripts[$script] = dirname($themes[$key]->filename) .'/'. $script;
00877       }
00878       $themes[$key]->info['scripts'] = $scripts;
00879       // Give the screenshot proper path information.
00880       if (!empty($themes[$key]->info['screenshot'])) {
00881         $themes[$key]->info['screenshot'] = dirname($themes[$key]->filename) .'/'. $themes[$key]->info['screenshot'];
00882       }
00883     }
00884
00885     // Now that we've established all our master themes, go back and fill in
00886     // data for subthemes.
00887     foreach ($sub_themes as $key) {
00888       $base_key = system_find_base_theme($themes, $key);
00889       if (!$base_key) {
00890         continue;
00891       }
00892       // Copy the 'owner' and 'engine' over if the top level theme uses a
00893       // theme engine.
00894       if (isset($themes[$base_key]->owner)) {
00895         if (isset($themes[$base_key]->info['engine'])) {
00896           $themes[$key]->info['engine'] = $themes[$base_key]->info['engine'];
00897           $themes[$key]->owner = $themes[$base_key]->owner;
00898           $themes[$key]->prefix = $themes[$base_key]->prefix;
00899         }
00900         else {
00901           $themes[$key]->prefix = $key;
00902         }
00903       }
00904     }
00905
00906     $themes_info = $themes;
00907   }
00908
00909   return $themes_info;
00910 }
00911
00925 function system_find_base_theme($themes, $key, $used_keys = array()) {
00926   $base_key = $themes[$key]->info['base theme'];
00927   // Does the base theme exist?
00928   if (!isset($themes[$base_key])) {
00929     return NULL;
00930   }
00931
00932   // Is the base theme itself a child of another theme?
00933   if (isset($themes[$base_key]->info['base theme'])) {
00934     // Prevent loops.
00935     if (!empty($used_keys[$base_key])) {
00936       return NULL;
00937     }
00938     $used_keys[$base_key] = TRUE;
00939     return system_find_base_theme($themes, $base_key, $used_keys);
00940   }
00941   // If we get here, then this is our parent theme.
00942   return $base_key;
00943 }
00944
00953 function system_region_list($theme_key) {
00954   static $list = array();
00955
00956   if (!array_key_exists($theme_key, $list)) {
00957     $info = unserialize(db_result(db_query("SELECT info FROM {system} WHERE type = 'theme' AND name = '%s'", $theme_key)));
00958     $list[$theme_key] = array_map('t', $info['regions']);
00959   }
00960
00961   return $list[$theme_key];
00962 }
00963
00972 function system_default_region($theme) {
00973   $regions = array_keys(system_region_list($theme));
00974   return isset($regions[0]) ? $regions[0] : '';
00975 }
00976
00988 function system_initialize_theme_blocks($theme) {
00989   // Initialize theme's blocks if none already registered.
00990   if (!(db_result(db_query("SELECT COUNT(*) FROM {blocks} WHERE theme = '%s'", $theme)))) {
00991     $default_theme = variable_get('theme_default', 'garland');
00992     $regions = system_region_list($theme);
00993     $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $default_theme);
00994     while ($block = db_fetch_array($result)) {
00995       // If the region isn't supported by the theme, assign the block to the theme's default region.
00996       if (!array_key_exists($block['region'], $regions)) {
00997         $block['region'] = system_default_region($theme);
00998       }
00999       db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, visibility, pages, custom, throttle, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, '%s', %d, %d, %d)",
01000           $block['module'], $block['delta'], $theme, $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['throttle'], $block['cache']);
01001     }
01002   }
01003 }
01004
01015 function system_settings_form($form) {
01016   $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') );
01017   $form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults') );
01018
01019   if (!empty($_POST) && form_get_errors()) {
01020     drupal_set_message(t('The settings have not been saved because of the errors.'), 'error');
01021   }
01022   $form['#submit'][] = 'system_settings_form_submit';
01023   $form['#theme'] = 'system_settings_form';
01024   return $form;
01025 }
01026
01033 function system_settings_form_submit($form, &$form_state) {
01034   $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
01035
01036   // Exclude unnecessary elements.
01037   unset($form_state['values']['submit'], $form_state['values']['reset'], $form_state['values']['form_id'], $form_state['values']['op'], $form_state['values']['form_token'], $form_state['values']['form_build_id']);
01038
01039   foreach ($form_state['values'] as $key => $value) {
01040     if ($op == t('Reset to defaults')) {
01041       variable_del($key);
01042     }
01043     else {
01044       if (is_array($value) && isset($form_state['values']['array_filter'])) {
01045         $value = array_keys(array_filter($value));
01046       }
01047       variable_set($key, $value);
01048     }
01049   }
01050   if ($op == t('Reset to defaults')) {
01051     drupal_set_message(t('The configuration options have been reset to their default values.'));
01052   }
01053   else {
01054     drupal_set_message(t('The configuration options have been saved.'));
01055   }
01056
01057   cache_clear_all();
01058   drupal_rebuild_theme_registry();
01059 }
01060
01064 function _system_sort_requirements($a, $b) {
01065   if (!isset($a['weight'])) {
01066     if (!isset($b['weight'])) {
01067       return strcmp($a['title'], $b['title']);
01068     }
01069     return -$b['weight'];
01070   }
01071   return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight'];
01072 }
01073
01079 function system_node_type($op, $info) {
01080   if ($op == 'update' && !empty($info->old_type) && $info->type != $info->old_type) {
01081     $old = 'toggle_node_info_'. $info->old_type;
01082     $new = 'toggle_node_info_'. $info->type;
01083
01084     $theme_settings = variable_get('theme_settings', array());
01085     if (isset($theme_settings[$old])) {
01086       $theme_settings[$new] = $theme_settings[$old];
01087       unset($theme_settings[$old]);
01088       variable_set('theme_settings', $theme_settings);
01089     }
01090   }
01091 }
01092
01125 function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm') {
01126   $description = isset($description) ? $description : t('This action cannot be undone.');
01127
01128   // Prepare cancel link
01129   $query = $fragment = NULL;
01130   if (is_array($path)) {
01131     $query = isset($path['query']) ? $path['query'] : NULL;
01132     $fragment = isset($path['fragment']) ? $path['fragment'] : NULL;
01133     $path = isset($path['path']) ? $path['path'] : NULL;
01134   }
01135   $cancel = l($no ? $no : t('Cancel'), $path, array('query' => $query, 'fragment' => $fragment));
01136
01137   drupal_set_title($question);
01138
01139   // Confirm form fails duplication check, as the form values rarely change -- so skip it.
01140   $form['#skip_duplicate_check'] = TRUE;
01141
01142   $form['#attributes'] = array('class' => 'confirmation');
01143   $form['description'] = array('#value' => $description);
01144   $form[$name] = array('#type' => 'hidden', '#value' => 1);
01145
01146   $form['actions'] = array('#prefix' => '<div class="container-inline">', '#suffix' => '</div>');
01147   $form['actions']['submit'] = array('#type' => 'submit', '#value' => $yes ? $yes : t('Confirm'));
01148   $form['actions']['cancel'] = array('#value' => $cancel);
01149   $form['#theme'] = 'confirm_form';
01150   return $form;
01151 }
01152
01156 function system_admin_compact_mode() {
01157   global $user;
01158   return (isset($user->admin_compact_mode)) ? $user->admin_compact_mode : variable_get('admin_compact_mode', FALSE);
01159 }
01160
01169 function system_get_module_admin_tasks($module) {
01170   static $items;
01171
01172   $admin_access = user_access('administer permissions');
01173   $admin_tasks = array();
01174
01175   if (!isset($items)) {
01176     $result = db_query("
01177        SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, ml.*
01178        FROM {menu_links} ml INNER JOIN {menu_router} m ON ml.router_path = m.path WHERE ml.link_path LIKE 'admin/%' AND hidden >= 0 AND module = 'system' AND m.number_parts > 2");
01179     $items = array();
01180     while ($item = db_fetch_array($result)) {
01181       _menu_link_translate($item);
01182       if ($item['access']) {
01183         $items[$item['router_path']] = $item;
01184       }
01185     }
01186   }
01187   $admin_tasks = array();
01188   $admin_task_count = 0;
01189   // Check for permissions.
01190   if (module_hook($module, 'perm') && $admin_access) {
01191     $admin_tasks[-1] = l(t('Configure permissions'), 'admin/user/permissions', array('fragment' => 'module-'. $module));
01192   }
01193
01194   // Check for menu items that are admin links.
01195   if ($menu = module_invoke($module, 'menu')) {
01196     foreach (array_keys($menu) as $path) {
01197       if (isset($items[$path])) {
01198         $admin_tasks[$items[$path]['title'] . $admin_task_count ++] = l($items[$path]['title'], $path);
01199       }
01200     }
01201   }
01202
01203   return $admin_tasks;
01204 }
01205
01211 function system_cron() {
01212   // Cleanup the flood.
01213   db_query('DELETE FROM {flood} WHERE timestamp < %d', time() - 3600);
01214   // Cleanup the batch table.
01215   db_query('DELETE FROM {batch} WHERE timestamp < %d', time() - 864000);
01216
01217   // Remove temporary files that are older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
01218   $result = db_query('SELECT * FROM {files} WHERE status = %d and timestamp < %d', FILE_STATUS_TEMPORARY, time() - DRUPAL_MAXIMUM_TEMP_FILE_AGE);
01219   while ($file = db_fetch_object($result)) {
01220     if (file_exists($file->filepath)) {
01221       // If files that exist cannot be deleted, continue so the database remains
01222       // consistent.
01223       if (!file_delete($file->filepath)) {
01224         watchdog('file system', 'Could not delete temporary file "%path" during garbage collection', array('%path' => $file->filepath), 'error');
01225         continue;
01226       }
01227     }
01228     db_query('DELETE FROM {files} WHERE fid = %d', $file->fid);
01229   }
01230 }
01231
01235 function system_hook_info() {
01236   return array(
01237     'system' => array(
01238       'cron' => array(
01239         'run' => array(
01240           'runs when' => t('When cron runs'),
01241         ),
01242       ),
01243     ),
01244   );
01245 }
01246
01250 function system_action_info() {
01251   return array(
01252     'system_message_action' => array(
01253       'type' => 'system',
01254       'description' => t('Display a message to the user'),
01255       'configurable' => TRUE,
01256       'hooks' => array(
01257         'nodeapi' => array('view', 'insert', 'update', 'delete'),
01258         'comment' => array('view', 'insert', 'update', 'delete'),
01259         'user' => array('view', 'insert', 'update', 'delete', 'login'),
01260         'taxonomy' => array('insert', 'update', 'delete'),
01261       ),
01262     ),
01263     'system_send_email_action' => array(
01264       'description' => t('Send e-mail'),
01265       'type' => 'system',
01266       'configurable' => TRUE,
01267       'hooks' => array(
01268         'nodeapi' => array('view', 'insert', 'update', 'delete'),
01269         'comment' => array('view', 'insert', 'update', 'delete'),
01270         'user' => array('view', 'insert', 'update', 'delete', 'login'),
01271         'taxonomy' => array('insert', 'update', 'delete'),
01272       )
01273     ),
01274     'system_goto_action' => array(
01275       'description' => t('Redirect to URL'),
01276       'type' => 'system',
01277       'configurable' => TRUE,
01278       'hooks' => array(
01279         'nodeapi' => array('view', 'insert', 'update', 'delete'),
01280         'comment' => array('view', 'insert', 'update', 'delete'),
01281         'user' => array('view', 'insert', 'update', 'delete', 'login'),
01282       )
01283     )
01284   );
01285 }
01286
01290 function system_actions_manage() {
01291   $output = '';
01292   $actions = actions_list();
01293   actions_synchronize($actions);
01294   $actions_map = actions_actions_map($actions);
01295   $options = array(t('Choose an advanced action'));
01296   $unconfigurable = array();
01297
01298   foreach ($actions_map as $key => $array) {
01299     if ($array['configurable']) {
01300       $options[$key] = $array['description'] .'...';
01301     }
01302     else {
01303       $unconfigurable[] = $array;
01304     }
01305   }
01306
01307   $row = array();
01308   $instances_present = db_fetch_object(db_query("SELECT aid FROM {actions} WHERE parameters != ''"));
01309   $header = array(
01310     array('data' => t('Action type'), 'field' => 'type'),
01311     array('data' => t('Description'), 'field' => 'description'),
01312     array('data' => $instances_present ? t('Operations') : '', 'colspan' => '2')
01313   );
01314   $sql = 'SELECT * FROM {actions}';
01315   $result = pager_query($sql . tablesort_sql($header), 50);
01316   while ($action = db_fetch_object($result)) {
01317     $row[] = array(
01318       array('data' => $action->type),
01319       array('data' => $action->description),
01320       array('data' => $action->parameters ? l(t('configure'), "admin/settings/actions/configure/$action->aid") : ''),
01321       array('data' => $action->parameters ? l(t('delete'), "admin/settings/actions/delete/$action->aid") : '')
01322     );
01323   }
01324
01325   if ($row) {
01326     $pager = theme('pager', NULL, 50, 0);
01327     if (!empty($pager)) {
01328       $row[] = array(array('data' => $pager, 'colspan' => '3'));
01329     }
01330     $output .= '<h3>'. t('Actions available to Drupal:') .'</h3>';
01331     $output .= theme('table', $header, $row);
01332   }
01333
01334   if ($actions_map) {
01335     $output .= drupal_get_form('system_actions_manage_form', $options);
01336   }
01337
01338   return $output;
01339 }
01340
01353 function system_actions_manage_form($form_state, $options = array()) {
01354   $form['parent'] = array(
01355     '#type' => 'fieldset',
01356     '#title' => t('Make a new advanced action available'),
01357     '#prefix' => '<div class="container-inline">',
01358     '#suffix' => '</div>',
01359   );
01360   $form['parent']['action'] = array(
01361     '#type' => 'select',
01362     '#default_value' => '',
01363     '#options' => $options,
01364     '#description' => '',
01365   );
01366   $form['parent']['buttons']['submit'] = array(
01367     '#type' => 'submit',
01368     '#value' => t('Create'),
01369   );
01370   return $form;
01371 }
01372
01376 function system_actions_manage_form_submit($form, &$form_state) {
01377   if ($form_state['values']['action']) {
01378     $form_state['redirect'] = 'admin/settings/actions/configure/'. $form_state['values']['action'];
01379   }
01380 }
01381
01399 function system_actions_configure($form_state, $action = NULL) {
01400   if ($action === NULL) {
01401     drupal_goto('admin/settings/actions');
01402   }
01403
01404   $actions_map = actions_actions_map(actions_list());
01405   $edit = array();
01406
01407   // Numeric action denotes saved instance of a configurable action;
01408   // else we are creating a new action instance.
01409   if (is_numeric($action)) {
01410     $aid = $action;
01411     // Load stored parameter values from database.
01412     $data = db_fetch_object(db_query("SELECT * FROM {actions} WHERE aid = %d", intval($aid)));
01413     $edit['actions_description'] = $data->description;
01414     $edit['actions_type'] = $data->type;
01415     $function = $data->callback;
01416     $action = md5($data->callback);
01417     $params = unserialize($data->parameters);
01418     if ($params) {
01419       foreach ($params as $name => $val) {
01420         $edit[$name] = $val;
01421       }
01422     }
01423   }
01424   else {
01425     $function = $actions_map[$action]['callback'];
01426     $edit['actions_description'] = $actions_map[$action]['description'];
01427     $edit['actions_type'] = $actions_map[$action]['type'];
01428   }
01429
01430   $form['actions_description'] = array(
01431     '#type' => 'textfield',
01432     '#title' => t('Description'),
01433     '#default_value' => $edit['actions_description'],
01434     '#maxlength' => '255',
01435     '#description' => t('A unique description for this advanced action. This description will be displayed in the interface of modules that integrate with actions, such as Trigger module.'),
01436     '#weight' => -10
01437   );
01438   $action_form = $function .'_form';
01439   $form = array_merge($form, $action_form($edit));
01440   $form['actions_type'] = array(
01441     '#type' => 'value',
01442     '#value' => $edit['actions_type'],
01443   );
01444   $form['actions_action'] = array(
01445     '#type' => 'hidden',
01446     '#value' => $action,
01447   );
01448   // $aid is set when configuring an existing action instance.
01449   if (isset($aid)) {
01450     $form['actions_aid'] = array(
01451       '#type' => 'hidden',
01452       '#value' => $aid,
01453     );
01454   }
01455   $form['actions_configured'] = array(
01456     '#type' => 'hidden',
01457     '#value' => '1',
01458   );
01459   $form['buttons']['submit'] = array(
01460     '#type' => 'submit',
01461     '#value' => t('Save'),
01462     '#weight' => 13
01463   );
01464
01465   return $form;
01466 }
01467
01471 function system_actions_configure_validate($form, $form_state) {
01472   $function = actions_function_lookup($form_state['values']['actions_action']) .'_validate';
01473   // Hand off validation to the action.
01474   if (function_exists($function)) {
01475     $function($form, $form_state);
01476   }
01477 }
01478
01482 function system_actions_configure_submit($form, &$form_state) {
01483   $function = actions_function_lookup($form_state['values']['actions_action']);
01484   $submit_function = $function .'_submit';
01485
01486   // Action will return keyed array of values to store.
01487   $params = $submit_function($form, $form_state);
01488   $aid = isset($form_state['values']['actions_aid']) ? $form_state['values']['actions_aid'] : NULL;
01489
01490   actions_save($function, $form_state['values']['actions_type'], $params, $form_state['values']['actions_description'], $aid);
01491   drupal_set_message(t('The action has been successfully saved.'));
01492
01493   $form_state['redirect'] = 'admin/settings/actions/manage';
01494 }
01495
01502 function system_actions_delete_form($form_state, $action) {
01503
01504   $form['aid'] = array(
01505     '#type' => 'hidden',
01506     '#value' => $action->aid,
01507   );
01508   return confirm_form($form,
01509     t('Are you sure you want to delete the action %action?', array('%action' => $action->description)),
01510     'admin/settings/actions/manage',
01511     t('This cannot be undone.'),
01512     t('Delete'), t('Cancel')
01513   );
01514 }
01515
01521 function system_actions_delete_form_submit($form, &$form_state) {
01522   $aid = $form_state['values']['aid'];
01523   $action = actions_load($aid);
01524   actions_delete($aid);
01525   $description = check_plain($action->description);
01526   watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $aid, '%action' => $description));
01527   drupal_set_message(t('Action %action was deleted', array('%action' => $description)));
01528   $form_state['redirect'] = 'admin/settings/actions/manage';
01529 }
01530
01537 function system_action_delete_orphans_post($orphaned) {
01538   foreach ($orphaned as $callback) {
01539     drupal_set_message(t("Deleted orphaned action (%action).", array('%action' => $callback)));
01540   }
01541 }
01542
01546 function system_actions_remove_orphans() {
01547   actions_synchronize(actions_list(), TRUE);
01548   drupal_goto('admin/settings/actions/manage');
01549 }
01550
01561 function system_send_email_action_form($context) {
01562   // Set default values for form.
01563   if (!isset($context['recipient'])) {
01564     $context['recipient'] = '';
01565   }
01566   if (!isset($context['subject'])) {
01567     $context['subject'] = '';
01568   }
01569   if (!isset($context['message'])) {
01570     $context['message'] = '';
01571   }
01572
01573   $form['recipient'] = array(
01574     '#type' => 'textfield',
01575     '#title' => t('Recipient'),
01576     '#default_value' => $context['recipient'],
01577     '#maxlength' => '254',
01578     '#description' => t('The email address to which the message should be sent OR enter %author if you would like to send an e-mail to the author of the original post.', array('%author' => '%author')),
01579   );
01580   $form['subject'] = array(
01581     '#type' => 'textfield',
01582     '#title' => t('Subject'),
01583     '#default_value' => $context['subject'],
01584     '#maxlength' => '254',
01585     '#description' => t('The subject of the message.'),
01586   );
01587   $form['message'] = array(
01588     '#type' => 'textarea',
01589     '#title' => t('Message'),
01590     '#default_value' => $context['message'],
01591     '#cols' => '80',
01592     '#rows' => '20',
01593     '#description' => t('The message that should be sent. You may include the following variables: %site_name, %username, %node_url, %node_type, %title, %teaser, %body. Not all variables will be available in all contexts.'),
01594   );
01595   return $form;
01596 }
01597
01601 function system_send_email_action_validate($form, $form_state) {
01602   $form_values = $form_state['values'];
01603   // Validate the configuration form.
01604   if (!valid_email_address($form_values['recipient']) && $form_values['recipient'] != '%author') {
01605     // We want the literal %author placeholder to be emphasized in the error message.
01606     form_set_error('recipient', t('Please enter a valid email address or %author.', array('%author' => '%author')));
01607   }
01608 }
01609
01613 function system_send_email_action_submit($form, $form_state) {
01614   $form_values = $form_state['values'];
01615   // Process the HTML form to store configuration. The keyed array that
01616   // we return will be serialized to the database.
01617   $params = array(
01618     'recipient' => $form_values['recipient'],
01619     'subject'   => $form_values['subject'],
01620     'message'   => $form_values['message'],
01621   );
01622   return $params;
01623 }
01624
01628 function system_send_email_action($object, $context) {
01629   global $user;
01630
01631   switch ($context['hook']) {
01632     case 'nodeapi':
01633       // Because this is not an action of type 'node' the node
01634       // will not be passed as $object, but it will still be available
01635       // in $context.
01636       $node = $context['node'];
01637       break;
01638     // The comment hook provides nid, in $context.
01639     case 'comment':
01640       $comment = $context['comment'];
01641       $node = node_load($comment->nid);
01642       break;
01643     case 'user':
01644       // Because this is not an action of type 'user' the user
01645       // object is not passed as $object, but it will still be available
01646       // in $context.
01647       $account = $context['account'];
01648       if (isset($context['node'])) {
01649         $node = $context['node'];
01650       }
01651       elseif ($context['recipient'] == '%author') {
01652         // If we don't have a node, we don't have a node author.
01653         watchdog('error', 'Cannot use %author token in this context.');
01654         return;
01655       }
01656       break;
01657     default:
01658       // We are being called directly.
01659       $node = $object;
01660   }
01661
01662   $recipient = $context['recipient'];
01663
01664   if (isset($node)) {
01665     if (!isset($account)) {
01666       $account = user_load(array('uid' => $node->uid));
01667     }
01668     if ($recipient == '%author') {
01669       $recipient = $account->mail;
01670     }
01671   }
01672
01673   if (!isset($account)) {
01674     $account = $user;
01675
01676   }
01677   $language = user_preferred_language($account);
01678   $params = array('account' => $account, 'object' => $object, 'context' => $context);
01679   if (isset($node)) {
01680     $params['node'] = $node;
01681   }
01682
01683   if (drupal_mail('system', 'action_send_email', $recipient, $language, $params)) {
01684     watchdog('action', 'Sent email to %recipient', array('%recipient' => $recipient));
01685   }
01686   else {
01687     watchdog('error', 'Unable to send email to %recipient', array('%recipient' => $recipient));
01688   }
01689 }
01690
01694 function system_mail($key, &$message, $params) {
01695   $account = $params['account'];
01696   $context = $params['context'];
01697   $variables = array(
01698     '%site_name' => variable_get('site_name', 'Drupal'),
01699     '%username' => $account->name,
01700   );
01701   if ($context['hook'] == 'taxonomy') {
01702     $object = $params['object'];
01703     $vocabulary = taxonomy_vocabulary_load($object->vid);
01704     $variables += array(
01705       '%term_name' => $object->name,
01706       '%term_description' => $object->description,
01707       '%term_id' => $object->tid,
01708       '%vocabulary_name' => $vocabulary->name,
01709       '%vocabulary_description' => $vocabulary->description,
01710       '%vocabulary_id' => $vocabulary->vid,
01711     );
01712   }
01713
01714   // Node-based variable translation is only available if we have a node.
01715   if (isset($params['node'])) {
01716     $node = $params['node'];
01717     $variables += array(
01718       '%uid' => $node->uid,
01719       '%node_url' => url('node/'. $node->nid, array('absolute' => TRUE)),
01720       '%node_type' => node_get_types('name', $node),
01721       '%title' => $node->title,
01722       '%teaser' => $node->teaser,
01723       '%body' => $node->body,
01724     );
01725   }
01726   $subject = strtr($context['subject'], $variables);
01727   $body = strtr($context['message'], $variables);
01728   $message['subject'] .= str_replace(array("\r", "\n"), '', $subject);
01729   $message['body'][] = drupal_html_to_text($body);
01730 }
01731
01732 function system_message_action_form($context) {
01733   $form['message'] = array(
01734     '#type' => 'textarea',
01735     '#title' => t('Message'),
01736     '#default_value' => isset($context['message']) ? $context['message'] : '',
01737     '#required' => TRUE,
01738     '#rows' => '8',
01739     '#description' => t('The message to be displayed to the current user. You may include the following variables: %site_name, %username, %node_url, %node_type, %title, %teaser, %body. Not all variables will be available in all contexts.'),
01740   );
01741   return $form;
01742 }
01743
01744 function system_message_action_submit($form, $form_state) {
01745   return array('message' => $form_state['values']['message']);
01746 }
01747
01751 function system_message_action(&$object, $context = array()) {
01752   global $user;
01753   $variables = array(
01754     '%site_name' => variable_get('site_name', 'Drupal'),
01755     '%username' => $user->name ? $user->name : variable_get('anonymous', t('Anonymous')),
01756   );
01757
01758   // This action can be called in any context, but if placeholders
01759   // are used a node object must be present to be the source
01760   // of substituted text.
01761   switch ($context['hook']) {
01762     case 'nodeapi':
01763       // Because this is not an action of type 'node' the node
01764       // will not be passed as $object, but it will still be available
01765       // in $context.
01766       $node = $context['node'];
01767       break;
01768     // The comment hook also provides the node, in context.
01769     case 'comment':
01770       $comment = $context['comment'];
01771       $node = node_load($comment->nid);
01772       break;
01773     case 'taxonomy':
01774       $vocabulary = taxonomy_vocabulary_load($object->vid);
01775       $variables = array_merge($variables, array(
01776         '%term_name' => $object->name,
01777         '%term_description' => $object->description,
01778         '%term_id' => $object->tid,
01779         '%vocabulary_name' => $vocabulary->name,
01780         '%vocabulary_description' => $vocabulary->description,
01781         '%vocabulary_id' => $vocabulary->vid,
01782         )
01783       );
01784       break;
01785     default:
01786       // We are being called directly.
01787       $node = $object;
01788   }
01789
01790   if (isset($node) && is_object($node)) {
01791     $variables = array_merge($variables, array(
01792       '%uid' => $node->uid,
01793       '%node_url' => url('node/'. $node->nid, array('absolute' => TRUE)),
01794       '%node_type' => check_plain(node_get_types('name', $node)),
01795       '%title' => filter_xss($node->title),
01796       '%teaser' => filter_xss($node->teaser),
01797       '%body' => filter_xss($node->body),
01798       )
01799     );
01800   }
01801   $context['message'] = strtr($context['message'], $variables);
01802   drupal_set_message($context['message']);
01803 }
01804
01808 function system_goto_action_form($context) {
01809   $form['url'] = array(
01810     '#type' => 'textfield',
01811     '#title' => t('URL'),
01812     '#description' => t('The URL to which the user should be redirected. This can be an internal URL like node/1234 or an external URL like http://drupal.org.'),
01813     '#default_value' => isset($context['url']) ? $context['url'] : '',
01814     '#required' => TRUE,
01815   );
01816   return $form;
01817 }
01818
01819 function system_goto_action_submit($form, $form_state) {
01820   return array(
01821     'url' => $form_state['values']['url']
01822   );
01823 }
01824
01825 function system_goto_action($object, $context) {
01826   drupal_goto($context['url']);
01827 }
01828
01832 function _system_zonelist() {
01833   $timestamp = time();
01834   $zonelist = array(-11, -10, -9.5, -9, -8, -7, -6, -5, -4, -3.5, -3, -2, -1, 0, 1, 2, 3, 3.5, 4, 5, 5.5, 5.75, 6, 6.5, 7, 8, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 14);
01835   $zones = array();
01836   foreach ($zonelist as $offset) {
01837     $zone = $offset * 3600;
01838     $zones[$zone] = format_date($timestamp, 'custom', variable_get('date_format_long', 'l, F j, Y - H:i') .' O', $zone);
01839   }
01840   return $zones;
01841 }
01842
01854 function system_check_http_request() {
01855   // Check whether we can do any request at all. First get the results for
01856   // a very simple page which has access TRUE set via the menu system. Then,
01857   // try to drupal_http_request() the same page and compare.
01858   ob_start();
01859   $path = 'admin/reports/request-test';
01860   menu_execute_active_handler($path);
01861   $nothing = ob_get_contents();
01862   ob_end_clean();
01863   $result = drupal_http_request(url($path, array('absolute' => TRUE)));
01864   $works = isset($result->data) && $result->data == $nothing;
01865   variable_set('drupal_http_request_fails', !$works);
01866   return $works;
01867 }
01868
01874 function theme_system_powered_by($image_path) {
01875   $image = theme('image', $image_path, t('Powered by Drupal, an open source content management system'), t('Powered by Drupal, an open source content management system'));
01876   return l($image, 'http://drupal.org', array('html' => TRUE, 'absolute' => TRUE, 'external' => TRUE));
01877 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/tablesort.inc Source File

includes

tablesort.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: tablesort.inc,v 1.47 2008/01/04 09:31:48 goba Exp $
00003
00015 function tablesort_init($header) {
00016   $ts = tablesort_get_order($header);
00017   $ts['sort'] = tablesort_get_sort($header);
00018   $ts['query_string'] = tablesort_get_querystring();
00019   return $ts;
00020 }
00021
00039 function tablesort_sql($header, $before = '') {
00040   $ts = tablesort_init($header);
00041   if ($ts['sql']) {
00042     // Based on code from db_escape_table(), but this can also contain a dot.
00043     $field = preg_replace('/[^A-Za-z0-9_.]+/', '', $ts['sql']);
00044
00045     // Sort order can only be ASC or DESC.
00046     $sort = drupal_strtoupper($ts['sort']);
00047     $sort = in_array($sort, array('ASC', 'DESC')) ? $sort : '';
00048
00049     return " ORDER BY $before $field $sort";
00050   }
00051 }
00052
00068 function tablesort_header($cell, $header, $ts) {
00069   // Special formatting for the currently sorted column header.
00070   if (is_array($cell) && isset($cell['field'])) {
00071     $title = t('sort by @s', array('@s' => $cell['data']));
00072     if ($cell['data'] == $ts['name']) {
00073       $ts['sort'] = (($ts['sort'] == 'asc') ? 'desc' : 'asc');
00074       if (isset($cell['class'])) {
00075         $cell['class'] .= ' active';
00076       }
00077       else {
00078         $cell['class'] = 'active';
00079       }
00080       $image = theme('tablesort_indicator', $ts['sort']);
00081     }
00082     else {
00083       // If the user clicks a different header, we want to sort ascending initially.
00084       $ts['sort'] = 'asc';
00085       $image = '';
00086     }
00087
00088     if (!empty($ts['query_string'])) {
00089       $ts['query_string'] = '&'. $ts['query_string'];
00090     }
00091     $cell['data'] = l($cell['data'] . $image, $_GET['q'], array('attributes' => array('title' => $title), 'query' => 'sort='. $ts['sort'] .'&order='. urlencode($cell['data']) . $ts['query_string'], 'html' => TRUE));
00092
00093     unset($cell['field'], $cell['sort']);
00094   }
00095   return $cell;
00096 }
00097
00114 function tablesort_cell($cell, $header, $ts, $i) {
00115   if (isset($header[$i]['data']) && $header[$i]['data'] == $ts['name'] && !empty($header[$i]['field'])) {
00116     if (is_array($cell)) {
00117       if (isset($cell['class'])) {
00118         $cell['class'] .= ' active';
00119       }
00120       else {
00121         $cell['class'] = 'active';
00122       }
00123     }
00124     else {
00125       $cell = array('data' => $cell, 'class' => 'active');
00126     }
00127   }
00128   return $cell;
00129 }
00130
00138 function tablesort_get_querystring() {
00139   return drupal_query_string_encode($_REQUEST, array_merge(array('q', 'sort', 'order'), array_keys($_COOKIE)));
00140 }
00141
00152 function tablesort_get_order($headers) {
00153   $order = isset($_GET['order']) ? $_GET['order'] : '';
00154   foreach ($headers as $header) {
00155     if (isset($header['data']) && $order == $header['data']) {
00156       return array('name' => $header['data'], 'sql' => isset($header['field']) ? $header['field'] : '');
00157     }
00158
00159     if (isset($header['sort']) && ($header['sort'] == 'asc' || $header['sort'] == 'desc')) {
00160       $default = array('name' => $header['data'], 'sql' => isset($header['field']) ? $header['field'] : '');
00161     }
00162   }
00163
00164   if (isset($default)) {
00165     return $default;
00166   }
00167   else {
00168     // The first column specified is initial 'order by' field unless otherwise specified
00169     if (is_array($headers[0])) {
00170       $headers[0] += array('data' => NULL, 'field' => NULL);
00171       return array('name' => $headers[0]['data'], 'sql' => $headers[0]['field']);
00172     }
00173     else {
00174       return array('name' => $headers[0]);
00175     }
00176   }
00177 }
00178
00187 function tablesort_get_sort($headers) {
00188   if (isset($_GET['sort'])) {
00189     return ($_GET['sort'] == 'desc') ? 'desc' : 'asc';
00190   }
00191   // User has not specified a sort. Use default if specified; otherwise use "asc".
00192   else {
00193     foreach ($headers as $header) {
00194       if (is_array($header) && array_key_exists('sort', $header)) {
00195         return $header['sort'];
00196       }
00197     }
00198   }
00199   return 'asc';
00200 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/taxonomy/taxonomy.admin.inc Source File

modules » taxonomy

taxonomy.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: taxonomy.admin.inc,v 1.22.2.1 2008/02/07 20:46:57 goba Exp $
00003
00016 function taxonomy_overview_vocabularies() {
00017   $vocabularies = taxonomy_get_vocabularies();
00018   $form = array('#tree' => TRUE);
00019   foreach ($vocabularies as $vocabulary) {
00020     $types = array();
00021     foreach ($vocabulary->nodes as $type) {
00022       $node_type = node_get_types('name', $type);
00023       $types[] = $node_type ? check_plain($node_type) : check_plain($type);
00024     }
00025     $form[$vocabulary->vid]['#vocabulary'] = (array)$vocabulary;
00026     $form[$vocabulary->vid]['name'] = array('#value' => check_plain($vocabulary->name));
00027     $form[$vocabulary->vid]['types'] = array('#value' => implode(', ', $types));
00028     $form[$vocabulary->vid]['weight'] = array('#type' => 'weight', '#delta' => 10, '#default_value' => $vocabulary->weight);
00029     $form[$vocabulary->vid]['edit'] = array('#value' => l(t('edit vocabulary'), "admin/content/taxonomy/edit/vocabulary/$vocabulary->vid"));
00030     $form[$vocabulary->vid]['list'] = array('#value' => l(t('list terms'), "admin/content/taxonomy/$vocabulary->vid"));
00031     $form[$vocabulary->vid]['add'] = array('#value' => l(t('add terms'), "admin/content/taxonomy/$vocabulary->vid/add/term"));
00032   }
00033
00034   // Only make this form include a submit button and weight if more than one
00035   // vocabulary exists.
00036   if (count($vocabularies) > 1) {
00037     $form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
00038   }
00039   elseif (isset($vocabulary)) {
00040     unset($form[$vocabulary->vid]['weight']);
00041   }
00042   return $form;
00043 }
00044
00050 function taxonomy_overview_vocabularies_submit($form, &$form_state) {
00051   foreach ($form_state['values'] as $vid => $vocabulary) {
00052     if (is_numeric($vid) && $form[$vid]['#vocabulary']['weight'] != $form_state['values'][$vid]['weight']) {
00053       $form[$vid]['#vocabulary']['weight'] = $form_state['values'][$vid]['weight'];
00054       taxonomy_save_vocabulary($form[$vid]['#vocabulary']);
00055     }
00056   }
00057 }
00058
00065 function theme_taxonomy_overview_vocabularies($form) {
00066   $rows = array();
00067   foreach (element_children($form) as $key) {
00068     if (isset($form[$key]['name'])) {
00069       $vocabulary = &$form[$key];
00070
00071       $row = array();
00072       $row[] = drupal_render($vocabulary['name']);
00073       $row[] = drupal_render($vocabulary['types']);
00074       if (isset($vocabulary['weight'])) {
00075         $vocabulary['weight']['#attributes']['class'] = 'vocabulary-weight';
00076         $row[] = drupal_render($vocabulary['weight']);
00077       }
00078       $row[] = drupal_render($vocabulary['edit']);
00079       $row[] = drupal_render($vocabulary['list']);
00080       $row[] = drupal_render($vocabulary['add']);
00081       $rows[] = array('data' => $row, 'class' => 'draggable');
00082     }
00083   }
00084   if (empty($rows)) {
00085     $rows[] = array(array('data' => t('No vocabularies available.'), 'colspan' => '5'));
00086   }
00087
00088   $header = array(t('Name'), t('Type'));
00089   if (isset($form['submit'])) {
00090     $header[] = t('Weight');
00091     drupal_add_tabledrag('taxonomy', 'order', 'sibling', 'vocabulary-weight');
00092   }
00093   $header[] = array('data' => t('Operations'), 'colspan' => '3');
00094   return theme('table', $header, $rows, array('id' => 'taxonomy')) . drupal_render($form);
00095 }
00096
00103 function taxonomy_form_vocabulary(&$form_state, $edit = array()) {
00104   $edit += array(
00105     'name' => '',
00106     'description' => '',
00107     'help' => '',
00108     'nodes' => array(),
00109     'hierarchy' => 0,
00110     'relations' => 0,
00111     'tags' => 0,
00112     'multiple' => 0,
00113     'required' => 0,
00114     'weight' => 0,
00115   );
00116   $form['identification'] = array(
00117     '#type' => 'fieldset',
00118     '#title' => t('Identification'),
00119     '#collapsible' => TRUE,
00120   );
00121   $form['identification']['name'] = array('#type' => 'textfield',
00122     '#title' => t('Vocabulary name'),
00123     '#default_value' => $edit['name'],
00124     '#maxlength' => 255,
00125     '#description' => t('The name for this vocabulary, e.g., <em>"Tags"</em>.'),
00126     '#required' => TRUE,
00127   );
00128   $form['identification']['description'] = array('#type' => 'textarea',
00129     '#title' => t('Description'),
00130     '#default_value' => $edit['description'],
00131     '#description' => t('Description of the vocabulary; can be used by modules.'),
00132   );
00133   $form['identification']['help'] = array('#type' => 'textfield',
00134     '#title' => t('Help text'),
00135     '#maxlength' => 255,
00136     '#default_value' => $edit['help'],
00137     '#description' => t('Instructions to present to the user when selecting terms, e.g., <em>"Enter a comma separated list of words"</em>.'),
00138   );
00139   $form['content_types'] = array(
00140     '#type' => 'fieldset',
00141     '#title' => t('Content types'),
00142     '#collapsible' => TRUE,
00143   );
00144   $form['content_types']['nodes'] = array('#type' => 'checkboxes',
00145     '#title' => t('Content types'),
00146     '#default_value' => $edit['nodes'],
00147     '#options' => array_map('check_plain', node_get_types('names')),
00148     '#description' => t('Select content types to categorize using this vocabulary.'),
00149   );
00150   $form['settings'] = array(
00151     '#type' => 'fieldset',
00152     '#title' => t('Settings'),
00153     '#collapsible' => TRUE,
00154   );
00155   $form['settings']['tags'] = array('#type' => 'checkbox',
00156     '#title' => t('Tags'),
00157     '#default_value' => $edit['tags'],
00158     '#description' => t('Terms are created by users when submitting posts by typing a comma separated list.'),
00159   );
00160   $form['settings']['multiple'] = array('#type' => 'checkbox',
00161     '#title' => t('Multiple select'),
00162     '#default_value' => $edit['multiple'],
00163     '#description' => t('Allows posts to have more than one term from this vocabulary (always true for tags).'),
00164   );
00165   $form['settings']['required'] = array('#type' => 'checkbox',
00166     '#title' => t('Required'),
00167     '#default_value' => $edit['required'],
00168     '#description' => t('At least one term in this vocabulary must be selected when submitting a post.'),
00169   );
00170   $form['settings']['weight'] = array('#type' => 'weight',
00171     '#title' => t('Weight'),
00172     '#default_value' => $edit['weight'],
00173     '#description' => t('Vocabularies are displayed in ascending order by weight.'),
00174   );
00175   // Set the hierarchy to "multiple parents" by default. This simplifies the
00176   // vocabulary form and standardizes the term form.
00177   $form['hierarchy'] = array('#type' => 'value',
00178     '#value' => '0',
00179   );
00180   // Enable "related terms" by default.
00181   $form['relations'] = array('#type' => 'value',
00182     '#value' => '1',
00183   );
00184
00185   $form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
00186   if (isset($edit['vid'])) {
00187     $form['delete'] = array('#type' => 'submit', '#value' => t('Delete'));
00188     $form['vid'] = array('#type' => 'value', '#value' => $edit['vid']);
00189     $form['module'] = array('#type' => 'value', '#value' => $edit['module']);
00190   }
00191   return $form;
00192 }
00193
00197 function taxonomy_form_vocabulary_submit($form, &$form_state) {
00198   // Fix up the nodes array to remove unchecked nodes.
00199   $form_state['values']['nodes'] = array_filter($form_state['values']['nodes']);
00200   switch (taxonomy_save_vocabulary($form_state['values'])) {
00201     case SAVED_NEW:
00202       drupal_set_message(t('Created new vocabulary %name.', array('%name' => $form_state['values']['name'])));
00203       watchdog('taxonomy', 'Created new vocabulary %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE, l(t('edit'), 'admin/content/taxonomy/edit/vocabulary/'. $form_state['values']['vid']));
00204       break;
00205     case SAVED_UPDATED:
00206       drupal_set_message(t('Updated vocabulary %name.', array('%name' => $form_state['values']['name'])));
00207       watchdog('taxonomy', 'Updated vocabulary %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE, l(t('edit'), 'admin/content/taxonomy/edit/vocabulary/'. $form_state['values']['vid']));
00208       break;
00209   }
00210
00211   $form_state['vid'] = $form_state['values']['vid'];
00212   $form_state['redirect'] = 'admin/content/taxonomy';
00213   return;
00214 }
00215
00219 function taxonomy_admin_vocabulary_edit($vocabulary) {
00220   if ((isset($_POST['op']) && $_POST['op'] == t('Delete')) || isset($_POST['confirm'])) {
00221     return drupal_get_form('taxonomy_vocabulary_confirm_delete', $vocabulary->vid);
00222   }
00223   return drupal_get_form('taxonomy_form_vocabulary', (array)$vocabulary);
00224 }
00225
00229 function taxonomy_admin_term_edit($tid) {
00230   if ($term = (array)taxonomy_get_term($tid)) {
00231     return drupal_get_form('taxonomy_form_term', taxonomy_vocabulary_load($term['vid']), $term);
00232   }
00233   return drupal_not_found();
00234 }
00235
00246 function taxonomy_overview_terms(&$form_state, $vocabulary) {
00247   global $pager_page_array, $pager_total, $pager_total_items;
00248
00249   // Check for confirmation forms.
00250   if (isset($form_state['confirm_reset_alphabetical'])) {
00251     return taxonomy_vocabulary_confirm_reset_alphabetical($form_state, $vocabulary->vid);
00252   }
00253
00254   drupal_set_title(t('Terms in %vocabulary', array('%vocabulary' => $vocabulary->name)));
00255   $form = array(
00256     '#vocabulary' => (array)$vocabulary,
00257     '#tree' => TRUE,
00258     '#parent_fields' => FALSE,
00259   );
00260
00261   $page            = isset($_GET['page']) ? $_GET['page'] : 0;
00262   $page_increment  = 10;  // Number of terms per page.
00263   $page_entries    = 0;   // Elements shown on this page.
00264   $before_entries  = 0;   // Elements at the root level before this page.
00265   $after_entries   = 0;   // Elements at the root level after this page.
00266   $root_entries    = 0;   // Elements at the root level on this page.
00267
00268   // Terms from previous and next pages are shown if the term tree would have
00269   // been cut in the middle. Keep track of how many extra terms we show on each
00270   // page of terms.
00271   $back_peddle    = NULL;
00272   $forward_peddle = 0;
00273
00274   // An array of the terms to be displayed on this page.
00275   $current_page = array();
00276
00277   // Case for free tagging.
00278   if ($vocabulary->tags) {
00279     // We are not calling taxonomy_get_tree because that might fail with a big
00280     // number of tags in the freetagging vocabulary.
00281     $results = pager_query(db_rewrite_sql('SELECT t.*, h.parent FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE t.vid = %d ORDER BY weight, name', 't', 'tid'), $page_increment, 0, NULL, $vocabulary->vid);
00282     $total_entries = db_query(db_rewrite_sql('SELECT count(*) FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE t.vid = %d'), $page_increment, 0, NULL, $vocabulary->vid);
00283     while ($term = db_fetch_object($results)) {
00284       $key = 'tid:'. $term->tid .':0';
00285       $current_page[$key] = $term;
00286       $page_entries++;
00287     }
00288   }
00289   // Case for restricted vocabulary.
00290   else {
00291     $term_deltas = array();
00292     $tree = taxonomy_get_tree($vocabulary->vid);
00293     $term = current($tree);
00294     do {
00295       // In case this tree is completely empty.
00296       if (empty($term)) {
00297         break;
00298       }
00299       // Count entries before the current page.
00300       if ($page && ($page * $page_increment) > $before_entries && !isset($back_peddle)) {
00301         $before_entries++;
00302         continue;
00303       }
00304       // Count entries after the current page.
00305       elseif ($page_entries > $page_increment && isset($complete_tree)) {
00306         $after_entries++;
00307         continue;
00308       }
00309
00310       // Do not let a term start the page that is not at the root.
00311       if (isset($term->depth) && ($term->depth > 0) && !isset($back_peddle)) {
00312         $back_peddle = 0;
00313         while ($pterm = prev($tree)) {
00314           $before_entries--;
00315           $back_peddle++;
00316           if ($pterm->depth == 0) {
00317             prev($tree);
00318             continue 2; // Jump back to the start of the root level parent.
00319           }
00320         }
00321       }
00322       $back_peddle = isset($back_peddle) ? $back_peddle : 0;
00323
00324       // Continue rendering the tree until we reach the a new root item.
00325       if ($page_entries >= $page_increment + $back_peddle + 1 && $term->depth == 0 && $root_entries > 1) {
00326         $complete_tree = TRUE;
00327         // This new item at the root level is the first item on the next page.
00328         $after_entries++;
00329         continue;
00330       }
00331       if ($page_entries >= $page_increment + $back_peddle) {
00332         $forward_peddle++;
00333       }
00334
00335       // Finally, if we've gotten down this far, we're rendering a term on this page.
00336       $page_entries++;
00337       $term_deltas[$term->tid] = isset($term_deltas[$term->tid]) ? $term_deltas[$term->tid] + 1 : 0;
00338       $key = 'tid:'. $term->tid .':'. $term_deltas[$term->tid];
00339
00340       // Keep track of the first term displayed on this page.
00341       if ($page_entries == 1) {
00342         $form['#first_tid'] = $term->tid;
00343       }
00344       // Keep a variable to make sure at least 2 root elements are displayed.
00345       if ($term->parents[0] == 0) {
00346         $root_entries++;
00347       }
00348       $current_page[$key] = $term;
00349     } while ($term = next($tree));
00350
00351     // Because we didn't use a pager query, set the necessary pager variables.
00352     $total_entries = $before_entries + $page_entries + $after_entries;
00353     $pager_total_items[0] = $total_entries;
00354     $pager_page_array[0] = $page;
00355     $pager_total[0] = ceil($total_entries / $page_increment);
00356   }
00357
00358   // If this form was already submitted once, it's probably hit a validation
00359   // error. Ensure the form is rebuilt in the same order as the user submitted.
00360   if (!empty($form_state['post'])) {
00361     $order = array_flip(array_keys($form_state['post'])); // Get the $_POST order.
00362     $current_page = array_merge($order, $current_page); // Update our form with the new order.
00363     foreach ($current_page as $key => $term) {
00364       // Verify this is a term for the current page and set at the current depth.
00365       if (is_array($form_state['post'][$key]) && is_numeric($form_state['post'][$key]['tid'])) {
00366         $current_page[$key]->depth = $form_state['post'][$key]['depth'];
00367       }
00368       else {
00369         unset($current_page[$key]);
00370       }
00371     }
00372   }
00373
00374   // Build the actual form.
00375   foreach ($current_page as $key => $term) {
00376     // Save the term for the current page so we don't have to load it a second time.
00377     $form[$key]['#term'] = (array)$term;
00378     if (isset($term->parents)) {
00379       $form[$key]['#term']['parent'] = $term->parent = $term->parents[0];
00380       unset($form[$key]['#term']['parents'], $term->parents);
00381     }
00382
00383     $form[$key]['view'] = array('#value' => l($term->name, "taxonomy/term/$term->tid"));
00384     if (!$vocabulary->tags && $vocabulary->hierarchy < 2 && count($tree) > 1) {
00385       $form['#parent_fields'] = TRUE;
00386       $form[$key]['tid'] = array(
00387         '#type' => 'hidden',
00388         '#value' => $term->tid
00389       );
00390       $form[$key]['parent'] = array(
00391         '#type' => 'hidden',
00392         // Yes, default_value on a hidden. It needs to be changeable by the javascript.
00393         '#default_value' => $term->parent,
00394       );
00395       $form[$key]['depth'] = array(
00396         '#type' => 'hidden',
00397         // Same as above, the depth is modified by javascript, so it's a default_value.
00398         '#default_value' => $term->depth,
00399       );
00400     }
00401     $form[$key]['edit'] = array('#value' => l(t('edit'), "admin/content/taxonomy/edit/term/$term->tid", array('query' => drupal_get_destination())));
00402   }
00403
00404   $form['#total_entries'] = $total_entries;
00405   $form['#page_increment'] = $page_increment;
00406   $form['#page_entries'] = $page_entries;
00407   $form['#back_peddle'] = $back_peddle;
00408   $form['#forward_peddle'] = $forward_peddle;
00409   $form['#empty_text'] = t('No terms available.');
00410
00411   if (!$vocabulary->tags && $vocabulary->hierarchy < 2 && count($tree) > 1) {
00412     $form['submit'] = array(
00413       '#type' => 'submit',
00414       '#value' => t('Save')
00415     );
00416     $form['reset_alphabetical'] = array(
00417       '#type' => 'submit',
00418       '#value' => t('Reset to alphabetical')
00419     );
00420     $form['destination'] = array(
00421       '#type' => 'hidden',
00422       '#value' => $_GET['q'] . (isset($_GET['page']) ? '?page='. $_GET['page'] : '')
00423     );
00424   }
00425
00426   return $form;
00427 }
00428
00444 function taxonomy_overview_terms_submit($form, &$form_state) {
00445   if ($form_state['clicked_button']['#value'] == t('Reset to alphabetical')) {
00446     // Execute the reset action.
00447     if ($form_state['values']['reset_alphabetical'] === TRUE) {
00448       return taxonomy_vocabulary_confirm_reset_alphabetical_submit($form, $form_state);
00449     }
00450     // Rebuild the form to confirm the reset action.
00451     $form_state['rebuild'] = TRUE;
00452     $form_state['confirm_reset_alphabetical'] = TRUE;
00453     return;
00454   }
00455
00456   $order = array_flip(array_keys($form['#post'])); // Get the $_POST order.
00457   $form_state['values'] = array_merge($order, $form_state['values']); // Update our original form with the new order.
00458
00459   $vocabulary = $form['#vocabulary'];
00460   $hierarchy = 0; // Update the current hierarchy type as we go.
00461
00462   $changed_terms = array();
00463   $tree = taxonomy_get_tree($vocabulary['vid']);
00464
00465   if (empty($tree)) {
00466     return;
00467   }
00468
00469   // Build a list of all terms that need to be updated on previous pages.
00470   $weight = 0;
00471   $term = (array)$tree[0];
00472   while ($term['tid'] != $form['#first_tid']) {
00473     if ($term['parents'][0] == 0 && $term['weight'] != $weight) {
00474       $term['parent'] = $term['parents'][0];
00475       $term['weight'] = $weight;
00476       $changed_terms[$term['tid']] = $term;
00477     }
00478     $weight++;
00479     $hierarchy = $term['parents'][0] != 0 ? 1 : $hierarchy;
00480     $term = (array)$tree[$weight];
00481   }
00482
00483   // Renumber the current page weights and assign any new parents.
00484   $level_weights = array();
00485   foreach ($form_state['values'] as $tid => $values) {
00486     if (isset($form[$tid]['#term'])) {
00487       $term = $form[$tid]['#term'];
00488       // Give terms at the root level a weight in sequence with terms on previous pages.
00489       if ($values['parent'] == 0 && $term['weight'] != $weight) {
00490         $term['weight'] = $weight;
00491         $changed_terms[$term['tid']] = $term;
00492       }
00493       // Terms not at the root level can safely start from 0 because they're all on this page.
00494       elseif ($values['parent'] > 0) {
00495         $level_weights[$values['parent']] = isset($level_weights[$values['parent']]) ? $level_weights[$values['parent']] + 1 : 0;
00496         if ($level_weights[$values['parent']] != $term['weight']) {
00497           $term['weight'] = $level_weights[$values['parent']];
00498           $changed_terms[$term['tid']] = $term;
00499         }
00500       }
00501       // Update any changed parents.
00502       if ($values['parent'] != $term['parent']) {
00503         $term['parent'] = $values['parent'];
00504         $changed_terms[$term['tid']] = $term;
00505       }
00506       $hierarchy = $term['parent'] != 0 ? 1 : $hierarchy;
00507       $weight++;
00508     }
00509   }
00510
00511   // Build a list of all terms that need to be updated on following pages.
00512   for ($weight; $weight < count($tree); $weight++) {
00513     $term = (array)$tree[$weight];
00514     if ($term['parents'][0] == 0 && $term['weight'] != $weight) {
00515       $term['parent'] = $term['parents'][0];
00516       $term['weight'] = $weight;
00517       $changed_terms[$term['tid']] = $term;
00518     }
00519     $hierarchy = $term['parents'][0] != 0 ? 1 : $hierarchy;
00520   }
00521
00522   // Save all updated terms.
00523   foreach ($changed_terms as $term) {
00524     taxonomy_save_term($term);
00525   }
00526
00527   // Update the vocabulary hierarchy to flat or single hierarchy.
00528   if ($vocabulary['hierarchy'] != $hierarchy) {
00529     $vocabulary['hierarchy'] = $hierarchy;
00530     taxonomy_save_vocabulary($vocabulary);
00531   }
00532 }
00533
00540 function theme_taxonomy_overview_terms($form) {
00541   $page_increment  = $form['#page_increment'];
00542   $page_entries    = $form['#page_entries'];
00543   $back_peddle     = $form['#back_peddle'];
00544   $forward_peddle  = $form['#forward_peddle'];
00545
00546   // Add drag and drop if parent fields are present in the form.
00547   if ($form['#parent_fields']) {
00548     drupal_add_tabledrag('taxonomy', 'match', 'parent', 'term-parent', 'term-parent', 'term-id', FALSE);
00549     drupal_add_tabledrag('taxonomy', 'depth', 'group', 'term-depth', NULL, NULL, FALSE);
00550     drupal_add_js(drupal_get_path('module', 'taxonomy') .'/taxonomy.js');
00551     drupal_add_js(array('taxonomy' => array('backPeddle' => $back_peddle, 'forwardPeddle' => $forward_peddle)), 'setting');
00552     drupal_add_css(drupal_get_path('module', 'taxonomy') .'/taxonomy.css');
00553   }
00554
00555   $errors = form_get_errors() != FALSE ? form_get_errors() : array();
00556   $rows = array();
00557   foreach (element_children($form) as $key) {
00558     if (isset($form[$key]['#term'])) {
00559       $term = &$form[$key];
00560
00561       $row = array();
00562       $row[] = (isset($term['#term']['depth']) && $term['#term']['depth'] > 0 ? theme('indentation', $term['#term']['depth']) : '') . drupal_render($term['view']);
00563       if ($form['#parent_fields']) {
00564         $term['tid']['#attributes']['class'] = 'term-id';
00565         $term['parent']['#attributes']['class'] = 'term-parent';
00566         $term['depth']['#attributes']['class'] = 'term-depth';
00567         $row[0] .= drupal_render($term['parent']) . drupal_render($term['tid']) . drupal_render($term['depth']);
00568       }
00569       $row[] = drupal_render($term['edit']);
00570
00571       $row = array('data' => $row);
00572       $rows[$key] = $row;
00573     }
00574   }
00575
00576   // Add necessary classes to rows.
00577   $row_position = 0;
00578   foreach ($rows as $key => $row) {
00579     $classes = array();
00580     if (isset($form['#parent_fields'])) {
00581       $classes[] = 'draggable';
00582     }
00583
00584     // Add classes that mark which terms belong to previous and next pages.
00585     if ($row_position < $back_peddle || $row_position >= $page_entries - $forward_peddle) {
00586       $classes[] = 'taxonomy-term-preview';
00587     }
00588
00589     if ($row_position !== 0 && $row_position !== count($rows) - 1) {
00590       if ($row_position == $back_peddle - 1 || $row_position == $page_entries - $forward_peddle - 1) {
00591         $classes[] = 'taxonomy-term-divider-top';
00592       }
00593       elseif ($row_position == $back_peddle || $row_position == $page_entries - $forward_peddle) {
00594         $classes[] = 'taxonomy-term-divider-bottom';
00595       }
00596     }
00597
00598     // Add an error class if this row contains a form error.
00599     foreach ($errors as $error_key => $error) {
00600       if (strpos($error_key, $key) === 0) {
00601         $classes[] = 'error';
00602       }
00603     }
00604     $rows[$key]['class'] = implode(' ', $classes);
00605     $row_position++;
00606   }
00607
00608   if (empty($rows)) {
00609     $rows[] = array(array('data' => $form['#empty_text'], 'colspan' => '2'));
00610   }
00611
00612   $header = array(t('Name'), t('Operations'));
00613   $output = theme('table', $header, $rows, array('id' => 'taxonomy'));
00614   $output .= drupal_render($form);
00615   $output .= theme('pager', NULL, $page_increment);
00616
00617   return $output;
00618 }
00619
00623 function taxonomy_add_term_page($vocabulary) {
00624   drupal_set_title(t('Add term to %vocabulary', array('%vocabulary' => $vocabulary->name)));
00625   return drupal_get_form('taxonomy_form_term' , $vocabulary);
00626 }
00627
00634 function taxonomy_form_term(&$form_state, $vocabulary, $edit = array()) {
00635   $edit += array(
00636     'name' => '',
00637     'description' => '',
00638     'tid' => NULL,
00639     'weight' => 0,
00640   );
00641
00642   $parent = array_keys(taxonomy_get_parents($edit['tid']));
00643   $form['#term'] = $edit;
00644   $form['#term']['parent'] = $parent;
00645   $form['#vocabulary'] = (array)$vocabulary;
00646   $form['#vocabulary']['nodes'] = drupal_map_assoc($vocabulary->nodes);;
00647
00648   // Check for confirmation forms.
00649   if (isset($form_state['confirm_delete'])) {
00650     return array_merge($form, taxonomy_term_confirm_delete($form_state, $edit['tid']));
00651   }
00652   elseif (isset($form_state['confirm_parents'])) {
00653     return array_merge($form, taxonomy_term_confirm_parents($form_state, $vocabulary));
00654   }
00655
00656   $form['identification'] = array(
00657     '#type' => 'fieldset',
00658     '#title' => t('Identification'),
00659     '#collapsible' => TRUE,
00660   );
00661   $form['identification']['name'] = array(
00662     '#type' => 'textfield',
00663     '#title' => t('Term name'),
00664     '#default_value' => $edit['name'],
00665     '#maxlength' => 255,
00666     '#description' => t('The name of this term.'),
00667     '#required' => TRUE);
00668   $form['identification']['description'] = array(
00669     '#type' => 'textarea',
00670     '#title' => t('Description'),
00671     '#default_value' => $edit['description'],
00672     '#description' => t('A description of the term. To be displayed on taxonomy/term pages and RSS feeds.'));
00673
00674   $form['advanced'] = array(
00675     '#type' => 'fieldset',
00676     '#title' => t('Advanced options'),
00677     '#collapsible' => TRUE,
00678     '#collapsed' => $vocabulary->hierarchy > 1 ? FALSE : TRUE,
00679   );
00680
00681   // taxonomy_get_tree and taxonomy_get_parents may contain large numbers of
00682   // items so we check for taxonomy_override_selector before loading the
00683   // full vocabulary. Contrib modules can then intercept before
00684   // hook_form_alter to provide scalable alternatives.
00685   if (!variable_get('taxonomy_override_selector', FALSE)) {
00686     $parent = array_keys(taxonomy_get_parents($edit['tid']));
00687     $children = taxonomy_get_tree($vocabulary->vid, $edit['tid']);
00688
00689     // A term can't be the child of itself, nor of its children.
00690     foreach ($children as $child) {
00691       $exclude[] = $child->tid;
00692     }
00693     $exclude[] = $edit['tid'];
00694
00695     $form['advanced']['parent'] = _taxonomy_term_select(t('Parents'), 'parent', $parent, $vocabulary->vid, t('Parent terms') .'.', 1, '<'. t('root') .'>', $exclude);
00696     $form['advanced']['relations'] = _taxonomy_term_select(t('Related terms'), 'relations', array_keys(taxonomy_get_related($edit['tid'])), $vocabulary->vid, NULL, 1, '<'. t('none') .'>', array($edit['tid']));
00697   }
00698   $form['advanced']['synonyms'] = array(
00699     '#type' => 'textarea',
00700     '#title' => t('Synonyms'),
00701     '#default_value' => implode("\n", taxonomy_get_synonyms($edit['tid'])),
00702     '#description' => t('Synonyms of this term, one synonym per line.'));
00703   $form['advanced']['weight'] = array(
00704     '#type' => 'textfield',
00705     '#title' => t('Weight'),
00706     '#size' => 6,
00707     '#default_value' => $edit['weight'],
00708     '#description' => t('Terms are displayed in ascending order by weight.'),
00709     '#required' => TRUE);
00710   $form['vid'] = array(
00711     '#type' => 'value',
00712     '#value' => $vocabulary->vid);
00713   $form['submit'] = array(
00714     '#type' => 'submit',
00715     '#value' => t('Save'));
00716
00717   if ($edit['tid']) {
00718     $form['delete'] = array(
00719       '#type' => 'submit',
00720       '#value' => t('Delete'));
00721     $form['tid'] = array(
00722       '#type' => 'value',
00723       '#value' => $edit['tid']);
00724   }
00725   else {
00726     $form['destination'] = array('#type' => 'hidden', '#value' => $_GET['q']);
00727   }
00728
00729   return $form;
00730 }
00731
00737 function taxonomy_form_term_validate($form, &$form_state) {
00738   if (isset($form_state['values']['weight']) && !is_numeric($form_state['values']['weight'])) {
00739     form_set_error('weight', t('Weight value must be numeric.'));
00740   }
00741 }
00742
00748 function taxonomy_form_term_submit($form, &$form_state) {
00749   if ($form_state['clicked_button']['#value'] == t('Delete')) {
00750     // Execute the term deletion.
00751     if ($form_state['values']['delete'] === TRUE) {
00752       return taxonomy_term_confirm_delete_submit($form, $form_state);
00753     }
00754     // Rebuild the form to confirm term deletion.
00755     $form_state['rebuild'] = TRUE;
00756     $form_state['confirm_delete'] = TRUE;
00757     return;
00758   }
00759   // Rebuild the form to confirm enabling multiple parents.
00760   elseif ($form_state['clicked_button']['#value'] == t('Save') && !$form['#vocabulary']['tags'] && count($form_state['values']['parent']) > 1 && $form['#vocabulary']['hierarchy'] < 2) {
00761     $form_state['rebuild'] = TRUE;
00762     $form_state['confirm_parents'] = TRUE;
00763     return;
00764   }
00765
00766   switch (taxonomy_save_term($form_state['values'])) {
00767     case SAVED_NEW:
00768       drupal_set_message(t('Created new term %term.', array('%term' => $form_state['values']['name'])));
00769       watchdog('taxonomy', 'Created new term %term.', array('%term' => $form_state['values']['name']), WATCHDOG_NOTICE, l(t('edit'), 'admin/content/taxonomy/edit/term/'. $form_state['values']['tid']));
00770       break;
00771     case SAVED_UPDATED:
00772       drupal_set_message(t('Updated term %term.', array('%term' => $form_state['values']['name'])));
00773       watchdog('taxonomy', 'Updated term %term.', array('%term' => $form_state['values']['name']), WATCHDOG_NOTICE, l(t('edit'), 'admin/content/taxonomy/edit/term/'. $form_state['values']['tid']));
00774       break;
00775   }
00776
00777   if (!$form['#vocabulary']['tags']) {
00778     $current_parent_count = count($form_state['values']['parent']);
00779     $previous_parent_count = count($form['#term']['parent']);
00780     // Root doesn't count if it's the only parent.
00781     if ($current_parent_count == 1 && isset($form_state['values']['parent'][''])) {
00782       $current_parent_count = 0;
00783       $form_state['values']['parent'] = array();
00784     }
00785
00786     // If the number of parents has been reduced to one or none, do a check on the
00787     // parents of every term in the vocabulary value.
00788     if ($current_parent_count < $previous_parent_count && $current_parent_count < 2) {
00789       taxonomy_check_vocabulary_hierarchy($form['#vocabulary'], $form_state['values']);
00790     }
00791     // If we've increased the number of parents and this is a single or flat
00792     // hierarchy, update the vocabulary immediately.
00793     elseif ($current_parent_count > $previous_parent_count && $form['#vocabulary']['hierarchy'] < 2) {
00794       $form['#vocabulary']['hierarchy'] = $current_parent_count == 1 ? 1 : 2;
00795       taxonomy_save_vocabulary($form['#vocabulary']);
00796     }
00797   }
00798
00799   $form_state['tid'] = $form_state['values']['tid'];
00800   $form_state['redirect'] = 'admin/content/taxonomy';
00801   return;
00802 }
00803
00810 function taxonomy_term_confirm_parents(&$form_state, $vocabulary) {
00811   $form = array();
00812   foreach (element_children($form_state['values']) as $key) {
00813     $form[$key] = array(
00814       '#type' => 'value',
00815       '#value' => $form_state['values'][$key],
00816     );
00817   }
00818   $question = t('Set multiple term parents?');
00819   $description = '<p>'. t("Adding multiple parents to a term will cause the %vocabulary vocabulary to look for multiple parents on every term. Because multiple parents are not supported when using the drag and drop outline interface, drag and drop will be disabled if you enable this option. If you choose to have multiple parents, you will only be able to set parents by using the term edit form.", array('%vocabulary' => $vocabulary->name)) .'</p>';
00820   $description .= '<p>'. t("You may re-enable the drag and drop interface at any time by reducing multiple parents to a single parent for the terms in this vocabulary.") .'</p>';
00821   return confirm_form($form, $question, drupal_get_destination(), $description, t('Set multiple parents'));
00822 }
00823
00830 function taxonomy_term_confirm_delete(&$form_state, $tid) {
00831   $term = taxonomy_get_term($tid);
00832
00833   $form['type'] = array('#type' => 'value', '#value' => 'term');
00834   $form['name'] = array('#type' => 'value', '#value' => $term->name);
00835   $form['tid'] = array('#type' => 'value', '#value' => $tid);
00836   $form['delete'] = array('#type' => 'value', '#value' => TRUE);
00837   return confirm_form($form,
00838                   t('Are you sure you want to delete the term %title?',
00839                   array('%title' => $term->name)),
00840                   'admin/content/taxonomy',
00841                   t('Deleting a term will delete all its children if there are any. This action cannot be undone.'),
00842                   t('Delete'),
00843                   t('Cancel'));
00844 }
00845
00851 function taxonomy_term_confirm_delete_submit($form, &$form_state) {
00852   taxonomy_del_term($form_state['values']['tid']);
00853   taxonomy_check_vocabulary_hierarchy($form['#vocabulary'], $form_state['values']);
00854   drupal_set_message(t('Deleted term %name.', array('%name' => $form_state['values']['name'])));
00855   watchdog('taxonomy', 'Deleted term %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
00856   $form_state['redirect'] = 'admin/content/taxonomy';
00857   return;
00858 }
00859
00866 function taxonomy_vocabulary_confirm_delete(&$form_state, $vid) {
00867   $vocabulary = taxonomy_vocabulary_load($vid);
00868
00869   $form['type'] = array('#type' => 'value', '#value' => 'vocabulary');
00870   $form['vid'] = array('#type' => 'value', '#value' => $vid);
00871   $form['name'] = array('#type' => 'value', '#value' => $vocabulary->name);
00872   return confirm_form($form,
00873                   t('Are you sure you want to delete the vocabulary %title?',
00874                   array('%title' => $vocabulary->name)),
00875                   'admin/content/taxonomy',
00876                   t('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'),
00877                   t('Delete'),
00878                   t('Cancel'));
00879 }
00880
00886 function taxonomy_vocabulary_confirm_delete_submit($form, &$form_state) {
00887   $status = taxonomy_del_vocabulary($form_state['values']['vid']);
00888   drupal_set_message(t('Deleted vocabulary %name.', array('%name' => $form_state['values']['name'])));
00889   watchdog('taxonomy', 'Deleted vocabulary %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
00890   $form_state['redirect'] = 'admin/content/taxonomy';
00891   return;
00892 }
00893
00900 function taxonomy_vocabulary_confirm_reset_alphabetical(&$form_state, $vid) {
00901   $vocabulary = taxonomy_vocabulary_load($vid);
00902
00903   $form['type'] = array('#type' => 'value', '#value' => 'vocabulary');
00904   $form['vid'] = array('#type' => 'value', '#value' => $vid);
00905   $form['name'] = array('#type' => 'value', '#value' => $vocabulary->name);
00906   $form['reset_alphabetical'] = array('#type' => 'value', '#value' => TRUE);
00907   return confirm_form($form,
00908                   t('Are you sure you want to reset the vocabulary %title to alphabetical order?',
00909                   array('%title' => $vocabulary->name)),
00910                   'admin/content/taxonomy/'. $vid,
00911                   t('Resetting a vocabulary will discard all custom ordering and sort items alphabetically.'),
00912                   t('Reset to alphabetical'),
00913                   t('Cancel'));
00914 }
00915
00921 function taxonomy_vocabulary_confirm_reset_alphabetical_submit($form, &$form_state) {
00922   db_query('UPDATE {term_data} t SET weight = 0 WHERE vid = %d', $form_state['values']['vid']);
00923   drupal_set_message(t('Reset vocabulary %name to alphabetical order.', array('%name' => $form_state['values']['name'])));
00924   watchdog('taxonomy', 'Reset vocabulary %name to alphabetical order.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE);
00925   $form_state['redirect'] = 'admin/content/taxonomy/'. $form_state['values']['vid'];
00926 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/taxonomy/taxonomy.install Source File

modules » taxonomy

taxonomy.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: taxonomy.install,v 1.7 2008/01/08 07:46:41 goba Exp $
00003
00007 function taxonomy_schema() {
00008   $schema['term_data'] = array(
00009     'description' => t('Stores term information.'),
00010     'fields' => array(
00011       'tid' => array(
00012         'type' => 'serial',
00013         'unsigned' => TRUE,
00014         'not null' => TRUE,
00015         'description' => t('Primary Key: Unique term ID.'),
00016       ),
00017       'vid' => array(
00018         'type' => 'int',
00019         'unsigned' => TRUE,
00020         'not null' => TRUE,
00021         'default' => 0,
00022         'description' => t('The {vocabulary}.vid of the vocabulary to which the term is assigned.'),
00023       ),
00024       'name' => array(
00025         'type' => 'varchar',
00026         'length' => 255,
00027         'not null' => TRUE,
00028         'default' => '',
00029         'description' => t('The term name.'),
00030       ),
00031       'description' => array(
00032         'type' => 'text',
00033         'not null' => FALSE,
00034         'size' => 'big',
00035         'description' => t('A description of the term.'),
00036       ),
00037       'weight' => array(
00038         'type' => 'int',
00039         'not null' => TRUE,
00040         'default' => 0,
00041         'size' => 'tiny',
00042         'description' => t('The weight of this term in relation to other terms.'),
00043       ),
00044     ),
00045     'primary key' => array('tid'),
00046     'indexes' => array(
00047       'taxonomy_tree' => array('vid', 'weight', 'name'),
00048       'vid_name' => array('vid', 'name'),
00049     ),
00050   );
00051
00052   $schema['term_hierarchy'] = array(
00053     'description' => t('Stores the hierarchical relationship between terms.'),
00054     'fields' => array(
00055       'tid' => array(
00056         'type' => 'int',
00057         'unsigned' => TRUE,
00058         'not null' => TRUE,
00059         'default' => 0,
00060         'description' => t('Primary Key: The {term_data}.tid of the term.'),
00061       ),
00062       'parent' => array(
00063         'type' => 'int',
00064         'unsigned' => TRUE,
00065         'not null' => TRUE,
00066         'default' => 0,
00067         'description' => t("Primary Key: The {term_data}.tid of the term's parent. 0 indicates no parent."),
00068       ),
00069     ),
00070     'indexes' => array(
00071       'parent' => array('parent'),
00072     ),
00073     'primary key' => array('tid', 'parent'),
00074   );
00075
00076   $schema['term_node'] = array(
00077     'description' => t('Stores the relationship of terms to nodes.'),
00078     'fields' => array(
00079       'nid' => array(
00080         'type' => 'int',
00081         'unsigned' => TRUE,
00082         'not null' => TRUE,
00083         'default' => 0,
00084         'description' => t('Primary Key: The {node}.nid of the node.'),
00085       ),
00086       'vid' => array(
00087         'type' => 'int',
00088         'unsigned' => TRUE,
00089         'not null' => TRUE,
00090         'default' => 0,
00091         'description' => t('Primary Key: The {node}.vid of the node.'),
00092       ),
00093       'tid' => array(
00094         'type' => 'int',
00095         'unsigned' => TRUE,
00096         'not null' => TRUE,
00097         'default' => 0,
00098         'description' => t('Primary Key: The {term_data}.tid of a term assigned to the node.'),
00099       ),
00100     ),
00101     'indexes' => array(
00102       'vid' => array('vid'),
00103       'nid' => array('nid'),
00104     ),
00105     'primary key' => array('tid', 'vid'),
00106   );
00107
00108   $schema['term_relation'] = array(
00109     'description' => t('Stores non-hierarchical relationships between terms.'),
00110     'fields' => array(
00111       'trid' => array(
00112         'type' => 'serial',
00113         'not null' => TRUE,
00114         'description' => t('Primary Key: Unique term relation ID.'),
00115       ),
00116       'tid1' => array(
00117         'type' => 'int',
00118         'unsigned' => TRUE,
00119         'not null' => TRUE,
00120         'default' => 0,
00121         'description' => t('The {term_data}.tid of the first term in a relationship.'),
00122       ),
00123       'tid2' => array(
00124         'type' => 'int',
00125         'unsigned' => TRUE,
00126         'not null' => TRUE,
00127         'default' => 0,
00128         'description' => t('The {term_data}.tid of the second term in a relationship.'),
00129       ),
00130     ),
00131     'unique keys' => array(
00132       'tid1_tid2' => array('tid1', 'tid2'),
00133     ),
00134     'indexes' => array(
00135       'tid2' => array('tid2'),
00136     ),
00137     'primary key' => array('trid'),
00138   );
00139
00140   $schema['term_synonym'] = array(
00141     'description' => t('Stores term synonyms.'),
00142     'fields' => array(
00143       'tsid' => array(
00144         'type' => 'serial',
00145         'not null' => TRUE,
00146         'description' => t('Primary Key: Unique term synonym ID.'),
00147       ),
00148       'tid' => array(
00149         'type' => 'int',
00150         'unsigned' => TRUE,
00151         'not null' => TRUE,
00152         'default' => 0,
00153         'description' => t('The {term_data}.tid of the term.'),
00154       ),
00155       'name' => array(
00156         'type' => 'varchar',
00157         'length' => 255,
00158         'not null' => TRUE,
00159         'default' => '',
00160         'description' => t('The name of the synonym.'),
00161       ),
00162     ),
00163     'indexes' => array(
00164       'tid' => array('tid'),
00165       'name_tid' => array('name', 'tid'),
00166     ),
00167     'primary key' => array('tsid'),
00168   );
00169
00170   $schema['vocabulary'] = array(
00171     'description' => t('Stores vocabulary information.'),
00172     'fields' => array(
00173       'vid' => array(
00174         'type' => 'serial',
00175         'unsigned' => TRUE,
00176         'not null' => TRUE,
00177         'description' => t('Primary Key: Unique vocabulary ID.'),
00178       ),
00179       'name' => array(
00180         'type' => 'varchar',
00181         'length' => 255,
00182         'not null' => TRUE,
00183         'default' => '',
00184         'description' => t('Name of the vocabulary.'),
00185       ),
00186       'description' => array(
00187         'type' => 'text',
00188         'not null' => FALSE,
00189         'size' => 'big',
00190         'description' => t('Description of the vocabulary.'),
00191       ),
00192       'help' => array(
00193         'type' => 'varchar',
00194         'length' => 255,
00195         'not null' => TRUE,
00196         'default' => '',
00197         'description' => t('Help text to display for the vocabulary.'),
00198       ),
00199       'relations' => array(
00200         'type' => 'int',
00201         'unsigned' => TRUE,
00202         'not null' => TRUE,
00203         'default' => 0,
00204         'size' => 'tiny',
00205         'description' => t('Whether or not related terms are enabled within the vocabulary. (0 = disabled, 1 = enabled)'),
00206       ),
00207       'hierarchy' => array(
00208         'type' => 'int',
00209         'unsigned' => TRUE,
00210         'not null' => TRUE,
00211         'default' => 0,
00212         'size' => 'tiny',
00213         'description' => t('The type of hierarchy allowed within the vocabulary. (0 = disabled, 1 = single, 2 = multiple)'),
00214       ),
00215       'multiple' => array(
00216         'type' => 'int',
00217         'unsigned' => TRUE,
00218         'not null' => TRUE,
00219         'default' => 0,
00220         'size' => 'tiny',
00221         'description' => t('Whether or not multiple terms from this vocabulary may be assigned to a node. (0 = disabled, 1 = enabled)'),
00222       ),
00223       'required' => array(
00224         'type' => 'int',
00225         'unsigned' => TRUE,
00226         'not null' => TRUE,
00227         'default' => 0,
00228         'size' => 'tiny',
00229         'description' => t('Whether or not terms are required for nodes using this vocabulary. (0 = disabled, 1 = enabled)'),
00230       ),
00231       'tags' => array(
00232         'type' => 'int',
00233         'unsigned' => TRUE,
00234         'not null' => TRUE,
00235         'default' => 0,
00236         'size' => 'tiny',
00237         'description' => t('Whether or not free tagging is enabled for the vocabulary. (0 = disabled, 1 = enabled)'),
00238       ),
00239       'module' => array(
00240         'type' => 'varchar',
00241         'length' => 255,
00242         'not null' => TRUE,
00243         'default' => '',
00244         'description' => t('The module which created the vocabulary.'),
00245       ),
00246       'weight' => array(
00247         'type' => 'int',
00248         'not null' => TRUE,
00249         'default' => 0,
00250         'size' => 'tiny',
00251         'description' => t('The weight of the vocabulary in relation to other vocabularies.'),
00252       ),
00253     ),
00254     'primary key' => array('vid'),
00255     'indexes' => array(
00256       'list' => array('weight', 'name'),
00257     ),
00258   );
00259
00260   $schema['vocabulary_node_types'] = array(
00261     'description' => t('Stores which node types vocabularies may be used with.'),
00262     'fields' => array(
00263       'vid' => array(
00264         'type' => 'int',
00265         'unsigned' => TRUE,
00266         'not null' => TRUE,
00267         'default' => 0,
00268         'description' => t('Primary Key: the {vocabulary}.vid of the vocabulary.'),
00269       ),
00270       'type' => array(
00271         'type' => 'varchar',
00272         'length' => 32,
00273         'not null' => TRUE,
00274         'default' => '',
00275         'description' => t('The {node}.type of the node type for which the vocabulary may be used.'),
00276       ),
00277     ),
00278     'primary key' => array('type', 'vid'),
00279     'indexes' => array(
00280       'vid' => array('vid'),
00281     ),
00282   );
00283
00284   return $schema;
00285 }
00286
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/taxonomy/taxonomy.module Source File

modules » taxonomy

taxonomy.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: taxonomy.module,v 1.414 2008/01/27 17:55:15 goba Exp $
00003
00012 function taxonomy_perm() {
00013   return array('administer taxonomy');
00014 }
00015
00019 function taxonomy_theme() {
00020   return array(
00021     'taxonomy_term_select' => array(
00022       'arguments' => array('element' => NULL),
00023     ),
00024     'taxonomy_term_page' => array(
00025       'arguments' => array('tids' => array(), 'result' => NULL),
00026     ),
00027     'taxonomy_overview_vocabularies' => array(
00028       'arguments' => array('form' => array()),
00029     ),
00030     'taxonomy_overview_terms' => array(
00031       'arguments' => array('form' => array()),
00032     ),
00033   );
00034 }
00035
00048 function taxonomy_link($type, $node = NULL) {
00049   if ($type == 'taxonomy terms' && $node != NULL) {
00050     $links = array();
00051     // If previewing, the terms must be converted to objects first.
00052     if ($node->build_mode == NODE_BUILD_PREVIEW) {
00053       $node->taxonomy = taxonomy_preview_terms($node);
00054     }
00055     if (!empty($node->taxonomy)) {
00056       foreach ($node->taxonomy as $term) {
00057         // During preview the free tagging terms are in an array unlike the
00058         // other terms which are objects. So we have to check if a $term
00059         // is an object or not.
00060         if (is_object($term)) {
00061           $links['taxonomy_term_'. $term->tid] = array(
00062             'title' => $term->name,
00063             'href' => taxonomy_term_path($term),
00064             'attributes' => array('rel' => 'tag', 'title' => strip_tags($term->description))
00065           );
00066         }
00067         // Previewing free tagging terms; we don't link them because the
00068         // term-page might not exist yet.
00069         else {
00070           foreach ($term as $free_typed) {
00071             $typed_terms = drupal_explode_tags($free_typed);
00072             foreach ($typed_terms as $typed_term) {
00073               $links['taxonomy_preview_term_'. $typed_term] = array(
00074                 'title' => $typed_term,
00075               );
00076             }
00077           }
00078         }
00079       }
00080     }
00081
00082     // We call this hook again because some modules and themes
00083     // call taxonomy_link('taxonomy terms') directly.
00084     drupal_alter('link', $links, $node);
00085
00086     return $links;
00087   }
00088 }
00089
00100 function taxonomy_term_path($term) {
00101   $vocabulary = taxonomy_vocabulary_load($term->vid);
00102   if ($vocabulary->module != 'taxonomy' && $path = module_invoke($vocabulary->module, 'term_path', $term)) {
00103     return $path;
00104   }
00105   return 'taxonomy/term/'. $term->tid;
00106 }
00107
00111 function taxonomy_menu() {
00112   $items['admin/content/taxonomy'] = array(
00113     'title' => 'Taxonomy',
00114     'description' => 'Manage tagging, categorization, and classification of your content.',
00115     'page callback' => 'drupal_get_form',
00116     'page arguments' => array('taxonomy_overview_vocabularies'),
00117     'access arguments' => array('administer taxonomy'),
00118     'file' => 'taxonomy.admin.inc',
00119   );
00120
00121   $items['admin/content/taxonomy/list'] = array(
00122     'title' => 'List',
00123     'type' => MENU_DEFAULT_LOCAL_TASK,
00124     'weight' => -10,
00125   );
00126
00127   $items['admin/content/taxonomy/add/vocabulary'] = array(
00128     'title' => 'Add vocabulary',
00129     'page callback' => 'drupal_get_form',
00130     'page arguments' => array('taxonomy_form_vocabulary'),
00131     'type' => MENU_LOCAL_TASK,
00132     'parent' => 'admin/content/taxonomy',
00133     'file' => 'taxonomy.admin.inc',
00134   );
00135
00136   $items['admin/content/taxonomy/edit/vocabulary/%taxonomy_vocabulary'] = array(
00137     'title' => 'Edit vocabulary',
00138     'page callback' => 'taxonomy_admin_vocabulary_edit',
00139     'page arguments' => array(5),
00140     'type' => MENU_CALLBACK,
00141     'file' => 'taxonomy.admin.inc',
00142   );
00143
00144   $items['admin/content/taxonomy/edit/term'] = array(
00145     'title' => 'Edit term',
00146     'page callback' => 'taxonomy_admin_term_edit',
00147     'type' => MENU_CALLBACK,
00148     'file' => 'taxonomy.admin.inc',
00149   );
00150
00151   $items['taxonomy/term/%'] = array(
00152     'title' => 'Taxonomy term',
00153     'page callback' => 'taxonomy_term_page',
00154     'page arguments' => array(2),
00155     'access arguments' => array('access content'),
00156     'type' => MENU_CALLBACK,
00157     'file' => 'taxonomy.pages.inc',
00158   );
00159
00160   $items['taxonomy/autocomplete'] = array(
00161     'title' => 'Autocomplete taxonomy',
00162     'page callback' => 'taxonomy_autocomplete',
00163     'access arguments' => array('access content'),
00164     'type' => MENU_CALLBACK,
00165     'file' => 'taxonomy.pages.inc',
00166   );
00167   $items['admin/content/taxonomy/%taxonomy_vocabulary'] = array(
00168     'title' => 'List terms',
00169     'page callback' => 'drupal_get_form',
00170     'page arguments' => array('taxonomy_overview_terms', 3),
00171     'access arguments' => array('administer taxonomy'),
00172     'type' => MENU_CALLBACK,
00173     'file' => 'taxonomy.admin.inc',
00174   );
00175
00176   $items['admin/content/taxonomy/%taxonomy_vocabulary/list'] = array(
00177     'title' => 'List',
00178     'type' => MENU_DEFAULT_LOCAL_TASK,
00179     'weight' => -10,
00180   );
00181
00182   $items['admin/content/taxonomy/%taxonomy_vocabulary/add/term'] = array(
00183     'title' => 'Add term',
00184     'page callback' => 'taxonomy_add_term_page',
00185     'page arguments' => array(3),
00186     'type' => MENU_LOCAL_TASK,
00187     'parent' => 'admin/content/taxonomy/%taxonomy_vocabulary',
00188     'file' => 'taxonomy.admin.inc',
00189   );
00190
00191   return $items;
00192 }
00193
00194 function taxonomy_save_vocabulary(&$edit) {
00195   $edit['nodes'] = empty($edit['nodes']) ? array() : $edit['nodes'];
00196
00197   if (!isset($edit['module'])) {
00198     $edit['module'] = 'taxonomy';
00199   }
00200
00201   if (!empty($edit['vid']) && !empty($edit['name'])) {
00202     drupal_write_record('vocabulary', $edit, 'vid');
00203     db_query("DELETE FROM {vocabulary_node_types} WHERE vid = %d", $edit['vid']);
00204     foreach ($edit['nodes'] as $type => $selected) {
00205       db_query("INSERT INTO {vocabulary_node_types} (vid, type) VALUES (%d, '%s')", $edit['vid'], $type);
00206     }
00207     module_invoke_all('taxonomy', 'update', 'vocabulary', $edit);
00208     $status = SAVED_UPDATED;
00209   }
00210   else if (!empty($edit['vid'])) {
00211     $status = taxonomy_del_vocabulary($edit['vid']);
00212   }
00213   else {
00214     drupal_write_record('vocabulary', $edit);
00215     foreach ($edit['nodes'] as $type => $selected) {
00216       db_query("INSERT INTO {vocabulary_node_types} (vid, type) VALUES (%d, '%s')", $edit['vid'], $type);
00217     }
00218     module_invoke_all('taxonomy', 'insert', 'vocabulary', $edit);
00219     $status = SAVED_NEW;
00220   }
00221
00222   cache_clear_all();
00223
00224   return $status;
00225 }
00226
00235 function taxonomy_del_vocabulary($vid) {
00236   $vocabulary = (array) taxonomy_vocabulary_load($vid);
00237
00238   db_query('DELETE FROM {vocabulary} WHERE vid = %d', $vid);
00239   db_query('DELETE FROM {vocabulary_node_types} WHERE vid = %d', $vid);
00240   $result = db_query('SELECT tid FROM {term_data} WHERE vid = %d', $vid);
00241   while ($term = db_fetch_object($result)) {
00242     taxonomy_del_term($term->tid);
00243   }
00244
00245   module_invoke_all('taxonomy', 'delete', 'vocabulary', $vocabulary);
00246
00247   cache_clear_all();
00248
00249   return SAVED_DELETED;
00250 }
00251
00267 function taxonomy_check_vocabulary_hierarchy($vocabulary, $changed_term) {
00268   $tree = taxonomy_get_tree($vocabulary['vid']);
00269   $hierarchy = 0;
00270   foreach ($tree as $term) {
00271     // Update the changed term with the new parent value before comparision.
00272     if ($term->tid == $changed_term['tid']) {
00273       $term = (object)$changed_term;
00274       $term->parents = $term->parent;
00275     }
00276     // Check this term's parent count.
00277     if (count($term->parents) > 1) {
00278       $hierarchy = 2;
00279       break;
00280     }
00281     elseif (count($term->parents) == 1 && 0 !== array_shift($term->parents)) {
00282       $hierarchy = 1;
00283     }
00284   }
00285   if ($hierarchy != $vocabulary['hierarchy']) {
00286     $vocabulary['hierarchy'] = $hierarchy;
00287     taxonomy_save_vocabulary($vocabulary);
00288   }
00289
00290   return $hierarchy;
00291 }
00292
00300 function taxonomy_save_term(&$form_values) {
00301   $form_values += array(
00302     'description' => '',
00303     'weight' => 0
00304   );
00305
00306   if (!empty($form_values['tid']) && $form_values['name']) {
00307     drupal_write_record('term_data', $form_values, 'tid');
00308     $hook = 'update';
00309     $status = SAVED_UPDATED;
00310   }
00311   else if (!empty($form_values['tid'])) {
00312     return taxonomy_del_term($form_values['tid']);
00313   }
00314   else {
00315     drupal_write_record('term_data', $form_values);
00316     $hook = 'insert';
00317     $status = SAVED_NEW;
00318   }
00319
00320   db_query('DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d', $form_values['tid'], $form_values['tid']);
00321   if (!empty($form_values['relations'])) {
00322     foreach ($form_values['relations'] as $related_id) {
00323       if ($related_id != 0) {
00324         db_query('INSERT INTO {term_relation} (tid1, tid2) VALUES (%d, %d)', $form_values['tid'], $related_id);
00325       }
00326     }
00327   }
00328
00329   db_query('DELETE FROM {term_hierarchy} WHERE tid = %d', $form_values['tid']);
00330   if (!isset($form_values['parent']) || empty($form_values['parent'])) {
00331     $form_values['parent'] = array(0);
00332   }
00333   if (is_array($form_values['parent'])) {
00334     foreach ($form_values['parent'] as $parent) {
00335       if (is_array($parent)) {
00336         foreach ($parent as $tid) {
00337           db_query('INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)', $form_values['tid'], $tid);
00338         }
00339       }
00340       else {
00341         db_query('INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)', $form_values['tid'], $parent);
00342       }
00343     }
00344   }
00345   else {
00346     db_query('INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)', $form_values['tid'], $form_values['parent']);
00347   }
00348
00349   db_query('DELETE FROM {term_synonym} WHERE tid = %d', $form_values['tid']);
00350   if (!empty($form_values['synonyms'])) {
00351     foreach (explode ("\n", str_replace("\r", '', $form_values['synonyms'])) as $synonym) {
00352       if ($synonym) {
00353         db_query("INSERT INTO {term_synonym} (tid, name) VALUES (%d, '%s')", $form_values['tid'], chop($synonym));
00354       }
00355     }
00356   }
00357
00358   if (isset($hook)) {
00359     module_invoke_all('taxonomy', $hook, 'term', $form_values);
00360   }
00361
00362   cache_clear_all();
00363
00364   return $status;
00365 }
00366
00375 function taxonomy_del_term($tid) {
00376   $tids = array($tid);
00377   while ($tids) {
00378     $children_tids = $orphans = array();
00379     foreach ($tids as $tid) {
00380       // See if any of the term's children are about to be become orphans:
00381       if ($children = taxonomy_get_children($tid)) {
00382         foreach ($children as $child) {
00383           // If the term has multiple parents, we don't delete it.
00384           $parents = taxonomy_get_parents($child->tid);
00385           if (count($parents) == 1) {
00386             $orphans[] = $child->tid;
00387           }
00388         }
00389       }
00390
00391       $term = (array) taxonomy_get_term($tid);
00392
00393       db_query('DELETE FROM {term_data} WHERE tid = %d', $tid);
00394       db_query('DELETE FROM {term_hierarchy} WHERE tid = %d', $tid);
00395       db_query('DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d', $tid, $tid);
00396       db_query('DELETE FROM {term_synonym} WHERE tid = %d', $tid);
00397       db_query('DELETE FROM {term_node} WHERE tid = %d', $tid);
00398
00399       module_invoke_all('taxonomy', 'delete', 'term', $term);
00400     }
00401
00402     $tids = $orphans;
00403   }
00404
00405   cache_clear_all();
00406
00407   return SAVED_DELETED;
00408 }
00409
00413 function taxonomy_form($vid, $value = 0, $help = NULL, $name = 'taxonomy') {
00414   $vocabulary = taxonomy_vocabulary_load($vid);
00415   $help = ($help) ? $help : $vocabulary->help;
00416
00417   if (!$vocabulary->multiple) {
00418     $blank = ($vocabulary->required) ? t('- Please choose -') : t('- None selected -');
00419   }
00420   else {
00421     $blank = ($vocabulary->required) ? 0 : t('- None -');
00422   }
00423
00424   return _taxonomy_term_select(check_plain($vocabulary->name), $name, $value, $vid, $help, intval($vocabulary->multiple), $blank);
00425 }
00426
00430 function taxonomy_form_all($free_tags = 0) {
00431   $vocabularies = taxonomy_get_vocabularies();
00432   $options = array();
00433   foreach ($vocabularies as $vid => $vocabulary) {
00434     if ($vocabulary->tags && !$free_tags) { continue; }
00435     $tree = taxonomy_get_tree($vid);
00436     if ($tree && (count($tree) > 0)) {
00437       $options[$vocabulary->name] = array();
00438       foreach ($tree as $term) {
00439         $options[$vocabulary->name][$term->tid] = str_repeat('-', $term->depth) . $term->name;
00440       }
00441     }
00442   }
00443   return $options;
00444 }
00445
00452 function taxonomy_get_vocabularies($type = NULL) {
00453   if ($type) {
00454     $result = db_query(db_rewrite_sql("SELECT v.vid, v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'v', 'vid'), $type);
00455   }
00456   else {
00457     $result = db_query(db_rewrite_sql('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid ORDER BY v.weight, v.name', 'v', 'vid'));
00458   }
00459
00460   $vocabularies = array();
00461   $node_types = array();
00462   while ($voc = db_fetch_object($result)) {
00463     // If no node types are associated with a vocabulary, the LEFT JOIN will
00464     // return a NULL value for type.
00465     if (isset($voc->type)) {
00466       $node_types[$voc->vid][$voc->type] = $voc->type;
00467       unset($voc->type);
00468       $voc->nodes = $node_types[$voc->vid];
00469     }
00470     elseif (!isset($voc->nodes)) {
00471       $voc->nodes = array();
00472     }
00473     $vocabularies[$voc->vid] = $voc;
00474   }
00475
00476   return $vocabularies;
00477 }
00478
00486 function taxonomy_form_alter(&$form, $form_state, $form_id) {
00487   if (isset($form['type']) && isset($form['#node']) && (!variable_get('taxonomy_override_selector', FALSE)) && $form['type']['#value'] .'_node_form' == $form_id) {
00488     $node = $form['#node'];
00489
00490     if (!isset($node->taxonomy)) {
00491       $terms = empty($node->nid) ? array() : taxonomy_node_get_terms($node);
00492     }
00493     else {
00494       // After preview the terms must be converted to objects.
00495       if (isset($form_state['node_preview'])) {
00496         $node->taxonomy = taxonomy_preview_terms($node);
00497       }
00498       $terms = $node->taxonomy;
00499     }
00500
00501     $c = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'v', 'vid'), $node->type);
00502
00503     while ($vocabulary = db_fetch_object($c)) {
00504       if ($vocabulary->tags) {
00505         if (isset($form_state['node_preview'])) {
00506           // Typed string can be changed by the user before preview,
00507           // so we just insert the tags directly as provided in the form.
00508           $typed_string = $node->taxonomy['tags'][$vocabulary->vid];
00509         }
00510         else {
00511           $typed_string = taxonomy_implode_tags($terms, $vocabulary->vid) . (array_key_exists('tags', $terms) ? $terms['tags'][$vocabulary->vid] : NULL);
00512         }
00513         if ($vocabulary->help) {
00514           $help = $vocabulary->help;
00515         }
00516         else {
00517           $help = t('A comma-separated list of terms describing this content. Example: funny, bungee jumping, "Company, Inc.".');
00518         }
00519         $form['taxonomy']['tags'][$vocabulary->vid] = array('#type' => 'textfield',
00520           '#title' => $vocabulary->name,
00521           '#description' => $help,
00522           '#required' => $vocabulary->required,
00523           '#default_value' => $typed_string,
00524           '#autocomplete_path' => 'taxonomy/autocomplete/'. $vocabulary->vid,
00525           '#weight' => $vocabulary->weight,
00526           '#maxlength' => 255,
00527         );
00528       }
00529       else {
00530         // Extract terms belonging to the vocabulary in question.
00531         $default_terms = array();
00532         foreach ($terms as $term) {
00533           // Free tagging has no default terms and also no vid after preview.
00534           if (isset($term->vid) && $term->vid == $vocabulary->vid) {
00535             $default_terms[$term->tid] = $term;
00536           }
00537         }
00538         $form['taxonomy'][$vocabulary->vid] = taxonomy_form($vocabulary->vid, array_keys($default_terms), $vocabulary->help);
00539         $form['taxonomy'][$vocabulary->vid]['#weight'] = $vocabulary->weight;
00540         $form['taxonomy'][$vocabulary->vid]['#required'] = $vocabulary->required;
00541       }
00542     }
00543     if (!empty($form['taxonomy']) && is_array($form['taxonomy'])) {
00544       if (count($form['taxonomy']) > 1) {
00545         // Add fieldset only if form has more than 1 element.
00546         $form['taxonomy'] += array(
00547           '#type' => 'fieldset',
00548           '#title' => t('Vocabularies'),
00549           '#collapsible' => TRUE,
00550           '#collapsed' => FALSE,
00551         );
00552       }
00553       $form['taxonomy']['#weight'] = -3;
00554       $form['taxonomy']['#tree'] = TRUE;
00555     }
00556   }
00557 }
00558
00568 function taxonomy_preview_terms($node) {
00569   $taxonomy = array();
00570   if (isset($node->taxonomy)) {
00571     foreach ($node->taxonomy as $key => $term) {
00572       unset($node->taxonomy[$key]);
00573       // A 'Multiple select' and a 'Free tagging' field returns an array.
00574       if (is_array($term)) {
00575         foreach ($term as $tid) {
00576           if ($key == 'tags') {
00577             // Free tagging; the values will be saved for later as strings
00578             // instead of objects to fill the form again.
00579             $taxonomy['tags'] = $term;
00580           }
00581           else {
00582             $taxonomy[$tid] = taxonomy_get_term($tid);
00583           }
00584         }
00585       }
00586       // A 'Single select' field returns the term id.
00587       elseif ($term) {
00588         $taxonomy[$term] = taxonomy_get_term($term);
00589       }
00590     }
00591   }
00592   return $taxonomy;
00593 }
00594
00598 function taxonomy_node_get_terms_by_vocabulary($node, $vid, $key = 'tid') {
00599   $result = db_query(db_rewrite_sql('SELECT t.tid, t.* FROM {term_data} t INNER JOIN {term_node} r ON r.tid = t.tid WHERE t.vid = %d AND r.vid = %d ORDER BY weight', 't', 'tid'), $vid, $node->vid);
00600   $terms = array();
00601   while ($term = db_fetch_object($result)) {
00602     $terms[$term->$key] = $term;
00603   }
00604   return $terms;
00605 }
00606
00610 function taxonomy_node_get_terms($node, $key = 'tid') {
00611   static $terms;
00612
00613   if (!isset($terms[$node->vid][$key])) {
00614     $result = db_query(db_rewrite_sql('SELECT t.* FROM {term_node} r INNER JOIN {term_data} t ON r.tid = t.tid INNER JOIN {vocabulary} v ON t.vid = v.vid WHERE r.vid = %d ORDER BY v.weight, t.weight, t.name', 't', 'tid'), $node->vid);
00615     $terms[$node->vid][$key] = array();
00616     while ($term = db_fetch_object($result)) {
00617       $terms[$node->vid][$key][$term->$key] = $term;
00618     }
00619   }
00620   return $terms[$node->vid][$key];
00621 }
00622
00626 function taxonomy_node_validate(&$node) {
00627   if (!empty($node->taxonomy)) {
00628     $terms = $node->taxonomy;
00629     if (!empty($terms['tags'])) {
00630       foreach ($terms['tags'] as $vid => $vid_value) {
00631         $vocabulary = taxonomy_vocabulary_load($vid);
00632         if (empty($vocabulary->tags)) {
00633           // see form_get_error $key = implode('][', $element['#parents']);
00634           // on why this is the key
00635           form_set_error("taxonomy][tags][$vid", t('The %name vocabulary can not be modified in this way.', array('%name' => $vocabulary->name)));
00636         }
00637       }
00638     }
00639   }
00640 }
00641
00645 function taxonomy_node_save($node, $terms) {
00646
00647   taxonomy_node_delete_revision($node);
00648
00649   // Free tagging vocabularies do not send their tids in the form,
00650   // so we'll detect them here and process them independently.
00651   if (isset($terms['tags'])) {
00652     $typed_input = $terms['tags'];
00653     unset($terms['tags']);
00654
00655     foreach ($typed_input as $vid => $vid_value) {
00656       $typed_terms = drupal_explode_tags($vid_value);
00657
00658       $inserted = array();
00659       foreach ($typed_terms as $typed_term) {
00660         // See if the term exists in the chosen vocabulary
00661         // and return the tid; otherwise, add a new record.
00662         $possibilities = taxonomy_get_term_by_name($typed_term);
00663         $typed_term_tid = NULL; // tid match, if any.
00664         foreach ($possibilities as $possibility) {
00665           if ($possibility->vid == $vid) {
00666             $typed_term_tid = $possibility->tid;
00667           }
00668         }
00669
00670         if (!$typed_term_tid) {
00671           $edit = array('vid' => $vid, 'name' => $typed_term);
00672           $status = taxonomy_save_term($edit);
00673           $typed_term_tid = $edit['tid'];
00674         }
00675
00676         // Defend against duplicate, differently cased tags
00677         if (!isset($inserted[$typed_term_tid])) {
00678           db_query('INSERT INTO {term_node} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $typed_term_tid);
00679           $inserted[$typed_term_tid] = TRUE;
00680         }
00681       }
00682     }
00683   }
00684
00685   if (is_array($terms)) {
00686     foreach ($terms as $term) {
00687       if (is_array($term)) {
00688         foreach ($term as $tid) {
00689           if ($tid) {
00690             db_query('INSERT INTO {term_node} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $tid);
00691           }
00692         }
00693       }
00694       else if (is_object($term)) {
00695         db_query('INSERT INTO {term_node} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $term->tid);
00696       }
00697       else if ($term) {
00698         db_query('INSERT INTO {term_node} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $term);
00699       }
00700     }
00701   }
00702 }
00703
00707 function taxonomy_node_delete($node) {
00708   db_query('DELETE FROM {term_node} WHERE nid = %d', $node->nid);
00709 }
00710
00714 function taxonomy_node_delete_revision($node) {
00715   db_query('DELETE FROM {term_node} WHERE vid = %d', $node->vid);
00716 }
00717
00721 function taxonomy_node_type($op, $info) {
00722   if ($op == 'update' && !empty($info->old_type) && $info->type != $info->old_type) {
00723     db_query("UPDATE {vocabulary_node_types} SET type = '%s' WHERE type = '%s'", $info->type, $info->old_type);
00724   }
00725   elseif ($op == 'delete') {
00726     db_query("DELETE FROM {vocabulary_node_types} WHERE type = '%s'", $info->type);
00727   }
00728 }
00729
00733 function taxonomy_get_related($tid, $key = 'tid') {
00734   if ($tid) {
00735     $result = db_query('SELECT t.*, tid1, tid2 FROM {term_relation}, {term_data} t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = %d OR tid2 = %d) AND t.tid != %d ORDER BY weight, name', $tid, $tid, $tid);
00736     $related = array();
00737     while ($term = db_fetch_object($result)) {
00738       $related[$term->$key] = $term;
00739     }
00740     return $related;
00741   }
00742   else {
00743     return array();
00744   }
00745 }
00746
00750 function taxonomy_get_parents($tid, $key = 'tid') {
00751   if ($tid) {
00752     $result = db_query(db_rewrite_sql('SELECT t.tid, t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.parent = t.tid WHERE h.tid = %d ORDER BY weight, name', 't', 'tid'), $tid);
00753     $parents = array();
00754     while ($parent = db_fetch_object($result)) {
00755       $parents[$parent->$key] = $parent;
00756     }
00757     return $parents;
00758   }
00759   else {
00760     return array();
00761   }
00762 }
00763
00767 function taxonomy_get_parents_all($tid) {
00768   $parents = array();
00769   if ($tid) {
00770     $parents[] = taxonomy_get_term($tid);
00771     $n = 0;
00772     while ($parent = taxonomy_get_parents($parents[$n]->tid)) {
00773       $parents = array_merge($parents, $parent);
00774       $n++;
00775     }
00776   }
00777   return $parents;
00778 }
00779
00783 function taxonomy_get_children($tid, $vid = 0, $key = 'tid') {
00784   if ($vid) {
00785     $result = db_query(db_rewrite_sql('SELECT t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.tid = t.tid WHERE t.vid = %d AND h.parent = %d ORDER BY weight, name', 't', 'tid'), $vid, $tid);
00786   }
00787   else {
00788     $result = db_query(db_rewrite_sql('SELECT t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.tid = t.tid WHERE parent = %d ORDER BY weight, name', 't', 'tid'), $tid);
00789   }
00790   $children = array();
00791   while ($term = db_fetch_object($result)) {
00792     $children[$term->$key] = $term;
00793   }
00794   return $children;
00795 }
00796
00818 function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL) {
00819   static $children, $parents, $terms;
00820
00821   $depth++;
00822
00823   // We cache trees, so it's not CPU-intensive to call get_tree() on a term
00824   // and its children, too.
00825   if (!isset($children[$vid])) {
00826     $children[$vid] = array();
00827
00828     $result = db_query(db_rewrite_sql('SELECT t.tid, t.*, parent FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE t.vid = %d ORDER BY weight, name', 't', 'tid'), $vid);
00829     while ($term = db_fetch_object($result)) {
00830       $children[$vid][$term->parent][] = $term->tid;
00831       $parents[$vid][$term->tid][] = $term->parent;
00832       $terms[$vid][$term->tid] = $term;
00833     }
00834   }
00835
00836   $max_depth = (is_null($max_depth)) ? count($children[$vid]) : $max_depth;
00837   $tree = array();
00838   if (!empty($children[$vid][$parent])) {
00839     foreach ($children[$vid][$parent] as $child) {
00840       if ($max_depth > $depth) {
00841         $term = drupal_clone($terms[$vid][$child]);
00842         $term->depth = $depth;
00843         // The "parent" attribute is not useful, as it would show one parent only.
00844         unset($term->parent);
00845         $term->parents = $parents[$vid][$child];
00846         $tree[] = $term;
00847
00848         if (!empty($children[$vid][$child])) {
00849           $tree = array_merge($tree, taxonomy_get_tree($vid, $child, $depth, $max_depth));
00850         }
00851       }
00852     }
00853   }
00854
00855   return $tree;
00856 }
00857
00861 function taxonomy_get_synonyms($tid) {
00862   if ($tid) {
00863     $synonyms = array();
00864     $result = db_query('SELECT name FROM {term_synonym} WHERE tid = %d', $tid);
00865     while ($synonym = db_fetch_array($result)) {
00866       $synonyms[] = $synonym['name'];
00867     }
00868     return $synonyms;
00869   }
00870   else {
00871     return array();
00872   }
00873 }
00874
00878 function taxonomy_get_synonym_root($synonym) {
00879   return db_fetch_object(db_query("SELECT * FROM {term_synonym} s, {term_data} t WHERE t.tid = s.tid AND s.name = '%s'", $synonym));
00880 }
00881
00896 function taxonomy_term_count_nodes($tid, $type = 0) {
00897   static $count;
00898
00899   if (!isset($count[$type])) {
00900     // $type == 0 always evaluates TRUE if $type is a string
00901     if (is_numeric($type)) {
00902       $result = db_query(db_rewrite_sql('SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 GROUP BY t.tid'));
00903     }
00904     else {
00905       $result = db_query(db_rewrite_sql("SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 AND n.type = '%s' GROUP BY t.tid"), $type);
00906     }
00907     while ($term = db_fetch_object($result)) {
00908       $count[$type][$term->tid] = $term->c;
00909     }
00910   }
00911   $children_count = 0;
00912   foreach (_taxonomy_term_children($tid) as $c) {
00913     $children_count += taxonomy_term_count_nodes($c, $type);
00914   }
00915   return $children_count + (isset($count[$type][$tid]) ? $count[$type][$tid] : 0);
00916 }
00917
00930 function _taxonomy_term_children($tid) {
00931   static $children;
00932
00933   if (!isset($children)) {
00934     $result = db_query('SELECT tid, parent FROM {term_hierarchy}');
00935     while ($term = db_fetch_object($result)) {
00936       $children[$term->parent][] = $term->tid;
00937     }
00938   }
00939   return isset($children[$tid]) ? $children[$tid] : array();
00940 }
00941
00954 function taxonomy_get_term_by_name($name) {
00955   $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {term_data} t WHERE LOWER(t.name) LIKE LOWER('%s')", 't', 'tid'), trim($name));
00956   $result = array();
00957   while ($term = db_fetch_object($db_result)) {
00958     $result[] = $term;
00959   }
00960
00961   return $result;
00962 }
00963
00974 function taxonomy_vocabulary_load($vid) {
00975   static $vocabularies = array();
00976
00977   if (!isset($vocabularies[$vid])) {
00978     // Initialize so if this vocabulary does not exist, we have
00979     // that cached, and we will not try to load this later.
00980     $vocabularies[$vid] = FALSE;
00981     // Try to load the data and fill up the object.
00982     $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d', $vid);
00983     $node_types = array();
00984     while ($voc = db_fetch_object($result)) {
00985       if (!empty($voc->type)) {
00986         $node_types[$voc->type] = $voc->type;
00987       }
00988       unset($voc->type);
00989       $voc->nodes = $node_types;
00990       $vocabularies[$vid] = $voc;
00991     }
00992   }
00993
00994   // Return NULL if this vocabulary does not exist.
00995   return !empty($vocabularies[$vid]) ? $vocabularies[$vid] : NULL;
00996 }
00997
01007 function taxonomy_get_term($tid) {
01008   static $terms = array();
01009
01010   if (!isset($terms[$tid])) {
01011     $terms[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid));
01012   }
01013
01014   return $terms[$tid];
01015 }
01016
01017 function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $description, $multiple, $blank, $exclude = array()) {
01018   $tree = taxonomy_get_tree($vocabulary_id);
01019   $options = array();
01020
01021   if ($blank) {
01022     $options[''] = $blank;
01023   }
01024   if ($tree) {
01025     foreach ($tree as $term) {
01026       if (!in_array($term->tid, $exclude)) {
01027         $choice = new stdClass();
01028         $choice->option = array($term->tid => str_repeat('-', $term->depth) . $term->name);
01029         $options[] = $choice;
01030       }
01031     }
01032   }
01033
01034   return array('#type' => 'select',
01035     '#title' => $title,
01036     '#default_value' => $value,
01037     '#options' => $options,
01038     '#description' => $description,
01039     '#multiple' => $multiple,
01040     '#size' => $multiple ? min(9, count($options)) : 0,
01041     '#weight' => -15,
01042     '#theme' => 'taxonomy_term_select',
01043   );
01044 }
01045
01052 function theme_taxonomy_term_select($element) {
01053   return theme('select', $element);
01054 }
01055
01074 function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $pager = TRUE, $order = 'n.sticky DESC, n.created DESC') {
01075   if (count($tids) > 0) {
01076     // For each term ID, generate an array of descendant term IDs to the right depth.
01077     $descendant_tids = array();
01078     if ($depth === 'all') {
01079       $depth = NULL;
01080     }
01081     foreach ($tids as $index => $tid) {
01082       $term = taxonomy_get_term($tid);
01083       $tree = taxonomy_get_tree($term->vid, $tid, -1, $depth);
01084       $descendant_tids[] = array_merge(array($tid), array_map('_taxonomy_get_tid_from_term', $tree));
01085     }
01086
01087     if ($operator == 'or') {
01088       $args = call_user_func_array('array_merge', $descendant_tids);
01089       $placeholders = db_placeholders($args, 'int');
01090       $sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid WHERE tn.tid IN ('. $placeholders .') AND n.status = 1 ORDER BY '. $order;
01091       $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid WHERE tn.tid IN ('. $placeholders .') AND n.status = 1';
01092     }
01093     else {
01094       $joins = '';
01095       $wheres = '';
01096       $args = array();
01097       foreach ($descendant_tids as $index => $tids) {
01098         $joins .= ' INNER JOIN {term_node} tn'. $index .' ON n.vid = tn'. $index .'.vid';
01099         $wheres .= ' AND tn'. $index .'.tid IN ('. db_placeholders($tids, 'int') .')';
01100         $args = array_merge($args, $tids);
01101       }
01102       $sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n '. $joins .' WHERE n.status = 1 '. $wheres .' ORDER BY '. $order;
01103       $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n '. $joins .' WHERE n.status = 1 '. $wheres;
01104     }
01105     $sql = db_rewrite_sql($sql);
01106     $sql_count = db_rewrite_sql($sql_count);
01107     if ($pager) {
01108       $result = pager_query($sql, variable_get('default_nodes_main', 10), 0, $sql_count, $args);
01109     }
01110     else {
01111       $result = db_query_range($sql, $args, 0, variable_get('feed_default_items', 10));
01112     }
01113   }
01114
01115   return $result;
01116 }
01117
01122 function taxonomy_render_nodes($result) {
01123   $output = '';
01124   $has_rows = FALSE;
01125   while ($node = db_fetch_object($result)) {
01126     $output .= node_view(node_load($node->nid), 1);
01127     $has_rows = TRUE;
01128   }
01129   if ($has_rows) {
01130     $output .= theme('pager', NULL, variable_get('default_nodes_main', 10), 0);
01131   }
01132   else {
01133     $output .= '<p>'. t('There are currently no posts in this category.') .'</p>';
01134   }
01135   return $output;
01136 }
01137
01141 function taxonomy_nodeapi($node, $op, $arg = 0) {
01142   switch ($op) {
01143     case 'load':
01144       $output['taxonomy'] = taxonomy_node_get_terms($node);
01145       return $output;
01146
01147     case 'insert':
01148       if (!empty($node->taxonomy)) {
01149         taxonomy_node_save($node, $node->taxonomy);
01150       }
01151       break;
01152
01153     case 'update':
01154       if (!empty($node->taxonomy)) {
01155         taxonomy_node_save($node, $node->taxonomy);
01156       }
01157       break;
01158
01159     case 'delete':
01160       taxonomy_node_delete($node);
01161       break;
01162
01163     case 'delete revision':
01164       taxonomy_node_delete_revision($node);
01165       break;
01166
01167     case 'validate':
01168       taxonomy_node_validate($node);
01169       break;
01170
01171     case 'rss item':
01172       return taxonomy_rss_item($node);
01173
01174     case 'update index':
01175       return taxonomy_node_update_index($node);
01176   }
01177 }
01178
01182 function taxonomy_node_update_index(&$node) {
01183   $output = array();
01184   foreach ($node->taxonomy as $term) {
01185     $output[] = $term->name;
01186   }
01187   if (count($output)) {
01188     return '<strong>('. implode(', ', $output) .')</strong>';
01189   }
01190 }
01191
01203 function taxonomy_terms_parse_string($str_tids) {
01204   $terms = array('operator' => '', 'tids' => array());
01205   if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', $str_tids)) {
01206     $terms['operator'] = 'or';
01207     // The '+' character in a query string may be parsed as ' '.
01208     $terms['tids'] = preg_split('/[+ ]/', $str_tids);
01209   }
01210   else if (preg_match('/^([0-9]+,)*[0-9]+$/', $str_tids)) {
01211     $terms['operator'] = 'and';
01212     $terms['tids'] = explode(',', $str_tids);
01213   }
01214   return $terms;
01215 }
01216
01220 function taxonomy_rss_item($node) {
01221   $output = array();
01222   foreach ($node->taxonomy as $term) {
01223     $output[] = array('key'   => 'category',
01224                       'value' => check_plain($term->name),
01225                       'attributes' => array('domain' => url('taxonomy/term/'. $term->tid, array('absolute' => TRUE))));
01226   }
01227   return $output;
01228 }
01229
01233 function taxonomy_help($path, $arg) {
01234   switch ($path) {
01235     case 'admin/help#taxonomy':
01236       $output = '<p>'. t('The taxonomy module allows you to categorize content using various systems of classification. Free-tagging vocabularies are created by users on the fly when they submit posts (as commonly found in blogs and social bookmarking applications). Controlled vocabularies allow for administrator-defined short lists of terms as well as complex hierarchies with multiple relationships between different terms. These methods can be applied to different content types and combined together to create a powerful and flexible method of classifying and presenting your content.') .'</p>';
01237       $output .= '<p>'. t('For example, when creating a recipe site, you might want to classify posts by both the type of meal and preparation time. A vocabulary for each allows you to categorize using each criteria independently instead of creating a tag for every possible combination.') .'</p>';
01238       $output .= '<p>'. t('Type of Meal: <em>Appetizer, Main Course, Salad, Dessert</em>') .'</p>';
01239       $output .= '<p>'. t('Preparation Time: <em>0-30mins, 30-60mins, 1-2 hrs, 2hrs+</em>') .'</p>';
01240       $output .= '<p>'. t("Each taxonomy term (often called a 'category' or 'tag' in other systems) automatically provides lists of posts and a corresponding RSS feed. These taxonomy/term URLs can be manipulated to generate AND and OR lists of posts classified with terms. In our recipe site example, it then becomes easy to create pages displaying 'Main courses', '30 minute recipes', or '30 minute main courses and appetizers' by using terms on their own or in combination with others. There are a significant number of contributed modules which you to alter and extend the behavior of the core module for both display and organization of terms.") .'</p>';
01241       $output .= '<p>'. t("Terms can also be organized in parent/child relationships from the admin interface. An example would be a vocabulary grouping countries under their parent geo-political regions. The taxonomy module also enables advanced implementations of hierarchy, for example placing Turkey in both the 'Middle East' and 'Europe'.") .'</p>';
01242       $output .= '<p>'. t('The taxonomy module supports the use of both synonyms and related terms, but does not directly use this functionality. However, optional contributed or custom modules may make full use of these advanced features.') .'</p>';
01243       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@taxonomy">Taxonomy module</a>.', array('@taxonomy' => 'http://drupal.org/handbook/modules/taxonomy/')) .'</p>';
01244       return $output;
01245     case 'admin/content/taxonomy':
01246       $output = '<p>'. t("The taxonomy module allows you to categorize your content using both tags and administrator defined terms. It is a flexible tool for classifying content with many advanced features. To begin, create a 'Vocabulary' to hold one set of terms or tags. You can create one free-tagging vocabulary for everything, or separate controlled vocabularies to define the various properties of your content, for example 'Countries' or 'Colors'.") .'</p>';
01247       $output .= '<p>'. t('Use the list below to configure and review the vocabularies defined on your site, or to list and manage the terms (tags) they contain. A vocabulary may (optionally) be tied to specific content types as shown in the <em>Type</em> column and, if so, will be displayed when creating or editing posts of that type. Multiple vocabularies tied to the same content type will be displayed in the order shown below. To change the order of a vocabulary, grab a drag-and-drop handle under the <em>Name</em> column and drag it to a new location in the list. (Grab a handle by clicking and holding the mouse while hovering over a handle icon.) Remember that your changes will not be saved until you click the <em>Save</em> button at the bottom of the page.') .'</p>';
01248       return $output;
01249     case 'admin/content/taxonomy/%':
01250       $vocabulary = taxonomy_vocabulary_load($arg[3]);
01251       if ($vocabulary->tags) {
01252         return '<p>'. t('%capital_name is a free-tagging vocabulary. To change the name or description of a term, click the <em>edit</em> link next to the term.', array('%capital_name' => drupal_ucfirst($vocabulary->name))) .'</p>';
01253       }
01254       switch ($vocabulary->hierarchy) {
01255         case 0:
01256           return '<p>'. t('%capital_name is a flat vocabulary. You may organize the terms in the %name vocabulary by using the handles on the left side of the table. To change the name or description of a term, click the <em>edit</em> link next to the term.', array('%capital_name' => drupal_ucfirst($vocabulary->name), '%name' => $vocabulary->name)) .'</p>';
01257         case 1:
01258           return '<p>'. t('%capital_name is a single hierarchy vocabulary. You may organize the terms in the %name vocabulary by using the handles on the left side of the table. To change the name or description of a term, click the <em>edit</em> link next to the term.', array('%capital_name' => drupal_ucfirst($vocabulary->name), '%name' => $vocabulary->name)) .'</p>';
01259         case 2:
01260           return '<p>'. t('%capital_name is a multiple hierarchy vocabulary. To change the name or description of a term, click the <em>edit</em> link next to the term. Drag and drop of multiple hierarchies is not supported, but you can re-enable drag and drop support by editing each term to include only a single parent.', array('%capital_name' => drupal_ucfirst($vocabulary->name))) .'</p>';
01261       }
01262     case 'admin/content/taxonomy/add/vocabulary':
01263       return '<p>'. t('Define how your vocabulary will be presented to administrators and users, and which content types to categorize with it. Tags allows users to create terms when submitting posts by typing a comma separated list. Otherwise terms are chosen from a select list and can only be created by users with the "administer taxonomy" permission.') .'</p>';
01264   }
01265 }
01266
01270 function _taxonomy_get_tid_from_term($term) {
01271   return $term->tid;
01272 }
01273
01277 function taxonomy_implode_tags($tags, $vid = NULL) {
01278   $typed_tags = array();
01279   foreach ($tags as $tag) {
01280     // Extract terms belonging to the vocabulary in question.
01281     if (is_null($vid) || $tag->vid == $vid) {
01282
01283       // Commas and quotes in tag names are special cases, so encode 'em.
01284       if (strpos($tag->name, ',') !== FALSE || strpos($tag->name, '"') !== FALSE) {
01285         $tag->name = '"'. str_replace('"', '""', $tag->name) .'"';
01286       }
01287
01288       $typed_tags[] = $tag->name;
01289     }
01290   }
01291   return implode(', ', $typed_tags);
01292 }
01293
01297 function taxonomy_hook_info() {
01298   return array(
01299     'taxonomy' => array(
01300       'taxonomy' => array(
01301         'insert' => array(
01302           'runs when' => t('After saving a new term to the database'),
01303         ),
01304         'update' => array(
01305           'runs when' => t('After saving an updated term to the database'),
01306         ),
01307         'delete' => array(
01308           'runs when' => t('After deleting a term')
01309         ),
01310       ),
01311     ),
01312   );
01313 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/taxonomy/taxonomy.pages.inc Source File

modules » taxonomy

taxonomy.pages.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: taxonomy.pages.inc,v 1.9 2008/01/18 16:23:57 goba Exp $
00003
00012 function taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') {
00013   $terms = taxonomy_terms_parse_string($str_tids);
00014   if ($terms['operator'] != 'and' && $terms['operator'] != 'or') {
00015     drupal_not_found();
00016   }
00017
00018   if ($terms['tids']) {
00019     $result = db_query(db_rewrite_sql('SELECT t.tid, t.name FROM {term_data} t WHERE t.tid IN ('. db_placeholders($terms['tids']) .')', 't', 'tid'), $terms['tids']);
00020     $tids = array(); // we rebuild the $tids-array so it only contains terms the user has access to.
00021     $names = array();
00022     while ($term = db_fetch_object($result)) {
00023       $tids[] = $term->tid;
00024       $names[] = $term->name;
00025     }
00026
00027     if ($names) {
00028       $title = check_plain(implode(', ', $names));
00029       drupal_set_title($title);
00030
00031       switch ($op) {
00032         case 'page':
00033           // Build breadcrumb based on first hierarchy of first term:
00034           $current->tid = $tids[0];
00035           $breadcrumb = array();
00036           while ($parents = taxonomy_get_parents($current->tid)) {
00037             $current = array_shift($parents);
00038             $breadcrumb[] = l($current->name, 'taxonomy/term/'. $current->tid);
00039           }
00040           $breadcrumb[] = l(t('Home'), NULL);
00041           $breadcrumb = array_reverse($breadcrumb);
00042           drupal_set_breadcrumb($breadcrumb);
00043
00044           $output = theme('taxonomy_term_page', $tids, taxonomy_select_nodes($tids, $terms['operator'], $depth, TRUE));
00045           drupal_add_feed(url('taxonomy/term/'. $str_tids .'/'. $depth .'/feed'), 'RSS - '. $title);
00046           return $output;
00047           break;
00048
00049         case 'feed':
00050           $channel['link'] = url('taxonomy/term/'. $str_tids .'/'. $depth, array('absolute' => TRUE));
00051           $channel['title'] = variable_get('site_name', 'Drupal') .' - '. $title;
00052           // Only display the description if we have a single term, to avoid clutter and confusion.
00053           if (count($tids) == 1) {
00054             $term = taxonomy_get_term($tids[0]);
00055             // HTML will be removed from feed description, so no need to filter here.
00056             $channel['description'] = $term->description;
00057           }
00058
00059           $result = taxonomy_select_nodes($tids, $terms['operator'], $depth, FALSE);
00060           $items = array();
00061           while ($row = db_fetch_object($result)) {
00062             $items[] = $row->nid;
00063           }
00064
00065           node_feed($items, $channel);
00066           break;
00067
00068         default:
00069           drupal_not_found();
00070       }
00071     }
00072     else {
00073       drupal_not_found();
00074     }
00075   }
00076 }
00077
00088 function theme_taxonomy_term_page($tids, $result) {
00089   drupal_add_css(drupal_get_path('module', 'taxonomy') .'/taxonomy.css');
00090
00091   $output = '';
00092
00093   // Only display the description if we have a single term, to avoid clutter and confusion.
00094   if (count($tids) == 1) {
00095     $term = taxonomy_get_term($tids[0]);
00096     $description = $term->description;
00097
00098     // Check that a description is set.
00099     if (!empty($description)) {
00100       $output .= '<div class="taxonomy-term-description">';
00101       $output .= filter_xss_admin($description);
00102       $output .= '</div>';
00103     }
00104   }
00105
00106   $output .= taxonomy_render_nodes($result);
00107
00108   return $output;
00109 }
00110
00114 function taxonomy_autocomplete($vid, $string = '') {
00115   // The user enters a comma-separated list of tags. We only autocomplete the last tag.
00116   $array = drupal_explode_tags($string);
00117
00118   // Fetch last tag
00119   $last_string = trim(array_pop($array));
00120   $matches = array();
00121   if ($last_string != '') {
00122     $result = db_query_range(db_rewrite_sql("SELECT t.tid, t.name FROM {term_data} t WHERE t.vid = %d AND LOWER(t.name) LIKE LOWER('%%%s%%')", 't', 'tid'), $vid, $last_string, 0, 10);
00123
00124     $prefix = count($array) ? implode(', ', $array) .', ' : '';
00125
00126     while ($tag = db_fetch_object($result)) {
00127       $n = $tag->name;
00128       // Commas and quotes in terms are special cases, so encode 'em.
00129       if (strpos($tag->name, ',') !== FALSE || strpos($tag->name, '"') !== FALSE) {
00130         $n = '"'. str_replace('"', '""', $tag->name) .'"';
00131       }
00132       $matches[$prefix . $n] = check_plain($tag->name);
00133     }
00134   }
00135
00136   drupal_json($matches);
00137 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/template.php Source File

themes » garland

template.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: template.php,v 1.16 2007/10/11 09:51:29 goba Exp $
00003
00009 function phptemplate_body_class($left, $right) {
00010   if ($left != '' && $right != '') {
00011     $class = 'sidebars';
00012   }
00013   else {
00014     if ($left != '') {
00015       $class = 'sidebar-left';
00016     }
00017     if ($right != '') {
00018       $class = 'sidebar-right';
00019     }
00020   }
00021
00022   if (isset($class)) {
00023     print ' class="'. $class .'"';
00024   }
00025 }
00026
00034 function phptemplate_breadcrumb($breadcrumb) {
00035   if (!empty($breadcrumb)) {
00036     return '<div class="breadcrumb">'. implode(' › ', $breadcrumb) .'</div>';
00037   }
00038 }
00039
00043 function phptemplate_comment_wrapper($content, $node) {
00044   if (!$content || $node->type == 'forum') {
00045     return '<div id="comments">'. $content .'</div>';
00046   }
00047   else {
00048     return '<div id="comments"><h2 class="comments">'. t('Comments') .'</h2>'. $content .'</div>';
00049   }
00050 }
00051
00055 function phptemplate_preprocess_page(&$vars) {
00056   $vars['tabs2'] = menu_secondary_local_tasks();
00057
00058   // Hook into color.module
00059   if (module_exists('color')) {
00060     _color_page_alter($vars);
00061   }
00062 }
00063
00070 function phptemplate_menu_local_tasks() {
00071   return menu_primary_local_tasks();
00072 }
00073
00074 function phptemplate_comment_submitted($comment) {
00075   return t('!datetime — !username',
00076     array(
00077       '!username' => theme('username', $comment),
00078       '!datetime' => format_date($comment->timestamp)
00079     ));
00080 }
00081
00082 function phptemplate_node_submitted($node) {
00083   return t('!datetime — !username',
00084     array(
00085       '!username' => theme('username', $node),
00086       '!datetime' => format_date($node->created),
00087     ));
00088 }
00089
00093 function phptemplate_get_ie_styles() {
00094   global $language;
00095
00096   $iecss = '<link type="text/css" rel="stylesheet" media="all" href="'. base_path() . path_to_theme() .'/fix-ie.css" />';
00097   if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) {
00098     $iecss .= '<style type="text/css" media="all">@import "'. base_path() . path_to_theme() .'/fix-ie-rtl.css";</style>';
00099   }
00100
00101   return $iecss;
00102 }
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/theme.inc Source File

includes

theme.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: theme.inc,v 1.415 2008/01/27 19:47:06 goba Exp $
00003
00021 define('MARK_READ',    0);
00022 define('MARK_NEW',     1);
00023 define('MARK_UPDATED', 2);
00031 function init_theme() {
00032   global $theme, $user, $custom_theme, $theme_key;
00033
00034   // If $theme is already set, assume the others are set, too, and do nothing
00035   if (isset($theme)) {
00036     return;
00037   }
00038
00039   drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
00040   $themes = list_themes();
00041
00042   // Only select the user selected theme if it is available in the
00043   // list of enabled themes.
00044   $theme = !empty($user->theme) && !empty($themes[$user->theme]->status) ? $user->theme : variable_get('theme_default', 'garland');
00045
00046   // Allow modules to override the present theme... only select custom theme
00047   // if it is available in the list of installed themes.
00048   $theme = $custom_theme && $themes[$custom_theme] ? $custom_theme : $theme;
00049
00050   // Store the identifier for retrieving theme settings with.
00051   $theme_key = $theme;
00052
00053   // Find all our ancestor themes and put them in an array.
00054   $base_theme = array();
00055   $ancestor = $theme;
00056   while ($ancestor && isset($themes[$ancestor]->base_theme)) {
00057     $base_theme[] = $new_base_theme = $themes[$themes[$ancestor]->base_theme];
00058     $ancestor = $themes[$ancestor]->base_theme;
00059   }
00060   _init_theme($themes[$theme], array_reverse($base_theme));
00061 }
00062
00088 function _init_theme($theme, $base_theme = array(), $registry_callback = '_theme_load_registry') {
00089   global $theme_info, $base_theme_info, $theme_engine, $theme_path;
00090   $theme_info = $theme;
00091   $base_theme_info = $base_theme;
00092
00093   $theme_path = dirname($theme->filename);
00094
00095   // Prepare stylesheets from this theme as well as all ancestor themes.
00096   // We work it this way so that we can have child themes override parent
00097   // theme stylesheets easily.
00098   $final_stylesheets = array();
00099
00100   // Grab stylesheets from base theme
00101   foreach ($base_theme as $base) {
00102     if (!empty($base->stylesheets)) {
00103       foreach ($base->stylesheets as $media => $stylesheets) {
00104         foreach ($stylesheets as $name => $stylesheet) {
00105           $final_stylesheets[$media][$name] = $stylesheet;
00106         }
00107       }
00108     }
00109   }
00110
00111   // Add stylesheets used by this theme.
00112   if (!empty($theme->stylesheets)) {
00113     foreach ($theme->stylesheets as $media => $stylesheets) {
00114       foreach ($stylesheets as $name => $stylesheet) {
00115         $final_stylesheets[$media][$name] = $stylesheet;
00116       }
00117     }
00118   }
00119
00120   // And now add the stylesheets properly
00121   foreach ($final_stylesheets as $media => $stylesheets) {
00122     foreach ($stylesheets as $stylesheet) {
00123       drupal_add_css($stylesheet, 'theme', $media);
00124     }
00125   }
00126
00127   // Do basically the same as the above for scripts
00128   $final_scripts = array();
00129
00130   // Grab scripts from base theme
00131   foreach ($base_theme as $base) {
00132     if (!empty($base->scripts)) {
00133       foreach ($base->scripts as $name => $script) {
00134         $final_scripts[$name] = $script;
00135       }
00136     }
00137   }
00138
00139   // Add scripts used by this theme.
00140   if (!empty($theme->scripts)) {
00141     foreach ($theme->scripts as $name => $script) {
00142       $final_scripts[$name] = $script;
00143     }
00144   }
00145
00146   // Add scripts used by this theme.
00147   foreach ($final_scripts as $script) {
00148     drupal_add_js($script, 'theme');
00149   }
00150
00151   $theme_engine = NULL;
00152
00153   // Initialize the theme.
00154   if (isset($theme->engine)) {
00155     // Include the engine.
00156     include_once './'. $theme->owner;
00157
00158     $theme_engine = $theme->engine;
00159     if (function_exists($theme_engine .'_init')) {
00160       foreach ($base_theme as $base) {
00161         call_user_func($theme_engine .'_init', $base);
00162       }
00163       call_user_func($theme_engine .'_init', $theme);
00164     }
00165   }
00166   else {
00167     // include non-engine theme files
00168     foreach ($base_theme as $base) {
00169       // Include the theme file or the engine.
00170       if (!empty($base->owner)) {
00171         include_once './'. $base->owner;
00172       }
00173     }
00174     // and our theme gets one too.
00175     if (!empty($theme->owner)) {
00176       include_once './'. $theme->owner;
00177     }
00178   }
00179
00180   $registry_callback($theme, $base_theme, $theme_engine);
00181 }
00182
00189 function theme_get_registry($registry = NULL) {
00190   static $theme_registry = NULL;
00191   if (isset($registry)) {
00192     $theme_registry = $registry;
00193   }
00194
00195   return $theme_registry;
00196 }
00197
00201 function _theme_set_registry($registry) {
00202   // Pass through for setting of static variable.
00203   return theme_get_registry($registry);
00204 }
00205
00218 function _theme_load_registry($theme, $base_theme = NULL, $theme_engine = NULL) {
00219   // Check the theme registry cache; if it exists, use it.
00220   $cache = cache_get("theme_registry:$theme->name", 'cache');
00221   if (isset($cache->data)) {
00222     $registry = $cache->data;
00223   }
00224   else {
00225     // If not, build one and cache it.
00226     $registry = _theme_build_registry($theme, $base_theme, $theme_engine);
00227     _theme_save_registry($theme, $registry);
00228   }
00229   _theme_set_registry($registry);
00230 }
00231
00235 function _theme_save_registry($theme, $registry) {
00236   cache_set("theme_registry:$theme->name", $registry);
00237 }
00238
00244 function drupal_rebuild_theme_registry() {
00245   cache_clear_all('theme_registry', 'cache', TRUE);
00246 }
00247
00263 function _theme_process_registry(&$cache, $name, $type, $theme, $path) {
00264   $function = $name .'_theme';
00265   if (function_exists($function)) {
00266     $result = $function($cache, $type, $theme, $path);
00267
00268     foreach ($result as $hook => $info) {
00269       $result[$hook]['type'] = $type;
00270       $result[$hook]['theme path'] = $path;
00271       // if function and file are left out, default to standard naming
00272       // conventions.
00273       if (!isset($info['template']) && !isset($info['function'])) {
00274         $result[$hook]['function'] = ($type == 'module' ? 'theme_' : $name .'_') . $hook;
00275       }
00276       // If a path is set in the info, use what was set. Otherwise use the
00277       // default path. This is mostly so system.module can declare theme
00278       // functions on behalf of core .include files.
00279       // All files are included to be safe. Conditionally included
00280       // files can prevent them from getting registered.
00281       if (isset($info['file']) && !isset($info['path'])) {
00282         $result[$hook]['file'] = $path .'/'. $info['file'];
00283         include_once($result[$hook]['file']);
00284       }
00285       elseif (isset($info['file']) && isset($info['path'])) {
00286         include_once($info['path'] .'/'. $info['file']);
00287       }
00288
00289       if (isset($info['template']) && !isset($info['path'])) {
00290         $result[$hook]['template'] = $path .'/'. $info['template'];
00291       }
00292       // If 'arguments' have been defined previously, carry them forward.
00293       // This should happen if a theme overrides a Drupal defined theme
00294       // function, for example.
00295       if (!isset($info['arguments']) && isset($cache[$hook])) {
00296         $result[$hook]['arguments'] = $cache[$hook]['arguments'];
00297       }
00298       // Likewise with theme paths. These are used for template naming suggestions.
00299       // Theme implementations can occur in multiple paths. Suggestions should follow.
00300       if (!isset($info['theme paths']) && isset($cache[$hook])) {
00301         $result[$hook]['theme paths'] = $cache[$hook]['theme paths'];
00302       }
00303       // Check for sub-directories.
00304       $result[$hook]['theme paths'][] = isset($info['path']) ? $info['path'] : $path;
00305
00306       // Check for default _preprocess_ functions. Ensure arrayness.
00307       if (!isset($info['preprocess functions']) || !is_array($info['preprocess functions'])) {
00308         $info['preprocess functions'] = array();
00309         $prefixes = array();
00310         if ($type == 'module') {
00311           // Default preprocessor prefix.
00312           $prefixes[] = 'template';
00313           // Add all modules so they can intervene with their own preprocessors. This allows them
00314           // to provide preprocess functions even if they are not the owner of the current hook.
00315           $prefixes += module_list();
00316         }
00317         elseif ($type == 'theme_engine') {
00318           // Theme engines get an extra set that come before the normally named preprocessors.
00319           $prefixes[] = $name .'_engine';
00320           // The theme engine also registers on behalf of the theme. The theme or engine name can be used.
00321           $prefixes[] = $name;
00322           $prefixes[] = $theme;
00323         }
00324         else {
00325           // This applies when the theme manually registers their own preprocessors.
00326           $prefixes[] = $name;
00327         }
00328
00329         foreach ($prefixes as $prefix) {
00330           if (function_exists($prefix .'_preprocess')) {
00331             $info['preprocess functions'][] = $prefix .'_preprocess';
00332           }
00333           if (function_exists($prefix .'_preprocess_'. $hook)) {
00334             $info['preprocess functions'][] = $prefix .'_preprocess_'. $hook;
00335           }
00336         }
00337       }
00338       // Check for the override flag and prevent the cached preprocess functions from being used.
00339       // This allows themes or theme engines to remove preprocessors set earlier in the registry build.
00340       if (!empty($info['override preprocess functions'])) {
00341         // Flag not needed inside the registry.
00342         unset($result[$hook]['override preprocess functions']);
00343       }
00344       elseif (isset($cache[$hook]['preprocess functions']) && is_array($cache[$hook]['preprocess functions'])) {
00345         $info['preprocess functions'] = array_merge($cache[$hook]['preprocess functions'], $info['preprocess functions']);
00346       }
00347       $result[$hook]['preprocess functions'] = $info['preprocess functions'];
00348     }
00349
00350     // Merge the newly created theme hooks into the existing cache.
00351     $cache = array_merge($cache, $result);
00352   }
00353 }
00354
00366 function _theme_build_registry($theme, $base_theme, $theme_engine) {
00367   $cache = array();
00368   // First, process the theme hooks advertised by modules. This will
00369   // serve as the basic registry.
00370   foreach (module_implements('theme') as $module) {
00371     _theme_process_registry($cache, $module, 'module', $module, drupal_get_path('module', $module));
00372   }
00373
00374   // Process each base theme.
00375   foreach ($base_theme as $base) {
00376     // If the theme uses a theme engine, process its hooks.
00377     $base_path = dirname($base->filename);
00378     if ($theme_engine) {
00379       _theme_process_registry($cache, $theme_engine, 'base_theme_engine', $base->name, $base_path);
00380     }
00381     _theme_process_registry($cache, $base->name, 'base_theme', $base->name, $base_path);
00382   }
00383
00384   // And then the same thing, but for the theme.
00385   if ($theme_engine) {
00386     _theme_process_registry($cache, $theme_engine, 'theme_engine', $theme->name, dirname($theme->filename));
00387   }
00388
00389   // Finally, hooks provided by the theme itself.
00390   _theme_process_registry($cache, $theme->name, 'theme', $theme->name, dirname($theme->filename));
00391
00392   // Let modules alter the registry
00393   drupal_alter('theme_registry', $cache);
00394   return $cache;
00395 }
00396
00408 function list_themes($refresh = FALSE) {
00409   static $list = array();
00410
00411   if ($refresh) {
00412     $list = array();
00413   }
00414
00415   if (empty($list)) {
00416     $list = array();
00417     $themes = array();
00418     // Extract from the database only when it is available.
00419     // Also check that the site is not in the middle of an install or update.
00420     if (db_is_active() && !defined('MAINTENANCE_MODE')) {
00421       $result = db_query("SELECT * FROM {system} WHERE type = '%s'", 'theme');
00422       while ($theme = db_fetch_object($result)) {
00423         if (file_exists($theme->filename)) {
00424           $theme->info = unserialize($theme->info);
00425           $themes[] = $theme;
00426         }
00427       }
00428     }
00429     else {
00430       // Scan the installation when the database should not be read.
00431       $themes = _system_theme_data();
00432     }
00433
00434     foreach ($themes as $theme) {
00435       foreach ($theme->info['stylesheets'] as $media => $stylesheets) {
00436         foreach ($stylesheets as $stylesheet => $path) {
00437           if (file_exists($path)) {
00438             $theme->stylesheets[$media][$stylesheet] = $path;
00439           }
00440         }
00441       }
00442       foreach ($theme->info['scripts'] as $script => $path) {
00443         if (file_exists($path)) {
00444           $theme->scripts[$script] = $path;
00445         }
00446       }
00447       if (isset($theme->info['engine'])) {
00448         $theme->engine = $theme->info['engine'];
00449       }
00450       if (isset($theme->info['base theme'])) {
00451         $theme->base_theme = $theme->info['base theme'];
00452       }
00453       // Status is normally retrieved from the database. Add zero values when
00454       // read from the installation directory to prevent notices.
00455       if (!isset($theme->status)) {
00456         $theme->status = 0;
00457       }
00458       $list[$theme->name] = $theme;
00459     }
00460   }
00461
00462   return $list;
00463 }
00464
00552 function theme() {
00553   $args = func_get_args();
00554   $hook = array_shift($args);
00555
00556   static $hooks = NULL;
00557   if (!isset($hooks)) {
00558     init_theme();
00559     $hooks = theme_get_registry();
00560   }
00561
00562   if (is_array($hook)) {
00563     foreach ($hook as $candidate) {
00564       if (isset($hooks[$candidate])) {
00565         break;
00566       }
00567     }
00568     $hook = $candidate;
00569   }
00570
00571   if (!isset($hooks[$hook])) {
00572     return;
00573   }
00574
00575   $info = $hooks[$hook];
00576   global $theme_path;
00577   $temp = $theme_path;
00578   // point path_to_theme() to the currently used theme path:
00579   $theme_path = $hooks[$hook]['theme path'];
00580
00581   // Include a file if the theme function or preprocess function is held elsewhere.
00582   if (!empty($info['file'])) {
00583     $include_file = $info['file'];
00584     if (isset($info['path'])) {
00585       $include_file = $info['path'] .'/'. $include_file;
00586     }
00587     include_once($include_file);
00588   }
00589   if (isset($info['function'])) {
00590     // The theme call is a function.
00591     $output = call_user_func_array($info['function'], $args);
00592   }
00593   else {
00594     // The theme call is a template.
00595     $variables = array(
00596       'template_files' => array()
00597     );
00598     if (!empty($info['arguments'])) {
00599       $count = 0;
00600       foreach ($info['arguments'] as $name => $default) {
00601         $variables[$name] = isset($args[$count]) ? $args[$count] : $default;
00602         $count++;
00603       }
00604     }
00605
00606     // default render function and extension.
00607     $render_function = 'theme_render_template';
00608     $extension = '.tpl.php';
00609
00610     // Run through the theme engine variables, if necessary
00611     global $theme_engine;
00612     if (isset($theme_engine)) {
00613       // If theme or theme engine is implementing this, it may have
00614       // a different extension and a different renderer.
00615       if ($hooks[$hook]['type'] != 'module') {
00616         if (function_exists($theme_engine .'_render_template')) {
00617           $render_function = $theme_engine .'_render_template';
00618         }
00619         $extension_function = $theme_engine .'_extension';
00620         if (function_exists($extension_function)) {
00621           $extension = $extension_function();
00622         }
00623       }
00624     }
00625
00626     if (isset($info['preprocess functions']) && is_array($info['preprocess functions'])) {
00627       // This construct ensures that we can keep a reference through
00628       // call_user_func_array.
00629       $args = array(&$variables, $hook);
00630       foreach ($info['preprocess functions'] as $preprocess_function) {
00631         if (function_exists($preprocess_function)) {
00632           call_user_func_array($preprocess_function, $args);
00633         }
00634       }
00635     }
00636
00637     // Get suggestions for alternate templates out of the variables
00638     // that were set. This lets us dynamically choose a template
00639     // from a list. The order is FILO, so this array is ordered from
00640     // least appropriate first to most appropriate last.
00641     $suggestions = array();
00642
00643     if (isset($variables['template_files'])) {
00644       $suggestions = $variables['template_files'];
00645     }
00646     if (isset($variables['template_file'])) {
00647       $suggestions[] = $variables['template_file'];
00648     }
00649
00650     if ($suggestions) {
00651       $template_file = drupal_discover_template($info['theme paths'], $suggestions, $extension);
00652     }
00653
00654     if (empty($template_file)) {
00655       $template_file = $hooks[$hook]['template'] . $extension;
00656       if (isset($hooks[$hook]['path'])) {
00657         $template_file = $hooks[$hook]['path'] .'/'. $template_file;
00658       }
00659     }
00660     $output = $render_function($template_file, $variables);
00661   }
00662   // restore path_to_theme()
00663   $theme_path = $temp;
00664   return $output;
00665 }
00666
00672 function drupal_discover_template($paths, $suggestions, $extension = '.tpl.php') {
00673   global $theme_engine;
00674
00675   // Loop through all paths and suggestions in FIFO order.
00676   $suggestions = array_reverse($suggestions);
00677   $paths = array_reverse($paths);
00678   foreach ($suggestions as $suggestion) {
00679     if (!empty($suggestion)) {
00680       foreach ($paths as $path) {
00681         if (file_exists($file = $path .'/'. $suggestion . $extension)) {
00682           return $file;
00683         }
00684       }
00685     }
00686   }
00687 }
00688
00692 function path_to_theme() {
00693   global $theme_path;
00694
00695   if (!isset($theme_path)) {
00696     init_theme();
00697   }
00698
00699   return $theme_path;
00700 }
00701
00714 function drupal_find_theme_functions($cache, $prefixes) {
00715   $templates = array();
00716   $functions = get_defined_functions();
00717
00718   foreach ($cache as $hook => $info) {
00719     foreach ($prefixes as $prefix) {
00720       if (!empty($info['pattern'])) {
00721         $matches = preg_grep('/^'. $prefix .'_'. $info['pattern'] .'/', $functions['user']);
00722         if ($matches) {
00723           foreach ($matches as $match) {
00724             $new_hook = str_replace($prefix .'_', '', $match);
00725             $templates[$new_hook] = array(
00726               'function' => $match,
00727               'arguments' => $info['arguments'],
00728             );
00729           }
00730         }
00731       }
00732       if (function_exists($prefix .'_'. $hook)) {
00733         $templates[$hook] = array(
00734           'function' => $prefix .'_'. $hook,
00735         );
00736       }
00737     }
00738   }
00739
00740   return $templates;
00741 }
00742
00754 function drupal_find_theme_templates($cache, $extension, $path) {
00755   $templates = array();
00756
00757   // Collect paths to all sub-themes grouped by base themes. These will be
00758   // used for filtering. This allows base themes to have sub-themes in its
00759   // folder hierarchy without affecting the base themes template discovery.
00760   $theme_paths = array();
00761   foreach (list_themes() as $theme_info) {
00762     if (!empty($theme_info->base_theme)) {
00763       $theme_paths[$theme_info->base_theme][$theme_info->name] = dirname($theme_info->filename);
00764     }
00765   }
00766   foreach ($theme_paths as $basetheme => $subthemes) {
00767     foreach ($subthemes as $subtheme => $subtheme_path) {
00768       if (isset($theme_paths[$subtheme])) {
00769         $theme_paths[$basetheme] = array_merge($theme_paths[$basetheme], $theme_paths[$subtheme]);
00770       }
00771     }
00772   }
00773   global $theme;
00774   $subtheme_paths = isset($theme_paths[$theme]) ? $theme_paths[$theme] : array();
00775
00776   // Escape the periods in the extension.
00777   $regex = str_replace('.', '\.', $extension) .'$';
00778   // Because drupal_system_listing works the way it does, we check for real
00779   // templates separately from checking for patterns.
00780   $files = drupal_system_listing($regex, $path, 'name', 0);
00781   foreach ($files as $template => $file) {
00782     // Ignore sub-theme templates for the current theme.
00783     if (strpos($file->filename, str_replace($subtheme_paths, '', $file->filename)) !== 0) {
00784       continue;
00785     }
00786     // Chop off the remaining extensions if there are any. $template already
00787     // has the rightmost extension removed, but there might still be more,
00788     // such as with .tpl.php, which still has .tpl in $template at this point.
00789     if (($pos = strpos($template, '.')) !== FALSE) {
00790       $template = substr($template, 0, $pos);
00791     }
00792     // Transform - in filenames to _ to match function naming scheme
00793     // for the purposes of searching.
00794     $hook = strtr($template, '-', '_');
00795     if (isset($cache[$hook])) {
00796       $templates[$hook] = array(
00797         'template' => $template,
00798         'path' => dirname($file->filename),
00799       );
00800     }
00801   }
00802
00803   $patterns = array_keys($files);
00804
00805   foreach ($cache as $hook => $info) {
00806     if (!empty($info['pattern'])) {
00807       // Transform _ in pattern to - to match file naming scheme
00808       // for the purposes of searching.
00809       $pattern = strtr($info['pattern'], '_', '-');
00810
00811       $matches = preg_grep('/^'. $pattern .'/', $patterns);
00812       if ($matches) {
00813         foreach ($matches as $match) {
00814           $file = substr($match, 0, strpos($match, '.'));
00815           // Put the underscores back in for the hook name and register this pattern.
00816           $templates[strtr($file, '-', '_')] = array(
00817             'template' => $file,
00818             'path' => dirname($files[$match]->filename),
00819             'arguments' => $info['arguments'],
00820           );
00821         }
00822       }
00823     }
00824   }
00825   return $templates;
00826 }
00827
00845 function theme_get_settings($key = NULL) {
00846   $defaults = array(
00847     'mission'                       =>  '',
00848     'default_logo'                  =>  1,
00849     'logo_path'                     =>  '',
00850     'default_favicon'               =>  1,
00851     'favicon_path'                  =>  '',
00852     'primary_links'                 =>  1,
00853     'secondary_links'               =>  1,
00854     'toggle_logo'                   =>  1,
00855     'toggle_favicon'                =>  1,
00856     'toggle_name'                   =>  1,
00857     'toggle_search'                 =>  1,
00858     'toggle_slogan'                 =>  0,
00859     'toggle_mission'                =>  1,
00860     'toggle_node_user_picture'      =>  0,
00861     'toggle_comment_user_picture'   =>  0,
00862     'toggle_primary_links'          =>  1,
00863     'toggle_secondary_links'        =>  1,
00864   );
00865
00866   if (module_exists('node')) {
00867     foreach (node_get_types() as $type => $name) {
00868       $defaults['toggle_node_info_'. $type] = 1;
00869     }
00870   }
00871   $settings = array_merge($defaults, variable_get('theme_settings', array()));
00872
00873   if ($key) {
00874     $settings = array_merge($settings, variable_get(str_replace('/', '_', 'theme_'. $key .'_settings'), array()));
00875   }
00876
00877   // Only offer search box if search.module is enabled.
00878   if (!module_exists('search') || !user_access('search content')) {
00879     $settings['toggle_search'] = 0;
00880   }
00881
00882   return $settings;
00883 }
00884
00901 function theme_get_setting($setting_name, $refresh = FALSE) {
00902   global $theme_key;
00903   static $settings;
00904
00905   if (empty($settings) || $refresh) {
00906     $settings = theme_get_settings($theme_key);
00907
00908     $themes = list_themes();
00909     $theme_object = $themes[$theme_key];
00910
00911     if ($settings['mission'] == '') {
00912       $settings['mission'] = variable_get('site_mission', '');
00913     }
00914
00915     if (!$settings['toggle_mission']) {
00916       $settings['mission'] = '';
00917     }
00918
00919     if ($settings['toggle_logo']) {
00920       if ($settings['default_logo']) {
00921         $settings['logo'] = base_path() . dirname($theme_object->filename) .'/logo.png';
00922       }
00923       elseif ($settings['logo_path']) {
00924         $settings['logo'] = base_path() . $settings['logo_path'];
00925       }
00926     }
00927
00928     if ($settings['toggle_favicon']) {
00929       if ($settings['default_favicon']) {
00930         if (file_exists($favicon = dirname($theme_object->filename) .'/favicon.ico')) {
00931           $settings['favicon'] = base_path() . $favicon;
00932         }
00933         else {
00934           $settings['favicon'] = base_path() .'misc/favicon.ico';
00935         }
00936       }
00937       elseif ($settings['favicon_path']) {
00938         $settings['favicon'] = base_path() . $settings['favicon_path'];
00939       }
00940       else {
00941         $settings['toggle_favicon'] = FALSE;
00942       }
00943     }
00944   }
00945
00946   return isset($settings[$setting_name]) ? $settings[$setting_name] : NULL;
00947 }
00948
00960 function theme_render_template($file, $variables) {
00961   extract($variables, EXTR_SKIP);  // Extract the variables to a local namespace
00962   ob_start();                      // Start output buffering
00963   include "./$file";               // Include the file
00964   $contents = ob_get_contents();   // Get the contents of the buffer
00965   ob_end_clean();                  // End buffering and discard
00966   return $contents;                // Return the contents
00967 }
00968
01044 function theme_placeholder($text) {
01045   return '<em>'. check_plain($text) .'</em>';
01046 }
01047
01058 function theme_status_messages($display = NULL) {
01059   $output = '';
01060   foreach (drupal_get_messages($display) as $type => $messages) {
01061     $output .= "<div class=\"messages $type\">\n";
01062     if (count($messages) > 1) {
01063       $output .= " <ul>\n";
01064       foreach ($messages as $message) {
01065         $output .= '  <li>'. $message ."</li>\n";
01066       }
01067       $output .= " </ul>\n";
01068     }
01069     else {
01070       $output .= $messages[0];
01071     }
01072     $output .= "</div>\n";
01073   }
01074   return $output;
01075 }
01076
01087 function theme_links($links, $attributes = array('class' => 'links')) {
01088   $output = '';
01089
01090   if (count($links) > 0) {
01091     $output = '<ul'. drupal_attributes($attributes) .'>';
01092
01093     $num_links = count($links);
01094     $i = 1;
01095
01096     foreach ($links as $key => $link) {
01097       $class = $key;
01098
01099       // Add first, last and active classes to the list of links to help out themers.
01100       if ($i == 1) {
01101         $class .= ' first';
01102       }
01103       if ($i == $num_links) {
01104         $class .= ' last';
01105       }
01106       if (isset($link['href']) && $link['href'] == $_GET['q']) {
01107         $class .= ' active';
01108       }
01109       $output .= '<li class="'. $class .'">';
01110
01111       if (isset($link['href'])) {
01112         // Pass in $link as $options, they share the same keys.
01113         $output .= l($link['title'], $link['href'], $link);
01114       }
01115       else if (!empty($link['title'])) {
01116         // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
01117         if (empty($link['html'])) {
01118           $link['title'] = check_plain($link['title']);
01119         }
01120         $span_attributes = '';
01121         if (isset($link['attributes'])) {
01122           $span_attributes = drupal_attributes($link['attributes']);
01123         }
01124         $output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
01125       }
01126
01127       $i++;
01128       $output .= "</li>\n";
01129     }
01130
01131     $output .= '</ul>';
01132   }
01133
01134   return $output;
01135 }
01136
01153 function theme_image($path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) {
01154   if (!$getsize || (is_file($path) && (list($width, $height, $type, $image_attributes) = @getimagesize($path)))) {
01155     $attributes = drupal_attributes($attributes);
01156     $url = (url($path) == $path) ? $path : (base_path() . $path);
01157     return '<img src="'. check_url($url) .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. (isset($image_attributes) ? $image_attributes : '') . $attributes .' />';
01158   }
01159 }
01160
01168 function theme_breadcrumb($breadcrumb) {
01169   if (!empty($breadcrumb)) {
01170     return '<div class="breadcrumb">'. implode(' » ', $breadcrumb) .'</div>';
01171   }
01172 }
01173
01179 function theme_help() {
01180   if ($help = menu_get_active_help()) {
01181     return '<div class="help">'. $help .'</div>';
01182   }
01183 }
01184
01191 function theme_submenu($links) {
01192   return '<div class="submenu">'. implode(' | ', $links) .'</div>';
01193 }
01194
01238 function theme_table($header, $rows, $attributes = array(), $caption = NULL) {
01239
01240   // Add sticky headers, if applicable.
01241   if (count($header)) {
01242     drupal_add_js('misc/tableheader.js');
01243     // Add 'sticky-enabled' class to the table to identify it for JS.
01244     // This is needed to target tables constructed by this function.
01245     $attributes['class'] = empty($attributes['class']) ? 'sticky-enabled' : ($attributes['class'] .' sticky-enabled');
01246   }
01247
01248   $output = '<table'. drupal_attributes($attributes) .">\n";
01249
01250   if (isset($caption)) {
01251     $output .= '<caption>'. $caption ."</caption>\n";
01252   }
01253
01254   // Format the table header:
01255   if (count($header)) {
01256     $ts = tablesort_init($header);
01257     // HTML requires that the thead tag has tr tags in it follwed by tbody
01258     // tags. Using ternary operator to check and see if we have any rows.
01259     $output .= (count($rows) ? ' <thead><tr>' : ' <tr>');
01260     foreach ($header as $cell) {
01261       $cell = tablesort_header($cell, $header, $ts);
01262       $output .= _theme_table_cell($cell, TRUE);
01263     }
01264     // Using ternary operator to close the tags based on whether or not there are rows
01265     $output .= (count($rows) ? " </tr></thead>\n" : "</tr>\n");
01266   }
01267   else {
01268     $ts = array();
01269   }
01270
01271   // Format the table rows:
01272   if (count($rows)) {
01273     $output .= "<tbody>\n";
01274     $flip = array('even' => 'odd', 'odd' => 'even');
01275     $class = 'even';
01276     foreach ($rows as $number => $row) {
01277       $attributes = array();
01278
01279       // Check if we're dealing with a simple or complex row
01280       if (isset($row['data'])) {
01281         foreach ($row as $key => $value) {
01282           if ($key == 'data') {
01283             $cells = $value;
01284           }
01285           else {
01286             $attributes[$key] = $value;
01287           }
01288         }
01289       }
01290       else {
01291         $cells = $row;
01292       }
01293       if (count($cells)) {
01294         // Add odd/even class
01295         $class = $flip[$class];
01296         if (isset($attributes['class'])) {
01297           $attributes['class'] .= ' '. $class;
01298         }
01299         else {
01300           $attributes['class'] = $class;
01301         }
01302
01303         // Build row
01304         $output .= ' <tr'. drupal_attributes($attributes) .'>';
01305         $i = 0;
01306         foreach ($cells as $cell) {
01307           $cell = tablesort_cell($cell, $header, $ts, $i++);
01308           $output .= _theme_table_cell($cell);
01309         }
01310         $output .= " </tr>\n";
01311       }
01312     }
01313     $output .= "</tbody>\n";
01314   }
01315
01316   $output .= "</table>\n";
01317   return $output;
01318 }
01319
01323 function theme_table_select_header_cell() {
01324   drupal_add_js('misc/tableselect.js');
01325
01326   return array('class' => 'select-all');
01327 }
01328
01337 function theme_tablesort_indicator($style) {
01338   if ($style == "asc") {
01339     return theme('image', 'misc/arrow-asc.png', t('sort icon'), t('sort ascending'));
01340   }
01341   else {
01342     return theme('image', 'misc/arrow-desc.png', t('sort icon'), t('sort descending'));
01343   }
01344 }
01345
01358 function theme_box($title, $content, $region = 'main') {
01359   $output = '<h2 class="title">'. $title .'</h2><div>'. $content .'</div>';
01360   return $output;
01361 }
01362
01373 function theme_mark($type = MARK_NEW) {
01374   global $user;
01375   if ($user->uid) {
01376     if ($type == MARK_NEW) {
01377       return ' <span class="marker">'. t('new') .'</span>';
01378     }
01379     else if ($type == MARK_UPDATED) {
01380       return ' <span class="marker">'. t('updated') .'</span>';
01381     }
01382   }
01383 }
01384
01403 function theme_item_list($items = array(), $title = NULL, $type = 'ul', $attributes = NULL) {
01404   $output = '<div class="item-list">';
01405   if (isset($title)) {
01406     $output .= '<h3>'. $title .'</h3>';
01407   }
01408
01409   if (!empty($items)) {
01410     $output .= "<$type". drupal_attributes($attributes) .'>';
01411     $num_items = count($items);
01412     foreach ($items as $i => $item) {
01413       $attributes = array();
01414       $children = array();
01415       if (is_array($item)) {
01416         foreach ($item as $key => $value) {
01417           if ($key == 'data') {
01418             $data = $value;
01419           }
01420           elseif ($key == 'children') {
01421             $children = $value;
01422           }
01423           else {
01424             $attributes[$key] = $value;
01425           }
01426         }
01427       }
01428       else {
01429         $data = $item;
01430       }
01431       if (count($children) > 0) {
01432         $data .= theme_item_list($children, NULL, $type, $attributes); // Render nested list
01433       }
01434       if ($i == 0) {
01435         $attributes['class'] = empty($attributes['class']) ? 'first' : ($attributes['class'] .' first');
01436       }
01437       if ($i == $num_items - 1) {
01438         $attributes['class'] = empty($attributes['class']) ? 'last' : ($attributes['class'] .' last');
01439       }
01440       $output .= '<li'. drupal_attributes($attributes) .'>'. $data ."</li>\n";
01441     }
01442     $output .= "</$type>";
01443   }
01444   $output .= '</div>';
01445   return $output;
01446 }
01447
01451 function theme_more_help_link($url) {
01452   return '<div class="more-help-link">'. t('[<a href="@link">more help...</a>]', array('@link' => check_url($url))) .'</div>';
01453 }
01454
01464 function theme_xml_icon($url) {
01465   if ($image = theme('image', 'misc/xml.png', t('XML feed'), t('XML feed'))) {
01466     return '<a href="'. check_url($url) .'" class="xml-icon">'. $image .'</a>';
01467   }
01468 }
01469
01478 function theme_feed_icon($url, $title) {
01479   if ($image = theme('image', 'misc/feed.png', t('Syndicate content'), $title)) {
01480     return '<a href="'. check_url($url) .'" class="feed-icon">'. $image .'</a>';
01481   }
01482 }
01483
01492 function theme_more_link($url, $title) {
01493   return '<div class="more-link">'. t('<a href="@link" title="@title">more</a>', array('@link' => check_url($url), '@title' => $title)) .'</div>';
01494 }
01495
01505 function theme_closure($main = 0) {
01506   $footer = module_invoke_all('footer', $main);
01507   return implode("\n", $footer) . drupal_get_js('footer');
01508 }
01509
01518 function theme_blocks($region) {
01519   $output = '';
01520
01521   if ($list = block_list($region)) {
01522     foreach ($list as $key => $block) {
01523       // $key == <i>module</i>_<i>delta</i>
01524       $output .= theme('block', $block);
01525     }
01526   }
01527
01528   // Add any content assigned to this region through drupal_set_content() calls.
01529   $output .= drupal_get_content($region);
01530
01531   return $output;
01532 }
01533
01543 function theme_username($object) {
01544
01545   if ($object->uid && $object->name) {
01546     // Shorten the name when it is too long or it will break many tables.
01547     if (drupal_strlen($object->name) > 20) {
01548       $name = drupal_substr($object->name, 0, 15) .'...';
01549     }
01550     else {
01551       $name = $object->name;
01552     }
01553
01554     if (user_access('access user profiles')) {
01555       $output = l($name, 'user/'. $object->uid, array('title' => t('View user profile.')));
01556     }
01557     else {
01558       $output = check_plain($name);
01559     }
01560   }
01561   else if ($object->name) {
01562     // Sometimes modules display content composed by people who are
01563     // not registered members of the site (e.g. mailing list or news
01564     // aggregator modules). This clause enables modules to display
01565     // the true author of the content.
01566     if (!empty($object->homepage)) {
01567       $output = l($object->name, $object->homepage, array('rel' => 'nofollow'));
01568     }
01569     else {
01570       $output = check_plain($object->name);
01571     }
01572
01573     $output .= ' ('. t('not verified') .')';
01574   }
01575   else {
01576     $output = variable_get('anonymous', t('Anonymous'));
01577   }
01578
01579   return $output;
01580 }
01581
01592 function theme_progress_bar($percent, $message) {
01593   $output = '<div id="progress" class="progress">';
01594   $output .= '<div class="bar"><div class="filled" style="width: '. $percent .'%"></div></div>';
01595   $output .= '<div class="percentage">'. $percent .'%</div>';
01596   $output .= '<div class="message">'. $message .'</div>';
01597   $output .= '</div>';
01598
01599   return $output;
01600 }
01601
01610 function theme_indentation($size = 1) {
01611   $output = '';
01612   for ($n = 0; $n < $size; $n++) {
01613     $output .= '<div class="indentation">&nbsp;</div>';
01614   }
01615   return $output;
01616 }
01617
01622 function _theme_table_cell($cell, $header = FALSE) {
01623   $attributes = '';
01624
01625   if (is_array($cell)) {
01626     $data = isset($cell['data']) ? $cell['data'] : '';
01627     $header |= isset($cell['header']);
01628     unset($cell['data']);
01629     unset($cell['header']);
01630     $attributes = drupal_attributes($cell);
01631   }
01632   else {
01633     $data = $cell;
01634   }
01635
01636   if ($header) {
01637     $output = "<th$attributes>$data</th>";
01638   }
01639   else {
01640     $output = "<td$attributes>$data</td>";
01641   }
01642
01643   return $output;
01644 }
01645
01652 function template_preprocess(&$variables, $hook) {
01653   global $user;
01654   static $count = array();
01655
01656   // Track run count for each hook to provide zebra striping.
01657   // See "template_preprocess_block()" which provides the same feature specific to blocks.
01658   $count[$hook] = isset($count[$hook]) && is_int($count[$hook]) ? $count[$hook] : 1;
01659   $variables['zebra'] = ($count[$hook] % 2) ? 'odd' : 'even';
01660   $variables['id'] = $count[$hook]++;
01661
01662   // Tell all templates where they are located.
01663   $variables['directory'] = path_to_theme();
01664
01665   // Set default variables that depend on the database.
01666   $variables['is_admin']            = FALSE;
01667   $variables['is_front']            = FALSE;
01668   $variables['logged_in']           = FALSE;
01669   if ($variables['db_is_active'] = db_is_active()  && !defined('MAINTENANCE_MODE')) {
01670     // Check for administrators.
01671     if (user_access('access administration pages')) {
01672       $variables['is_admin'] = TRUE;
01673     }
01674     // Flag front page status.
01675     $variables['is_front'] = drupal_is_front_page();
01676     // Tell all templates by which kind of user they're viewed.
01677     $variables['logged_in'] = ($user->uid > 0);
01678     // Provide user object to all templates
01679     $variables['user'] = $user;
01680   }
01681 }
01682
01702 function template_preprocess_page(&$variables) {
01703   // Add favicon
01704   if (theme_get_setting('toggle_favicon')) {
01705     drupal_set_html_head('<link rel="shortcut icon" href="'. check_url(theme_get_setting('favicon')) .'" type="image/x-icon" />');
01706   }
01707
01708   global $theme;
01709   // Populate all block regions.
01710   $regions = system_region_list($theme);
01711   // Load all region content assigned via blocks.
01712   foreach (array_keys($regions) as $region) {
01713     // Prevent left and right regions from rendering blocks when 'show_blocks' == FALSE.
01714     if (!(!$variables['show_blocks'] && ($region == 'left' || $region == 'right'))) {
01715       $blocks = theme('blocks', $region);
01716     }
01717     else {
01718       $blocks = '';
01719     }
01720     // Assign region to a region variable.
01721     isset($variables[$region]) ? $variables[$region] .= $blocks : $variables[$region] = $blocks;
01722   }
01723
01724   // Set up layout variable.
01725   $variables['layout'] = 'none';
01726   if (!empty($variables['left'])) {
01727     $variables['layout'] = 'left';
01728   }
01729   if (!empty($variables['right'])) {
01730     $variables['layout'] = ($variables['layout'] == 'left') ? 'both' : 'right';
01731   }
01732
01733   // Set mission when viewing the frontpage.
01734   if (drupal_is_front_page()) {
01735     $mission = filter_xss_admin(theme_get_setting('mission'));
01736   }
01737
01738   // Construct page title
01739   if (drupal_get_title()) {
01740     $head_title = array(strip_tags(drupal_get_title()), variable_get('site_name', 'Drupal'));
01741   }
01742   else {
01743     $head_title = array(variable_get('site_name', 'Drupal'));
01744     if (variable_get('site_slogan', '')) {
01745       $head_title[] = variable_get('site_slogan', '');
01746     }
01747   }
01748   $variables['head_title']        = implode(' | ', $head_title);
01749   $variables['base_path']         = base_path();
01750   $variables['front_page']        = url();
01751   $variables['breadcrumb']        = theme('breadcrumb', drupal_get_breadcrumb());
01752   $variables['feed_icons']        = drupal_get_feeds();
01753   $variables['footer_message']    = filter_xss_admin(variable_get('site_footer', FALSE));
01754   $variables['head']              = drupal_get_html_head();
01755   $variables['help']              = theme('help');
01756   $variables['language']          = $GLOBALS['language'];
01757   $variables['language']->dir     = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
01758   $variables['logo']              = theme_get_setting('logo');
01759   $variables['messages']          = $variables['show_messages'] ? theme('status_messages') : '';
01760   $variables['mission']           = isset($mission) ? $mission : '';
01761   $variables['primary_links']     = theme_get_setting('toggle_primary_links') ? menu_primary_links() : array();
01762   $variables['secondary_links']   = theme_get_setting('toggle_secondary_links') ? menu_secondary_links() : array();
01763   $variables['search_box']        = (theme_get_setting('toggle_search') ? drupal_get_form('search_theme_form') : '');
01764   $variables['site_name']         = (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : '');
01765   $variables['site_slogan']       = (theme_get_setting('toggle_slogan') ? variable_get('site_slogan', '') : '');
01766   $variables['css']               = drupal_add_css();
01767   $variables['styles']            = drupal_get_css();
01768   $variables['scripts']           = drupal_get_js();
01769   $variables['tabs']              = theme('menu_local_tasks');
01770   $variables['title']             = drupal_get_title();
01771   // Closure should be filled last.
01772   $variables['closure']           = theme('closure');
01773
01774   if ($node = menu_get_object()) {
01775     $variables['node'] = $node;
01776   }
01777
01778   // Compile a list of classes that are going to be applied to the body element.
01779   // This allows advanced theming based on context (home page, node of certain type, etc.).
01780   $body_classes = array();
01781   // Add a class that tells us whether we're on the front page or not.
01782   $body_classes[] = $variables['is_front'] ? 'front' : 'not-front';
01783   // Add a class that tells us whether the page is viewed by an authenticated user or not.
01784   $body_classes[] = $variables['logged_in'] ? 'logged-in' : 'not-logged-in';
01785   // Add arg(0) to make it possible to theme the page depending on the current page
01786   // type (e.g. node, admin, user, etc.). To avoid illegal characters in the class,
01787   // we're removing everything disallowed. We are not using 'a-z' as that might leave
01788   // in certain international characters (e.g. German umlauts).
01789   $body_classes[] = preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-'. form_clean_id(drupal_strtolower(arg(0))));
01790   // If on an individual node page, add the node type.
01791   if (isset($variables['node']) && $variables['node']->type) {
01792     $body_classes[] = 'node-type-'. form_clean_id($variables['node']->type);
01793   }
01794   // Add information about the number of sidebars.
01795   if ($variables['layout'] == 'both') {
01796     $body_classes[] = 'two-sidebars';
01797   }
01798   elseif ($variables['layout'] == 'none') {
01799     $body_classes[] = 'no-sidebars';
01800   }
01801   else {
01802     $body_classes[] = 'one-sidebar sidebar-'. $variables['layout'];
01803   }
01804   // Implode with spaces.
01805   $variables['body_classes'] = implode(' ', $body_classes);
01806
01807   // Build a list of suggested template files in order of specificity. One
01808   // suggestion is made for every element of the current path, though
01809   // numeric elements are not carried to subsequent suggestions. For example,
01810   // http://www.example.com/node/1/edit would result in the following
01811   // suggestions:
01812   //
01813   // page-node-edit.tpl.php
01814   // page-node-1.tpl.php
01815   // page-node.tpl.php
01816   // page.tpl.php
01817   $i = 0;
01818   $suggestion = 'page';
01819   $suggestions = array();
01820   while ($arg = arg($i++)) {
01821     $suggestions[] = $suggestion .'-'. $arg;
01822     if (!is_numeric($arg)) {
01823       $suggestion .= '-'. $arg;
01824     }
01825   }
01826   if (drupal_is_front_page()) {
01827     $suggestions[] = 'page-front';
01828   }
01829
01830   if ($suggestions) {
01831     $variables['template_files'] = $suggestions;
01832   }
01833 }
01834
01849 function template_preprocess_node(&$variables) {
01850   $node = $variables['node'];
01851   if (module_exists('taxonomy')) {
01852     $variables['taxonomy'] = taxonomy_link('taxonomy terms', $node);
01853   }
01854   else {
01855     $variables['taxonomy'] = array();
01856   }
01857
01858   if ($variables['teaser'] && $node->teaser) {
01859     $variables['content'] = $node->teaser;
01860   }
01861   elseif (isset($node->body)) {
01862     $variables['content'] = $node->body;
01863   }
01864   else {
01865     $variables['content'] = '';
01866   }
01867
01868   $variables['date']      = format_date($node->created);
01869   $variables['links']     = !empty($node->links) ? theme('links', $node->links, array('class' => 'links inline')) : '';
01870   $variables['name']      = theme('username', $node);
01871   $variables['node_url']  = url('node/'. $node->nid);
01872   $variables['terms']     = theme('links', $variables['taxonomy'], array('class' => 'links inline'));
01873   $variables['title']     = check_plain($node->title);
01874
01875   // Flatten the node object's member fields.
01876   $variables = array_merge((array)$node, $variables);
01877
01878   // Display info only on certain node types.
01879   if (theme_get_setting('toggle_node_info_'. $node->type)) {
01880     $variables['submitted'] = theme('node_submitted', $node);
01881     $variables['picture'] = theme_get_setting('toggle_node_user_picture') ? theme('user_picture', $node) : '';
01882   }
01883   else {
01884     $variables['submitted'] = '';
01885     $variables['picture'] = '';
01886   }
01887   // Clean up name so there are no underscores.
01888   $variables['template_files'][] = 'node-'. $node->type;
01889 }
01890
01908 function template_preprocess_block(&$variables) {
01909   static $block_counter = array();
01910   // All blocks get an independent counter for each region.
01911   if (!isset($block_counter[$variables['block']->region])) {
01912     $block_counter[$variables['block']->region] = 1;
01913   }
01914   // Same with zebra striping.
01915   $variables['block_zebra'] = ($block_counter[$variables['block']->region] % 2) ? 'odd' : 'even';
01916   $variables['block_id'] = $block_counter[$variables['block']->region]++;
01917
01918   $variables['template_files'][] = 'block-'. $variables['block']->region;
01919   $variables['template_files'][] = 'block-'. $variables['block']->module;
01920   $variables['template_files'][] = 'block-'. $variables['block']->module .'-'. $variables['block']->delta;
01921 }
01922
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/theme.maintenance.inc Source File

includes

theme.maintenance.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: theme.maintenance.inc,v 1.10 2008/01/24 09:42:50 goba Exp $
00003
00017 function _drupal_maintenance_theme() {
00018   global $theme, $theme_key;
00019
00020   // If $theme is already set, assume the others are set too, and do nothing.
00021   if (isset($theme)) {
00022     return;
00023   }
00024
00025   require_once './includes/path.inc';
00026   require_once './includes/theme.inc';
00027   require_once './includes/common.inc';
00028   require_once './includes/unicode.inc';
00029   require_once './includes/file.inc';
00030   require_once './includes/module.inc';
00031   require_once './includes/database.inc';
00032   unicode_check();
00033
00034   // Install and update pages are treated differently to prevent theming overrides.
00035   if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) {
00036     $theme = 'minnelli';
00037   }
00038   else {
00039     // Load module basics (needed for hook invokes).
00040     $module_list['system']['filename'] = 'modules/system/system.module';
00041     $module_list['filter']['filename'] = 'modules/filter/filter.module';
00042     module_list(TRUE, FALSE, FALSE, $module_list);
00043     drupal_load('module', 'system');
00044     drupal_load('module', 'filter');
00045
00046     $theme = variable_get('maintenance_theme', 'minnelli');
00047   }
00048
00049   $themes = list_themes();
00050
00051   // Store the identifier for retrieving theme settings with.
00052   $theme_key = $theme;
00053
00054   // Find all our ancestor themes and put them in an array.
00055   $base_theme = array();
00056   $ancestor = $theme;
00057   while ($ancestor && isset($themes[$ancestor]->base_theme)) {
00058     $base_theme[] = $new_base_theme = $themes[$themes[$ancestor]->base_theme];
00059     $ancestor = $themes[$ancestor]->base_theme;
00060   }
00061   _init_theme($themes[$theme], array_reverse($base_theme), '_theme_load_offline_registry');
00062
00063   // These are usually added from system_init() -except maintenance.css.
00064   // When the database is inactive it's not called so we add it here.
00065   drupal_add_css(drupal_get_path('module', 'system') .'/defaults.css', 'module');
00066   drupal_add_css(drupal_get_path('module', 'system') .'/system.css', 'module');
00067   drupal_add_css(drupal_get_path('module', 'system') .'/system-menus.css', 'module');
00068   drupal_add_css(drupal_get_path('module', 'system') .'/maintenance.css', 'module');
00069 }
00070
00074 function _theme_load_offline_registry($theme, $base_theme = NULL, $theme_engine = NULL) {
00075   $registry = _theme_build_registry($theme, $base_theme, $theme_engine);
00076   _theme_set_registry($registry);
00077 }
00078
00084 function theme_task_list($items, $active = NULL) {
00085   $done = isset($items[$active]) || $active == NULL;
00086   $output = '<ol class="task-list">';
00087   foreach ($items as $k => $item) {
00088     if ($active == $k) {
00089       $class = 'active';
00090       $done = false;
00091     }
00092     else {
00093       $class = $done ? 'done' : '';
00094     }
00095     $output .= '<li class="'. $class .'">'. $item .'</li>';
00096   }
00097   $output .= '</ol>';
00098   return $output;
00099 }
00100
00109 function theme_install_page($content) {
00110   drupal_set_header('Content-Type: text/html; charset=utf-8');
00111
00112   // Assign content.
00113   $variables['content'] = $content;
00114   // Delay setting the message variable so it can be processed below.
00115   $variables['show_messages'] = FALSE;
00116   // The maintenance preprocess function is recycled here.
00117   template_preprocess_maintenance_page($variables);
00118
00119   // Special handling of error messages
00120   $messages = drupal_set_message();
00121   if (isset($messages['error'])) {
00122     $title = count($messages['error']) > 1 ? st('The following errors must be resolved before you can continue the installation process') : st('The following error must be resolved before you can continue the installation process');
00123     $variables['messages'] .= '<h3>'. $title .':</h3>';
00124     $variables['messages'] .= theme('status_messages', 'error');
00125     $variables['content'] .= '<p>'. st('Please check the error messages and <a href="!url">try again</a>.', array('!url' => request_uri())) .'</p>';
00126   }
00127
00128   // Special handling of warning messages
00129   if (isset($messages['warning'])) {
00130     $title = count($messages['warning']) > 1 ? st('The following installation warnings should be carefully reviewed') : st('The following installation warning should be carefully reviewed');
00131     $variables['messages'] .= '<h4>'. $title .':</h4>';
00132     $variables['messages'] .= theme('status_messages', 'warning');
00133   }
00134
00135   // Special handling of status messages
00136   if (isset($messages['status'])) {
00137     $title = count($messages['status']) > 1 ? st('The following installation warnings should be carefully reviewed, but in most cases may be safely ignored') : st('The following installation warning should be carefully reviewed, but in most cases may be safely ignored');
00138     $variables['messages'] .= '<h4>'. $title .':</h4>';
00139     $variables['messages'] .= theme('status_messages', 'status');
00140   }
00141
00142   // This was called as a theme hook (not template), so we need to
00143   // fix path_to_theme() for the template, to point at the actual
00144   // theme rather than system module as owner of the hook.
00145   global $theme_path;
00146   $theme_path = 'themes/garland';
00147
00148   return theme_render_template('themes/garland/maintenance-page.tpl.php', $variables);
00149 }
00150
00162 function theme_update_page($content, $show_messages = TRUE) {
00163   // Set required headers.
00164   drupal_set_header('Content-Type: text/html; charset=utf-8');
00165
00166   // Assign content and show message flag.
00167   $variables['content'] = $content;
00168   $variables['show_messages'] = $show_messages;
00169   // The maintenance preprocess function is recycled here.
00170   template_preprocess_maintenance_page($variables);
00171
00172   // Special handling of warning messages.
00173   $messages = drupal_set_message();
00174   if (isset($messages['warning'])) {
00175     $title = count($messages['warning']) > 1 ? 'The following update warnings should be carefully reviewed before continuing' : 'The following update warning should be carefully reviewed before continuing';
00176     $variables['messages'] .= '<h4>'. $title .':</h4>';
00177     $variables['messages'] .= theme('status_messages', 'warning');
00178   }
00179
00180   // This was called as a theme hook (not template), so we need to
00181   // fix path_to_theme() for the template, to point at the actual
00182   // theme rather than system module as owner of the hook.
00183   global $theme_path;
00184   $theme_path = 'themes/garland';
00185
00186   return theme_render_template('themes/garland/maintenance-page.tpl.php', $variables);
00187 }
00188
00205 function template_preprocess_maintenance_page(&$variables) {
00206   // Add favicon
00207   if (theme_get_setting('toggle_favicon')) {
00208     drupal_set_html_head('<link rel="shortcut icon" href="'. check_url(theme_get_setting('favicon')) .'" type="image/x-icon" />');
00209   }
00210
00211   global $theme;
00212   // Retrieve the theme data to list all available regions.
00213   $theme_data = _system_theme_data();
00214   $regions = $theme_data[$theme]->info['regions'];
00215
00216   // Get all region content set with drupal_set_content().
00217   foreach (array_keys($regions) as $region) {
00218     // Assign region to a region variable.
00219     $region_content = drupal_get_content($region);
00220     isset($variables[$region]) ? $variables[$region] .= $region_content : $variables[$region] = $region_content;
00221   }
00222
00223   // Setup layout variable.
00224   $variables['layout'] = 'none';
00225   if (!empty($variables['left'])) {
00226     $variables['layout'] = 'left';
00227   }
00228   if (!empty($variables['right'])) {
00229     $variables['layout'] = ($variables['layout'] == 'left') ? 'both' : 'right';
00230   }
00231
00232   // Construct page title
00233   if (drupal_get_title()) {
00234     $head_title = array(strip_tags(drupal_get_title()), variable_get('site_name', 'Drupal'));
00235   }
00236   else {
00237     $head_title = array(variable_get('site_name', 'Drupal'));
00238     if (variable_get('site_slogan', '')) {
00239       $head_title[] = variable_get('site_slogan', '');
00240     }
00241   }
00242   $variables['head_title']        = implode(' | ', $head_title);
00243   $variables['base_path']         = base_path();
00244   $variables['breadcrumb']        = '';
00245   $variables['feed_icons']        = '';
00246   $variables['footer_message']    = filter_xss_admin(variable_get('site_footer', FALSE));
00247   $variables['head']              = drupal_get_html_head();
00248   $variables['help']              = '';
00249   $variables['language']          = $GLOBALS['language'];
00250   $variables['language']->dir     = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
00251   $variables['logo']              = theme_get_setting('logo');
00252   $variables['messages']          = $variables['show_messages'] ? theme('status_messages') : '';
00253   $variables['mission']           = '';
00254   $variables['primary_links']     = array();
00255   $variables['secondary_links']   = array();
00256   $variables['search_box']        = '';
00257   $variables['site_name']         = (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : '');
00258   $variables['site_slogan']       = (theme_get_setting('toggle_slogan') ? variable_get('site_slogan', '') : '');
00259   $variables['css']               = drupal_add_css();
00260   $variables['styles']            = drupal_get_css();
00261   $variables['scripts']           = drupal_get_js();
00262   $variables['tabs']              = '';
00263   $variables['title']             = drupal_get_title();
00264   $variables['closure']           = '';
00265
00266   // Compile a list of classes that are going to be applied to the body element.
00267   $body_classes = array();
00268   $body_classes[] = 'in-maintenance';
00269   if (isset($variables['db_is_active']) && !$variables['db_is_active']) {
00270     $body_classes[] = 'db-offline';
00271   }
00272   if ($variables['layout'] == 'both') {
00273     $body_classes[] = 'two-sidebars';
00274   }
00275   elseif ($variables['layout'] == 'none') {
00276     $body_classes[] = 'no-sidebars';
00277   }
00278   else {
00279     $body_classes[] = 'one-sidebar sidebar-'. $variables['layout'];
00280   }
00281   $variables['body_classes'] = implode(' ', $body_classes);
00282
00283   // Dead databases will show error messages so supplying this template will
00284   // allow themers to override the page and the content completely.
00285   if (isset($variables['db_is_active']) && !$variables['db_is_active']) {
00286     $variables['template_file'] = 'maintenance-page-offline';
00287   }
00288 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/bluemarine/block.tpl.php Source File

themes » bluemarine

block.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: block.tpl.php,v 1.3 2007/08/07 08:39:36 goba Exp $
00003 ?>
00004   <div class="block block-<?php print $block->module; ?>" id="block-<?php print $block->module; ?>-<?php print $block->delta; ?>">
00005     <h2 class="title"><?php print $block->subject; ?></h2>
00006     <div class="content"><?php print $block->content; ?></div>
00007  </div>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/bluemarine/box.tpl.php Source File

themes » bluemarine

box.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: box.tpl.php,v 1.3 2007/08/07 08:39:36 goba Exp $
00003 ?>
00004   <div class="box">
00005     <?php if ($title) { ?><h2 class="title"><?php print $title; ?></h2><?php } ?>
00006     <div class="content"><?php print $content; ?></div>
00007  </div>
00008
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/bluemarine/comment.tpl.php Source File

themes » bluemarine

comment.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: comment.tpl.php,v 1.7 2008/01/04 19:24:23 goba Exp $
00003 ?>
00004   <div class="comment<?php print ' '. $status; ?>">
00005     <?php if ($picture) {
00006     print $picture;
00007   } ?>
00008 <h3 class="title"><?php print $title; ?></h3><?php if ($new != '') { ?><span class="new"><?php print $new; ?></span><?php } ?>
00009     <div class="submitted"><?php print $submitted; ?></div>
00010     <div class="content">
00011      <?php print $content; ?>
00012      <?php if ($signature): ?>
00013       <div class="clear-block">
00014        <div>—</div>
00015        <?php print $signature ?>
00016       </div>
00017      <?php endif; ?>
00018     </div>
00019     <div class="links">&raquo; <?php print $links; ?></div>
00020   </div>
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/bluemarine/node.tpl.php Source File

themes » bluemarine

node.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: node.tpl.php,v 1.7 2007/08/07 08:39:36 goba Exp $
00003 ?>
00004   <div class="node<?php if ($sticky) { print " sticky"; } ?><?php if (!$status) { print " node-unpublished"; } ?>">
00005     <?php if ($picture) {
00006       print $picture;
00007     }?>
00008     <?php if ($page == 0) { ?><h2 class="title"><a href="<?php print $node_url?>"><?php print $title?></a></h2><?php }; ?>
00009     <span class="submitted"><?php print $submitted?></span>
00010     <div class="taxonomy"><?php print $terms?></div>
00011     <div class="content"><?php print $content?></div>
00012     <?php if ($links) { ?><div class="links">&raquo; <?php print $links?></div><?php }; ?>
00013   </div>
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/bluemarine/page.tpl.php Source File

themes » bluemarine

page.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: page.tpl.php,v 1.28 2008/01/24 09:42:52 goba Exp $
00003 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
00004 <html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language->language ?>" xml:lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
00005
00006 <head>
00007   <title><?php print $head_title ?></title>
00008   <?php print $head ?>
00009   <?php print $styles ?>
00010   <?php print $scripts ?>
00011   <script type="text/javascript"><?php /* Needed to avoid Flash of Unstyle Content in IE */ ?> </script>
00012 </head>
00013
00014 <body>
00015
00016 <table border="0" cellpadding="0" cellspacing="0" id="header">
00017   <tr>
00018     <td id="logo">
00019       <?php if ($logo) { ?><a href="<?php print $front_page ?>" title="<?php print t('Home') ?>"><img src="<?php print $logo ?>" alt="<?php print t('Home') ?>" /></a><?php } ?>
00020       <?php if ($site_name) { ?><h1 class='site-name'><a href="<?php print $front_page ?>" title="<?php print t('Home') ?>"><?php print $site_name ?></a></h1><?php } ?>
00021       <?php if ($site_slogan) { ?><div class='site-slogan'><?php print $site_slogan ?></div><?php } ?>
00022     </td>
00023     <td id="menu">
00024       <?php if (isset($secondary_links)) { ?><?php print theme('links', $secondary_links, array('class' => 'links', 'id' => 'subnavlist')) ?><?php } ?>
00025       <?php if (isset($primary_links)) { ?><?php print theme('links', $primary_links, array('class' => 'links', 'id' => 'navlist')) ?><?php } ?>
00026       <?php print $search_box ?>
00027     </td>
00028   </tr>
00029   <tr>
00030     <td colspan="2"><div><?php print $header ?></div></td>
00031   </tr>
00032 </table>
00033
00034 <table border="0" cellpadding="0" cellspacing="0" id="content">
00035   <tr>
00036     <?php if ($left) { ?><td id="sidebar-left">
00037       <?php print $left ?>
00038     </td><?php } ?>
00039     <td valign="top">
00040       <?php if ($mission) { ?><div id="mission"><?php print $mission ?></div><?php } ?>
00041       <div id="main">
00042         <?php print $breadcrumb ?>
00043         <h1 class="title"><?php print $title ?></h1>
00044         <div class="tabs"><?php print $tabs ?></div>
00045         <?php if ($show_messages) { print $messages; } ?>
00046         <?php print $help ?>
00047         <?php print $content; ?>
00048         <?php print $feed_icons; ?>
00049       </div>
00050     </td>
00051     <?php if ($right) { ?><td id="sidebar-right">
00052       <?php print $right ?>
00053     </td><?php } ?>
00054   </tr>
00055 </table>
00056
00057 <div id="footer">
00058   <?php print $footer_message ?>
00059   <?php print $footer ?>
00060 </div>
00061 <?php print $closure ?>
00062 </body>
00063 </html>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/block.tpl.php Source File

themes » garland

block.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: block.tpl.php,v 1.3 2007/08/07 08:39:36 goba Exp $
00003 ?>
00004 <div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="clear-block block block-<?php print $block->module ?>">
00005
00006 <?php if (!empty($block->subject)): ?>
00007   <h2><?php print $block->subject ?></h2>
00008 <?php endif;?>
00009
00010   <div class="content"><?php print $block->content ?></div>
00011 </div>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/comment.tpl.php Source File

themes » garland

comment.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: comment.tpl.php,v 1.10 2008/01/04 19:24:24 goba Exp $
00003 ?>
00004 <div class="comment<?php print ($comment->new) ? ' comment-new' : ''; print ' '. $status; print ' '. $zebra; ?>">
00005
00006   <div class="clear-block">
00007   <?php if ($submitted): ?>
00008     <span class="submitted"><?php print $submitted; ?></span>
00009   <?php endif; ?>
00010
00011   <?php if ($comment->new) : ?>
00012     <span class="new"><?php print drupal_ucfirst($new) ?></span>
00013   <?php endif; ?>
00014
00015   <?php print $picture ?>
00016
00017     <h3><?php print $title ?></h3>
00018
00019     <div class="content">
00020       <?php print $content ?>
00021       <?php if ($signature): ?>
00022       <div class="clear-block">
00023         <div>—</div>
00024         <?php print $signature ?>
00025       </div>
00026       <?php endif; ?>
00027     </div>
00028   </div>
00029
00030   <?php if ($links): ?>
00031     <div class="links"><?php print $links ?></div>
00032   <?php endif; ?>
00033 </div>
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/maintenance-page.tpl.php Source File

themes » garland

maintenance-page.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: maintenance-page.tpl.php,v 1.3 2008/01/24 09:42:53 goba Exp $
00003
00014 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
00015   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
00016 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language ?>" lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
00017   <head>
00018     <title><?php print $head_title ?></title>
00019     <?php print $head ?>
00020     <?php print $styles ?>
00021     <?php print $scripts ?>
00022     <!--[if lt IE 7]>
00023       <?php print phptemplate_get_ie_styles(); ?>
00024     <![endif]-->
00025   </head>
00026   <body<?php print phptemplate_body_class($left, $right); ?>>
00027
00028 <!-- Layout -->
00029   <div id="header-region" class="clear-block"><?php print $header; ?></div>
00030
00031     <div id="wrapper">
00032     <div id="container" class="clear-block">
00033
00034       <div id="header">
00035         <div id="logo-floater">
00036         <?php
00037           // Prepare header
00038           $site_fields = array();
00039           if ($site_name) {
00040             $site_fields[] = check_plain($site_name);
00041           }
00042           if ($site_slogan) {
00043             $site_fields[] = check_plain($site_slogan);
00044           }
00045           $site_title = implode(' ', $site_fields);
00046           if ($site_fields) {
00047             $site_fields[0] = '<span>'. $site_fields[0] .'</span>';
00048           }
00049           $site_html = implode(' ', $site_fields);
00050
00051           if ($logo || $site_title) {
00052             print '<h1><a href="'. check_url($base_path) .'" title="'. $site_title .'">';
00053             if ($logo) {
00054               print '<img src="'. check_url($logo) .'" alt="'. $site_title .'" id="logo" />';
00055             }
00056             print $site_html .'</a></h1>';
00057           }
00058         ?>
00059         </div>
00060
00061       </div> <!-- /header -->
00062
00063       <?php if ($left): ?>
00064         <div id="sidebar-left" class="sidebar">
00065           <?php if ($search_box): ?><div class="block block-theme"><?php print $search_box ?></div><?php endif; ?>
00066           <?php print $left ?>
00067         </div>
00068       <?php endif; ?>
00069
00070       <div id="center"><div id="squeeze"><div class="right-corner"><div class="left-corner">
00071           <?php if ($title): print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>'; endif; ?>
00072           <?php print $help; ?>
00073           <?php print $messages; ?>
00074           <div class="clear-block">
00075             <?php print $content ?>
00076           </div>
00077           <div id="footer"><?php print $footer_message . $footer ?></div>
00078       </div></div></div></div> <!-- /.left-corner, /.right-corner, /#squeeze, /#center -->
00079
00080       <?php if ($right): ?>
00081         <div id="sidebar-right" class="sidebar">
00082           <?php print $right ?>
00083         </div>
00084       <?php endif; ?>
00085
00086     </div> <!-- /container -->
00087   </div>
00088 <!-- /layout -->
00089
00090   </body>
00091 </html>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/node.tpl.php Source File

themes » garland

node.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: node.tpl.php,v 1.5 2007/10/11 09:51:29 goba Exp $
00003 ?>
00004 <div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">
00005
00006 <?php print $picture ?>
00007
00008 <?php if ($page == 0): ?>
00009   <h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
00010 <?php endif; ?>
00011
00012   <?php if ($submitted): ?>
00013     <span class="submitted"><?php print $submitted; ?></span>
00014   <?php endif; ?>
00015
00016   <div class="content clear-block">
00017     <?php print $content ?>
00018   </div>
00019
00020   <div class="clear-block">
00021     <div class="meta">
00022     <?php if ($taxonomy): ?>
00023       <div class="terms"><?php print $terms ?></div>
00024     <?php endif;?>
00025     </div>
00026
00027     <?php if ($links): ?>
00028       <div class="links"><?php print $links; ?></div>
00029     <?php endif; ?>
00030   </div>
00031
00032 </div>
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/garland/page.tpl.php Source File

themes » garland

page.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: page.tpl.php,v 1.18 2008/01/24 09:42:53 goba Exp $
00003 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
00004   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
00005 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language ?>" lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
00006   <head>
00007     <title><?php print $head_title ?></title>
00008     <?php print $head ?>
00009     <?php print $styles ?>
00010     <?php print $scripts ?>
00011     <!--[if lt IE 7]>
00012       <?php print phptemplate_get_ie_styles(); ?>
00013     <![endif]-->
00014   </head>
00015   <body<?php print phptemplate_body_class($left, $right); ?>>
00016
00017 <!-- Layout -->
00018   <div id="header-region" class="clear-block"><?php print $header; ?></div>
00019
00020     <div id="wrapper">
00021     <div id="container" class="clear-block">
00022
00023       <div id="header">
00024         <div id="logo-floater">
00025         <?php
00026           // Prepare header
00027           $site_fields = array();
00028           if ($site_name) {
00029             $site_fields[] = check_plain($site_name);
00030           }
00031           if ($site_slogan) {
00032             $site_fields[] = check_plain($site_slogan);
00033           }
00034           $site_title = implode(' ', $site_fields);
00035           if ($site_fields) {
00036             $site_fields[0] = '<span>'. $site_fields[0] .'</span>';
00037           }
00038           $site_html = implode(' ', $site_fields);
00039
00040           if ($logo || $site_title) {
00041             print '<h1><a href="'. check_url($front_page) .'" title="'. $site_title .'">';
00042             if ($logo) {
00043               print '<img src="'. check_url($logo) .'" alt="'. $site_title .'" id="logo" />';
00044             }
00045             print $site_html .'</a></h1>';
00046           }
00047         ?>
00048         </div>
00049
00050         <?php if (isset($primary_links)) : ?>
00051           <?php print theme('links', $primary_links, array('class' => 'links primary-links')) ?>
00052         <?php endif; ?>
00053         <?php if (isset($secondary_links)) : ?>
00054           <?php print theme('links', $secondary_links, array('class' => 'links secondary-links')) ?>
00055         <?php endif; ?>
00056
00057       </div> <!-- /header -->
00058
00059       <?php if ($left): ?>
00060         <div id="sidebar-left" class="sidebar">
00061           <?php if ($search_box): ?><div class="block block-theme"><?php print $search_box ?></div><?php endif; ?>
00062           <?php print $left ?>
00063         </div>
00064       <?php endif; ?>
00065
00066       <div id="center"><div id="squeeze"><div class="right-corner"><div class="left-corner">
00067           <?php print $breadcrumb; ?>
00068           <?php if ($mission): print '<div id="mission">'. $mission .'</div>'; endif; ?>
00069           <?php if ($tabs): print '<div id="tabs-wrapper" class="clear-block">'; endif; ?>
00070           <?php if ($title): print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>'; endif; ?>
00071           <?php if ($tabs): print '<ul class="tabs primary">'. $tabs .'</ul></div>'; endif; ?>
00072           <?php if ($tabs2): print '<ul class="tabs secondary">'. $tabs2 .'</ul>'; endif; ?>
00073           <?php if ($show_messages && $messages): print $messages; endif; ?>
00074           <?php print $help; ?>
00075           <div class="clear-block">
00076             <?php print $content ?>
00077           </div>
00078           <?php print $feed_icons ?>
00079           <div id="footer"><?php print $footer_message . $footer ?></div>
00080       </div></div></div></div> <!-- /.left-corner, /.right-corner, /#squeeze, /#center -->
00081
00082       <?php if ($right): ?>
00083         <div id="sidebar-right" class="sidebar">
00084           <?php if (!$left && $search_box): ?><div class="block block-theme"><?php print $search_box ?></div><?php endif; ?>
00085           <?php print $right ?>
00086         </div>
00087       <?php endif; ?>
00088
00089     </div> <!-- /container -->
00090   </div>
00091 <!-- /layout -->
00092
00093   <?php print $closure ?>
00094   </body>
00095 </html>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/pushbutton/block.tpl.php Source File

themes » pushbutton

block.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: block.tpl.php,v 1.2 2007/08/07 08:39:36 goba Exp $
00003 ?>
00004 <div class="<?php print "block block-$block->module" ?>" id="<?php print "block-$block->module-$block->delta"; ?>">
00005   <div class="title"><h3><?php print $block->subject ?></h3></div>
00006   <div class="content"><?php print $block->content ?></div>
00007 </div>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/pushbutton/box.tpl.php Source File

themes » pushbutton

box.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: box.tpl.php,v 1.3 2007/08/07 08:39:36 goba Exp $
00003 ?>
00004 <div class="box">
00005   <?php if ($title): ?>
00006   <h2 class="title"><?php print $title ?></h2>
00007   <?php endif; ?>
00008   <div class="content"><?php print $content ?></div>
00009 </div>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/pushbutton/comment.tpl.php Source File

themes » pushbutton

comment.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: comment.tpl.php,v 1.6 2008/01/04 19:24:24 goba Exp $
00003 ?>
00004 <div class="comment<?php print ' '. $status; ?>">
00005   <?php if ($picture) : ?>
00006     <?php print $picture ?>
00007   <?php endif; ?>
00008   <h3 class="title"><?php print $title ?></h3>
00009   <div class="submitted"><?php print $submitted ?><?php if ($comment->new) : ?><span class="new"> *<?php print $new ?></span><?php endif; ?></div>
00010   <div class="content">
00011     <?php print $content ?>
00012     <?php if ($signature): ?>
00013       <div class="clear-block">
00014         <div>—</div>
00015         <?php print $signature ?>
00016       </div>
00017     <?php endif; ?>
00018   </div>
00019   <!-- BEGIN: links -->
00020   <div class="links">&raquo; <?php print $links ?></div>
00021   <!-- END: links -->
00022 </div>
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/pushbutton/node.tpl.php Source File

themes » pushbutton

node.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: node.tpl.php,v 1.4 2007/08/07 08:39:36 goba Exp $
00003 ?>
00004 <div class="node<?php if ($sticky) { print " sticky"; } ?><?php if (!$status) { print " node-unpublished"; } ?>">
00005   <?php print $picture ?>
00006   <?php if ($page == 0): ?>
00007     <h1 class="title"><a href="<?php print $node_url ?>"><?php print $title ?></a></h1>
00008   <?php endif; ?>
00009     <span class="submitted"><?php print $submitted ?></span>
00010     <div class="taxonomy"><?php print $terms ?></div>
00011     <div class="content"><?php print $content ?></div>
00012     <?php if ($links): ?>
00013     <div class="links">&raquo; <?php print $links ?></div>
00014     <?php endif; ?>
00015 </div>
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: themes/pushbutton/page.tpl.php Source File

themes » pushbutton

page.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: page.tpl.php,v 1.25 2008/01/24 09:42:53 goba Exp $
00003 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
00004 <html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language->language ?>" xml:lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
00005 <head>
00006   <title><?php print $head_title ?></title>
00007   <meta http-equiv="Content-Style-Type" content="text/css" />
00008   <?php print $head ?>
00009   <?php print $styles ?>
00010   <?php print $scripts ?>
00011 </head>
00012
00013 <body bgcolor="#ffffff">
00014
00015 <div class="hide"><a href="#content" title="<?php print t('Skip navigation') ?>." accesskey="2"><?php print t('Skip navigation') ?></a>.</div>
00016
00017 <table id="primary-menu" summary="Navigation elements." border="0" cellpadding="0" cellspacing="0" width="100%">
00018   <tr>
00019     <td id="home" width="10%">
00020       <?php if ($logo) : ?>
00021         <a href="<?php print $front_page ?>" title="<?php print t('Home') ?>"><img src="<?php print($logo) ?>" alt="<?php print t('Home') ?>" border="0" /></a>
00022       <?php endif; ?>
00023     </td>
00024
00025     <td id="site-info" width="20%">
00026       <?php if ($site_name) : ?>
00027         <div class='site-name'><a href="<?php print $front_page ?>" title="<?php print t('Home') ?>"><?php print($site_name) ?></a></div>
00028       <?php endif;?>
00029       <?php if ($site_slogan) : ?>
00030         <div class='site-slogan'><?php print($site_slogan) ?></div>
00031       <?php endif;?>
00032     </td>
00033     <td class="primary-links" width="70%" align="center" valign="middle">
00034       <?php print theme('links', $primary_links, array('class' => 'links', 'id' => 'navlist')) ?>
00035     </td>
00036   </tr>
00037 </table>
00038
00039 <table id="secondary-menu" summary="Navigation elements." border="0" cellpadding="0" cellspacing="0" width="100%">
00040   <tr>
00041     <td class="secondary-links" width="75%"  align="center" valign="middle">
00042       <?php print theme('links', $secondary_links, array('class' => 'links', 'id' => 'subnavlist')) ?>
00043     </td>
00044     <td width="25%" align="center" valign="middle">
00045       <?php print $search_box ?>
00046     </td>
00047   </tr>
00048   <tr>
00049     <td colspan="2"><div><?php print $header ?></div></td>
00050   </tr>
00051 </table>
00052
00053 <table id="content" border="0" cellpadding="15" cellspacing="0" width="100%">
00054   <tr>
00055     <?php if ($left != ""): ?>
00056     <td id="sidebar-left">
00057       <?php print $left ?>
00058     </td>
00059     <?php endif; ?>
00060
00061     <td valign="top">
00062       <?php if ($mission != ""): ?>
00063       <div id="mission"><?php print $mission ?></div>
00064       <?php endif; ?>
00065
00066       <div id="main">
00067         <?php if ($title != ""): ?>
00068           <?php print $breadcrumb ?>
00069           <h1 class="title"><?php print $title ?></h1>
00070
00071           <?php if ($tabs != ""): ?>
00072             <div class="tabs"><?php print $tabs ?></div>
00073           <?php endif; ?>
00074
00075         <?php endif; ?>
00076
00077         <?php if ($show_messages && $messages != ""): ?>
00078           <?php print $messages ?>
00079         <?php endif; ?>
00080
00081         <?php if ($help != ""): ?>
00082             <div id="help"><?php print $help ?></div>
00083         <?php endif; ?>
00084
00085       <!-- start main content -->
00086       <?php print $content; ?>
00087       <?php print $feed_icons; ?>
00088       <!-- end main content -->
00089
00090       </div><!-- main -->
00091     </td>
00092     <?php if ($right != ""): ?>
00093     <td id="sidebar-right">
00094       <?php print $right ?>
00095     </td>
00096     <?php endif; ?>
00097   </tr>
00098 </table>
00099
00100 <table id="footer-menu" summary="Navigation elements." border="0" cellpadding="0" cellspacing="0" width="100%">
00101   <tr>
00102     <td align="center" valign="middle">
00103     <?php if (isset($primary_links)) : ?>
00104       <?php print theme('links', $primary_links, array('class' => 'links primary-links')) ?>
00105     <?php endif; ?>
00106     <?php if (isset($secondary_links)) : ?>
00107       <?php print theme('links', $secondary_links, array('class' => 'links secondary-links')) ?>
00108     <?php endif; ?>
00109     </td>
00110   </tr>
00111 </table>
00112
00113 <?php if ($footer_message || $footer) : ?>
00114 <div id="footer-message">
00115     <p><?php print $footer_message . $footer;?></p>
00116 </div>
00117 <?php endif; ?>
00118 <?php print $closure;?>
00119 </body>
00120 </html>
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/throttle/throttle.admin.inc Source File

modules » throttle

throttle.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: throttle.admin.inc,v 1.2 2008/01/08 10:35:43 goba Exp $
00003
00016 function throttle_admin_settings() {
00017   $probabilities = array(0 => '100%', 1 => '50%', 2 => '33.3%', 3 => '25%', 4 => '20%', 5 => '16.6%', 7 => '12.5%', 9 => '10%', 19 => '5%', 99 => '1%', 199 => '.5%', 399 => '.25%', 989 => '.1%');
00018
00019   $form['throttle_anonymous'] = array(
00020     '#type' => 'textfield',
00021     '#title' => t('Auto-throttle on anonymous users'),
00022     '#default_value' => variable_get('throttle_anonymous', 0),
00023     '#size' => 5,
00024     '#maxlength' => 6,
00025     '#description' => t('The congestion control throttle can be automatically enabled when the number of anonymous users currently visiting your site exceeds the specified threshold. For example, to start the throttle when your site has 250 anonymous users online at once, enter \'250\' in this field. Leave this value blank or set to "0" if you do not wish to auto-throttle on anonymous users. You can inspect the current number of anonymous users using the "Who\'s online" block.')
00026   );
00027   $form['throttle_user'] = array(
00028     '#type' => 'textfield',
00029     '#title' => t('Auto-throttle on authenticated users'),
00030     '#default_value' => variable_get('throttle_user', 0),
00031     '#size' => 5,
00032     '#maxlength' => 6,
00033     '#description' => t('The congestion control throttle can be automatically enabled when the number of authenticated users currently visiting your site exceeds the specified threshold. For example, to start the throttle when your site has 50 registered users online at once, enter \'50\' in this field. Leave this value blank or set to "0" if you do not wish to auto-throttle on authenticated users. You can inspect the current number of authenticated users using the "Who\'s online" block.')
00034   );
00035   $form['throttle_probability_limiter'] = array(
00036     '#type' => 'select',
00037     '#title' => t('Auto-throttle probability limiter'),
00038     '#default_value' => variable_get('throttle_probability_limiter', 9),
00039     '#options' => $probabilities,
00040     '#description' => t('The auto-throttle probability limiter is an efficiency mechanism to statistically reduce the overhead of the auto-throttle. The limiter is expressed as a percentage of page views, so for example if set to the default of 10% we only perform the extra database queries to update the throttle status 1 out of every 10 page views. The busier your site, the lower you should set the limiter value.')
00041   );
00042
00043   $form['#validate'] = array('throttle_admin_settings_validate');
00044
00045   return system_settings_form($form);
00046 }
00047
00048 function throttle_admin_settings_validate($form, &$form_state) {
00049   if (!is_numeric($form_state['values']['throttle_anonymous']) || $form_state['values']['throttle_anonymous'] < 0) {
00050     form_set_error('throttle_anonymous', t("%value is not a valid auto-throttle setting. Please enter a positive numeric value.", array('%value' => $form_state['values']['throttle_anonymous'])));
00051   }
00052   if (!is_numeric($form_state['values']['throttle_user']) || $form_state['values']['throttle_user'] < 0) {
00053     form_set_error('throttle_user', t("%value is not a valid auto-throttle setting. Please enter a positive numeric value.", array('%value' => $form_state['values']['throttle_user'])));
00054   }
00055 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/throttle/throttle.module Source File

modules » throttle

throttle.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: throttle.module,v 1.83 2007/12/14 18:08:49 goba Exp $
00003
00009 function throttle_menu() {
00010   $items['admin/settings/throttle'] = array(
00011     'title' => 'Throttle',
00012     'description' => 'Control how your site cuts out content during heavy load.',
00013     'page callback' => 'drupal_get_form',
00014     'page arguments' => array('throttle_admin_settings'),
00015     'access arguments' => array('administer site configuration'),
00016     'file' => 'throttle.admin.inc',
00017   );
00018   return $items;
00019 }
00020
00040 function throttle_status() {
00041   return variable_get('throttle_level', 0);
00042 }
00043
00049 function throttle_exit() {
00050   // The following logic determines what the current throttle level should
00051   //  be, and can be disabled by the admin. If enabled, the mt_rand() function
00052   //  returns a number between 0 and N, N being specified by the admin. If
00053   //  0 is returned, the throttle logic is run, adding two additional database
00054   //  queries. Otherwise, the following logic is skipped. This mechanism is
00055   //  referred to in the admin page as the 'probability limiter', roughly
00056   //  limiting throttle related database calls to 1 in N.
00057   if (!mt_rand(0, variable_get('throttle_probability_limiter', 9))) {
00058
00059     // Count users with activity in the past n seconds.
00060     // This value is defined in the user module Who's Online block.
00061     $time_period = variable_get('user_block_seconds_online', 900);
00062
00063     // When determining throttle status in your own module or theme, use
00064     // $throttle = module_invoke('throttle', 'status');
00065     // as that will still work when throttle.module is disabled.
00066     // Clearly here the module is enabled so we call throttle_status() directly.
00067     $throttle = throttle_status();
00068
00069     if ($max_guests = variable_get('throttle_anonymous', 0)) {
00070       $guests = sess_count(time() - $time_period, TRUE);
00071     }
00072     else {
00073       $guests = 0;
00074     }
00075     if ($max_users = variable_get('throttle_user', 0)) {
00076       $users = sess_count(time() - $time_period, FALSE);
00077     }
00078     else {
00079       $users = 0;
00080     }
00081
00082     // update the throttle status
00083     $message = '';
00084     if ($max_users && $users > $max_users) {
00085       if (!$throttle) {
00086         variable_set('throttle_level', 1);
00087         $message = format_plural($users,
00088                                  '1 user accessing site; throttle enabled.',
00089                                  '@count users accessing site; throttle enabled.');
00090       }
00091     }
00092     elseif ($max_guests && $guests > $max_guests) {
00093       if (!$throttle) {
00094         variable_set('throttle_level', 1);
00095         $message = format_plural($guests,
00096                                  '1 guest accessing site; throttle enabled.',
00097                                  '@count guests accessing site; throttle enabled.');
00098       }
00099     }
00100     else {
00101       if ($throttle) {
00102         variable_set('throttle_level', 0);
00103         // Note: unorthodox format_plural() usage due to Gettext plural limitations.
00104         $message = format_plural($users, '1 user', '@count users') .', ';
00105         $message .= format_plural($guests, '1 guest accessing site; throttle disabled', '@count guests accessing site; throttle disabled');
00106       }
00107     }
00108     if ($message) {
00109       cache_clear_all();
00110       watchdog('throttle', 'Throttle: %message', array('%message' => $message));
00111     }
00112   }
00113 }
00114
00118 function throttle_help($path, $arg) {
00119   switch ($path) {
00120     case 'admin/help#throttle':
00121       $output = '<p>'. t('The throttle module provides a congestion control mechanism that automatically adjusts to a surge in incoming traffic. If your site is referenced by a popular website, or experiences a "Denial of Service" (DoS) attack, your webserver might become overwhelmed. The throttle mechanism is utilized by modules to temporarily disable CPU-intensive functionality, increasing performance. For instance, via the throttle module, modules may choose to disable resource-intensive blocks or the code within the site theme may temporarily disable user pictures in posts.') .'</p>';
00122       $output .= '<p>'. t('The congestion control throttle can be automatically enabled when the number of anonymous or authenticated users currently visiting the site exceeds a specified threshold.') .'</p>';
00123       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@throttle">Throttle module</a>.', array('@throttle' => 'http://drupal.org/handbook/modules/throttle/')) .'</p>';
00124       return $output;
00125     case 'admin/settings/throttle':
00126       return '<p>'. t('The throttle module provides a congestion control mechanism that automatically adjusts to a surge in incoming traffic. If your site is referenced by a popular website, or experiences a "Denial of Service" (DoS) attack, your webserver might become overwhelmed. The throttle mechanism is utilized by modules to temporarily disable CPU-intensive functionality, increasing performance.') .'</p>';
00127   }
00128 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/tracker/tracker.module Source File

modules » tracker

tracker.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: tracker.module,v 1.154 2007/12/14 18:08:49 goba Exp $
00003
00012 function tracker_help($path, $arg) {
00013   switch ($path) {
00014     case 'admin/help#tracker':
00015       $output = '<p>'. t('The tracker module displays the most recently added or updated content on your site, and provides user-level tracking to follow the contributions of particular authors.') .'</p>';
00016       $output .= '<p>'. t("The <em>Recent posts</em> page is available via a link in the navigation menu block and displays new and recently-updated content (including the content type, the title, the author's name, number of comments, and time of last update) in reverse chronological order. Posts are marked updated when changes occur in the text, or when new comments are added. To use the tracker module to follow a specific user's contributions, select the <em>Track</em> tab from the user's profile page.") .'</p>';
00017       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@tracker">Tracker module</a>.', array('@tracker' => 'http://drupal.org/handbook/modules/tracker/')) .'</p>';
00018       return $output;
00019   }
00020 }
00021
00025 function tracker_menu() {
00026   $items['tracker'] = array(
00027     'title' => 'Recent posts',
00028     'page callback' => 'tracker_page',
00029     'access arguments' => array('access content'),
00030     'weight' => 1,
00031     'file' => 'tracker.pages.inc',
00032   );
00033   $items['tracker/all'] = array(
00034     'title' => 'All recent posts',
00035     'type' => MENU_DEFAULT_LOCAL_TASK,
00036     'access callback' => 'user_is_logged_in',
00037   );
00038   $items['tracker/%user_current'] = array(
00039     'title' => 'My recent posts',
00040     'access callback' => 'user_is_logged_in',
00041     'page arguments' => array(1),
00042     'type' => MENU_LOCAL_TASK,
00043   );
00044
00045   $items['user/%user/track'] = array(
00046     'title' => 'Track',
00047     'page callback' => 'tracker_page',
00048     'page arguments' => array(1, TRUE),
00049     'type' => MENU_LOCAL_TASK,
00050     'file' => 'tracker.pages.inc',
00051   );
00052   $items['user/%user/track/posts'] = array(
00053     'title' => 'Track posts',
00054     'type' => MENU_DEFAULT_LOCAL_TASK,
00055   );
00056   return $items;
00057 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/tracker/tracker.pages.inc Source File

modules » tracker

tracker.pages.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: tracker.pages.inc,v 1.5 2007/11/28 10:29:20 dries Exp $
00003
00013 function tracker_page($account = NULL, $set_title = FALSE) {
00014   // Add CSS
00015   drupal_add_css(drupal_get_path('module', 'tracker') .'/tracker.css', 'module', 'all', FALSE);
00016
00017   if ($account) {
00018     if ($set_title) {
00019       // When viewed from user/%user/track, display the name of the user
00020       // as page title -- the tab title remains Track so this needs to be done
00021       // here and not in the menu definiton.
00022       drupal_set_title(check_plain($account->name));
00023     }
00024   // TODO: These queries are very expensive, see http://drupal.org/node/105639
00025     $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d) ORDER BY last_updated DESC';
00026     $sql = db_rewrite_sql($sql);
00027     $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d)';
00028     $sql_count = db_rewrite_sql($sql_count);
00029     $result = pager_query($sql, 25, 0, $sql_count, COMMENT_PUBLISHED, $account->uid, $account->uid);
00030   }
00031   else {
00032     $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, l.comment_count FROM {node} n INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 ORDER BY last_updated DESC';
00033     $sql = db_rewrite_sql($sql);
00034     $sql_count = 'SELECT COUNT(n.nid) FROM {node} n WHERE n.status = 1';
00035     $sql_count = db_rewrite_sql($sql_count);
00036     $result = pager_query($sql, 25, 0, $sql_count);
00037   }
00038
00039   $rows = array();
00040   while ($node = db_fetch_object($result)) {
00041     // Determine the number of comments:
00042     $comments = 0;
00043     if ($node->comment_count) {
00044       $comments = $node->comment_count;
00045
00046       if ($new = comment_num_new($node->nid)) {
00047         $comments .= '<br />';
00048         $comments .= l(format_plural($new, '1 new', '@count new'), "node/$node->nid", array('query' => comment_new_page_count($node->comment_count, $new, $node), 'fragment' => 'new'));
00049       }
00050     }
00051
00052     $rows[] = array(
00053       check_plain(node_get_types('name', $node->type)),
00054       l($node->title, "node/$node->nid") .' '. theme('mark', node_mark($node->nid, $node->changed)),
00055       theme('username', $node),
00056       array('class' => 'replies', 'data' => $comments),
00057       t('!time ago', array('!time' => format_interval(time() - $node->last_updated)))
00058     );
00059   }
00060
00061   if (!$rows) {
00062     $rows[] = array(array('data' => t('No posts available.'), 'colspan' => '5'));
00063   }
00064
00065   $header = array(t('Type'), t('Post'), t('Author'), t('Replies'), t('Last updated'));
00066
00067   $output = '<div id="tracker">';
00068   $output .= theme('table', $header, $rows);
00069   $output .= theme('pager', NULL, 25, 0);
00070   $output .= '</div>';
00071
00072   return $output;
00073 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/translation/translation.module Source File

modules » translation

translation.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: translation.module,v 1.23 2008/01/28 11:38:58 goba Exp $
00003
00026 define('TRANSLATION_ENABLED', 2);
00027
00031 function translation_help($path, $arg) {
00032   switch ($path) {
00033     case 'admin/help#translation':
00034       $output = '<p>'. t('The content translation module allows content to be translated into different languages. Working with the <a href="@locale">locale module</a> (which manages enabled languages and provides translation for the site interface), the content translation module is key to creating and maintaining translated site content.', array('@locale' => url('admin/help/locale'))) .'</p>';
00035       $output .= '<p>'. t('Configuring content translation and translation-enabled content types:') .'</p>';
00036       $output .= '<ul><li>'. t('Assign the <em>translate content</em> permission to the appropriate user roles at the <a href="@permissions">Permissions configuration page</a>.', array('@permissions' => url('admin/user/permissions'))) .'</li>';
00037       $output .= '<li>'. t('Add and enable desired languages at the <a href="@languages">Languages configuration page</a>.', array('@languages' => url('admin/settings/language'))) .'</li>';
00038       $output .= '<li>'. t('Determine which <a href="@content-types">content types</a> should support translation features. To enable translation support for a content type, edit the type and at the <em>Multilingual support</em> drop down, select <em>Enabled, with translation</em>. (<em>Multilingual support</em> is located within <em>Workflow settings</em>.) Be sure to save each content type after enabling multilingual support.', array('@content-types' => url('admin/content/types'))) .'</li></ul>';
00039       $output .= '<p>'. t('Working with translation-enabled content types:') .'</p>';
00040       $output .= '<ul><li>'. t('Use the <em>Language</em> drop down to select the appropriate language when creating or editing posts.') .'</li>';
00041       $output .= '<li>'. t('Provide new or edit current translations for existing posts via the <em>Translation</em> tab. Only visible while viewing a post as a user with the <em>translate content</em> permission, this tab allows translations to be added or edited using a specialized editing form that also displays the content being translated.') .'</li>';
00042       $output .= '<li>'. t('Update translations as needed, so that they accurately reflect changes in the content of the original post. The translation status flag provides a simple method for tracking outdated translations. After editing a post, for example, select the <em>Flag translations as outdated</em> check box to mark all of its translations as outdated and in need of revision. Individual translations may be marked for revision by selecting the <em>This translation needs to be updated</em> check box on the translation editing form.') .'</li>';
00043       $output .= '<li>'. t('The <a href="@content-node">Content management administration page</a> displays the language of each post, and also allows filtering by language or translation status.', array('@content-node' => url('admin/content/node'))) .'</li></ul>';
00044       $output .= '<p>'. t('Use the <a href="@blocks">language switcher block</a> provided by locale module to allow users to select a language. If available, both the site interface and site content are presented in the language selected.', array('@blocks' => url('admin/build/block'))) .'</p>';
00045       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@translation">Translation module</a>.', array('@translation' => 'http://drupal.org/handbook/modules/translation/')) .'</p>';
00046       return $output;
00047     case 'node/%/translate':
00048       $output = '<p>'. t('Translations of a piece of content are managed with translation sets. Each translation set has one source post and any number of translations in any of the <a href="!languages">enabled languages</a>. All translations are tracked to be up to date or outdated based on whether the source post was modified significantly.', array('!languages' => url('admin/settings/language'))) .'</p>';
00049       return $output;
00050   }
00051 }
00052
00056 function translation_menu() {
00057   $items = array();
00058   $items['node/%node/translate'] = array(
00059     'title' => 'Translate',
00060     'page callback' => 'translation_node_overview',
00061     'page arguments' => array(1),
00062     'access callback' => '_translation_tab_access',
00063     'access arguments' => array(1),
00064     'type' => MENU_LOCAL_TASK,
00065     'weight' => 2,
00066     'file' => 'translation.pages.inc',
00067   );
00068   return $items;
00069 }
00070
00078 function _translation_tab_access($node) {
00079   if (!empty($node->language) && translation_supported_type($node->type)) {
00080     return user_access('translate content');
00081   }
00082   return FALSE;
00083 }
00084
00088 function translation_perm() {
00089   return array('translate content');
00090 }
00091
00099 function translation_form_alter(&$form, $form_state, $form_id) {
00100   if ($form_id == 'node_type_form') {
00101     // Add translation option to content type form.
00102     $form['workflow']['language_content_type']['#options'][TRANSLATION_ENABLED] = t('Enabled, with translation');
00103     // Description based on text from locale.module.
00104     $form['workflow']['language_content_type']['#description'] = t('Enable multilingual support for this content type. If enabled, a language selection field will be added to the editing form, allowing you to select from one of the <a href="!languages">enabled languages</a>. You can also turn on translation for this content type, which lets you have content translated to any of the enabled languages. If disabled, new posts are saved with the default language. Existing content will not be affected by changing this option.', array('!languages' => url('admin/settings/language')));
00105   }
00106   elseif (isset($form['#id']) && $form['#id'] == 'node-form' && translation_supported_type($form['#node']->type)) {
00107     $node = $form['#node'];
00108     if (!empty($node->translation_source)) {
00109       // We are creating a translation. Add values and lock language field.
00110       $form['translation_source'] = array('#type' => 'value', '#value' => $node->translation_source);
00111       $form['language']['#disabled'] = TRUE;
00112     }
00113     elseif (!empty($node->nid) && !empty($node->tnid)) {
00114       // Disable languages for existing translations, so it is not possible to switch this
00115       // node to some language which is already in the translation set. Also remove the
00116       // language neutral option.
00117       unset($form['language']['#options']['']);
00118       foreach (translation_node_get_translations($node->tnid) as $translation) {
00119         if ($translation->nid != $node->nid) {
00120           unset($form['language']['#options'][$translation->language]);
00121         }
00122       }
00123       // Add translation values and workflow options.
00124       $form['tnid'] = array('#type' => 'value', '#value' => $node->tnid);
00125       $form['translation'] = array(
00126         '#type' => 'fieldset',
00127         '#title' => t('Translation settings'),
00128         '#access' => user_access('translate content'),
00129         '#collapsible' => TRUE,
00130         '#collapsed' => !$node->translate,
00131         '#tree' => TRUE,
00132         '#weight' => 30,
00133       );
00134       if ($node->tnid == $node->nid) {
00135         // This is the source node of the translation
00136         $form['translation']['retranslate'] = array(
00137           '#type' => 'checkbox',
00138           '#title' => t('Flag translations as outdated'),
00139           '#default_value' => 0,
00140           '#description' => t('If you made a significant change, which means translations should be updated, you can flag all translations of this post as outdated. This will not change any other property of those posts, like whether they are published or not.'),
00141         );
00142         $form['translation']['status'] = array('#type' => 'value', '#value' => 0);
00143       }
00144       else {
00145         $form['translation']['status'] = array(
00146           '#type' => 'checkbox',
00147           '#title' => t('This translation needs to be updated'),
00148           '#default_value' => $node->translate,
00149           '#description' => t('When this option is checked, this translation needs to be updated because the source post has changed. Uncheck when the translation is up to date again.'),
00150         );
00151       }
00152     }
00153   }
00154 }
00155
00162 function translation_link($type, $node = NULL, $teaser = FALSE) {
00163   $links = array();
00164   if ($type == 'node' && ($node->tnid) && $translations = translation_node_get_translations($node->tnid)) {
00165     // Do not show link to the same node.
00166     unset($translations[$node->language]);
00167     $languages = language_list();
00168     foreach ($translations as $language => $translation) {
00169       $links["node_translation_$language"] = array(
00170         'title' => $languages[$language]->native,
00171         'href' => "node/$translation->nid",
00172         'language' => $languages[$language],
00173         'attributes' => array('title' => $translation->title, 'class' => 'translation-link')
00174       );
00175     }
00176   }
00177   return $links;
00178 }
00179
00185 function translation_nodeapi(&$node, $op, $teaser, $page) {
00186   // Only act if we are dealing with a content type supporting translations.
00187   if (!translation_supported_type($node->type)) {
00188     return;
00189   }
00190
00191   switch ($op) {
00192     case 'prepare':
00193       if (empty($node->nid) && isset($_GET['translation']) && isset($_GET['language']) &&
00194           ($source_nid = $_GET['translation']) && ($language = $_GET['language']) &&
00195           (user_access('translate content'))) {
00196         // We are translating a node from a source node, so
00197         // load the node to be translated and populate fields.
00198         $node->language = $language;
00199         $node->translation_source = node_load($source_nid);
00200         $node->title = $node->translation_source->title;
00201         $node->body = $node->translation_source->body;
00202         // Let every module add custom translated fields.
00203         node_invoke_nodeapi($node, 'prepare translation');
00204       }
00205       break;
00206
00207     case 'insert':
00208       if (!empty($node->translation_source)) {
00209         if ($node->translation_source->tnid) {
00210           // Add node to existing translation set.
00211           $tnid = $node->translation_source->tnid;
00212         }
00213         else {
00214           // Create new translation set, using nid from the source node.
00215           $tnid = $node->translation_source->nid;
00216           db_query("UPDATE {node} SET tnid = %d, translate = %d WHERE nid = %d", $tnid, 0, $node->translation_source->nid);
00217         }
00218         db_query("UPDATE {node} SET tnid = %d, translate = %d WHERE nid = %d", $tnid, 0, $node->nid);
00219       }
00220       break;
00221
00222     case 'update':
00223       if (isset($node->translation) && $node->translation && !empty($node->language) && $node->tnid) {
00224         // Update translation information.
00225         db_query("UPDATE {node} SET tnid = %d, translate = %d WHERE nid = %d", $node->tnid, $node->translation['status'], $node->nid);
00226         if (!empty($node->translation['retranslate'])) {
00227           // This is the source node, asking to mark all translations outdated.
00228           db_query("UPDATE {node} SET translate = 1 WHERE tnid = %d AND nid != %d", $node->tnid, $node->nid);
00229         }
00230       }
00231       break;
00232
00233     case 'delete':
00234       translation_remove_from_set($node);
00235       break;
00236   }
00237 }
00238
00243 function translation_remove_from_set($node) {
00244   if (isset($node->tnid)) {
00245     if (db_result(db_query('SELECT COUNT(*) FROM {node} WHERE tnid = %d', $node->tnid)) <= 2) {
00246       // There would only be one node left in the set: remove the set altogether.
00247       db_query('UPDATE {node} SET tnid = 0, translate = 0 WHERE tnid = %d', $node->tnid);
00248     }
00249     else {
00250       db_query('UPDATE {node} SET tnid = 0, translate = 0 WHERE nid = %d', $node->nid);
00251
00252       // If the node being removed was the source of the translation set,
00253       // we pick a new source - preferably one that is up to date.
00254       if ($node->tnid == $node->nid) {
00255         $new_tnid = db_result(db_query('SELECT nid FROM {node} WHERE tnid = %d ORDER BY translate ASC, nid ASC', $node->tnid));
00256         db_query('UPDATE {node} SET tnid = %d WHERE tnid = %d', $new_tnid, $node->tnid);
00257       }
00258     }
00259   }
00260 }
00261
00275 function translation_node_get_translations($tnid) {
00276   static $translations = array();
00277
00278   if (is_numeric($tnid) && $tnid) {
00279     if (!isset($translations[$tnid])) {
00280       $translations[$tnid] = array();
00281       $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.language FROM {node} n WHERE n.tnid = %d'), $tnid);
00282       while ($node = db_fetch_object($result)) {
00283         $translations[$tnid][$node->language] = $node;
00284       }
00285     }
00286     return $translations[$tnid];
00287   }
00288 }
00289
00296 function translation_supported_type($type) {
00297   return variable_get('language_content_type_'. $type, 0) == TRANSLATION_ENABLED;
00298 }
00299
00310 function translation_path_get_translations($path) {
00311   $paths = array();
00312   // Check for a node related path, and for its translations.
00313   if ((preg_match("!^node/([0-9]+)(/.+|)$!", $path, $matches)) && ($node = node_load((int)$matches[1])) && !empty($node->tnid)) {
00314     foreach (translation_node_get_translations($node->tnid) as $language => $translation_node) {
00315       $paths[$language] = 'node/'. $translation_node->nid . $matches[2];
00316     }
00317   }
00318   return $paths;
00319 }
00320
00326 function translation_translation_link_alter(&$links, $path) {
00327   if ($paths = translation_path_get_translations($path)) {
00328     foreach ($links as $langcode => $link) {
00329       if (isset($paths[$langcode])) {
00330         // Translation in a different node.
00331         $links[$langcode]['href'] = $paths[$langcode];
00332       }
00333       else {
00334         // No translation in this language, or no permission to view.
00335         unset($links[$langcode]);
00336       }
00337     }
00338   }
00339 }
00340
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/translation/translation.pages.inc Source File

modules » translation

translation.pages.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: translation.pages.inc,v 1.2 2008/01/07 13:18:40 goba Exp $
00003
00015 function translation_node_overview($node) {
00016   if ($node->tnid) {
00017     // Already part of a set, grab that set.
00018     $tnid = $node->tnid;
00019     $translations = translation_node_get_translations($node->tnid);
00020   }
00021   else {
00022     // We have no translation source nid, this could be a new set, emulate that.
00023     $tnid = $node->nid;
00024     $translations = array($node->language => $node);
00025   }
00026
00027   $header = array(t('Language'), t('Title'), t('Status'), t('Operations'));
00028
00029   foreach (language_list() as $language) {
00030     $options = array();
00031     $language_name = $language->name;
00032     if (isset($translations[$language->language])) {
00033       // Existing translation in the translation set: display status.
00034       // We load the full node to check whether the user can edit it.
00035       $translation_node = node_load($translations[$language->language]->nid);
00036       $title = l($translation_node->title, 'node/'. $translation_node->nid);
00037       if (node_access('update', $translation_node)) {
00038         $options[] = l(t('edit'), "node/$translation_node->nid/edit");
00039       }
00040       $status = $translation_node->status ? t('Published') : t('Not published');
00041       $status .= $translation_node->translate ? ' - <span class="marker">'. t('outdated') .'</span>' : '';
00042       if ($translation_node->nid == $tnid) {
00043         $language_name = '<strong>'. $language_name .'</strong> (source)';
00044       }
00045     }
00046     else {
00047       // No such translation in the set yet: help user to create it.
00048       $title = t('n/a');
00049       if (node_access('create', $node)) {
00050         $options[] = l(t('add translation'), 'node/add/'. str_replace('_', '-', $node->type), array('query' => "translation=$node->nid&language=$language->language"));
00051       }
00052       $status = t('Not translated');
00053     }
00054     $rows[] = array($language_name, $title, $status, implode(" | ", $options));
00055   }
00056
00057   drupal_set_title(t('Translations of %title', array('%title' => $node->title)));
00058   return theme('table', $header, $rows);
00059 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/trigger/trigger.admin.inc Source File

modules » trigger

trigger.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: trigger.admin.inc,v 1.5 2008/01/08 10:35:43 goba Exp $
00003
00017 function trigger_assign($type = NULL) {
00018   // If no type is specified we default to node actions, since they
00019   // are the most common.
00020   if (!isset($type)) {
00021     drupal_goto('admin/build/trigger/node');
00022   }
00023   if ($type == 'node') {
00024     $type = 'nodeapi';
00025   }
00026
00027   $output = '';
00028   $hooks = module_invoke_all('hook_info');
00029   foreach ($hooks as $module => $hook) {
00030     if (isset($hook[$type])) {
00031       foreach ($hook[$type] as $op => $description) {
00032         $form_id = 'trigger_'. $type .'_'. $op .'_assign_form';
00033         $output .= drupal_get_form($form_id, $type, $op, $description['runs when']);
00034       }
00035     }
00036   }
00037   return $output;
00038 }
00039
00050 function trigger_unassign($form_state, $hook = NULL, $op = NULL, $aid = NULL) {
00051   if (!($hook && $op && $aid)) {
00052     drupal_goto('admin/build/trigger/assign');
00053   }
00054
00055   $form['hook'] = array(
00056     '#type' => 'value',
00057     '#value' => $hook,
00058   );
00059   $form['operation'] = array(
00060     '#type' => 'value',
00061     '#value' => $op,
00062   );
00063   $form['aid'] = array(
00064     '#type' => 'value',
00065     '#value' => $aid,
00066   );
00067
00068   $action = actions_function_lookup($aid);
00069   $actions = actions_get_all_actions();
00070
00071   $destination = 'admin/build/trigger/'. ($hook == 'nodeapi' ? 'node' : $hook);
00072
00073   return confirm_form($form,
00074     t('Are you sure you want to unassign the action %title?', array('%title' => $actions[$action]['description'])),
00075     $destination,
00076     t('You can assign it again later if you wish.'),
00077     t('Unassign'), t('Cancel')
00078   );
00079 }
00080
00081 function trigger_unassign_submit($form, &$form_state) {
00082   $form_values = $form_state['values'];
00083   if ($form_values['confirm'] == 1) {
00084     $aid = actions_function_lookup($form_values['aid']);
00085     db_query("DELETE FROM {trigger_assignments} WHERE hook = '%s' AND op = '%s' AND aid = '%s'", $form_values['hook'], $form_values['operation'], $aid);
00086     $actions = actions_get_all_actions();
00087     watchdog('actions', 'Action %action has been unassigned.',  array('%action' => check_plain($actions[$aid]['description'])));
00088     drupal_set_message(t('Action %action has been unassigned.', array('%action' => $actions[$aid]['description'])));
00089     $hook = $form_values['hook'] == 'nodeapi' ? 'node' : $form_values['hook'];
00090     $form_state['redirect'] = 'admin/build/trigger/'. $hook;
00091   }
00092   else {
00093     drupal_goto('admin/build/trigger');
00094   }
00095 }
00096
00114 function trigger_assign_form($form_state, $hook, $op, $description) {
00115   $form['hook'] = array(
00116     '#type' => 'hidden',
00117     '#value' => $hook,
00118   );
00119   $form['operation'] = array(
00120     '#type' => 'hidden',
00121     '#value' => $op,
00122   );
00123   // All of these forms use the same validate and submit functions.
00124   $form['#validate'][] = 'trigger_assign_form_validate';
00125   $form['#submit'][] = 'trigger_assign_form_submit';
00126
00127   $options = array();
00128   $functions = array();
00129   // Restrict the options list to actions that declare support for this hook-op
00130   // combination.
00131   foreach (actions_list() as $func => $metadata) {
00132     if (isset($metadata['hooks']['any']) || (isset($metadata['hooks'][$hook]) && is_array($metadata['hooks'][$hook]) && (in_array($op, $metadata['hooks'][$hook])))) {
00133       $functions[] = $func;
00134     }
00135   }
00136   foreach (actions_actions_map(actions_get_all_actions()) as $aid => $action) {
00137     if (in_array($action['callback'], $functions)) {
00138       $options[$action['type']][$aid] = $action['description'];
00139     }
00140   }
00141
00142   $form[$op] = array(
00143     '#type' => 'fieldset',
00144     '#title' => t('Trigger: ') . $description,
00145     '#theme' => 'trigger_display'
00146     );
00147   // Retrieve actions that are already assigned to this hook-op combination.
00148   $actions = _trigger_get_hook_actions($hook, $op);
00149   $form[$op]['assigned']['#type'] = 'value';
00150   $form[$op]['assigned']['#value'] = array();
00151   foreach ($actions as $aid => $description) {
00152     $form[$op]['assigned']['#value'][$aid] = array(
00153       'description' => $description,
00154       'link' => l(t('unassign'), "admin/build/trigger/unassign/$hook/$op/". md5($aid))
00155     );
00156   }
00157
00158   $form[$op]['parent'] = array(
00159     '#prefix' => "<div class='container-inline'>",
00160     '#suffix' => '</div>',
00161   );
00162   // List possible actions that may be assigned.
00163   if (count($options) != 0) {
00164     array_unshift($options, t('Choose an action'));
00165     $form[$op]['parent']['aid'] = array(
00166       '#type' => 'select',
00167       '#options' => $options,
00168     );
00169     $form[$op]['parent']['submit'] = array(
00170       '#type' => 'submit',
00171       '#value' => t('Assign')
00172     );
00173   }
00174   else {
00175     $form[$op]['none'] = array(
00176       '#value' => t('No available actions for this trigger.')
00177     );
00178   }
00179   return $form;
00180 }
00181
00187 function trigger_assign_form_validate($form, $form_state) {
00188   $form_values = $form_state['values'];
00189   if (!empty($form_values['aid'])) {
00190     $aid = actions_function_lookup($form_values['aid']);
00191     if (db_result(db_query("SELECT aid FROM {trigger_assignments} WHERE hook = '%s' AND op = '%s' AND aid = '%s'", $form_values['hook'], $form_values['operation'], $aid))) {
00192       form_set_error($form_values['operation'], t('The action you chose is already assigned to that trigger.'));
00193     }
00194   }
00195 }
00196
00200 function trigger_assign_form_submit($form, $form_state) {
00201   $form_values = $form_state['values'];
00202
00203   if (!empty($form_values['aid'])) {
00204     $aid = actions_function_lookup($form_values['aid']);
00205     $weight = db_result(db_query("SELECT MAX(weight) FROM {trigger_assignments} WHERE hook = '%s' AND op = '%s'", $form_values['hook'], $form_values['operation']));
00206     db_query("INSERT INTO {trigger_assignments} values ('%s', '%s', '%s', %d)", $form_values['hook'], $form_values['operation'], $aid, $weight + 1);
00207     // If this action changes a node property, we need to save the node
00208     // so the change will persist.
00209     $actions = actions_list();
00210     if (isset($actions[$aid]['behavior']) && in_array('changes_node_property', $actions[$aid]['behavior']) && ($form_values['operation'] != 'presave')) {
00211       // Delete previous node_save_action if it exists, and re-add a new one at a higher weight.
00212       $save_post_action_assigned = db_result(db_query("SELECT aid FROM {trigger_assignments} WHERE hook = '%s' AND op = '%s' AND aid = 'node_save_action'", $form_values['hook'], $form_values['operation']));
00213       if ($save_post_action_assigned) {
00214         db_query("DELETE FROM {trigger_assignments} WHERE hook = '%s' AND op = '%s' AND aid = 'node_save_action'", $form_values['hook'], $form_values['operation']);
00215       }
00216       db_query("INSERT INTO {trigger_assignments} VALUES ('%s', '%s', '%s', %d)", $form_values['hook'], $form_values['operation'], 'node_save_action', $weight + 2);
00217       if (!$save_post_action_assigned) {
00218         drupal_set_message(t('You have added an action that changes a the property of a post. A Save post action has been added so that the property change will be saved.'));
00219       }
00220     }
00221   }
00222 }
00223
00234 function theme_trigger_display($element) {
00235   $header = array();
00236   $rows = array();
00237   if (count($element['assigned']['#value'])) {
00238     $header = array(array('data' => t('Name')), array('data' => t('Operation')));
00239     $rows = array();
00240     foreach ($element['assigned']['#value'] as $aid => $info) {
00241       $rows[] = array(
00242         $info['description'],
00243         $info['link']
00244       );
00245     }
00246   }
00247
00248   if (count($rows)) {
00249     $output = theme('table', $header, $rows) . drupal_render($element);
00250   }
00251   else {
00252     $output = drupal_render($element);
00253   }
00254   return $output;
00255 }
00256
00257
00273 function _trigger_get_hook_actions($hook, $op, $type = NULL) {
00274   $actions = array();
00275   if ($type) {
00276     $result = db_query("SELECT h.aid, a.description FROM {trigger_assignments} h LEFT JOIN {actions} a on a.aid = h.aid WHERE a.type = '%s' AND h.hook = '%s' AND h.op = '%s' ORDER BY h.weight", $type, $hook, $op);
00277   }
00278   else {
00279     $result = db_query("SELECT h.aid, a.description FROM {trigger_assignments} h LEFT JOIN {actions} a on a.aid = h.aid WHERE h.hook = '%s' AND h.op = '%s' ORDER BY h.weight", $hook, $op);
00280   }
00281   while ($action = db_fetch_object($result)) {
00282     $actions[$action->aid] = $action->description;
00283   }
00284   return $actions;
00285 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/trigger/trigger.install Source File

modules » trigger

trigger.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: trigger.install,v 1.5 2007/12/28 12:02:52 dries Exp $
00003
00007 function trigger_install() {
00008   // Create tables.
00009   drupal_install_schema('trigger');
00010
00011   // Do initial synchronization of actions in code and the database.
00012   actions_synchronize(actions_list());
00013 }
00014
00018 function trigger_uninstall() {
00019   // Remove tables.
00020   drupal_uninstall_schema('trigger');
00021 }
00022
00026 function trigger_schema() {
00027   $schema['trigger_assignments'] = array(
00028     'description' => t('Maps trigger to hook and operation assignments from trigger.module.'),
00029     'fields' => array(
00030       'hook' => array(
00031         'type' => 'varchar',
00032         'length' => 32,
00033         'not null' => TRUE,
00034         'default' => '',
00035         'description' => t('Primary Key: The name of the internal Drupal hook upon which an action is firing; for example, nodeapi.'),
00036       ),
00037       'op' => array(
00038         'type' => 'varchar',
00039         'length' => 32,
00040         'not null' => TRUE,
00041         'default' => '',
00042         'description' => t('Primary Key: The specific operation of the hook upon which an action is firing: for example, presave.'),
00043       ),
00044       'aid' => array(
00045         'type' => 'varchar',
00046         'length' => 255,
00047         'not null' => TRUE,
00048         'default' => '',
00049         'description' => t("Primary Key: Action's {actions}.aid."),
00050       ),
00051       'weight' => array(
00052         'type' => 'int',
00053         'not null' => TRUE,
00054         'default' => 0,
00055         'description' => t('The weight of the trigger assignment in relation to other triggers.'),
00056       ),
00057     ),
00058     'primary key' => array('hook', 'op', 'aid'),
00059   );
00060   return $schema;
00061 }
00062
00063
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/trigger/trigger.module Source File

modules » trigger

trigger.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: trigger.module,v 1.13 2008/01/21 20:08:15 goba Exp $
00003
00013 function trigger_help($path, $arg) {
00014   $explanation = '<p>'. t('Triggers are system events, such as when new content is added or when a user logs in. Trigger module combines these triggers with actions (functional tasks), such as unpublishing content or e-mailing an administrator. The <a href="@url">Actions settings page</a> contains a list of existing actions and provides the ability to create and configure additional actions.', array('@url' => url('admin/settings/actions'))) .'</p>';
00015   switch ($path) {
00016     case 'admin/build/trigger/comment':
00017       return $explanation .'<p>'. t('Below you can assign actions to run when certain comment-related triggers happen. For example, you could promote a post to the front page when a comment is added.') .'</p>';
00018     case 'admin/build/trigger/node':
00019       return $explanation .'<p>'. t('Below you can assign actions to run when certain content-related triggers happen. For example, you could send an e-mail to an administrator when a post is created or updated.') .'</p>';
00020     case 'admin/build/trigger/cron':
00021       return $explanation .'<p>'. t('Below you can assign actions to run during each pass of a <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))) .'</p>';
00022     case 'admin/build/trigger/taxonomy':
00023       return $explanation .'<p>'. t('Below you can assign actions to run when certain taxonomy-related triggers happen. For example, you could send an e-mail to an administrator when a term is deleted.') .'</p>';
00024     case 'admin/build/trigger/user':
00025       return $explanation .'<p>'. t("Below you can assign actions to run when certain user-related triggers happen. For example, you could send an e-mail to an administrator when a user account is deleted.") .'</p>';
00026     case 'admin/help#trigger':
00027       $output = '<p>'. t('The Trigger module provides the ability to trigger <a href="@actions">actions</a> upon system events, such as when new content is added or when a user logs in.', array('@actions' => url('admin/settings/actions'))) .'</p>';
00028       $output .= '<p>'. t('The combination of actions and triggers can perform many useful tasks, such as e-mailing an administrator if a user account is deleted, or automatically unpublishing comments that contain certain words. By default, there are five "contexts" of events (Comments, Content, Cron, Taxonomy, and Users), but more may be added by additional modules.') .'</p>';
00029       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@trigger">Trigger module</a>.', array('@trigger' => 'http://drupal.org/handbook/modules/trigger/')) .'</p>';
00030       return $output;
00031   }
00032 }
00033
00037 function trigger_menu() {
00038   $items['admin/build/trigger'] = array(
00039     'title' => 'Triggers',
00040     'description' => 'Tell Drupal when to execute actions.',
00041     'page callback' => 'trigger_assign',
00042     'access callback' => 'trigger_access_check',
00043     'access arguments' => array('node'),
00044     'file' => 'trigger.admin.inc',
00045   );
00046   // We don't use a menu wildcard here because these are tabs,
00047   // not invisible items.
00048   $items['admin/build/trigger/node'] = array(
00049     'title' => 'Content',
00050     'page callback' => 'trigger_assign',
00051     'page arguments' => array('node'),
00052     'access arguments' => array('node'),
00053     'type' => MENU_LOCAL_TASK,
00054     'file' => 'trigger.admin.inc',
00055   );
00056   $items['admin/build/trigger/user'] = array(
00057     'title' => 'Users',
00058     'page callback' => 'trigger_assign',
00059     'page arguments' => array('user'),
00060     'access arguments' => array('user'),
00061     'type' => MENU_LOCAL_TASK,
00062     'file' => 'trigger.admin.inc',
00063   );
00064   $items['admin/build/trigger/comment'] = array(
00065     'title' => 'Comments',
00066     'page callback' => 'trigger_assign',
00067     'page arguments' => array('comment'),
00068     'access callback' => 'trigger_access_check',
00069     'access arguments' => array('comment'),
00070     'type' => MENU_LOCAL_TASK,
00071     'file' => 'trigger.admin.inc',
00072   );
00073   $items['admin/build/trigger/taxonomy'] = array(
00074     'title' => 'Taxonomy',
00075     'page callback' => 'trigger_assign',
00076     'page arguments' => array('taxonomy'),
00077     'access callback' => 'trigger_access_check',
00078     'access arguments' => array('taxonomy'),
00079     'type' => MENU_LOCAL_TASK,
00080     'file' => 'trigger.admin.inc',
00081   );
00082   $items['admin/build/trigger/cron'] = array(
00083     'title' => 'Cron',
00084     'page callback' => 'trigger_assign',
00085     'page arguments' => array('cron'),
00086     'type' => MENU_LOCAL_TASK,
00087     'file' => 'trigger.admin.inc',
00088   );
00089
00090   // We want contributed modules to be able to describe
00091   // their hooks and have actions assignable to them.
00092   $hooks = module_invoke_all('hook_info');
00093   foreach ($hooks as $module => $hook) {
00094     // We've already done these.
00095     if (in_array($module, array('node', 'comment', 'user', 'system', 'taxonomy'))) {
00096       continue;
00097     }
00098     $info = db_result(db_query("SELECT info FROM {system} WHERE name = '%s'", $module));
00099     $info = unserialize($info);
00100     $nice_name = $info['name'];
00101     $items["admin/build/trigger/$module"] = array(
00102       'title' => $nice_name,
00103       'page callback' => 'trigger_assign',
00104       'page arguments' => array($module),
00105       'access arguments' => array($module),
00106       'type' => MENU_LOCAL_TASK,
00107       'file' => 'trigger.admin.inc',
00108     );
00109   }
00110   $items['admin/build/trigger/unassign'] = array(
00111     'title' => 'Unassign',
00112     'description' => 'Unassign an action from a trigger.',
00113     'page callback' => 'drupal_get_form',
00114     'page arguments' => array('trigger_unassign'),
00115     'type' => MENU_CALLBACK,
00116     'file' => 'trigger.admin.inc',
00117   );
00118
00119   return $items;
00120 }
00121
00125 function trigger_access_check($module) {
00126   return (module_exists($module) && user_access('administer actions'));
00127 }
00128
00140 function _trigger_get_hook_aids($hook, $op = '') {
00141   $aids = array();
00142   $result = db_query("SELECT aa.aid, a.type FROM {trigger_assignments} aa LEFT JOIN {actions} a ON aa.aid = a.aid WHERE aa.hook = '%s' AND aa.op = '%s' ORDER BY weight", $hook, $op);
00143   while ($action = db_fetch_object($result)) {
00144     $aids[$action->aid]['type'] = $action->type;
00145   }
00146   return $aids;
00147 }
00148
00152 function trigger_theme() {
00153   return array(
00154     'trigger_display' => array(
00155       'arguments' => array('element'),
00156       'file' => 'trigger.admin.inc',
00157     ),
00158   );
00159 }
00160
00165 function trigger_forms() {
00166   $hooks = module_invoke_all('hook_info');
00167   foreach ($hooks as $module => $info) {
00168     foreach ($hooks[$module] as $hook => $ops) {
00169       foreach ($ops as $op => $description) {
00170         $forms['trigger_'. $hook .'_'. $op .'_assign_form'] = array('callback' => 'trigger_assign_form');
00171       }
00172     }
00173   }
00174
00175   return $forms;
00176 }
00177
00192 function _trigger_normalize_node_context($type, $node) {
00193   switch ($type) {
00194     // If an action that works on comments is being called in a node context,
00195     // the action is expecting a comment object. But we do not know which comment
00196     // to give it. The first? The most recent? All of them? So comment actions
00197     // in a node context are not supported.
00198
00199     // An action that works on users is being called in a node context.
00200     // Load the user object of the node's author.
00201     case 'user':
00202       return user_load(array('uid' => $node->uid));
00203   }
00204 }
00205
00209 function trigger_nodeapi(&$node, $op, $a3, $a4) {
00210   // Keep objects for reuse so that changes actions make to objects can persist.
00211   static $objects;
00212   // Prevent recursion by tracking which operations have already been called.
00213   static $recursion;
00214   // Support a subset of operations.
00215   if (!in_array($op, array('view', 'update', 'presave', 'insert', 'delete')) || isset($recursion[$op])) {
00216     return;
00217   }
00218   $recursion[$op] = TRUE;
00219
00220   $aids = _trigger_get_hook_aids('nodeapi', $op);
00221   if (!$aids) {
00222     return;
00223   }
00224   $context = array(
00225     'hook' => 'nodeapi',
00226     'op' => $op,
00227   );
00228
00229   // We need to get the expected object if the action's type is not 'node'.
00230   // We keep the object in $objects so we can reuse it if we have multiple actions
00231   // that make changes to an object.
00232   foreach ($aids as $aid => $action_info) {
00233     if ($action_info['type'] != 'node') {
00234       if (!isset($objects[$action_info['type']])) {
00235         $objects[$action_info['type']] = _trigger_normalize_node_context($action_info['type'], $node);
00236       }
00237       // Since we know about the node, we pass that info along to the action.
00238       $context['node'] = $node;
00239       $result = actions_do($aid, $objects[$action_info['type']], $context, $a4, $a4);
00240     }
00241     else {
00242       actions_do($aid, $node, $context, $a3, $a4);
00243     }
00244   }
00245 }
00246
00261 function _trigger_normalize_comment_context($type, $comment) {
00262   switch ($type) {
00263     // An action that works with nodes is being called in a comment context.
00264     case 'node':
00265       return node_load(is_array($comment) ? $comment['nid'] : $comment->nid);
00266
00267     // An action that works on users is being called in a comment context.
00268     case 'user':
00269       return user_load(array('uid' => is_array($comment) ? $comment['uid'] : $comment->uid));
00270   }
00271 }
00272
00276 function trigger_comment($a1, $op) {
00277   // Keep objects for reuse so that changes actions make to objects can persist.
00278   static $objects;
00279   // We support a subset of operations.
00280   if (!in_array($op, array('insert', 'update', 'delete', 'view'))) {
00281     return;
00282   }
00283   $aids = _trigger_get_hook_aids('comment', $op);
00284   $context = array(
00285     'hook' => 'comment',
00286     'op' => $op,
00287   );
00288   // We need to get the expected object if the action's type is not 'comment'.
00289   // We keep the object in $objects so we can reuse it if we have multiple actions
00290   // that make changes to an object.
00291   foreach ($aids as $aid => $action_info) {
00292     if ($action_info['type'] != 'comment') {
00293       if (!isset($objects[$action_info['type']])) {
00294         $objects[$action_info['type']] = _trigger_normalize_comment_context($action_info['type'], $a1);
00295       }
00296       // Since we know about the comment, we pass it along to the action
00297       // in case it wants to peek at it.
00298       $context['comment'] = (object) $a1;
00299       actions_do($aid, $objects[$action_info['type']], $context);
00300     }
00301     else {
00302       $comment = (object) $a1;
00303       actions_do($aid, $comment, $context);
00304     }
00305   }
00306 }
00307
00311 function trigger_cron() {
00312   $aids = _trigger_get_hook_aids('cron');
00313   $context = array(
00314     'hook' => 'cron',
00315     'op' => '',
00316   );
00317   // Cron does not act on any specific object.
00318   $object = NULL;
00319   actions_do(array_keys($aids), $object, $context);
00320 }
00321
00336 function _trigger_normalize_user_context($type, $account) {
00337   switch ($type) {
00338     // If an action that works on comments is being called in a user context,
00339     // the action is expecting a comment object. But we have no way of
00340     // determining the appropriate comment object to pass. So comment
00341     // actions in a user context are not supported.
00342
00343     // An action that works with nodes is being called in a user context.
00344     // If a single node is being viewed, return the node.
00345     case 'node':
00346       // If we are viewing an individual node, return the node.
00347       if ((arg(0) == 'node') && is_numeric(arg(1)) && (arg(2) == NULL)) {
00348         return node_load(array('nid' => arg(1)));
00349       }
00350   }
00351 }
00352
00356 function trigger_user($op, &$edit, &$account, $category = NULL) {
00357   // Keep objects for reuse so that changes actions make to objects can persist.
00358   static $objects;
00359   // We support a subset of operations.
00360   if (!in_array($op, array('login', 'logout', 'insert', 'update', 'delete', 'view'))) {
00361     return;
00362   }
00363   $aids = _trigger_get_hook_aids('user', $op);
00364   $context = array(
00365     'hook' => 'user',
00366     'op' => $op,
00367     'form_values' => &$edit,
00368   );
00369   foreach ($aids as $aid => $action_info) {
00370     if ($action_info['type'] != 'user') {
00371       if (!isset($objects[$action_info['type']])) {
00372         $objects[$action_info['type']] = _trigger_normalize_user_context($action_info['type'], $account);
00373       }
00374       $context['account'] = $account;
00375       actions_do($aid, $objects[$action_info['type']], $context);
00376     }
00377     else {
00378       actions_do($aid, $account, $context, $category);
00379     }
00380   }
00381 }
00382
00386 function trigger_taxonomy($op, $type, $array) {
00387   if ($type != 'term') {
00388     return;
00389   }
00390   $aids = _trigger_get_hook_aids('taxonomy', $op);
00391   $context = array(
00392     'hook' => 'taxonomy',
00393     'op' => $op
00394   );
00395   foreach ($aids as $aid => $action_info) {
00396     $taxonomy_object = (object) $array;
00397     actions_do($aid, $taxonomy_object, $context);
00398   }
00399 }
00400
00410 function trigger_options($type = 'all') {
00411   $options = array(t('Choose an action'));
00412   foreach (actions_actions_map(actions_get_all_actions()) as $aid => $action) {
00413     $options[$action['type']][$aid] = $action['description'];
00414   }
00415
00416   if ($type == 'all') {
00417     return $options;
00418   }
00419   else {
00420     return $options[$type];
00421   }
00422 }
00423
00429 function trigger_actions_delete($aid) {
00430   db_query("DELETE FROM {trigger_assignments} WHERE aid = '%s'", $aid);
00431 }
Generated on Tue Feb 12 15:30:41 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/unicode.inc Source File

includes

unicode.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: unicode.inc,v 1.29 2007/12/28 12:02:50 dries Exp $
00003
00007 define('UNICODE_ERROR', -1);
00008
00012 define('UNICODE_SINGLEBYTE', 0);
00013
00018 define('UNICODE_MULTIBYTE', 1);
00019
00023 function unicode_check() {
00024   list($GLOBALS['multibyte']) = _unicode_check();
00025 }
00026
00038 function _unicode_check() {
00039   // Ensure translations don't break at install time
00040   $t = get_t();
00041
00042   // Set the standard C locale to ensure consistent, ASCII-only string handling.
00043   setlocale(LC_CTYPE, 'C');
00044
00045   // Check for outdated PCRE library
00046   // Note: we check if U+E2 is in the range U+E0 - U+E1. This test returns TRUE on old PCRE versions.
00047   if (preg_match('/[à-á]/u', 'â')) {
00048     return array(UNICODE_ERROR, $t('The PCRE library in your PHP installation is outdated. This will cause problems when handling Unicode text. If you are running PHP 4.3.3 or higher, make sure you are using the PCRE library supplied by PHP. Please refer to the <a href="@url">PHP PCRE documentation</a> for more information.', array('@url' => 'http://www.php.net/pcre')));
00049   }
00050
00051   // Check for mbstring extension
00052   if (!function_exists('mb_strlen')) {
00053     return array(UNICODE_SINGLEBYTE, $t('Operations on Unicode strings are emulated on a best-effort basis. Install the <a href="@url">PHP mbstring extension</a> for improved Unicode support.', array('@url' => 'http://www.php.net/mbstring')));
00054   }
00055
00056   // Check mbstring configuration
00057   if (ini_get('mbstring.func_overload') != 0) {
00058     return array(UNICODE_ERROR, $t('Multibyte string function overloading in PHP is active and must be disabled. Check the php.ini <em>mbstring.func_overload</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')));
00059   }
00060   if (ini_get('mbstring.encoding_translation') != 0) {
00061     return array(UNICODE_ERROR, $t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.encoding_translation</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')));
00062   }
00063   if (ini_get('mbstring.http_input') != 'pass') {
00064     return array(UNICODE_ERROR, $t('Multibyte string input conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_input</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')));
00065   }
00066   if (ini_get('mbstring.http_output') != 'pass') {
00067     return array(UNICODE_ERROR, $t('Multibyte string output conversion in PHP is active and must be disabled. Check the php.ini <em>mbstring.http_output</em> setting. Please refer to the <a href="@url">PHP mbstring documentation</a> for more information.', array('@url' => 'http://www.php.net/mbstring')));
00068   }
00069
00070   // Set appropriate configuration
00071   mb_internal_encoding('utf-8');
00072   mb_language('uni');
00073   return array(UNICODE_MULTIBYTE, '');
00074 }
00075
00079 function unicode_requirements() {
00080   // Ensure translations don't break at install time
00081   $t = get_t();
00082
00083   $libraries = array(
00084     UNICODE_SINGLEBYTE => $t('Standard PHP'),
00085     UNICODE_MULTIBYTE => $t('PHP Mbstring Extension'),
00086     UNICODE_ERROR => $t('Error'),
00087   );
00088   $severities = array(
00089     UNICODE_SINGLEBYTE => REQUIREMENT_WARNING,
00090     UNICODE_MULTIBYTE => REQUIREMENT_OK,
00091     UNICODE_ERROR => REQUIREMENT_ERROR,
00092   );
00093   list($library, $description) = _unicode_check();
00094
00095   $requirements['unicode'] = array(
00096     'title' => $t('Unicode library'),
00097     'value' => $libraries[$library],
00098   );
00099   if ($description) {
00100     $requirements['unicode']['description'] = $description;
00101   }
00102
00103   $requirements['unicode']['severity'] = $severities[$library];
00104
00105   return $requirements;
00106 }
00107
00126 function drupal_xml_parser_create(&$data) {
00127   // Default XML encoding is UTF-8
00128   $encoding = 'utf-8';
00129   $bom = FALSE;
00130
00131   // Check for UTF-8 byte order mark (PHP5's XML parser doesn't handle it).
00132   if (!strncmp($data, "\xEF\xBB\xBF", 3)) {
00133     $bom = TRUE;
00134     $data = substr($data, 3);
00135   }
00136
00137   // Check for an encoding declaration in the XML prolog if no BOM was found.
00138   if (!$bom && ereg('^<\?xml[^>]+encoding="([^"]+)"', $data, $match)) {
00139     $encoding = $match[1];
00140   }
00141
00142   // Unsupported encodings are converted here into UTF-8.
00143   $php_supported = array('utf-8', 'iso-8859-1', 'us-ascii');
00144   if (!in_array(strtolower($encoding), $php_supported)) {
00145     $out = drupal_convert_to_utf8($data, $encoding);
00146     if ($out !== FALSE) {
00147       $encoding = 'utf-8';
00148       $data = ereg_replace('^(<\?xml[^>]+encoding)="([^"]+)"', '\\1="utf-8"', $out);
00149     }
00150     else {
00151       watchdog('php', 'Could not convert XML encoding %s to UTF-8.', array('%s' => $encoding), WATCHDOG_WARNING);
00152       return 0;
00153     }
00154   }
00155
00156   $xml_parser = xml_parser_create($encoding);
00157   xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, 'utf-8');
00158   return $xml_parser;
00159 }
00160
00173 function drupal_convert_to_utf8($data, $encoding) {
00174   if (function_exists('iconv')) {
00175     $out = @iconv($encoding, 'utf-8', $data);
00176   }
00177   else if (function_exists('mb_convert_encoding')) {
00178     $out = @mb_convert_encoding($data, 'utf-8', $encoding);
00179   }
00180   else if (function_exists('recode_string')) {
00181     $out = @recode_string($encoding .'..utf-8', $data);
00182   }
00183   else {
00184     watchdog('php', 'Unsupported encoding %s. Please install iconv, GNU recode or mbstring for PHP.', array('%s' => $encoding), WATCHDOG_ERROR);
00185     return FALSE;
00186   }
00187
00188   return $out;
00189 }
00190
00209 function drupal_truncate_bytes($string, $len) {
00210   if (strlen($string) <= $len) {
00211     return $string;
00212   }
00213   if ((ord($string[$len]) < 0x80) || (ord($string[$len]) >= 0xC0)) {
00214     return substr($string, 0, $len);
00215   }
00216   while (--$len >= 0 && ord($string[$len]) >= 0x80 && ord($string[$len]) < 0xC0) {};
00217   return substr($string, 0, $len);
00218 }
00219
00234 function truncate_utf8($string, $len, $wordsafe = FALSE, $dots = FALSE) {
00235
00236   if (drupal_strlen($string) <= $len) {
00237     return $string;
00238   }
00239
00240   if ($dots) {
00241     $len -= 4;
00242   }
00243
00244   if ($wordsafe) {
00245     $string = drupal_substr($string, 0, $len + 1); // leave one more character
00246     if ($last_space = strrpos($string, ' ')) { // space exists AND is not on position 0
00247       $string = substr($string, 0, $last_space);
00248     }
00249     else {
00250       $string = drupal_substr($string, 0, $len);
00251     }
00252   }
00253   else {
00254     $string = drupal_substr($string, 0, $len);
00255   }
00256
00257   if ($dots) {
00258     $string .= ' ...';
00259   }
00260
00261   return $string;
00262 }
00263
00279 function mime_header_encode($string) {
00280   if (preg_match('/[^\x20-\x7E]/', $string)) {
00281     $chunk_size = 47; // floor((75 - strlen("=?UTF-8?B??=")) * 0.75);
00282     $len = strlen($string);
00283     $output = '';
00284     while ($len > 0) {
00285       $chunk = drupal_truncate_bytes($string, $chunk_size);
00286       $output .= ' =?UTF-8?B?'. base64_encode($chunk) ."?=\n";
00287       $c = strlen($chunk);
00288       $string = substr($string, $c);
00289       $len -= $c;
00290     }
00291     return trim($output);
00292   }
00293   return $string;
00294 }
00295
00299 function mime_header_decode($header) {
00300   // First step: encoded chunks followed by other encoded chunks (need to collapse whitespace)
00301   $header = preg_replace_callback('/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=\s+(?==\?)/', '_mime_header_decode', $header);
00302   // Second step: remaining chunks (do not collapse whitespace)
00303   return preg_replace_callback('/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=/', '_mime_header_decode', $header);
00304 }
00305
00309 function _mime_header_decode($matches) {
00310   // Regexp groups:
00311   // 1: Character set name
00312   // 2: Escaping method (Q or B)
00313   // 3: Encoded data
00314   $data = ($matches[2] == 'B') ? base64_decode($matches[3]) : str_replace('_', ' ', quoted_printable_decode($matches[3]));
00315   if (strtolower($matches[1]) != 'utf-8') {
00316     $data = drupal_convert_to_utf8($data, $matches[1]);
00317   }
00318   return $data;
00319 }
00320
00331 function decode_entities($text, $exclude = array()) {
00332   static $table;
00333   // We store named entities in a table for quick processing.
00334   if (!isset($table)) {
00335     // Get all named HTML entities.
00336     $table = array_flip(get_html_translation_table(HTML_ENTITIES));
00337     // PHP gives us ISO-8859-1 data, we need UTF-8.
00338     $table = array_map('utf8_encode', $table);
00339     // Add apostrophe (XML)
00340     $table['&apos;'] = "'";
00341   }
00342   $newtable = array_diff($table, $exclude);
00343
00344   // Use a regexp to select all entities in one pass, to avoid decoding double-escaped entities twice.
00345   return preg_replace('/&(#x?)?([A-Za-z0-9]+);/e', '_decode_entities("$1", "$2", "$0", $newtable, $exclude)', $text);
00346 }
00347
00351 function _decode_entities($prefix, $codepoint, $original, &$table, &$exclude) {
00352   // Named entity
00353   if (!$prefix) {
00354     if (isset($table[$original])) {
00355       return $table[$original];
00356     }
00357     else {
00358       return $original;
00359     }
00360   }
00361   // Hexadecimal numerical entity
00362   if ($prefix == '#x') {
00363     $codepoint = base_convert($codepoint, 16, 10);
00364   }
00365   // Decimal numerical entity (strip leading zeros to avoid PHP octal notation)
00366   else {
00367     $codepoint = preg_replace('/^0+/', '', $codepoint);
00368   }
00369   // Encode codepoint as UTF-8 bytes
00370   if ($codepoint < 0x80) {
00371     $str = chr($codepoint);
00372   }
00373   else if ($codepoint < 0x800) {
00374     $str = chr(0xC0 | ($codepoint >> 6))
00375          . chr(0x80 | ($codepoint & 0x3F));
00376   }
00377   else if ($codepoint < 0x10000) {
00378     $str = chr(0xE0 | ( $codepoint >> 12))
00379          . chr(0x80 | (($codepoint >> 6) & 0x3F))
00380          . chr(0x80 | ( $codepoint       & 0x3F));
00381   }
00382   else if ($codepoint < 0x200000) {
00383     $str = chr(0xF0 | ( $codepoint >> 18))
00384          . chr(0x80 | (($codepoint >> 12) & 0x3F))
00385          . chr(0x80 | (($codepoint >> 6)  & 0x3F))
00386          . chr(0x80 | ( $codepoint        & 0x3F));
00387   }
00388   // Check for excluded characters
00389   if (in_array($str, $exclude)) {
00390     return $original;
00391   }
00392   else {
00393     return $str;
00394   }
00395 }
00396
00401 function drupal_strlen($text) {
00402   global $multibyte;
00403   if ($multibyte == UNICODE_MULTIBYTE) {
00404     return mb_strlen($text);
00405   }
00406   else {
00407     // Do not count UTF-8 continuation bytes.
00408     return strlen(preg_replace("/[\x80-\xBF]/", '', $text));
00409   }
00410 }
00411
00415 function drupal_strtoupper($text) {
00416   global $multibyte;
00417   if ($multibyte == UNICODE_MULTIBYTE) {
00418     return mb_strtoupper($text);
00419   }
00420   else {
00421     // Use C-locale for ASCII-only uppercase
00422     $text = strtoupper($text);
00423     // Case flip Latin-1 accented letters
00424     $text = preg_replace_callback('/\xC3[\xA0-\xB6\xB8-\xBE]/', '_unicode_caseflip', $text);
00425     return $text;
00426   }
00427 }
00428
00432 function drupal_strtolower($text) {
00433   global $multibyte;
00434   if ($multibyte == UNICODE_MULTIBYTE) {
00435     return mb_strtolower($text);
00436   }
00437   else {
00438     // Use C-locale for ASCII-only lowercase
00439     $text = strtolower($text);
00440     // Case flip Latin-1 accented letters
00441     $text = preg_replace_callback('/\xC3[\x80-\x96\x98-\x9E]/', '_unicode_caseflip', $text);
00442     return $text;
00443   }
00444 }
00445
00450 function _unicode_caseflip($matches) {
00451   return $matches[0][0] . chr(ord($matches[0][1]) ^ 32);
00452 }
00453
00457 function drupal_ucfirst($text) {
00458   // Note: no mbstring equivalent!
00459   return drupal_strtoupper(drupal_substr($text, 0, 1)) . drupal_substr($text, 1);
00460 }
00461
00470 function drupal_substr($text, $start, $length = NULL) {
00471   global $multibyte;
00472   if ($multibyte == UNICODE_MULTIBYTE) {
00473     return $length === NULL ? mb_substr($text, $start) : mb_substr($text, $start, $length);
00474   }
00475   else {
00476     $strlen = strlen($text);
00477     // Find the starting byte offset
00478     $bytes = 0;
00479     if ($start > 0) {
00480       // Count all the continuation bytes from the start until we have found
00481       // $start characters
00482       $bytes = -1; $chars = -1;
00483       while ($bytes < $strlen && $chars < $start) {
00484         $bytes++;
00485         $c = ord($text[$bytes]);
00486         if ($c < 0x80 || $c >= 0xC0) {
00487           $chars++;
00488         }
00489       }
00490     }
00491     else if ($start < 0) {
00492       // Count all the continuation bytes from the end until we have found
00493       // abs($start) characters
00494       $start = abs($start);
00495       $bytes = $strlen; $chars = 0;
00496       while ($bytes > 0 && $chars < $start) {
00497         $bytes--;
00498         $c = ord($text[$bytes]);
00499         if ($c < 0x80 || $c >= 0xC0) {
00500           $chars++;
00501         }
00502       }
00503     }
00504     $istart = $bytes;
00505
00506     // Find the ending byte offset
00507     if ($length === NULL) {
00508       $bytes = $strlen - 1;
00509     }
00510     else if ($length > 0) {
00511       // Count all the continuation bytes from the starting index until we have
00512       // found $length + 1 characters. Then backtrack one byte.
00513       $bytes = $istart; $chars = 0;
00514       while ($bytes < $strlen && $chars < $length) {
00515         $bytes++;
00516         $c = ord($text[$bytes]);
00517         if ($c < 0x80 || $c >= 0xC0) {
00518           $chars++;
00519         }
00520       }
00521       $bytes--;
00522     }
00523     else if ($length < 0) {
00524       // Count all the continuation bytes from the end until we have found
00525       // abs($length) characters
00526       $length = abs($length);
00527       $bytes = $strlen - 1; $chars = 0;
00528       while ($bytes >= 0 && $chars < $length) {
00529         $c = ord($text[$bytes]);
00530         if ($c < 0x80 || $c >= 0xC0) {
00531           $chars++;
00532         }
00533         $bytes--;
00534       }
00535     }
00536     $iend = $bytes;
00537
00538     return substr($text, $istart, max(0, $iend - $istart + 1));
00539   }
00540 }
00541
00542
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/update/update.compare.inc Source File

modules » update

update.compare.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: update.compare.inc,v 1.8 2008/02/03 19:34:02 goba Exp $
00003
00023 function update_get_projects() {
00024   static $projects = array();
00025   if (empty($projects)) {
00026     // Retrieve the projects from cache, if present.
00027     $projects = update_project_cache('update_project_projects');
00028     if (empty($projects)) {
00029       // Still empty, so we have to rebuild the cache.
00030       _update_process_info_list($projects, module_rebuild_cache(), 'module');
00031       _update_process_info_list($projects, system_theme_data(), 'theme');
00032       // Set the projects array into the cache table.
00033       cache_set('update_project_projects', $projects, 'cache_update', time() + 3600);
00034     }
00035   }
00036   return $projects;
00037 }
00038
00042 function _update_process_info_list(&$projects, $list, $project_type) {
00043   foreach ($list as $file) {
00044     if (empty($file->status)) {
00045       // Skip disabled modules or themes.
00046       continue;
00047     }
00048
00049     // Skip if the .info file is broken.
00050     if (empty($file->info)) {
00051       continue;
00052     }
00053
00054     // If the .info doesn't define the 'project', try to figure it out.
00055     if (!isset($file->info['project'])) {
00056       $file->info['project'] = update_get_project_name($file);
00057     }
00058
00059     // If we still don't know the 'project', give up.
00060     if (empty($file->info['project'])) {
00061       continue;
00062     }
00063
00064     // If we don't already know it, grab the change time on the .info file
00065     // itself. Note: we need to use the ctime, not the mtime (modification
00066     // time) since many (all?) tar implementations will go out of their way to
00067     // set the mtime on the files it creates to the timestamps recorded in the
00068     // tarball. We want to see the last time the file was changed on disk,
00069     // which is left alone by tar and correctly set to the time the .info file
00070     // was unpacked.
00071     if (!isset($file->info['_info_file_ctime'])) {
00072       $info_filename = dirname($file->filename) .'/'. $file->name .'.info';
00073       $file->info['_info_file_ctime'] = filectime($info_filename);
00074     }
00075
00076     $project_name = $file->info['project'];
00077     if (!isset($projects[$project_name])) {
00078       // Only process this if we haven't done this project, since a single
00079       // project can have multiple modules or themes.
00080       $projects[$project_name] = array(
00081         'name' => $project_name,
00082         'info' => $file->info,
00083         'datestamp' => isset($file->info['datestamp']) ? $file->info['datestamp'] : 0,
00084         'includes' => array($file->name => $file->info['name']),
00085         'project_type' => $project_name == 'drupal' ? 'core' : $project_type,
00086       );
00087     }
00088     else {
00089       $projects[$project_name]['includes'][$file->name] = $file->info['name'];
00090       $projects[$project_name]['info']['_info_file_ctime'] = max($projects[$project_name]['info']['_info_file_ctime'], $file->info['_info_file_ctime']);
00091     }
00092   }
00093 }
00094
00101 function update_get_project_name($file) {
00102   $project_name = '';
00103   if (isset($file->info['project'])) {
00104     $project_name = $file->info['project'];
00105   }
00106   elseif (isset($file->info['package']) && (strpos($file->info['package'], 'Core -') !== FALSE)) {
00107     $project_name = 'drupal';
00108   }
00109   elseif (in_array($file->name, array('bluemarine', 'chameleon', 'garland', 'marvin', 'minnelli', 'pushbutton'))) {
00110     // Unfortunately, there's no way to tell if a theme is part of core,
00111     // so we must hard-code a list here.
00112     $project_name = 'drupal';
00113   }
00114   return $project_name;
00115 }
00116
00125 function update_process_project_info(&$projects) {
00126   foreach ($projects as $key => $project) {
00127     // Assume an official release until we see otherwise.
00128     $install_type = 'official';
00129
00130     $info = $project['info'];
00131
00132     if (isset($info['version'])) {
00133       // Check for development snapshots
00134       if (preg_match('@(dev|HEAD)@', $info['version'])) {
00135         $install_type = 'dev';
00136       }
00137
00138       // Figure out what the currently installed major version is. We need
00139       // to handle both contribution (e.g. "5.x-1.3", major = 1) and core
00140       // (e.g. "5.1", major = 5) version strings.
00141       $matches = array();
00142       if (preg_match('/^(\d+\.x-)?(\d+)\..*$/', $info['version'], $matches)) {
00143         $info['major'] = $matches[2];
00144       }
00145       elseif (!isset($info['major'])) {
00146         // This would only happen for version strings that don't follow the
00147         // drupal.org convention. We let contribs define "major" in their
00148         // .info in this case, and only if that's missing would we hit this.
00149         $info['major'] = -1;
00150       }
00151     }
00152     else {
00153       // No version info available at all.
00154       $install_type = 'unknown';
00155       $info['version'] = t('Unknown');
00156       $info['major'] = -1;
00157     }
00158
00159     // Finally, save the results we care about into the $projects array.
00160     $projects[$key]['existing_version'] = $info['version'];
00161     $projects[$key]['existing_major'] = $info['major'];
00162     $projects[$key]['install_type'] = $install_type;
00163     unset($projects[$key]['info']);
00164   }
00165 }
00166
00234 function update_calculate_project_data($available) {
00235   // Retrieve the projects from cache, if present.
00236   $projects = update_project_cache('update_project_data');
00237   // If $projects is empty, then the cache must be rebuilt.
00238   // Otherwise, return the cached data and skip the rest of the function.
00239   if (!empty($projects)) {
00240     return $projects;
00241   }
00242   $projects = update_get_projects();
00243   update_process_project_info($projects);
00244   foreach ($projects as $project => $project_info) {
00245     if (isset($available[$project])) {
00246
00247       // If the project status is marked as something bad, there's nothing
00248       // else to consider.
00249       if (isset($available[$project]['project_status'])) {
00250         switch ($available[$project]['project_status']) {
00251           case 'insecure':
00252             $projects[$project]['status'] = UPDATE_NOT_SECURE;
00253             if (empty($projects[$project]['extra'])) {
00254               $projects[$project]['extra'] = array();
00255             }
00256             $projects[$project]['extra'][] = array(
00257               'class' => 'project-not-secure',
00258               'label' => t('Project not secure'),
00259               'data' => t('This project has been labeled insecure by the Drupal security team, and is no longer available for download. Immediately disabling everything included by this project is strongly recommended!'),
00260             );
00261             break;
00262           case 'unpublished':
00263           case 'revoked':
00264             $projects[$project]['status'] = UPDATE_REVOKED;
00265             if (empty($projects[$project]['extra'])) {
00266               $projects[$project]['extra'] = array();
00267             }
00268             $projects[$project]['extra'][] = array(
00269               'class' => 'project-revoked',
00270               'label' => t('Project revoked'),
00271               'data' => t('This project has been revoked, and is no longer available for download. Disabling everything included by this project is strongly recommended!'),
00272             );
00273             break;
00274           case 'unsupported':
00275             $projects[$project]['status'] = UPDATE_NOT_SUPPORTED;
00276             if (empty($projects[$project]['extra'])) {
00277               $projects[$project]['extra'] = array();
00278             }
00279             $projects[$project]['extra'][] = array(
00280               'class' => 'project-not-supported',
00281               'label' => t('Project not supported'),
00282               'data' => t('This project is no longer supported, and is no longer available for download. Disabling everything included by this project is strongly recommended!'),
00283             );
00284             break;
00285           default:
00286             // Assume anything else (e.g. 'published') is valid and we should
00287             // perform the rest of the logic in this function.
00288             break;
00289         }
00290       }
00291
00292       if (!empty($projects[$project]['status'])) {
00293         // We already know the status for this project, so there's nothing
00294         // else to compute. Just record everything else we fetched from the
00295         // XML file into our projects array and move to the next project.
00296         $projects[$project] += $available[$project];
00297         continue;
00298       }
00299
00300       // Figure out the target major version.
00301       $existing_major = $project_info['existing_major'];
00302       $supported_majors = array();
00303       if (isset($available[$project]['supported_majors'])) {
00304         $supported_majors = explode(',', $available[$project]['supported_majors']);
00305       }
00306       elseif (isset($available[$project]['default_major'])) {
00307         // Older release history XML file without supported or recommended.
00308         $supported_majors[] = $available[$project]['default_major'];
00309       }
00310
00311       if (in_array($existing_major, $supported_majors)) {
00312         // Still supported, stay at the current major version.
00313         $target_major = $existing_major;
00314       }
00315       elseif (isset($available[$project]['recommended_major'])) {
00316         // Since 'recommended_major' is defined, we know this is the new XML
00317         // format. Therefore, we know the current release is unsupported since
00318         // its major version was not in the 'supported_majors' list. We should
00319         // find the best release from the recommended major version.
00320         $target_major = $available[$project]['recommended_major'];
00321         $projects[$project]['status'] = UPDATE_NOT_SUPPORTED;
00322       }
00323       elseif (isset($available[$project]['default_major'])) {
00324         // Older release history XML file without recommended, so recommend
00325         // the currently defined "default_major" version.
00326         $target_major = $available[$project]['default_major'];
00327       }
00328       else {
00329         // Malformed XML file? Stick with the current version.
00330         $target_major = $existing_major;
00331       }
00332
00333       // Make sure we never tell the admin to downgrade. If we recommended an
00334       // earlier version than the one they're running, they'd face an
00335       // impossible data migration problem, since Drupal never supports a DB
00336       // downgrade path. In the unfortunate case that what they're running is
00337       // unsupported, and there's nothing newer for them to upgrade to, we
00338       // can't print out a "Recommended version", but just have to tell them
00339       // what they have is unsupported and let them figure it out.
00340       $target_major = max($existing_major, $target_major);
00341
00342       $version_patch_changed = '';
00343       $patch = '';
00344
00345       // Defend ourselves from XML history files that contain no releases.
00346       if (empty($available[$project]['releases'])) {
00347         $projects[$project]['status'] = UPDATE_UNKNOWN;
00348         $projects[$project]['reason'] = t('No available releases found');
00349         continue;
00350       }
00351       foreach ($available[$project]['releases'] as $version => $release) {
00352         // First, if this is the existing release, check a few conditions.
00353         if ($projects[$project]['existing_version'] == $version) {
00354           if (isset($release['terms']['Release type']) &&
00355               in_array('Insecure', $release['terms']['Release type'])) {
00356             $projects[$project]['status'] = UPDATE_NOT_SECURE;
00357           }
00358           elseif ($release['status'] == 'unpublished') {
00359             $projects[$project]['status'] = UPDATE_REVOKED;
00360             if (empty($projects[$project]['extra'])) {
00361               $projects[$project]['extra'] = array();
00362             }
00363             $projects[$project]['extra'][] = array(
00364               'class' => 'release-revoked',
00365               'label' => t('Release revoked'),
00366               'data' => t('Your currently installed release has been revoked, and is no longer available for download. Disabling everything included in this release or upgrading is strongly recommended!'),
00367             );
00368           }
00369           elseif (isset($release['terms']['Release type']) &&
00370                   in_array('Unsupported', $release['terms']['Release type'])) {
00371             $projects[$project]['status'] = UPDATE_NOT_SUPPORTED;
00372             if (empty($projects[$project]['extra'])) {
00373               $projects[$project]['extra'] = array();
00374             }
00375             $projects[$project]['extra'][] = array(
00376               'class' => 'release-not-supported',
00377               'label' => t('Release not supported'),
00378               'data' => t('Your currently installed release is now unsupported, and is no longer available for download. Disabling everything included in this release or upgrading is strongly recommended!'),
00379             );
00380           }
00381         }
00382
00383         // Otherwise, ignore unpublished, insecure, or unsupported releases.
00384         if ($release['status'] == 'unpublished' ||
00385             (isset($release['terms']['Release type']) &&
00386              (in_array('Insecure', $release['terms']['Release type']) ||
00387               in_array('Unsupported', $release['terms']['Release type'])))) {
00388           continue;
00389         }
00390
00391         // See if this is a higher major version than our target and yet still
00392         // supported. If so, record it as an "Also available" release.
00393         if ($release['version_major'] > $target_major) {
00394           if (in_array($release['version_major'], $supported_majors)) {
00395             if (!isset($available[$project]['also'])) {
00396               $available[$project]['also'] = array();
00397             }
00398             if (!isset($available[$project]['also'][$release['version_major']])) {
00399               $available[$project]['also'][$release['version_major']] = $version;
00400             }
00401           }
00402           // Otherwise, this release can't matter to us, since it's neither
00403           // from the release series we're currently using nor the recommended
00404           // release. We don't even care about security updates for this
00405           // branch, since if a project maintainer puts out a security release
00406           // at a higher major version and not at the lower major version,
00407           // they must remove the lower version from the supported major
00408           // versions at the same time, in which case we won't hit this code.
00409           continue;
00410         }
00411
00412         // Look for the 'latest version' if we haven't found it yet. Latest is
00413         // defined as the most recent version for the target major version.
00414         if (!isset($available[$project]['latest_version'])
00415             && $release['version_major'] == $target_major) {
00416           $available[$project]['latest_version'] = $version;
00417         }
00418
00419         // Look for the development snapshot release for this branch.
00420         if (!isset($available[$project]['dev_version'])
00421             && $release['version_major'] == $target_major
00422             && isset($release['version_extra'])
00423             && $release['version_extra'] == 'dev') {
00424           $available[$project]['dev_version'] = $version;
00425         }
00426
00427         // Look for the 'recommended' version if we haven't found it yet (see
00428         // phpdoc at the top of this function for the definition).
00429         if (!isset($available[$project]['recommended'])
00430             && $release['version_major'] == $target_major
00431             && isset($release['version_patch'])) {
00432           if ($patch != $release['version_patch']) {
00433             $patch = $release['version_patch'];
00434             $version_patch_changed = $release['version'];
00435           }
00436           if (empty($release['version_extra']) && $patch == $release['version_patch']) {
00437             $available[$project]['recommended'] = $version_patch_changed;
00438           }
00439         }
00440
00441         // Stop searching once we hit the currently installed version.
00442         if ($projects[$project]['existing_version'] == $version) {
00443           break;
00444         }
00445
00446         // If we're running a dev snapshot and have a timestamp, stop
00447         // searching for security updates once we hit an official release
00448         // older than what we've got.  Allow 100 seconds of leeway to handle
00449         // differences between the datestamp in the .info file and the
00450         // timestamp of the tarball itself (which are usually off by 1 or 2
00451         // seconds) so that we don't flag that as a new release.
00452         if ($projects[$project]['install_type'] == 'dev') {
00453           if (empty($projects[$project]['datestamp'])) {
00454             // We don't have current timestamp info, so we can't know.
00455             continue;
00456           }
00457           elseif (isset($release['date']) && ($projects[$project]['datestamp'] + 100 > $release['date'])) {
00458             // We're newer than this, so we can skip it.
00459             continue;
00460           }
00461         }
00462
00463         // See if this release is a security update.
00464         if (isset($release['terms']['Release type'])
00465             && in_array('Security update', $release['terms']['Release type'])) {
00466           $projects[$project]['security updates'][] = $release;
00467         }
00468       }
00469
00470       // If we were unable to find a recommended version, then make the latest
00471       // version the recommended version if possible.
00472       if (!isset($available[$project]['recommended']) && isset($available[$project]['latest_version'])) {
00473         $available[$project]['recommended'] = $available[$project]['latest_version'];
00474       }
00475
00476       // Stash the info about available releases into our $projects array.
00477       $projects[$project] += $available[$project];
00478
00479       //
00480       // Check to see if we need an update or not.
00481       //
00482
00483       if (!empty($projects[$project]['security updates'])) {
00484         // If we found security updates, that always trumps any other status.
00485         $projects[$project]['status'] = UPDATE_NOT_SECURE;
00486       }
00487
00488       if (isset($projects[$project]['status'])) {
00489         // If we already know the status, we're done.
00490         continue;
00491       }
00492
00493       // If we don't know what to recommend, there's nothing we can report.
00494       // Bail out early.
00495       if (!isset($projects[$project]['recommended'])) {
00496         $projects[$project]['status'] = UPDATE_UNKNOWN;
00497         $projects[$project]['reason'] = t('No available releases found');
00498         continue;
00499       }
00500
00501       // If we're running a dev snapshot, compare the date of the dev snapshot
00502       // with the latest official version, and record the absolute latest in
00503       // 'latest_dev' so we can correctly decide if there's a newer release
00504       // than our current snapshot.
00505       if ($projects[$project]['install_type'] == 'dev') {
00506         if (isset($available[$project]['dev_version']) && $available[$project]['releases'][$available[$project]['dev_version']]['date'] > $available[$project]['releases'][$available[$project]['latest_version']]['date']) {
00507           $projects[$project]['latest_dev'] = $available[$project]['dev_version'];
00508         }
00509         else {
00510           $projects[$project]['latest_dev'] = $available[$project]['latest_version'];
00511         }
00512       }
00513
00514       // Figure out the status, based on what we've seen and the install type.
00515       switch ($projects[$project]['install_type']) {
00516         case 'official':
00517           if ($projects[$project]['existing_version'] == $projects[$project]['recommended'] || $projects[$project]['existing_version'] == $projects[$project]['latest_version']) {
00518             $projects[$project]['status'] = UPDATE_CURRENT;
00519           }
00520           else {
00521             $projects[$project]['status'] = UPDATE_NOT_CURRENT;
00522           }
00523           break;
00524
00525         case 'dev':
00526           $latest = $available[$project]['releases'][$projects[$project]['latest_dev']];
00527           if (empty($projects[$project]['datestamp'])) {
00528             $projects[$project]['status'] = UPDATE_NOT_CHECKED;
00529             $projects[$project]['reason'] = t('Unknown release date');
00530           }
00531           elseif (($projects[$project]['datestamp'] + 100 > $latest['date'])) {
00532             $projects[$project]['status'] = UPDATE_CURRENT;
00533           }
00534           else {
00535             $projects[$project]['status'] = UPDATE_NOT_CURRENT;
00536           }
00537           break;
00538
00539         default:
00540           $projects[$project]['status'] = UPDATE_UNKNOWN;
00541           $projects[$project]['reason'] = t('Invalid info');
00542       }
00543     }
00544     else {
00545       $projects[$project]['status'] = UPDATE_UNKNOWN;
00546       $projects[$project]['reason'] = t('No available releases found');
00547     }
00548   }
00549   // Give other modules a chance to alter the status (for example, to allow a
00550   // contrib module to provide fine-grained settings to ignore specific
00551   // projects or releases).
00552   drupal_alter('update_status', $projects);
00553
00554   // Set the projects array into the cache table.
00555   cache_set('update_project_data', $projects, 'cache_update', time() + 3600);
00556   return $projects;
00557 }
00558
00580 function update_project_cache($cid) {
00581   $projects = array();
00582
00583   // In some cases, we must clear the cache.  Rather than do so on a time
00584   // basis, we check for specific paths.
00585   $q = $_GET['q'];
00586   $paths = array('admin/build/modules', 'admin/build/themes', 'admin/reports', 'admin/reports/updates', 'admin/reports/status', 'admin/reports/updates/check');
00587   if (in_array($q, $paths)) {
00588     cache_clear_all($cid, 'cache_update');
00589   }
00590   else {
00591     $cache = cache_get($cid, 'cache_update');
00592     if (!empty($cache->data) && $cache->expire > time()) {
00593       $projects = $cache->data;
00594     }
00595   }
00596   return $projects;
00597 }
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/update/update.fetch.inc Source File

modules » update

update.fetch.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: update.fetch.inc,v 1.7 2008/01/30 10:14:42 goba Exp $
00003
00012 function update_manual_status() {
00013   if (_update_refresh()) {
00014     drupal_set_message(t('Fetched information about all available new releases and updates.'));
00015   }
00016   else {
00017     drupal_set_message(t('Unable to fetch any information about available new releases and updates.'), 'error');
00018   }
00019   drupal_goto('admin/reports/updates');
00020 }
00021
00025 function _update_refresh() {
00026   global $base_url;
00027   module_load_include('inc', 'update', 'update.compare');
00028
00029   // Since we're fetching new available update data, we want to clear
00030   // everything in our cache, to ensure we recompute the status. Note that
00031   // this does not cause update_get_projects() to be recomputed twice in the
00032   // same page load (e.g. when manually checking) since that function stashes
00033   // its answer in a static array.
00034   update_invalidate_cache();
00035
00036   $available = array();
00037   $data = array();
00038   $site_key = md5($base_url . drupal_get_private_key());
00039   $projects = update_get_projects();
00040
00041   foreach ($projects as $key => $project) {
00042     $url = _update_build_fetch_url($project, $site_key);
00043     $xml = drupal_http_request($url);
00044     if (isset($xml->data)) {
00045       $data[] = $xml->data;
00046     }
00047   }
00048
00049   if ($data) {
00050     $parser = new update_xml_parser;
00051     $available = $parser->parse($data);
00052   }
00053   if (!empty($available) && is_array($available)) {
00054     $frequency = variable_get('update_check_frequency', 1);
00055     cache_set('update_info', $available, 'cache_update', time() + (60 * 60 * 24 * $frequency));
00056     variable_set('update_last_check', time());
00057     watchdog('update', 'Fetched information about all available new releases and updates.', array(), WATCHDOG_NOTICE, l('view', 'admin/reports/updates'));
00058   }
00059   else {
00060     module_invoke('system', 'check_http_request');
00061     watchdog('update', 'Unable to fetch any information about available new releases and updates.', array(), WATCHDOG_ERROR, l('view', 'admin/reports/updates'));
00062   }
00063   return $available;
00064 }
00065
00081 function _update_build_fetch_url($project, $site_key = '') {
00082   $default_url = variable_get('update_fetch_url', UPDATE_DEFAULT_URL);
00083   if (!isset($project['info']['project status url'])) {
00084     $project['info']['project status url'] = $default_url;
00085   }
00086   $name = $project['name'];
00087   $url = $project['info']['project status url'];
00088   $url .= '/'. $name .'/'. DRUPAL_CORE_COMPATIBILITY;
00089   if (!empty($site_key)) {
00090     $url .= (strpos($url, '?') === TRUE) ? '&' : '?';
00091     $url .= 'site_key=';
00092     $url .= drupal_urlencode($site_key);
00093     if (!empty($project['info']['version'])) {
00094       $url .= '&version=';
00095       $url .= drupal_urlencode($project['info']['version']);
00096     }
00097   }
00098   return $url;
00099 }
00100
00110 function _update_cron_notify() {
00111   include_once './includes/install.inc';
00112   $status = update_requirements('runtime');
00113   $params = array();
00114   foreach (array('core', 'contrib') as $report_type) {
00115     $type = 'update_'. $report_type;
00116     if (isset($status[$type]['severity'])
00117         && $status[$type]['severity'] == REQUIREMENT_ERROR) {
00118       $params[$report_type] = $status[$type]['reason'];
00119     }
00120   }
00121   if (!empty($params)) {
00122     $notify_list = variable_get('update_notify_emails', '');
00123     if (!empty($notify_list)) {
00124       $default_language = language_default();
00125       foreach ($notify_list as $target) {
00126         if ($target_user = user_load(array('mail' => $target))) {
00127           $target_language = user_preferred_language($target_user);
00128         }
00129         else {
00130           $target_language = $default_language;
00131         }
00132         drupal_mail('update', 'status_notify', $target, $target_language, $params);
00133       }
00134     }
00135   }
00136 }
00137
00142 class update_xml_parser {
00143   var $projects = array();
00144   var $current_project;
00145   var $current_release;
00146   var $current_term;
00147   var $current_tag;
00148   var $current_object;
00149
00153   function parse($data) {
00154     foreach ($data as $datum) {
00155       $parser = xml_parser_create();
00156       xml_set_object($parser, $this);
00157       xml_set_element_handler($parser, 'start', 'end');
00158       xml_set_character_data_handler($parser, "data");
00159       xml_parse($parser, $datum);
00160       xml_parser_free($parser);
00161     }
00162     return $this->projects;
00163   }
00164
00165   function start($parser, $name, $attr) {
00166     $this->current_tag = $name;
00167     switch ($name) {
00168       case 'PROJECT':
00169         unset($this->current_object);
00170         $this->current_project = array();
00171         $this->current_object = &$this->current_project;
00172         break;
00173       case 'RELEASE':
00174         unset($this->current_object);
00175         $this->current_release = array();
00176         $this->current_object = &$this->current_release;
00177         break;
00178       case 'TERM':
00179         unset($this->current_object);
00180         $this->current_term = array();
00181         $this->current_object = &$this->current_term;
00182         break;
00183     }
00184   }
00185
00186   function end($parser, $name) {
00187     switch ($name) {
00188       case 'PROJECT':
00189         unset($this->current_object);
00190         $this->projects[$this->current_project['short_name']] = $this->current_project;
00191         $this->current_project = array();
00192         break;
00193       case 'RELEASE':
00194         unset($this->current_object);
00195         $this->current_project['releases'][$this->current_release['version']] = $this->current_release;
00196         break;
00197       case 'RELEASES':
00198         $this->current_object = &$this->current_project;
00199         break;
00200       case 'TERM':
00201         unset($this->current_object);
00202         $term_name = $this->current_term['name'];
00203         if (!isset($this->current_release['terms'])) {
00204           $this->current_release['terms'] = array();
00205         }
00206         if (!isset($this->current_release['terms'][$term_name])) {
00207           $this->current_release['terms'][$term_name] = array();
00208         }
00209         $this->current_release['terms'][$term_name][] = $this->current_term['value'];
00210         break;
00211       case 'TERMS':
00212         $this->current_object = &$this->current_release;
00213         break;
00214       default:
00215         $this->current_object[strtolower($this->current_tag)] = trim($this->current_object[strtolower($this->current_tag)]);
00216         $this->current_tag = '';
00217     }
00218   }
00219
00220   function data($parser, $data) {
00221     if ($this->current_tag && !in_array($this->current_tag, array('PROJECT', 'RELEASE', 'RELEASES', 'TERM', 'TERMS'))) {
00222       $tag = strtolower($this->current_tag);
00223       if (isset($this->current_object[$tag])) {
00224         $this->current_object[$tag] .= $data;
00225       }
00226       else {
00227         $this->current_object[$tag] = $data;
00228       }
00229     }
00230   }
00231 }
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/update/update.install Source File

modules » update

update.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: update.install,v 1.4 2008/02/03 18:38:14 goba Exp $
00003
00007 function update_install() {
00008   // Create cache table.
00009   drupal_install_schema('update');
00010   // Remove stale variables from update_status 5.x contrib, if any.
00011   _update_remove_update_status_variables();
00012 }
00013
00017 function update_uninstall() {
00018   // Remove cache table.
00019   drupal_uninstall_schema('update');
00020   // Clear any variables that might be in use
00021   $variables = array(
00022     'update_check_frequency',
00023     'update_fetch_url',
00024     'update_last_check',
00025     'update_notification_threshold',
00026     'update_notify_emails',
00027   );
00028   foreach ($variables as $variable) {
00029     variable_del($variable);
00030   }
00031   menu_rebuild();
00032 }
00033
00037 function update_schema() {
00038   $schema['cache_update'] = drupal_get_schema_unprocessed('system', 'cache');
00039   $schema['cache_update']['description'] = t('Cache table for the Update module to store information about available releases, fetched from central server.');
00040   return $schema;
00041 }
00042
00049 function _update_remove_update_status_variables() {
00050   variable_del('update_status_settings');
00051   variable_del('update_status_notify_emails');
00052   variable_del('update_status_check_frequency');
00053   variable_del('update_status_notification_threshold');
00054   variable_del('update_status_last');
00055   variable_del('update_status_fetch_url');
00056 }
00057
00061 function update_update_6000() {
00062   _update_remove_update_status_variables();
00063   return array();
00064 }
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/update/update.module Source File

modules » update

update.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: update.module,v 1.17 2008/01/30 10:14:42 goba Exp $
00003
00015 define('UPDATE_DEFAULT_URL', 'http://updates.drupal.org/release-history');
00016
00017 // These are internally used constants for this code, do not modify.
00018
00022 define('UPDATE_NOT_SECURE', 1);
00023
00027 define('UPDATE_REVOKED', 2);
00028
00032 define('UPDATE_NOT_SUPPORTED', 3);
00033
00037 define('UPDATE_NOT_CURRENT', 4);
00038
00042 define('UPDATE_CURRENT', 5);
00043
00047 define('UPDATE_NOT_CHECKED', -1);
00048
00052 define('UPDATE_UNKNOWN', -2);
00053
00054
00058 function update_help($path, $arg) {
00059   switch ($path) {
00060     case 'admin/reports/updates':
00061       $output = '<p>'. t('Here you can find information about available updates for your installed modules and themes. Note that each module or theme is part of a "project", which may or may not have the same name, and might include multiple modules or themes within it.') .'</p>';
00062       $output .= '<p>'. t('To extend the functionality or to change the look of your site, a number of contributed <a href="@modules">modules</a> and <a href="@themes">themes</a> are available.', array('@modules' => 'http://drupal.org/project/modules', '@themes' => 'http://drupal.org/project/themes')) .'</p>';
00063       return $output;
00064     case 'admin/build/themes':
00065     case 'admin/build/modules':
00066       include_once './includes/install.inc';
00067       $status = update_requirements('runtime');
00068       foreach (array('core', 'contrib') as $report_type) {
00069         $type = 'update_'. $report_type;
00070         if (isset($status[$type]['severity'])) {
00071           if ($status[$type]['severity'] == REQUIREMENT_ERROR) {
00072             drupal_set_message($status[$type]['description'], 'error');
00073           }
00074           elseif ($status[$type]['severity'] == REQUIREMENT_WARNING) {
00075             drupal_set_message($status[$type]['description'], 'warning');
00076           }
00077         }
00078       }
00079       return '<p>'. t('See the <a href="@available_updates">available updates</a> page for information on installed modules and themes with new versions released.', array('@available_updates' => url('admin/reports/updates'))) .'</p>';
00080
00081     case 'admin/reports/updates/settings':
00082     case 'admin/reports/status':
00083       // These two pages don't need additional nagging.
00084       break;
00085
00086     case 'admin/help#update':
00087       $output = '<p>'. t("The Update status module periodically checks for new versions of your site's software (including contributed modules and themes), and alerts you to available updates.") .'</p>';
00088       $output .= '<p>'. t('The <a href="@update-report">report of available updates</a> will alert you when new releases are available for download. You may configure options for update checking frequency and notifications at the <a href="@update-settings">Update status module settings page</a>.', array('@update-report' => url('admin/reports/updates'), '@update-settings' => url('admin/reports/updates/settings'))) .'</p>';
00089       $output .= '<p>'. t('Please note that in order to provide this information, anonymous usage statistics are sent to drupal.org. If desired, you may disable the Update status module from the <a href="@modules">module administration page</a>.', array('@modules' => url('admin/build/modules'))) .'</p>';
00090       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@update">Update status module</a>.', array('@update' => 'http://drupal.org/handbook/modules/update')) .'</p>';
00091       return $output;
00092
00093     default:
00094       // Otherwise, if we're on *any* admin page and there's a security
00095       // update missing, print an error message about it.
00096       if (arg(0) == 'admin' && strpos($path, '#') === FALSE
00097           && user_access('administer site configuration')) {
00098         include_once './includes/install.inc';
00099         $status = update_requirements('runtime');
00100         foreach (array('core', 'contrib') as $report_type) {
00101           $type = 'update_'. $report_type;
00102           if (isset($status[$type])
00103               && isset($status[$type]['reason'])
00104               && $status[$type]['reason'] === UPDATE_NOT_SECURE) {
00105             drupal_set_message($status[$type]['description'], 'error');
00106           }
00107         }
00108       }
00109
00110   }
00111 }
00112
00116 function update_menu() {
00117   $items = array();
00118
00119   $items['admin/reports/updates'] = array(
00120     'title' => 'Available updates',
00121     'description' => 'Get a status report about available updates for your installed modules and themes.',
00122     'page callback' => 'update_status',
00123     'access arguments' => array('administer site configuration'),
00124     'file' => 'update.report.inc',
00125     'weight' => 10,
00126   );
00127   $items['admin/reports/updates/list'] = array(
00128     'title' => 'List',
00129     'page callback' => 'update_status',
00130     'access arguments' => array('administer site configuration'),
00131     'file' => 'update.report.inc',
00132     'type' => MENU_DEFAULT_LOCAL_TASK,
00133   );
00134   $items['admin/reports/updates/settings'] = array(
00135     'title' => 'Settings',
00136     'page callback' => 'drupal_get_form',
00137     'page arguments' => array('update_settings'),
00138     'access arguments' => array('administer site configuration'),
00139     'file' => 'update.settings.inc',
00140     'type' => MENU_LOCAL_TASK,
00141   );
00142   $items['admin/reports/updates/check'] = array(
00143     'title' => 'Manual update check',
00144     'page callback' => 'update_manual_status',
00145     'access arguments' => array('administer site configuration'),
00146     'file' => 'update.fetch.inc',
00147     'type' => MENU_CALLBACK,
00148   );
00149
00150   return $items;
00151 }
00152
00156 function update_theme() {
00157   return array(
00158     'update_settings' => array(
00159       'arguments' => array('form' => NULL),
00160     ),
00161     'update_report' => array(
00162       'arguments' => array('data' => NULL),
00163     ),
00164     'update_version' => array(
00165       'arguments' => array('version' => NULL, 'tag' => NULL, 'class' => NULL),
00166     ),
00167   );
00168 }
00169
00191 function update_requirements($phase) {
00192   if ($phase == 'runtime') {
00193     if ($available = update_get_available(FALSE)) {
00194       module_load_include('inc', 'update', 'update.compare');
00195       $data = update_calculate_project_data($available);
00196       // First, populate the requirements for core:
00197       $requirements['update_core'] = _update_requirement_check($data['drupal'], 'core');
00198       // We don't want to check drupal a second time.
00199       unset($data['drupal']);
00200       if (!empty($data)) {
00201         // Now, sort our $data array based on each project's status. The
00202         // status constants are numbered in the right order of precedence, so
00203         // we just need to make sure the projects are sorted in ascending
00204         // order of status, and we can look at the first project we find.
00205         uasort($data, '_update_project_status_sort');
00206         $first_project = reset($data);
00207         $requirements['update_contrib'] = _update_requirement_check($first_project, 'contrib');
00208       }
00209     }
00210     else {
00211       $requirements['update_core']['title'] = t('Drupal core update status');
00212       $requirements['update_core']['value'] = t('No update data available');
00213       $requirements['update_core']['severity'] = REQUIREMENT_WARNING;
00214       $requirements['update_core']['reason'] = UPDATE_UNKNOWN;
00215       $requirements['update_core']['description'] = _update_no_data();
00216     }
00217     return $requirements;
00218   }
00219 }
00220
00240 function _update_requirement_check($project, $type) {
00241   $requirement = array();
00242   if ($type == 'core') {
00243     $requirement['title'] = t('Drupal core update status');
00244   }
00245   else {
00246     $requirement['title'] = t('Module and theme update status');
00247   }
00248   $status = $project['status'];
00249   if ($status != UPDATE_CURRENT) {
00250     $requirement['reason'] = $status;
00251     $requirement['description'] = _update_message_text($type, $status, TRUE);
00252     $requirement['severity'] = REQUIREMENT_ERROR;
00253   }
00254   switch ($status) {
00255     case UPDATE_NOT_SECURE:
00256       $requirement_label = t('Not secure!');
00257       break;
00258     case UPDATE_REVOKED:
00259       $requirement_label = t('Revoked!');
00260       break;
00261     case UPDATE_NOT_SUPPORTED:
00262       $requirement_label = t('Unsupported release');
00263       break;
00264     case UPDATE_NOT_CURRENT:
00265       $requirement_label = t('Out of date');
00266       $requirement['severity'] = variable_get('update_notification_threshold', 'all') == 'all' ? REQUIREMENT_ERROR : REQUIREMENT_WARNING;
00267       break;
00268     case UPDATE_UNKNOWN:
00269     case UPDATE_NOT_CHECKED:
00270       $requirement_label = isset($project['reason']) ? $project['reason'] : t('Can not determine status');
00271       $requirement['severity'] = REQUIREMENT_WARNING;
00272       break;
00273     default:
00274       $requirement_label = t('Up to date');
00275   }
00276   if ($status != UPDATE_CURRENT && $type == 'core' && isset($project['recommended'])) {
00277     $requirement_label .= ' '. t('(version @version available)', array('@version' => $project['recommended']));
00278   }
00279   $requirement['value'] = l($requirement_label, 'admin/reports/updates');
00280   return $requirement;
00281 }
00282
00286 function update_cron() {
00287   $frequency = variable_get('update_check_frequency', 1);
00288   $interval = 60 * 60 * 24 * $frequency;
00289   if (time() - variable_get('update_last_check', 0) > $interval) {
00290     update_refresh();
00291     _update_cron_notify();
00292   }
00293 }
00294
00303 function update_form_alter(&$form, $form_state, $form_id) {
00304   if ($form_id == 'system_modules' || $form_id == 'system_themes' ) {
00305     $form['#submit'][] = 'update_invalidate_cache';
00306   }
00307 }
00308
00312 function _update_no_data() {
00313   $destination = drupal_get_destination();
00314   return t('No information is available about potential new releases for currently installed modules and themes. To check for updates, you may need to <a href="@run_cron">run cron</a> or you can <a href="@check_manually">check manually</a>. Please note that checking for available updates can take a long time, so please be patient.', array(
00315     '@run_cron' => url('admin/reports/status/run-cron', array('query' => $destination)),
00316     '@check_manually' => url('admin/reports/updates/check', array('query' => $destination)),
00317   ));
00318 }
00319
00339 function update_get_available($refresh = FALSE) {
00340   module_load_include('inc', 'update', 'update.compare');
00341   $available = array();
00342
00343   // First, make sure that none of the .info files have a change time
00344   // newer than the last time we checked for available updates.
00345   $needs_refresh = FALSE;
00346   $last_check = variable_get('update_last_check', 0);
00347   $projects = update_get_projects();
00348   foreach ($projects as $key => $project) {
00349     if ($project['info']['_info_file_ctime'] > $last_check) {
00350       $needs_refresh = TRUE;
00351       break;
00352     }
00353   }
00354   if (!$needs_refresh && ($cache = cache_get('update_info', 'cache_update'))
00355        && $cache->expire > time()) {
00356     $available = $cache->data;
00357   }
00358   elseif ($needs_refresh || $refresh) {
00359     // If we need to refresh due to a newer .info file, ignore the argument
00360     // and force the refresh (e.g., even for update_requirements()) to prevent
00361     // bogus results.
00362     $available = update_refresh();
00363   }
00364   return $available;
00365 }
00366
00374 function update_flush_caches() {
00375   return array('cache_update');
00376 }
00377
00381 function update_invalidate_cache() {
00382   cache_clear_all('*', 'cache_update', TRUE);
00383 }
00384
00388 function update_refresh() {
00389   module_load_include('inc', 'update', 'update.fetch');
00390   return _update_refresh();
00391 }
00392
00412 function update_mail($key, &$message, $params) {
00413   $language = $message['language'];
00414   $langcode = $language->language;
00415   $message['subject'] .= t('New release(s) available for !site_name', array('!site_name' => variable_get('site_name', 'Drupal')), $langcode);
00416   foreach ($params as $msg_type => $msg_reason) {
00417     $message['body'][] = _update_message_text($msg_type, $msg_reason, FALSE, $language);
00418   }
00419   $message['body'][] = t('See the available updates page for more information:', array(), $langcode) ."\n". url('admin/reports/updates', array('absolute' => TRUE, 'language' => $language));
00420 }
00421
00442 function _update_message_text($msg_type, $msg_reason, $report_link = FALSE, $language = NULL) {
00443   $langcode = isset($language) ? $language->language : NULL;
00444   $text = '';
00445   switch ($msg_reason) {
00446     case UPDATE_NOT_SECURE:
00447       if ($msg_type == 'core') {
00448         $text = t('There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!', array(), $langcode);
00449       }
00450       else {
00451         $text = t('There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!', array(), $langcode);
00452       }
00453       break;
00454
00455     case UPDATE_REVOKED:
00456       if ($msg_type == 'core') {
00457         $text = t('Your version of Drupal has been revoked and is no longer available for download. Upgrading is strongly recommended!', array(), $langcode);
00458       }
00459       else {
00460         $text = t('The installed version of at least one of your modules or themes has been revoked and is no longer available for download. Upgrading or disabling is strongly recommended!', array(), $langcode);
00461       }
00462       break;
00463
00464     case UPDATE_NOT_SUPPORTED:
00465       if ($msg_type == 'core') {
00466         $text = t('Your version of Drupal is no longer supported. Upgrading is strongly recommended!', array(), $langcode);
00467       }
00468       else {
00469         $text = t('The installed version of at least one of your modules or themes is no longer supported. Upgrading or disabling is strongly recommended! Please see the project homepage for more details.', array(), $langcode);
00470       }
00471       break;
00472
00473     case UPDATE_NOT_CURRENT:
00474       if ($msg_type == 'core') {
00475         $text = t('There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible.', array(), $langcode);
00476       }
00477       else {
00478         $text = t('There are updates available for one or more of your modules or themes. To ensure the proper functioning of your site, you should update as soon as possible.', array(), $langcode);
00479       }
00480       break;
00481
00482     case UPDATE_UNKNOWN:
00483     case UPDATE_NOT_CHECKED:
00484       if ($msg_type == 'core') {
00485         $text = t('There was a problem determining the status of available updates for your version of Drupal.', array(), $langcode);
00486       }
00487       else {
00488         $text = t('There was a problem determining the status of available updates for one or more of your modules or themes.', array(), $langcode);
00489       }
00490       break;
00491   }
00492
00493   if ($report_link) {
00494     $text .= ' '. t('See the <a href="@available_updates">available updates</a> page for more information.', array('@available_updates' => url('admin/reports/updates', array('language' => $language))), $langcode);
00495   }
00496
00497   return $text;
00498 }
00499
00506 function _update_project_status_sort($a, $b) {
00507   // The status constants are numerically in the right order, so we can
00508   // usually subtract the two to compare in the order we want. However,
00509   // negative status values should be treated as if they are huge, since we
00510   // always want them at the bottom of the list.
00511   $a_status = $a['status'] > 0 ? $a['status'] : (-10 * $a['status']);
00512   $b_status = $b['status'] > 0 ? $b['status'] : (-10 * $b['status']);
00513   return $a_status - $b_status;
00514 }
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: update.php Source File

update.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: update.php,v 1.252 2008/02/03 18:41:16 goba Exp $
00003
00022 define('MAINTENANCE_MODE', 'update');
00023
00051 function db_add_column(&$ret, $table, $column, $type, $attributes = array()) {
00052   if (array_key_exists('not null', $attributes) and $attributes['not null']) {
00053     $not_null = 'NOT NULL';
00054   }
00055   if (array_key_exists('default', $attributes)) {
00056     if (is_null($attributes['default'])) {
00057       $default_val = 'NULL';
00058       $default = 'default NULL';
00059     }
00060     elseif ($attributes['default'] === FALSE) {
00061       $default = '';
00062     }
00063     else {
00064       $default_val = "$attributes[default]";
00065       $default = "default $attributes[default]";
00066     }
00067   }
00068
00069   $ret[] = update_sql("ALTER TABLE {". $table ."} ADD $column $type");
00070   if (!empty($default)) {
00071     $ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $column SET $default");
00072   }
00073   if (!empty($not_null)) {
00074     if (!empty($default)) {
00075       $ret[] = update_sql("UPDATE {". $table ."} SET $column = $default_val");
00076     }
00077     $ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $column SET NOT NULL");
00078   }
00079 }
00080
00107 function db_change_column(&$ret, $table, $column, $column_new, $type, $attributes = array()) {
00108   if (array_key_exists('not null', $attributes) and $attributes['not null']) {
00109     $not_null = 'NOT NULL';
00110   }
00111   if (array_key_exists('default', $attributes)) {
00112     if (is_null($attributes['default'])) {
00113       $default_val = 'NULL';
00114       $default = 'default NULL';
00115     }
00116     elseif ($attributes['default'] === FALSE) {
00117       $default = '';
00118     }
00119     else {
00120       $default_val = "$attributes[default]";
00121       $default = "default $attributes[default]";
00122     }
00123   }
00124
00125   $ret[] = update_sql("ALTER TABLE {". $table ."} RENAME $column TO ". $column ."_old");
00126   $ret[] = update_sql("ALTER TABLE {". $table ."} ADD $column_new $type");
00127   $ret[] = update_sql("UPDATE {". $table ."} SET $column_new = ". $column ."_old");
00128   if ($default) { $ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $column_new SET $default"); }
00129   if ($not_null) { $ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $column_new SET NOT NULL"); }
00130   $ret[] = update_sql("ALTER TABLE {". $table ."} DROP ". $column ."_old");
00131 }
00132
00151 function update_do_one($module, $number, &$context) {
00152   // If updates for this module have been aborted
00153   // in a previous step, go no further.
00154   if (!empty($context['results'][$module]['#abort'])) {
00155     return;
00156   }
00157
00158   $function = $module .'_update_'. $number;
00159   if (function_exists($function)) {
00160     $ret = $function($context['sandbox']);
00161   }
00162
00163   if (isset($ret['#finished'])) {
00164     $context['finished'] = $ret['#finished'];
00165     unset($ret['#finished']);
00166   }
00167
00168   if (!isset($context['results'][$module])) {
00169     $context['results'][$module] = array();
00170   }
00171   if (!isset($context['results'][$module][$number])) {
00172     $context['results'][$module][$number] = array();
00173   }
00174   $context['results'][$module][$number] = array_merge($context['results'][$module][$number], $ret);
00175
00176   if (!empty($ret['#abort'])) {
00177     $context['results'][$module]['#abort'] = TRUE;
00178   }
00179   // Record the schema update if it was completed successfully.
00180   if ($context['finished'] == 1 && empty($context['results'][$module]['#abort'])) {
00181     drupal_set_installed_schema_version($module, $number);
00182   }
00183
00184   $context['message'] = 'Updating '. check_plain($module) .' module';
00185 }
00186
00187 function update_selection_page() {
00188   $output = '<p>The version of Drupal you are updating from has been automatically detected. You can select a different version, but you should not need to.</p>';
00189   $output .= '<p>Click Update to start the update process.</p>';
00190
00191   drupal_set_title('Drupal database update');
00192   $output .= drupal_get_form('update_script_selection_form');
00193
00194   update_task_list('select');
00195
00196   return $output;
00197 }
00198
00199 function update_script_selection_form() {
00200   $form = array();
00201   $form['start'] = array(
00202     '#tree' => TRUE,
00203     '#type' => 'fieldset',
00204     '#title' => 'Select versions',
00205     '#collapsible' => TRUE,
00206     '#collapsed' => TRUE,
00207   );
00208
00209   // Ensure system.module's updates appear first
00210   $form['start']['system'] = array();
00211
00212   $modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
00213   foreach ($modules as $module => $schema_version) {
00214     $updates = drupal_get_schema_versions($module);
00215     // Skip incompatible module updates completely, otherwise test schema versions.
00216     if (!update_check_incompatibility($module) && $updates !== FALSE && $schema_version >= 0) {
00217       // module_invoke returns NULL for nonexisting hooks, so if no updates
00218       // are removed, it will == 0.
00219       $last_removed = module_invoke($module, 'update_last_removed');
00220       if ($schema_version < $last_removed) {
00221         $form['start'][$module] = array(
00222           '#value'  => '<em>'. $module .'</em> module can not be updated. Its schema version is '. $schema_version .'. Updates up to and including '. $last_removed .' have been removed in this release. In order to update <em>'. $module .'</em> module, you will first <a href="http://drupal.org/upgrade">need to upgrade</a> to the last version in which these updates were available.',
00223           '#prefix' => '<div class="warning">',
00224           '#suffix' => '</div>',
00225         );
00226         $form['start']['#collapsed'] = FALSE;
00227         continue;
00228       }
00229       $updates = drupal_map_assoc($updates);
00230       $updates[] = 'No updates available';
00231       $default = $schema_version;
00232       foreach (array_keys($updates) as $update) {
00233         if ($update > $schema_version) {
00234           $default = $update;
00235           break;
00236         }
00237       }
00238       $form['start'][$module] = array(
00239         '#type' => 'select',
00240         '#title' => $module .' module',
00241         '#default_value' => $default,
00242         '#options' => $updates,
00243       );
00244     }
00245   }
00246
00247   $form['has_js'] = array(
00248     '#type' => 'hidden',
00249     '#default_value' => FALSE,
00250     '#attributes' => array('id' => 'edit-has_js'),
00251   );
00252   $form['submit'] = array(
00253     '#type' => 'submit',
00254     '#value' => 'Update',
00255   );
00256   return $form;
00257 }
00258
00259 function update_batch() {
00260   global $base_url;
00261
00262   $operations = array();
00263   // Set the installed version so updates start at the correct place.
00264   foreach ($_POST['start'] as $module => $version) {
00265     drupal_set_installed_schema_version($module, $version - 1);
00266     $updates = drupal_get_schema_versions($module);
00267     $max_version = max($updates);
00268     if ($version <= $max_version) {
00269       foreach ($updates as $update) {
00270         if ($update >= $version) {
00271           $operations[] = array('update_do_one', array($module, $update));
00272         }
00273       }
00274     }
00275   }
00276   $batch = array(
00277     'operations' => $operations,
00278     'title' => 'Updating',
00279     'init_message' => 'Starting updates',
00280     'error_message' => 'An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.',
00281     'finished' => 'update_finished',
00282   );
00283   batch_set($batch);
00284   batch_process($base_url .'/update.php?op=results', $base_url .'/update.php');
00285 }
00286
00287 function update_finished($success, $results, $operations) {
00288   // clear the caches in case the data has been updated.
00289   drupal_flush_all_caches();
00290
00291   $_SESSION['update_results'] = $results;
00292   $_SESSION['update_success'] = $success;
00293   $_SESSION['updates_remaining'] = $operations;
00294 }
00295
00296 function update_results_page() {
00297   drupal_set_title('Drupal database update');
00298   // NOTE: we can't use l() here because the URL would point to 'update.php?q=admin'.
00299   $links[] = '<a href="'. base_path() .'">Main page</a>';
00300   $links[] = '<a href="'. base_path() .'?q=admin">Administration pages</a>';
00301
00302   update_task_list();
00303   // Report end result
00304   if (module_exists('dblog')) {
00305     $log_message = ' All errors have been <a href="'. base_path() .'?q=admin/reports/dblog">logged</a>.';
00306   }
00307   else {
00308     $log_message = ' All errors have been logged.';
00309   }
00310
00311   if ($_SESSION['update_success']) {
00312     $output = '<p>Updates were attempted. If you see no failures below, you may proceed happily to the <a href="'. base_path() .'?q=admin">administration pages</a>. Otherwise, you may need to update your database manually.'. $log_message .'</p>';
00313   }
00314   else {
00315     list($module, $version) = array_pop(reset($_SESSION['updates_remaining']));
00316     $output = '<p class="error">The update process was aborted prematurely while running <strong>update #'. $version .' in '. $module .'.module</strong>.'. $log_message;
00317     if (module_exists('dblog')) {
00318       $output .= ' You may need to check the <code>watchdog</code> database table manually.';
00319     }
00320     $output .= '</p>';
00321   }
00322
00323   if (!empty($GLOBALS['update_free_access'])) {
00324     $output .= "<p><strong>Reminder: don't forget to set the <code>\$update_free_access</code> value in your <code>settings.php</code> file back to <code>FALSE</code>.</strong></p>";
00325   }
00326
00327   $output .= theme('item_list', $links);
00328
00329   // Output a list of queries executed
00330   if (!empty($_SESSION['update_results'])) {
00331     $output .= '<div id="update-results">';
00332     $output .= '<h2>The following queries were executed</h2>';
00333     foreach ($_SESSION['update_results'] as $module => $updates) {
00334       $output .= '<h3>'. $module .' module</h3>';
00335       foreach ($updates as $number => $queries) {
00336         if ($number != '#abort') {
00337           $output .= '<h4>Update #'. $number .'</h4>';
00338           $output .= '<ul>';
00339           foreach ($queries as $query) {
00340             if ($query['success']) {
00341               $output .= '<li class="success">'. $query['query'] .'</li>';
00342             }
00343             else {
00344               $output .= '<li class="failure"><strong>Failed:</strong> '. $query['query'] .'</li>';
00345             }
00346           }
00347           if (!count($queries)) {
00348             $output .= '<li class="none">No queries</li>';
00349           }
00350         }
00351         $output .= '</ul>';
00352       }
00353     }
00354     $output .= '</div>';
00355   }
00356   unset($_SESSION['update_results']);
00357   unset($_SESSION['update_success']);
00358
00359   return $output;
00360 }
00361
00362 function update_info_page() {
00363   // Change query-strings on css/js files to enforce reload for all users.
00364   _drupal_flush_css_js();
00365   // Flush the cache of all data for the update status module.
00366   if (db_table_exists('cache_update')) {
00367     cache_clear_all('*', 'cache_update', TRUE);
00368   }
00369
00370   update_task_list('info');
00371   drupal_set_title('Drupal database update');
00372   $output = '<p>Use this utility to update your database whenever a new release of Drupal or a module is installed.</p><p>For more detailed information, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.</p>';
00373   $output .= "<ol>\n";
00374   $output .= "<li><strong>Back up your database</strong>. This process will change your database values and in case of emergency you may need to revert to a backup.</li>\n";
00375   $output .= "<li><strong>Back up your code</strong>. Hint: when backing up module code, do not leave that backup in the 'modules' or 'sites/*/modules' directories as this may confuse Drupal's auto-discovery mechanism.</li>\n";
00376   $output .= '<li>Put your site into <a href="'. base_path() .'?q=admin/settings/site-maintenance">maintenance mode</a>.</li>'."\n";
00377   $output .= "<li>Install your new files in the appropriate location, as described in the handbook.</li>\n";
00378   $output .= "</ol>\n";
00379   $output .= "<p>When you have performed the steps above, you may proceed.</p>\n";
00380   $output .= '<form method="post" action="update.php?op=selection"><input type="submit" value="Continue" /></form>';
00381   $output .= "\n";
00382   return $output;
00383 }
00384
00385 function update_access_denied_page() {
00386   drupal_set_title('Access denied');
00387   return '<p>Access denied. You are not authorized to access this page. Please log in as the admin user (the first user you created). If you cannot log in, you will have to edit <code>settings.php</code> to bypass this access check. To do this:</p>
00388 <ol>
00389  <li>With a text editor find the settings.php file on your system. From the main Drupal directory that you installed all the files into, go to <code>sites/your_site_name</code> if such directory exists, or else to <code>sites/default</code> which applies otherwise.</li>
00390  <li>There is a line inside your settings.php file that says <code>$update_free_access = FALSE;</code>. Change it to <code>$update_free_access = TRUE;</code>.</li>
00391  <li>As soon as the update.php script is done, you must change the settings.php file back to its original form with <code>$update_free_access = FALSE;</code>.</li>
00392  <li>To avoid having this problem in future, remember to log in to your website as the admin user (the user you first created) before you backup your database at the beginning of the update process.</li>
00393 </ol>';
00394 }
00395
00401 function update_create_batch_table() {
00402
00403   // If batch table exists, update is not necessary
00404   if (db_table_exists('batch')) {
00405     return;
00406   }
00407
00408   $schema['batch'] = array(
00409     'fields' => array(
00410       'bid'       => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
00411       'token'     => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE),
00412       'timestamp' => array('type' => 'int', 'not null' => TRUE),
00413       'batch'     => array('type' => 'text', 'not null' => FALSE, 'size' => 'big')
00414     ),
00415     'primary key' => array('bid'),
00416     'indexes' => array('token' => array('token')),
00417   );
00418
00419   $ret = array();
00420   db_create_table($ret, 'batch', $schema['batch']);
00421   return $ret;
00422 }
00423
00428 function update_fix_compatibility() {
00429   $ret = array();
00430   $incompatible = array();
00431   $query = db_query("SELECT name, type, status FROM {system} WHERE status = 1 AND type IN ('module','theme')");
00432   while ($result = db_fetch_object($query)) {
00433     if (update_check_incompatibility($result->name, $result->type)) {
00434       $incompatible[] = $result->name;
00435     }
00436   }
00437   if (!empty($incompatible)) {
00438     $ret[] = update_sql("UPDATE {system} SET status = 0 WHERE name IN ('". implode("','", $incompatible) ."')");
00439   }
00440   return $ret;
00441 }
00442
00446 function update_check_incompatibility($name, $type = 'module') {
00447   static $themes, $modules;
00448
00449   // Store values of expensive functions for future use.
00450   if (empty($themes) || empty($modules)) {
00451     $themes = system_theme_data();
00452     $modules = module_rebuild_cache();
00453   }
00454
00455   if ($type == 'module' && isset($modules[$name])) {
00456     $file = $modules[$name];
00457   }
00458   else if ($type == 'theme' && isset($themes[$name])) {
00459     $file = $themes[$name];
00460   }
00461   if (!isset($file)
00462       || !isset($file->info['core'])
00463       || $file->info['core'] != DRUPAL_CORE_COMPATIBILITY
00464       || version_compare(phpversion(), $file->info['php']) < 0) {
00465     return TRUE;
00466   }
00467   return FALSE;
00468 }
00469
00485 function update_fix_d6_requirements() {
00486   $ret = array();
00487
00488   if (drupal_get_installed_schema_version('system') < 6000 && !variable_get('update_d6_requirements', FALSE)) {
00489     $spec = array('type' => 'int', 'size' => 'small', 'default' => 0, 'not null' => TRUE);
00490     db_add_field($ret, 'cache', 'serialized', $spec);
00491     db_add_field($ret, 'cache_filter', 'serialized', $spec);
00492     db_add_field($ret, 'cache_page', 'serialized', $spec);
00493     db_add_field($ret, 'cache_menu', 'serialized', $spec);
00494
00495     db_add_field($ret, 'system', 'info', array('type' => 'text'));
00496     db_add_field($ret, 'system', 'owner', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
00497     if (db_table_exists('locales_target')) {
00498       db_add_field($ret, 'locales_target', 'language', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''));
00499     }
00500     if (db_table_exists('locales_source')) {
00501       db_add_field($ret, 'locales_source', 'textgroup', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'default'));
00502       db_add_field($ret, 'locales_source', 'version', array('type' => 'varchar', 'length' => 20, 'not null' => TRUE, 'default' => 'none'));
00503     }
00504     variable_set('update_d6_requirements', TRUE);
00505
00506     // Create the cache_block table. See system_update_6027() for more details.
00507     $schema['cache_block'] = array(
00508       'fields' => array(
00509         'cid'        => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
00510         'data'       => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
00511         'expire'     => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
00512         'created'    => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
00513         'headers'    => array('type' => 'text', 'not null' => FALSE),
00514         'serialized' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)
00515       ),
00516       'indexes' => array('expire' => array('expire')),
00517       'primary key' => array('cid'),
00518     );
00519     db_create_table($ret, 'cache_block', $schema['cache_block']);
00520   }
00521
00522   return $ret;
00523 }
00524
00528 function update_task_list($active = NULL) {
00529   // Default list of tasks.
00530   $tasks = array(
00531     'info' => 'Overview',
00532     'select' => 'Select updates',
00533     'run' => 'Run updates',
00534     'finished' => 'Review log',
00535   );
00536
00537   drupal_set_content('left', theme('task_list', $tasks, $active));
00538 }
00539
00543 function update_check_requirements() {
00544   // Check the system module requirements only.
00545   $requirements = module_invoke('system', 'requirements', 'update');
00546   $severity = drupal_requirements_severity($requirements);
00547
00548   // If there are issues, report them.
00549   if ($severity != REQUIREMENT_OK) {
00550     foreach ($requirements as $requirement) {
00551       if (isset($requirement['severity']) && $requirement['severity'] != REQUIREMENT_OK) {
00552         $message = isset($requirement['description']) ? $requirement['description'] : '';
00553         if (isset($requirement['value']) && $requirement['value']) {
00554           $message .= ' (Currently using '. $requirement['title'] .' '. $requirement['value'] .')';
00555         }
00556         drupal_set_message($message, 'warning');
00557       }
00558     }
00559   }
00560 }
00561
00562 // Some unavoidable errors happen because the database is not yet up-to-date.
00563 // Our custom error handler is not yet installed, so we just suppress them.
00564 ini_set('display_errors', FALSE);
00565
00566 require_once './includes/bootstrap.inc';
00567
00568 // We only load DRUPAL_BOOTSTRAP_CONFIGURATION for the update requirements
00569 // check to avoid reaching the PHP memory limit.
00570 $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
00571 if (empty($op)) {
00572   // Minimum load of components.
00573   drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
00574
00575   require_once './includes/install.inc';
00576   require_once './includes/file.inc';
00577   require_once './modules/system/system.install';
00578
00579   // Load module basics.
00580   include_once './includes/module.inc';
00581   $module_list['system']['filename'] = 'modules/system/system.module';
00582   $module_list['filter']['filename'] = 'modules/filter/filter.module';
00583   module_list(TRUE, FALSE, FALSE, $module_list);
00584   drupal_load('module', 'system');
00585   drupal_load('module', 'filter');
00586
00587   // Set up $language, since the installer components require it.
00588   drupal_init_language();
00589
00590   // Set up theme system for the maintenance page.
00591   drupal_maintenance_theme();
00592
00593   // Check the update requirements for Drupal.
00594   update_check_requirements();
00595
00596   // Display the warning messages (if any) in a dedicated maintenance page,
00597   // or redirect to the update information page if no message.
00598   $messages = drupal_set_message();
00599   if (!empty($messages['warning'])) {
00600     drupal_maintenance_theme();
00601     print theme('update_page', '<form method="post" action="update.php?op=info"><input type="submit" value="Continue" /></form>', FALSE);
00602     exit;
00603   }
00604   install_goto('update.php?op=info');
00605 }
00606
00607 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
00608 drupal_maintenance_theme();
00609
00610 // This must happen *after* drupal_bootstrap(), since it calls
00611 // variable_(get|set), which only works after a full bootstrap.
00612 update_create_batch_table();
00613
00614 // Turn error reporting back on. From now on, only fatal errors (which are
00615 // not passed through the error handler) will cause a message to be printed.
00616 ini_set('display_errors', TRUE);
00617
00618 // Access check:
00619 if (!empty($update_free_access) || $user->uid == 1) {
00620
00621   include_once './includes/install.inc';
00622   include_once './includes/batch.inc';
00623   drupal_load_updates();
00624
00625   update_fix_d6_requirements();
00626   update_fix_compatibility();
00627
00628   $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
00629   switch ($op) {
00630     // update.php ops
00631     case 'info':
00632       $output = update_info_page();
00633       break;
00634
00635     case 'selection':
00636       $output = update_selection_page();
00637       break;
00638
00639     case 'Update':
00640       update_batch();
00641       break;
00642
00643     case 'results':
00644       $output = update_results_page();
00645       break;
00646
00647     // Regular batch ops : defer to batch processing API
00648     default:
00649       update_task_list('run');
00650       $output = _batch_page();
00651       break;
00652   }
00653 }
00654 else {
00655   $output = update_access_denied_page();
00656 }
00657 if (isset($output) && $output) {
00658   // We defer the display of messages until all updates are done.
00659   $progress_page = ($batch = batch_get()) && isset($batch['running']);
00660   print theme('update_page', $output, !$progress_page);
00661 }
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/update/update.report.inc Source File

modules » update

update.report.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: update.report.inc,v 1.10.2.1 2008/02/05 09:59:21 goba Exp $
00003
00012 function update_status() {
00013   if ($available = update_get_available(TRUE)) {
00014     module_load_include('inc', 'update', 'update.compare');
00015     $data = update_calculate_project_data($available);
00016     return theme('update_report', $data);
00017   }
00018   else {
00019     return theme('update_report', _update_no_data());
00020   }
00021 }
00022
00028 function theme_update_report($data) {
00029   $last = variable_get('update_last_check', 0);
00030   $output = '<div class="update checked">'. ($last ? t('Last checked: @time ago', array('@time' => format_interval(time() - $last))) : t('Last checked: never'));
00031   $output .= ' <span class="check-manually">('. l(t('Check manually'), 'admin/reports/updates/check') .')</span>';
00032   $output .= "</div>\n";
00033
00034   if (!is_array($data)) {
00035     $output .= '<p>'. $data .'</p>';
00036     return $output;
00037   }
00038
00039   $header = array();
00040   $rows = array();
00041
00042   $notification_level = variable_get('update_notification_threshold', 'all');
00043
00044   foreach ($data as $project) {
00045     switch ($project['status']) {
00046       case UPDATE_CURRENT:
00047         $class = 'ok';
00048         $icon = theme('image', 'misc/watchdog-ok.png', t('ok'), t('ok'));
00049         break;
00050       case UPDATE_NOT_SECURE:
00051       case UPDATE_REVOKED:
00052       case UPDATE_NOT_SUPPORTED:
00053       case UPDATE_NOT_CURRENT:
00054         if ($notification_level == 'all'
00055             || $project['status'] != UPDATE_NOT_CURRENT) {
00056           $class = 'error';
00057           $icon = theme('image', 'misc/watchdog-error.png', t('error'), t('error'));
00058           break;
00059         }
00060         // Otherwise, deliberate no break and use the warning class/icon.
00061       default:
00062         $class = 'warning';
00063         $icon = theme('image', 'misc/watchdog-warning.png', t('warning'), t('warning'));
00064         break;
00065     }
00066
00067     $row = '<div class="version-status">';
00068     switch ($project['status']) {
00069       case UPDATE_NOT_SECURE:
00070         $row .= '<span class="security-error">'. t('Security update required!') .'</span>';
00071         break;
00072       case UPDATE_REVOKED:
00073         $row .= '<span class="revoked">'. t('Revoked!') .'</span>';
00074         break;
00075       case UPDATE_NOT_SUPPORTED:
00076         $row .= '<span class="not-supported">'. t('Not supported!') .'</span>';
00077         break;
00078       case UPDATE_NOT_CURRENT:
00079         $row .= '<span class="not-current">'. t('Update available') .'</span>';
00080         break;
00081       case UPDATE_CURRENT:
00082         $row .= '<span class="current">'. t('Up to date') .'</span>';
00083         break;
00084       default:
00085         $row .= check_plain($project['reason']);
00086         break;
00087     }
00088     $row .= '<span class="icon">'. $icon .'</span>';
00089     $row .= "</div>\n";
00090
00091     $row .= '<div class="project">';
00092     if (isset($project['title'])) {
00093       if (isset($project['link'])) {
00094         $row .= l($project['title'], $project['link']);
00095       }
00096       else {
00097         $row .= check_plain($project['title']);
00098       }
00099     }
00100     else {
00101       $row .= check_plain($project['name']);
00102     }
00103     $row .= ' '. check_plain($project['existing_version']);
00104     if ($project['install_type'] == 'dev' && !empty($project['datestamp'])) {
00105       $row .= ' <span class="version-date">('. format_date($project['datestamp'], 'custom', 'Y-M-d') .')</span>';
00106     }
00107     $row .= "</div>\n";
00108
00109     $row .= "<div class=\"versions\">\n";
00110
00111     if (isset($project['recommended'])) {
00112       if ($project['status'] != UPDATE_CURRENT || $project['existing_version'] != $project['recommended']) {
00113
00114         // First, figure out what to recommend.
00115         // If there's only 1 security update and it has the same version we're
00116         // recommending, give it the same CSS class as if it was recommended,
00117         // but don't print out a separate "Recommended" line for this project.
00118         if (!empty($project['security updates']) && count($project['security updates']) == 1 && $project['security updates'][0]['version'] == $project['recommended']) {
00119           $security_class = ' version-recommended version-recommended-strong';
00120         }
00121         else {
00122           $security_class = '';
00123           $version_class = 'version-recommended';
00124           // Apply an extra class if we're displaying both a recommended
00125           // version and anything else for an extra visual hint.
00126           if ($project['recommended'] != $project['latest_version']
00127               || !empty($project['also'])
00128               || ($project['install_type'] == 'dev'
00129                  && isset($project['dev_version'])
00130                  && $project['latest_version'] != $project['dev_version']
00131                  && $project['recommended'] != $project['dev_version'])
00132               || (isset($project['security updates'][0])
00133                  && $project['recommended'] != $project['security updates'][0])
00134               ) {
00135             $version_class .= ' version-recommended-strong';
00136           }
00137           $row .= theme('update_version', $project['releases'][$project['recommended']], t('Recommended version:'), $version_class);
00138         }
00139
00140         // Now, print any security updates.
00141         if (!empty($project['security updates'])) {
00142           foreach ($project['security updates'] as $security_update) {
00143             $row .= theme('update_version', $security_update, t('Security update:'), 'version-security'. $security_class);
00144           }
00145         }
00146       }
00147
00148       if ($project['recommended'] != $project['latest_version']) {
00149         $row .= theme('update_version', $project['releases'][$project['latest_version']], t('Latest version:'), 'version-latest');
00150       }
00151       if ($project['install_type'] == 'dev'
00152           && $project['status'] != UPDATE_CURRENT
00153           && isset($project['dev_version'])
00154           && $project['recommended'] != $project['dev_version']) {
00155         $row .= theme('update_version', $project['releases'][$project['dev_version']], t('Development version:'), 'version-latest');
00156       }
00157     }
00158
00159     if (isset($project['also'])) {
00160       foreach ($project['also'] as $also) {
00161         $row .= theme('update_version', $project['releases'][$also], t('Also available:'), 'version-also-available');
00162       }
00163     }
00164
00165     $row .= "</div>\n"; // versions div.
00166
00167     $row .= "<div class=\"info\">\n";
00168     if (!empty($project['extra'])) {
00169       $row .= '<div class="extra">'."\n";
00170       foreach ($project['extra'] as $key => $value) {
00171         $row .= '<div class="'. $value['class'] .'">';
00172         $row .= check_plain($value['label']) .': ';
00173         $row .= theme('placeholder', $value['data']);
00174         $row .= "</div>\n";
00175       }
00176       $row .= "</div>\n";  // extra div.
00177     }
00178
00179     $row .= '<div class="includes">';
00180     sort($project['includes']);
00181     $row .= t('Includes: %includes', array('%includes' => implode(', ', $project['includes'])));
00182     $row .= "</div>\n";
00183
00184     $row .= "</div>\n"; // info div.
00185
00186     if (!isset($rows[$project['project_type']])) {
00187       $rows[$project['project_type']] = array();
00188     }
00189     $rows[$project['project_type']][] = array(
00190       'class' => $class,
00191       'data' => array($row),
00192     );
00193   }
00194
00195   $project_types = array(
00196     'core' => t('Drupal core'),
00197     'module' => t('Modules'),
00198     'theme' => t('Themes'),
00199     'disabled-module' => t('Disabled modules'),
00200     'disabled-theme' => t('Disabled themes'),
00201   );
00202   foreach ($project_types as $type_name => $type_label) {
00203     if (!empty($rows[$type_name])) {
00204       $output .= "\n<h3>". $type_label ."</h3>\n";
00205       $output .= theme('table', $header, $rows[$type_name], array('class' => 'update'));
00206     }
00207   }
00208   drupal_add_css(drupal_get_path('module', 'update') .'/update.css');
00209   return $output;
00210 }
00211
00217 function theme_update_version($version, $tag, $class) {
00218   $output = '';
00219   $output .= '<table class="version '. $class .'">';
00220   $output .= '<tr>';
00221   $output .= '<td class="version-title">'. $tag ."</td>\n";
00222   $output .= '<td class="version-details">';
00223   $output .= l($version['version'], $version['release_link']);
00224   $output .= ' <span class="version-date">('. format_date($version['date'], 'custom', 'Y-M-d') .')</span>';
00225   $output .= "</td>\n";
00226   $output .= '<td class="version-links">';
00227   $links = array();
00228   $links['update-download'] = array(
00229     'title' => t('Download'),
00230     'href' => $version['download_link'],
00231   );
00232   $links['update-release-notes'] = array(
00233     'title' => t('Release notes'),
00234     'href' => $version['release_link'],
00235   );
00236   $output .= theme('links', $links);
00237   $output .= '</td>';
00238   $output .= '</tr>';
00239   $output .= "</table>\n";
00240   return $output;
00241 }
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/update/update.settings.inc Source File

modules » update

update.settings.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: update.settings.inc,v 1.3 2007/10/20 21:57:50 goba Exp $
00003
00012 function update_settings() {
00013   $form = array();
00014
00015   $notify_emails = variable_get('update_notify_emails', array());
00016   $form['update_notify_emails'] = array(
00017     '#type' => 'textarea',
00018     '#title' => t('E-mail addresses to notify when updates are available'),
00019     '#rows' => 4,
00020     '#default_value' => implode("\n", $notify_emails),
00021     '#description' => t('Whenever your site checks for available updates and finds new releases, it can notify a list of users via e-mail. Put each address on a separate line. If blank, no e-mails will be sent.'),
00022   );
00023
00024   $form['update_check_frequency'] = array(
00025     '#type' => 'radios',
00026     '#title' => t('Check for updates'),
00027     '#default_value' => variable_get('update_check_frequency', 1),
00028     '#options' => array(
00029       '1' => t('Daily'),
00030       '7' => t('Weekly'),
00031     ),
00032     '#description' => t('Select how frequently you want to automatically check for new releases of your currently installed modules and themes.'),
00033   );
00034
00035   $form['update_notification_threshold'] = array(
00036     '#type' => 'radios',
00037     '#title' => t('Notification threshold'),
00038     '#default_value' => variable_get('update_notification_threshold', 'all'),
00039     '#options' => array(
00040       'all' => t('All newer versions'),
00041       'security' => t('Only security updates'),
00042     ),
00043     '#description' => t('If there are updates available of Drupal core or any of your installed modules and themes, your site will print an error message on the <a href="@status_report">status report</a>, the <a href="@modules_page">modules page</a>, and the <a href="@themes_page">themes page</a>. You can choose to only see these error messages if a security update is available, or to be notified about any newer versions.', array('@status_report' => url('admin/reports/status'), '@modules_page' => url('admin/build/modules'), '@themes_page' => url('admin/build/themes')))
00044   );
00045
00046   $form = system_settings_form($form);
00047   // Custom valiation callback for the email notification setting.
00048   $form['#validate'][] = 'update_settings_validate';
00049   // We need to call our own submit callback first, not the one from
00050   // system_settings_form(), so that we can process and save the emails.
00051   unset($form['#submit']);
00052
00053   return $form;
00054 }
00055
00061 function update_settings_validate($form, &$form_state) {
00062   if (!empty($form_state['values']['update_notify_emails'])) {
00063     $valid = array();
00064     $invalid = array();
00065     foreach (explode("\n", trim($form_state['values']['update_notify_emails'])) as $email) {
00066       $email = trim($email);
00067       if (!empty($email)) {
00068         if (valid_email_address($email)) {
00069           $valid[] = $email;
00070         }
00071         else {
00072           $invalid[] = $email;
00073         }
00074       }
00075     }
00076     if (empty($invalid)) {
00077       $form_state['notify_emails'] = $valid;
00078     }
00079     elseif (count($invalid) == 1) {
00080       form_set_error('update_notify_emails', t('%email is not a valid e-mail address.', array('%email' => reset($invalid))));
00081     }
00082     else {
00083       form_set_error('update_notify_emails', t('%emails are not valid e-mail addresses.', array('%emails' => implode(', ', $invalid))));
00084     }
00085   }
00086 }
00087
00091 function update_settings_submit($form, $form_state) {
00092   $op = $form_state['values']['op'];
00093
00094   if ($op == t('Reset to defaults')) {
00095     unset($form_state['notify_emails']);
00096   }
00097   else {
00098     if (empty($form_state['notify_emails'])) {
00099       variable_del('update_notify_emails');
00100     }
00101     else {
00102       variable_set('update_notify_emails', $form_state['notify_emails']);
00103     }
00104     unset($form_state['notify_emails']);
00105     unset($form_state['values']['update_notify_emails']);
00106   }
00107   system_settings_form_submit($form, $form_state);
00108 }
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/upload/upload.admin.inc Source File

modules » upload

upload.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: upload.admin.inc,v 1.7 2008/01/10 20:22:57 goba Exp $
00003
00007 function upload_admin_settings_validate($form, &$form_state) {
00008   if (($form_state['values']['upload_max_resolution'] != '0')) {
00009     if (!preg_match('/^[0-9]+x[0-9]+$/', $form_state['values']['upload_max_resolution'])) {
00010       form_set_error('upload_max_resolution', t('The maximum allowed image size expressed as WIDTHxHEIGHT (e.g. 640x480). Set to 0 for no restriction.'));
00011     }
00012   }
00013
00014   $default_uploadsize = $form_state['values']['upload_uploadsize_default'];
00015   $default_usersize = $form_state['values']['upload_usersize_default'];
00016
00017   $exceed_max_msg = t('Your PHP settings limit the maximum file size per upload to %size.', array('%size' => format_size(file_upload_max_size()))) .'<br/>';
00018   $more_info = t("Depending on your server environment, these settings may be changed in the system-wide php.ini file, a php.ini file in your Drupal root directory, in your Drupal site's settings.php file, or in the .htaccess file in your Drupal root directory.");
00019
00020   if (!is_numeric($default_uploadsize) || ($default_uploadsize <= 0)) {
00021     form_set_error('upload_uploadsize_default', t('The %role file size limit must be a number and greater than zero.', array('%role' => t('default'))));
00022   }
00023   if (!is_numeric($default_usersize) || ($default_usersize <= 0)) {
00024     form_set_error('upload_usersize_default', t('The %role file size limit must be a number and greater than zero.', array('%role' => t('default'))));
00025   }
00026   if ($default_uploadsize * 1024 * 1024 > file_upload_max_size()) {
00027     form_set_error('upload_uploadsize_default', $exceed_max_msg . $more_info);
00028     $more_info = '';
00029   }
00030   if ($default_uploadsize > $default_usersize) {
00031     form_set_error('upload_uploadsize_default', t('The %role maximum file size per upload is greater than the total file size allowed per user', array('%role' => t('default'))));
00032   }
00033
00034   foreach ($form_state['values']['roles'] as $rid => $role) {
00035     $uploadsize = $form_state['values']['upload_uploadsize_'. $rid];
00036     $usersize = $form_state['values']['upload_usersize_'. $rid];
00037
00038     if (!is_numeric($uploadsize) || ($uploadsize <= 0)) {
00039       form_set_error('upload_uploadsize_'. $rid, t('The %role file size limit must be a number and greater than zero.', array('%role' => $role)));
00040     }
00041     if (!is_numeric($usersize) || ($usersize <= 0)) {
00042       form_set_error('upload_usersize_'. $rid, t('The %role file size limit must be a number and greater than zero.', array('%role' => $role)));
00043     }
00044     if ($uploadsize * 1024 * 1024 > file_upload_max_size()) {
00045       form_set_error('upload_uploadsize_'. $rid, $exceed_max_msg . $more_info);
00046       $more_info = '';
00047     }
00048     if ($uploadsize > $usersize) {
00049       form_set_error('upload_uploadsize_'. $rid, t('The %role maximum file size per upload is greater than the total file size allowed per user', array('%role' => $role)));
00050     }
00051   }
00052 }
00053
00057 function upload_admin_settings() {
00058   $upload_extensions_default = variable_get('upload_extensions_default', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp');
00059   $upload_uploadsize_default = variable_get('upload_uploadsize_default', 1);
00060   $upload_usersize_default = variable_get('upload_usersize_default', 1);
00061
00062   $form['settings_general'] = array(
00063     '#type' => 'fieldset',
00064     '#title' => t('General settings'),
00065     '#collapsible' => TRUE,
00066   );
00067   $form['settings_general']['upload_max_resolution'] = array(
00068     '#type' => 'textfield',
00069     '#title' => t('Maximum resolution for uploaded images'),
00070     '#default_value' => variable_get('upload_max_resolution', 0),
00071     '#size' => 15,
00072     '#maxlength' => 10,
00073     '#description' => t('The maximum allowed image size (e.g. 640x480). Set to 0 for no restriction. If an <a href="!image-toolkit-link">image toolkit</a> is installed, files exceeding this value will be scaled down to fit.', array('!image-toolkit-link' => url('admin/settings/image-toolkit'))),
00074     '#field_suffix' => '<kbd>'. t('WIDTHxHEIGHT') .'</kbd>'
00075   );
00076   $form['settings_general']['upload_list_default'] = array(
00077     '#type' => 'select',
00078     '#title' => t('List files by default'),
00079     '#default_value' => variable_get('upload_list_default', 1),
00080     '#options' => array(0 => t('No'), 1 => t('Yes')),
00081     '#description' => t('Display attached files when viewing a post.'),
00082   );
00083
00084   $form['settings_general']['upload_extensions_default'] = array(
00085     '#type' => 'textfield',
00086     '#title' => t('Default permitted file extensions'),
00087     '#default_value' => $upload_extensions_default,
00088     '#maxlength' => 255,
00089     '#description' => t('Default extensions that users can upload. Separate extensions with a space and do not include the leading dot.'),
00090   );
00091   $form['settings_general']['upload_uploadsize_default'] = array(
00092     '#type' => 'textfield',
00093     '#title' => t('Default maximum file size per upload'),
00094     '#default_value' => $upload_uploadsize_default,
00095     '#size' => 5,
00096     '#maxlength' => 5,
00097     '#description' => t('The default maximum file size a user can upload. If an image is uploaded and a maximum resolution is set, the size will be checked after the file has been resized.'),
00098     '#field_suffix' => t('MB'),
00099   );
00100   $form['settings_general']['upload_usersize_default'] = array(
00101     '#type' => 'textfield',
00102     '#title' => t('Default total file size per user'),
00103     '#default_value' => $upload_usersize_default,
00104     '#size' => 5,
00105     '#maxlength' => 5,
00106     '#description' => t('The default maximum size of all files a user can have on the site.'),
00107     '#field_suffix' => t('MB'),
00108   );
00109
00110   $form['settings_general']['upload_max_size'] = array('#value' => '<p>'. t('Your PHP settings limit the maximum file size per upload to %size.', array('%size' => format_size(file_upload_max_size()))) .'</p>');
00111
00112   $roles = user_roles(FALSE, 'upload files');
00113   $form['roles'] = array('#type' => 'value', '#value' => $roles);
00114
00115   foreach ($roles as $rid => $role) {
00116     $form['settings_role_'. $rid] = array(
00117       '#type' => 'fieldset',
00118       '#title' => t('Settings for @role', array('@role' => $role)),
00119       '#collapsible' => TRUE,
00120       '#collapsed' => TRUE,
00121     );
00122     $form['settings_role_'. $rid]['upload_extensions_'. $rid] = array(
00123       '#type' => 'textfield',
00124       '#title' => t('Permitted file extensions'),
00125       '#default_value' => variable_get('upload_extensions_'. $rid, $upload_extensions_default),
00126       '#maxlength' => 255,
00127       '#description' => t('Extensions that users in this role can upload. Separate extensions with a space and do not include the leading dot.'),
00128     );
00129     $form['settings_role_'. $rid]['upload_uploadsize_'. $rid] = array(
00130       '#type' => 'textfield',
00131       '#title' => t('Maximum file size per upload'),
00132       '#default_value' => variable_get('upload_uploadsize_'. $rid, $upload_uploadsize_default),
00133       '#size' => 5,
00134       '#maxlength' => 5,
00135       '#description' => t('The maximum size of a file a user can upload. If an image is uploaded and a maximum resolution is set, the size will be checked after the file has been resized.'),
00136       '#field_suffix' => t('MB'),
00137     );
00138     $form['settings_role_'. $rid]['upload_usersize_'. $rid] = array(
00139       '#type' => 'textfield',
00140       '#title' => t('Total file size per user'),
00141       '#default_value' => variable_get('upload_usersize_'. $rid, $upload_usersize_default),
00142       '#size' => 5,
00143       '#maxlength' => 5,
00144       '#description' => t('The maximum size of all files a user can have on the site.'),
00145       '#field_suffix' => t('MB'),
00146     );
00147   }
00148
00149   $form['#validate'] = array('upload_admin_settings_validate');
00150
00151   return system_settings_form($form);
00152 }
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/upload/upload.install Source File

modules » upload

upload.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: upload.install,v 1.6.2.1 2008/02/08 18:01:14 goba Exp $
00003
00007 function upload_install() {
00008   // Create table. The upload table might have been created in the Drupal 5
00009   // to Drupal 6 upgrade, and was migrated from the file_revisions table. So
00010   // in this case, there is no need to create the table, it is already there.
00011   if (!db_table_exists('upload')) {
00012     drupal_install_schema('upload');
00013   }
00014 }
00015
00019 function upload_uninstall() {
00020   // Remove tables.
00021   drupal_uninstall_schema('upload');
00022 }
00023
00027 function upload_schema() {
00028   $schema['upload'] = array(
00029     'description' => t('Stores uploaded file information and table associations.'),
00030     'fields' => array(
00031       'fid' => array(
00032         'type' => 'int',
00033         'unsigned' => TRUE,
00034         'not null' => TRUE,
00035         'default' => 0,
00036         'description' => t('Primary Key: The {files}.fid.'),
00037       ),
00038       'nid' => array(
00039         'type' => 'int',
00040         'unsigned' => TRUE,
00041         'not null' => TRUE,
00042         'default' => 0,
00043         'description' => t('The {node}.nid associated with the uploaded file.'),
00044       ),
00045       'vid' => array(
00046         'type' => 'int',
00047         'unsigned' => TRUE,
00048         'not null' => TRUE,
00049         'default' => 0,
00050         'description' => t('Primary Key: The {node}.vid associated with the uploaded file.'),
00051       ),
00052       'description' => array(
00053         'type' => 'varchar',
00054         'length' => 255,
00055         'not null' => TRUE,
00056         'default' => '',
00057         'description' => t('Description of the uploaded file.'),
00058       ),
00059       'list' => array(
00060         'type' => 'int',
00061         'unsigned' => TRUE,
00062         'not null' => TRUE,
00063         'default' => 0,
00064         'size' => 'tiny',
00065         'description' => t('Whether the file should be visibly listed on the node: yes(1) or no(0).'),
00066       ),
00067       'weight' => array(
00068         'type' => 'int',
00069         'not null' => TRUE,
00070         'default' => 0,
00071         'size' => 'tiny',
00072         'description' => t('Weight of this upload in relation to other uploads in this node.'),
00073       ),
00074     ),
00075     'primary key' => array('vid', 'fid'),
00076     'indexes' => array(
00077       'fid' => array('fid'),
00078       'nid' => array('nid'),
00079     ),
00080   );
00081
00082   return $schema;
00083 }
00084
00085
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/upload/upload.module Source File

modules » upload

upload.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: upload.module,v 1.197.2.1 2008/02/11 15:08:09 goba Exp $
00003
00013 function upload_help($path, $arg) {
00014   switch ($path) {
00015     case 'admin/help#upload':
00016       $output = '<p>'. t('The upload module allows users to upload files to the site. The ability to upload files is important for members of a community who want to share work. It is also useful to administrators who want to keep uploaded files connected to posts.') .'</p>';
00017       $output .= '<p>'. t('Users with the upload files permission can upload attachments to posts. Uploads may be enabled for specific content types on the content types settings page. Each user role can be customized to limit or control the file size of uploads, or the maximum dimension of image files.') .'</p>';
00018       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@upload">Upload module</a>.', array('@upload' => 'http://drupal.org/handbook/modules/upload/')) .'</p>';
00019       return $output;
00020     case 'admin/settings/upload':
00021       return '<p>'. t('Users with the <a href="@permissions">upload files permission</a> can upload attachments. Users with the <a href="@permissions">view uploaded files permission</a> can view uploaded attachments. You can choose which post types can take attachments on the <a href="@types">content types settings</a> page.', array('@permissions' => url('admin/user/permissions'), '@types' => url('admin/settings/types'))) .'</p>';
00022   }
00023 }
00024
00028 function upload_theme() {
00029   return array(
00030     'upload_attachments' => array(
00031       'arguments' => array('files' => NULL),
00032     ),
00033     'upload_form_current' => array(
00034       'arguments' => array('form' => NULL),
00035     ),
00036     'upload_form_new' => array(
00037       'arguments' => array('form' => NULL),
00038     ),
00039   );
00040 }
00041
00045 function upload_perm() {
00046   return array('upload files', 'view uploaded files');
00047 }
00048
00052 function upload_link($type, $node = NULL, $teaser = FALSE) {
00053   $links = array();
00054
00055   // Display a link with the number of attachments
00056   if ($teaser && $type == 'node' && isset($node->files) && user_access('view uploaded files')) {
00057     $num_files = 0;
00058     foreach ($node->files as $file) {
00059       if ($file->list) {
00060         $num_files++;
00061       }
00062     }
00063     if ($num_files) {
00064       $links['upload_attachments'] = array(
00065         'title' => format_plural($num_files, '1 attachment', '@count attachments'),
00066         'href' => "node/$node->nid",
00067         'attributes' => array('title' => t('Read full article to view attachments.')),
00068         'fragment' => 'attachments'
00069       );
00070     }
00071   }
00072
00073   return $links;
00074 }
00075
00079 function upload_menu() {
00080   $items['upload/js'] = array(
00081     'page callback' => 'upload_js',
00082     'access arguments' => array('upload files'),
00083     'type' => MENU_CALLBACK,
00084   );
00085   $items['admin/settings/uploads'] = array(
00086     'title' => 'File uploads',
00087     'description' => 'Control how files may be attached to content.',
00088     'page callback' => 'drupal_get_form',
00089     'page arguments' => array('upload_admin_settings'),
00090     'access arguments' => array('administer site configuration'),
00091     'type' => MENU_NORMAL_ITEM,
00092     'file' => 'upload.admin.inc',
00093   );
00094   return $items;
00095 }
00096
00097 function upload_menu_alter(&$items) {
00098   $items['system/files']['access arguments'] = array('view uploaded files');
00099 }
00100
00120 function _upload_file_limits($user) {
00121   $file_limit = variable_get('upload_uploadsize_default', 1);
00122   $user_limit = variable_get('upload_usersize_default', 1);
00123   $all_extensions = explode(' ', variable_get('upload_extensions_default', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp'));
00124   foreach ($user->roles as $rid => $name) {
00125     $extensions = variable_get("upload_extensions_$rid", variable_get('upload_extensions_default', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp'));
00126     $all_extensions = array_merge($all_extensions, explode(' ', $extensions));
00127
00128     // A zero value indicates no limit, take the least restrictive limit.
00129     $file_size = variable_get("upload_uploadsize_$rid", variable_get('upload_uploadsize_default', 1)) * 1024 * 1024;
00130     $file_limit = ($file_limit && $file_size) ? max($file_limit, $file_size) : 0;
00131
00132     $user_size = variable_get("upload_usersize_$rid", variable_get('upload_usersize_default', 1)) * 1024 * 1024;
00133     $user_limit = ($user_limit && $user_size) ? max($user_limit, $user_size) : 0;
00134   }
00135   $all_extensions = implode(' ', array_unique($all_extensions));
00136   return array(
00137     'extensions' => $all_extensions,
00138     'file_size' => $file_limit,
00139     'user_size' => $user_limit,
00140     'resolution' => variable_get('upload_max_resolution', 0),
00141   );
00142 }
00143
00147 function upload_file_download($file) {
00148   if (!user_access('view uploaded files')) {
00149     return -1;
00150   }
00151   $file = file_create_path($file);
00152   $result = db_query("SELECT f.* FROM {files} f INNER JOIN {upload} u ON f.fid = u.fid WHERE filepath = '%s'", $file);
00153   if ($file = db_fetch_object($result)) {
00154     return array(
00155       'Content-Type: '. $file->filemime,
00156       'Content-Length: '. $file->filesize,
00157     );
00158   }
00159 }
00160
00168 function upload_node_form_submit($form, &$form_state) {
00169   global $user;
00170
00171   $limits = _upload_file_limits($user);
00172   $validators = array(
00173     'file_validate_extensions' => array($limits['extensions']),
00174     'file_validate_image_resolution' => array($limits['resolution']),
00175     'file_validate_size' => array($limits['file_size'], $limits['user_size']),
00176   );
00177
00178   // Save new file uploads.
00179   if (($user->uid != 1 || user_access('upload files')) && ($file = file_save_upload('upload', $validators, file_directory_path()))) {
00180     $file->list = variable_get('upload_list_default', 1);
00181     $file->description = $file->filename;
00182     $file->weight = 0;
00183     $_SESSION['upload_files'][$file->fid] = $file;
00184   }
00185
00186   // Attach session files to node.
00187   if (!empty($_SESSION['upload_files'])) {
00188     foreach ($_SESSION['upload_files'] as $fid => $file) {
00189       if (!isset($form_state['values']['files'][$fid]['filepath'])) {
00190         $form_state['values']['files'][$fid] = (array)$file;
00191       }
00192     }
00193   }
00194
00195   // Order the form according to the set file weight values.
00196   if (!empty($form_state['values']['files'])) {
00197     $microweight = 0.001;
00198     foreach ($form_state['values']['files'] as $fid => $file) {
00199       if (is_numeric($fid)) {
00200         $form_state['values']['files'][$fid]['#weight'] = $file['weight'] + $microweight;
00201         $microweight += 0.001;
00202       }
00203     }
00204     uasort($form_state['values']['files'], 'element_sort');
00205   }
00206 }
00207
00208 function upload_form_alter(&$form, $form_state, $form_id) {
00209   if ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
00210     $form['workflow']['upload'] = array(
00211       '#type' => 'radios',
00212       '#title' => t('Attachments'),
00213       '#default_value' => variable_get('upload_'. $form['#node_type']->type, 1),
00214       '#options' => array(t('Disabled'), t('Enabled')),
00215     );
00216   }
00217
00218   if (isset($form['type']) && isset($form['#node'])) {
00219     $node = $form['#node'];
00220     if ($form['type']['#value'] .'_node_form' == $form_id && variable_get("upload_$node->type", TRUE)) {
00221       // Attachments fieldset
00222       $form['attachments'] = array(
00223         '#type' => 'fieldset',
00224         '#access' => user_access('upload files'),
00225         '#title' => t('File attachments'),
00226         '#collapsible' => TRUE,
00227         '#collapsed' => empty($node->files),
00228         '#description' => t('Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.'),
00229         '#prefix' => '<div class="attachments">',
00230         '#suffix' => '</div>',
00231         '#weight' => 30,
00232       );
00233
00234       // Wrapper for fieldset contents (used by ahah.js).
00235       $form['attachments']['wrapper'] = array(
00236         '#prefix' => '<div id="attach-wrapper">',
00237         '#suffix' => '</div>',
00238       );
00239
00240       // Make sure necessary directories for upload.module exist and are
00241       // writable before displaying the attachment form.
00242       $path = file_directory_path();
00243       $temp = file_directory_temp();
00244       // Note: pass by reference
00245       if (!file_check_directory($path, FILE_CREATE_DIRECTORY) || !file_check_directory($temp, FILE_CREATE_DIRECTORY)) {
00246         $form['attachments']['#description'] =  t('File attachments are disabled. The file directories have not been properly configured.');
00247         if (user_access('administer site configuration')) {
00248           $form['attachments']['#description'] .= ' '. t('Please visit the <a href="@admin-file-system">file system configuration page</a>.', array('@admin-file-system' => url('admin/settings/file-system')));
00249         }
00250         else {
00251           $form['attachments']['#description'] .= ' '. t('Please contact the site administrator.');
00252         }
00253       }
00254       else {
00255         $form['attachments']['wrapper'] += _upload_form($node);
00256         $form['#attributes']['enctype'] = 'multipart/form-data';
00257       }
00258     }
00259     $form['#submit'][] = 'upload_node_form_submit';
00260   }
00261 }
00262
00266 function upload_nodeapi(&$node, $op, $teaser) {
00267   switch ($op) {
00268
00269     case 'load':
00270       $output = '';
00271       if (variable_get("upload_$node->type", 1) == 1) {
00272         $output['files'] = upload_load($node);
00273         return $output;
00274       }
00275       break;
00276
00277     case 'view':
00278       if (isset($node->files) && user_access('view uploaded files')) {
00279         // Add the attachments list to node body with a heavy
00280         // weight to ensure they're below other elements
00281         if (count($node->files)) {
00282           if (!$teaser && user_access('view uploaded files')) {
00283             $node->content['files'] = array(
00284               '#value' => theme('upload_attachments', $node->files),
00285               '#weight' => 50,
00286             );
00287           }
00288         }
00289       }
00290       break;
00291
00292     case 'prepare':
00293       // Initialize $_SESSION['upload_files'] if no post occurred.
00294       // This clears the variable from old forms and makes sure it
00295       // is an array to prevent notices and errors in other parts
00296       // of upload.module.
00297       if (!$_POST) {
00298         $_SESSION['upload_files'] = array();
00299       }
00300       break;
00301
00302     case 'insert':
00303     case 'update':
00304       if (user_access('upload files')) {
00305         upload_save($node);
00306       }
00307       break;
00308
00309     case 'delete':
00310       upload_delete($node);
00311       break;
00312
00313     case 'delete revision':
00314       upload_delete_revision($node);
00315       break;
00316
00317     case 'search result':
00318       return isset($node->files) && is_array($node->files) ? format_plural(count($node->files), '1 attachment', '@count attachments') : NULL;
00319
00320     case 'rss item':
00321       if (is_array($node->files)) {
00322         $files = array();
00323         foreach ($node->files as $file) {
00324           if ($file->list) {
00325             $files[] = $file;
00326           }
00327         }
00328         if (count($files) > 0) {
00329           // RSS only allows one enclosure per item
00330           $file = array_shift($files);
00331           return array(
00332             array(
00333               'key' => 'enclosure',
00334               'attributes' => array(
00335                 'url' => file_create_url($file->filepath),
00336                 'length' => $file->filesize,
00337                 'type' => $file->filemime
00338               )
00339             )
00340           );
00341         }
00342       }
00343       return array();
00344   }
00345 }
00346
00352 function theme_upload_attachments($files) {
00353   $header = array(t('Attachment'), t('Size'));
00354   $rows = array();
00355   foreach ($files as $file) {
00356     $file = (object)$file;
00357     if ($file->list && empty($file->remove)) {
00358       $href = file_create_url($file->filepath);
00359       $text = $file->description ? $file->description : $file->filename;
00360       $rows[] = array(l($text, $href), format_size($file->filesize));
00361     }
00362   }
00363   if (count($rows)) {
00364     return theme('table', $header, $rows, array('id' => 'attachments'));
00365   }
00366 }
00367
00376 function upload_space_used($uid) {
00377   return file_space_used($uid);
00378 }
00379
00386 function upload_total_space_used() {
00387   return db_result(db_query('SELECT SUM(f.filesize) FROM {files} f INNER JOIN {upload} u ON f.fid = u.fid'));
00388 }
00389
00390 function upload_save(&$node) {
00391   if (empty($node->files) || !is_array($node->files)) {
00392     return;
00393   }
00394
00395   foreach ($node->files as $fid => $file) {
00396     // Convert file to object for compatibility
00397     $file = (object)$file;
00398
00399     // Remove file. Process removals first since no further processing
00400     // will be required.
00401     if (!empty($file->remove)) {
00402       db_query('DELETE FROM {upload} WHERE fid = %d AND vid = %d', $fid, $node->vid);
00403
00404       // If the file isn't used by any other revisions delete it.
00405       $count = db_result(db_query('SELECT COUNT(fid) FROM {upload} WHERE fid = %d', $fid));
00406       if ($count < 1) {
00407         file_delete($file->filepath);
00408         db_query('DELETE FROM {files} WHERE fid = %d', $fid);
00409       }
00410
00411       // Remove it from the session in the case of new uploads,
00412       // that you want to disassociate before node submission.
00413       unset($_SESSION['upload_files'][$fid]);
00414       // Move on, so the removed file won't be added to new revisions.
00415       continue;
00416     }
00417
00418     // Create a new revision, or associate a new file needed.
00419     if (!empty($node->old_vid) || isset($_SESSION['upload_files'][$fid])) {
00420       db_query("INSERT INTO {upload} (fid, nid, vid, list, description, weight) VALUES (%d, %d, %d, %d, '%s', %d)", $file->fid, $node->nid, $node->vid, $file->list, $file->description, $file->weight);
00421       file_set_status($file, FILE_STATUS_PERMANENT);
00422     }
00423     // Update existing revision.
00424     else {
00425       db_query("UPDATE {upload} SET list = %d, description = '%s', weight = %d WHERE fid = %d AND vid = %d", $file->list, $file->description, $file->weight, $file->fid, $node->vid);
00426       file_set_status($file, FILE_STATUS_PERMANENT);
00427     }
00428   }
00429   // Empty the session storage after save. We use this variable to track files
00430   // that haven't been related to the node yet.
00431   unset($_SESSION['upload_files']);
00432 }
00433
00434 function upload_delete($node) {
00435   $files = array();
00436   $result = db_query('SELECT DISTINCT f.* FROM {upload} u INNER JOIN {files} f ON u.fid = f.fid WHERE u.nid = %d', $node->nid);
00437   while ($file = db_fetch_object($result)) {
00438     $files[$file->fid] = $file;
00439   }
00440
00441   foreach ($files as $fid => $file) {
00442     // Delete all files associated with the node
00443     db_query('DELETE FROM {files} WHERE fid = %d', $fid);
00444     file_delete($file->filepath);
00445   }
00446
00447   // Delete all file revision information associated with the node
00448   db_query('DELETE FROM {upload} WHERE nid = %d', $node->nid);
00449 }
00450
00451 function upload_delete_revision($node) {
00452   if (is_array($node->files)) {
00453     foreach ($node->files as $file) {
00454       // Check if the file will be used after this revision is deleted
00455       $count = db_result(db_query('SELECT COUNT(fid) FROM {upload} WHERE fid = %d', $file->fid));
00456
00457       // if the file won't be used, delete it
00458       if ($count < 2) {
00459         db_query('DELETE FROM {files} WHERE fid = %d', $file->fid);
00460         file_delete($file->filepath);
00461       }
00462     }
00463   }
00464
00465   // delete the revision
00466   db_query('DELETE FROM {upload} WHERE vid = %d', $node->vid);
00467 }
00468
00469 function _upload_form($node) {
00470   global $user;
00471
00472   $form = array(
00473     '#theme' => 'upload_form_new',
00474     '#cache' => TRUE,
00475   );
00476
00477   if (!empty($node->files) && is_array($node->files)) {
00478     $form['files']['#theme'] = 'upload_form_current';
00479     $form['files']['#tree'] = TRUE;
00480     foreach ($node->files as $key => $file) {
00481       $file = (object)$file;
00482       $description = file_create_url($file->filepath);
00483       $description = "<small>". check_plain($description) ."</small>";
00484       $form['files'][$key]['description'] = array('#type' => 'textfield', '#default_value' => !empty($file->description) ? $file->description : $file->filename, '#maxlength' => 256, '#description' => $description );
00485       $form['files'][$key]['size'] = array('#value' => format_size($file->filesize));
00486       $form['files'][$key]['remove'] = array('#type' => 'checkbox', '#default_value' => !empty($file->remove));
00487       $form['files'][$key]['list'] = array('#type' => 'checkbox',  '#default_value' => $file->list);
00488       $form['files'][$key]['weight'] = array('#type' => 'weight', '#delta' => count($node->files), '#default_value' => $file->weight);
00489       $form['files'][$key]['filename'] = array('#type' => 'value',  '#value' => $file->filename);
00490       $form['files'][$key]['filepath'] = array('#type' => 'value',  '#value' => $file->filepath);
00491       $form['files'][$key]['filemime'] = array('#type' => 'value',  '#value' => $file->filemime);
00492       $form['files'][$key]['filesize'] = array('#type' => 'value',  '#value' => $file->filesize);
00493       $form['files'][$key]['fid'] = array('#type' => 'value',  '#value' => $file->fid);
00494     }
00495   }
00496
00497   if (user_access('upload files')) {
00498     $limits = _upload_file_limits($user);
00499     $form['new']['#weight'] = 10;
00500     $form['new']['upload'] = array(
00501       '#type' => 'file',
00502       '#title' => t('Attach new file'),
00503       '#size' => 40,
00504       '#description' => ($limits['resolution'] ? t('Images are larger than %resolution will be resized. ', array('%resolution' => $limits['resolution'])) : '') . t('The maximum upload size is %filesize. Only files with the following extensions may be uploaded: %extensions. ', array('%extensions' => $limits['extensions'], '%filesize' => format_size($limits['file_size']))),
00505     );
00506     $form['new']['attach'] = array(
00507       '#type' => 'submit',
00508       '#value' => t('Attach'),
00509       '#name' => 'attach',
00510       '#ahah' => array(
00511         'path' => 'upload/js',
00512         'wrapper' => 'attach-wrapper',
00513         'progress' => array('type' => 'bar', 'message' => t('Please wait...')),
00514       ),
00515       '#submit' => array('node_form_submit_build_node'),
00516     );
00517   }
00518
00519   // This value is used in upload_js().
00520   $form['current']['vid'] = array('#type' => 'hidden', '#value' => isset($node->vid) ? $node->vid : 0);
00521   return $form;
00522 }
00523
00529 function theme_upload_form_current(&$form) {
00530   $header = array('', t('Delete'), t('List'), t('Description'), t('Weight'), t('Size'));
00531   drupal_add_tabledrag('upload-attachments', 'order', 'sibling', 'upload-weight');
00532
00533   foreach (element_children($form) as $key) {
00534     // Add class to group weight fields for drag and drop.
00535     $form[$key]['weight']['#attributes']['class'] = 'upload-weight';
00536
00537     $row = array('');
00538     $row[] = drupal_render($form[$key]['remove']);
00539     $row[] = drupal_render($form[$key]['list']);
00540     $row[] = drupal_render($form[$key]['description']);
00541     $row[] = drupal_render($form[$key]['weight']);
00542     $row[] = drupal_render($form[$key]['size']);
00543     $rows[] = array('data' => $row, 'class' => 'draggable');
00544   }
00545   $output = theme('table', $header, $rows, array('id' => 'upload-attachments'));
00546   $output .= drupal_render($form);
00547   return $output;
00548 }
00549
00556 function theme_upload_form_new($form) {
00557   drupal_add_tabledrag('upload-attachments', 'order', 'sibling', 'upload-weight');
00558   $output = drupal_render($form);
00559   return $output;
00560 }
00561
00562 function upload_load($node) {
00563   $files = array();
00564
00565   if ($node->vid) {
00566     $result = db_query('SELECT * FROM {files} f INNER JOIN {upload} r ON f.fid = r.fid WHERE r.vid = %d ORDER BY r.weight, f.fid', $node->vid);
00567     while ($file = db_fetch_object($result)) {
00568       $files[$file->fid] = $file;
00569     }
00570   }
00571
00572   return $files;
00573 }
00574
00578 function upload_js() {
00579   // Load the form from the Form API cache.
00580   $cache = cache_get('form_'. $_POST['form_build_id'], 'cache_form');
00581
00582   // We only do the upload.module part of the node validation process.
00583   $node = (object)$_POST;
00584   unset($node->files['upload']);
00585   $form = $cache->data;
00586   $form_state = array('values' => $_POST);
00587
00588   // Handle new uploads, and merge tmp files into node-files.
00589   upload_node_form_submit($form, $form_state);
00590   $node_files = upload_load($node);
00591   if (!empty($form_state['values']['files'])) {
00592     foreach ($form_state['values']['files'] as $fid => $file) {
00593       if (is_numeric($fid)) {
00594         $node->files[$fid] = $file;
00595         if (!isset($file['filepath'])) {
00596           $node->files[$fid] = $node_files[$fid];
00597         }
00598       }
00599     }
00600   }
00601   $form = _upload_form($node);
00602
00603   // Update the default values changed in the $_POST array.
00604   $files = isset($_POST['files']) ? $_POST['files'] : array();
00605   foreach ($files as $fid => $file) {
00606     if (is_numeric($fid)) {
00607       $form['files'][$fid]['description']['#default_value'] = $file['description'];
00608       $form['files'][$fid]['list']['#default_value'] = isset($file['list']) ? 1 : 0;
00609       $form['files'][$fid]['remove']['#default_value'] = isset($file['remove']) ? 1 : 0;
00610       $form['files'][$fid]['weight']['#default_value'] = $file['weight'];
00611     }
00612   }
00613
00614   // Add the new element to the stored form state and resave.
00615   $cache->data['attachments']['wrapper'] = array_merge($cache->data['attachments']['wrapper'], $form);
00616   cache_set('form_'. $_POST['form_build_id'], $cache->data, 'cache_form', $cache->expire);
00617
00618   // Render the form for output.
00619   $form += array(
00620     '#post' => $_POST,
00621     '#programmed' => FALSE,
00622     '#tree' => FALSE,
00623     '#parents' => array(),
00624   );
00625   drupal_alter('form', $form, array(), 'upload_js');
00626   $form_state = array('submitted' => FALSE);
00627   $form = form_builder('upload_js', $form, $form_state);
00628   $output = theme('status_messages') . drupal_render($form);
00629
00630   // We send the updated file attachments form.
00631   // Don't call drupal_json(). ahah.js uses an iframe and
00632   // the header output by drupal_json() causes problems in some browsers.
00633   print drupal_to_js(array('status' => TRUE, 'data' => $output));
00634   exit;
00635 }
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/user/user-picture.tpl.php Source File

modules » user

user-picture.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: user-picture.tpl.php,v 1.2 2007/08/07 08:39:36 goba Exp $
00003
00017 ?>
00018 <div class="picture">
00019   <?php print $picture; ?>
00020 </div>
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/user/user-profile-category.tpl.php Source File

modules » user

user-profile-category.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: user-profile-category.tpl.php,v 1.2 2007/08/07 08:39:36 goba Exp $
00003
00027 ?>
00028 <?php if ($title) : ?>
00029   <h3><?php print $title; ?></h3>
00030 <?php endif; ?>
00031
00032 <dl<?php print $attributes; ?>>
00033   <?php print $profile_items; ?>
00034 </dl>
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/user/user-profile-item.tpl.php Source File

modules » user

user-profile-item.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: user-profile-item.tpl.php,v 1.2 2007/08/07 08:39:36 goba Exp $
00003
00025 ?>
00026 <dt<?php print $attributes; ?>><?php print $title; ?></dt>
00027 <dd<?php print $attributes; ?>><?php print $value; ?></dd>
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/user/user-profile.tpl.php Source File

modules » user

user-profile.tpl.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: user-profile.tpl.php,v 1.2 2007/08/07 08:39:36 goba Exp $
00003
00043 ?>
00044 <div class="profile">
00045   <?php print $user_profile; ?>
00046 </div>
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/user/user.admin.inc Source File

modules » user

user.admin.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: user.admin.inc,v 1.18 2008/01/16 22:54:41 goba Exp $
00003
00009 function user_admin($callback_arg = '') {
00010   $op = isset($_POST['op']) ? $_POST['op'] : $callback_arg;
00011
00012   switch ($op) {
00013     case t('Create new account'):
00014     case 'create':
00015       $output = drupal_get_form('user_register');
00016       break;
00017     default:
00018       if (!empty($_POST['accounts']) && isset($_POST['operation']) && ($_POST['operation'] == 'delete')) {
00019         $output = drupal_get_form('user_multiple_delete_confirm');
00020       }
00021       else {
00022         $output = drupal_get_form('user_filter_form');
00023         $output .= drupal_get_form('user_admin_account');
00024       }
00025   }
00026   return $output;
00027 }
00028
00035 function user_filter_form() {
00036   $session = &$_SESSION['user_overview_filter'];
00037   $session = is_array($session) ? $session : array();
00038   $filters = user_filters();
00039
00040   $i = 0;
00041   $form['filters'] = array(
00042     '#type' => 'fieldset',
00043     '#title' => t('Show only users where'),
00044     '#theme' => 'user_filters',
00045   );
00046   foreach ($session as $filter) {
00047     list($type, $value) = $filter;
00048     // Merge an array of arrays into one if necessary.
00049     $options = $type == 'permission' ? call_user_func_array('array_merge', $filters[$type]['options']) : $filters[$type]['options'];
00050     $params = array('%property' => $filters[$type]['title'] , '%value' => $options[$value]);
00051     if ($i++ > 0) {
00052       $form['filters']['current'][] = array('#value' => t('<em>and</em> where <strong>%property</strong> is <strong>%value</strong>', $params));
00053     }
00054     else {
00055       $form['filters']['current'][] = array('#value' => t('<strong>%property</strong> is <strong>%value</strong>', $params));
00056     }
00057   }
00058
00059   foreach ($filters as $key => $filter) {
00060     $names[$key] = $filter['title'];
00061     $form['filters']['status'][$key] = array(
00062       '#type' => 'select',
00063       '#options' => $filter['options'],
00064     );
00065   }
00066
00067   $form['filters']['filter'] = array(
00068     '#type' => 'radios',
00069     '#options' => $names,
00070   );
00071   $form['filters']['buttons']['submit'] = array(
00072     '#type' => 'submit',
00073     '#value' => (count($session) ? t('Refine') : t('Filter')),
00074   );
00075   if (count($session)) {
00076     $form['filters']['buttons']['undo'] = array(
00077       '#type' => 'submit',
00078       '#value' => t('Undo'),
00079     );
00080     $form['filters']['buttons']['reset'] = array(
00081       '#type' => 'submit',
00082       '#value' => t('Reset'),
00083     );
00084   }
00085
00086   drupal_add_js('misc/form.js', 'core');
00087
00088   return $form;
00089 }
00090
00094 function user_filter_form_submit($form, &$form_state) {
00095   $op = $form_state['values']['op'];
00096   $filters = user_filters();
00097   switch ($op) {
00098     case t('Filter'): case t('Refine'):
00099       if (isset($form_state['values']['filter'])) {
00100         $filter = $form_state['values']['filter'];
00101         // Merge an array of arrays into one if necessary.
00102         $options = $filter == 'permission' ? call_user_func_array('array_merge', $filters[$filter]['options']) : $filters[$filter]['options'];
00103         if (isset($options[$form_state['values'][$filter]])) {
00104           $_SESSION['user_overview_filter'][] = array($filter, $form_state['values'][$filter]);
00105         }
00106       }
00107       break;
00108     case t('Undo'):
00109       array_pop($_SESSION['user_overview_filter']);
00110       break;
00111     case t('Reset'):
00112       $_SESSION['user_overview_filter'] = array();
00113       break;
00114     case t('Update'):
00115       return;
00116   }
00117
00118   $form_state['redirect'] = 'admin/user/user';
00119   return;
00120 }
00121
00129 function user_admin_account() {
00130   $filter = user_build_filter_query();
00131
00132   $header = array(
00133     array(),
00134     array('data' => t('Username'), 'field' => 'u.name'),
00135     array('data' => t('Status'), 'field' => 'u.status'),
00136     t('Roles'),
00137     array('data' => t('Member for'), 'field' => 'u.created', 'sort' => 'desc'),
00138     array('data' => t('Last access'), 'field' => 'u.access'),
00139     t('Operations')
00140   );
00141
00142   $sql = 'SELECT DISTINCT u.uid, u.name, u.status, u.created, u.access FROM {users} u LEFT JOIN {users_roles} ur ON u.uid = ur.uid '. $filter['join'] .' WHERE u.uid != 0 '. $filter['where'];
00143   $sql .= tablesort_sql($header);
00144   $query_count = 'SELECT COUNT(DISTINCT u.uid) FROM {users} u LEFT JOIN {users_roles} ur ON u.uid = ur.uid '. $filter['join'] .' WHERE u.uid != 0 '. $filter['where'];
00145   $result = pager_query($sql, 50, 0, $query_count, $filter['args']);
00146
00147   $form['options'] = array(
00148     '#type' => 'fieldset',
00149     '#title' => t('Update options'),
00150     '#prefix' => '<div class="container-inline">',
00151     '#suffix' => '</div>',
00152   );
00153   $options = array();
00154   foreach (module_invoke_all('user_operations') as $operation => $array) {
00155     $options[$operation] = $array['label'];
00156   }
00157   $form['options']['operation'] = array(
00158     '#type' => 'select',
00159     '#options' => $options,
00160     '#default_value' => 'unblock',
00161   );
00162   $form['options']['submit'] = array(
00163     '#type' => 'submit',
00164     '#value' => t('Update'),
00165   );
00166
00167   $destination = drupal_get_destination();
00168
00169   $status = array(t('blocked'), t('active'));
00170   $roles = user_roles(TRUE);
00171   $accounts = array();
00172   while ($account = db_fetch_object($result)) {
00173     $accounts[$account->uid] = '';
00174     $form['name'][$account->uid] = array('#value' => theme('username', $account));
00175     $form['status'][$account->uid] =  array('#value' => $status[$account->status]);
00176     $users_roles = array();
00177     $roles_result = db_query('SELECT rid FROM {users_roles} WHERE uid = %d', $account->uid);
00178     while ($user_role = db_fetch_object($roles_result)) {
00179       $users_roles[] = $roles[$user_role->rid];
00180     }
00181     asort($users_roles);
00182     $form['roles'][$account->uid][0] = array('#value' => theme('item_list', $users_roles));
00183     $form['member_for'][$account->uid] = array('#value' => format_interval(time() - $account->created));
00184     $form['last_access'][$account->uid] =  array('#value' => $account->access ? t('@time ago', array('@time' => format_interval(time() - $account->access))) : t('never'));
00185     $form['operations'][$account->uid] = array('#value' => l(t('edit'), "user/$account->uid/edit", array('query' => $destination)));
00186   }
00187   $form['accounts'] = array(
00188     '#type' => 'checkboxes',
00189     '#options' => $accounts
00190   );
00191   $form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
00192
00193   return $form;
00194 }
00195
00199 function user_admin_account_submit($form, &$form_state) {
00200   $operations = module_invoke_all('user_operations', $form_state);
00201   $operation = $operations[$form_state['values']['operation']];
00202   // Filter out unchecked accounts.
00203   $accounts = array_filter($form_state['values']['accounts']);
00204   if ($function = $operation['callback']) {
00205     // Add in callback arguments if present.
00206     if (isset($operation['callback arguments'])) {
00207       $args = array_merge(array($accounts), $operation['callback arguments']);
00208     }
00209     else {
00210       $args = array($accounts);
00211     }
00212     call_user_func_array($function, $args);
00213
00214     drupal_set_message(t('The update has been performed.'));
00215   }
00216 }
00217
00218 function user_admin_account_validate($form, &$form_state) {
00219   $form_state['values']['accounts'] = array_filter($form_state['values']['accounts']);
00220   if (count($form_state['values']['accounts']) == 0) {
00221     form_set_error('', t('No users selected.'));
00222   }
00223 }
00224
00231 function user_admin_settings() {
00232   // User registration settings.
00233   $form['registration'] = array('#type' => 'fieldset', '#title' => t('User registration settings'));
00234   $form['registration']['user_register'] = array('#type' => 'radios', '#title' => t('Public registrations'), '#default_value' => variable_get('user_register', 1), '#options' => array(t('Only site administrators can create new user accounts.'), t('Visitors can create accounts and no administrator approval is required.'), t('Visitors can create accounts but administrator approval is required.')));
00235   $form['registration']['user_email_verification'] = array('#type' => 'checkbox', '#title' => t('Require e-mail verification when a visitor creates an account'), '#default_value' => variable_get('user_email_verification', TRUE), '#description' => t('If this box is checked, new users will be required to validate their e-mail address prior to logging into the site, and will be assigned a system-generated password. With it unchecked, users will be logged in immediately upon registering, and may select their own passwords during registration.'));
00236   $form['registration']['user_registration_help'] = array('#type' => 'textarea', '#title' => t('User registration guidelines'), '#default_value' => variable_get('user_registration_help', ''), '#description' => t('This text is displayed at the top of the user registration form and is useful for helping or instructing your users.'));
00237
00238   // User e-mail settings.
00239   $form['email'] = array(
00240     '#type' => 'fieldset',
00241     '#title' => t('User e-mail settings'),
00242     '#description' => t('Drupal sends emails whenever new users register on your site, and optionally, may also notify users after other account actions. Using a simple set of content templates, notification e-mails can be customized to fit the specific needs of your site.'),
00243   );
00244   // These email tokens are shared for all settings, so just define
00245   // the list once to help ensure they stay in sync.
00246   $email_token_help = t('Available variables are:') .' !username, !site, !password, !uri, !uri_brief, !mailto, !date, !login_uri, !edit_uri, !login_url.';
00247
00248   $form['email']['admin_created'] = array(
00249     '#type' => 'fieldset',
00250     '#title' => t('Welcome, new user created by administrator'),
00251     '#collapsible' => TRUE,
00252     '#collapsed' => (variable_get('user_register', 1) != 0),
00253     '#description' => t('Customize welcome e-mail messages sent to new member accounts created by an administrator.') .' '. $email_token_help,
00254   );
00255   $form['email']['admin_created']['user_mail_register_admin_created_subject'] = array(
00256     '#type' => 'textfield',
00257     '#title' => t('Subject'),
00258     '#default_value' => _user_mail_text('register_admin_created_subject'),
00259     '#maxlength' => 180,
00260   );
00261   $form['email']['admin_created']['user_mail_register_admin_created_body'] = array(
00262     '#type' => 'textarea',
00263     '#title' => t('Body'),
00264     '#default_value' => _user_mail_text('register_admin_created_body'),
00265     '#rows' => 15,
00266   );
00267
00268   $form['email']['no_approval_required'] = array(
00269     '#type' => 'fieldset',
00270     '#title' => t('Welcome, no approval required'),
00271     '#collapsible' => TRUE,
00272     '#collapsed' => (variable_get('user_register', 1) != 1),
00273     '#description' => t('Customize welcome e-mail messages sent to new members upon registering, when no administrator approval is required.') .' '. $email_token_help
00274   );
00275   $form['email']['no_approval_required']['user_mail_register_no_approval_required_subject'] = array(
00276     '#type' => 'textfield',
00277     '#title' => t('Subject'),
00278     '#default_value' => _user_mail_text('register_no_approval_required_subject'),
00279     '#maxlength' => 180,
00280   );
00281   $form['email']['no_approval_required']['user_mail_register_no_approval_required_body'] = array(
00282     '#type' => 'textarea',
00283     '#title' => t('Body'),
00284     '#default_value' => _user_mail_text('register_no_approval_required_body'),
00285     '#rows' => 15,
00286   );
00287
00288   $form['email']['pending_approval'] = array(
00289     '#type' => 'fieldset',
00290     '#title' => t('Welcome, awaiting administrator approval'),
00291     '#collapsible' => TRUE,
00292     '#collapsed' => (variable_get('user_register', 1) != 2),
00293     '#description' => t('Customize welcome e-mail messages sent to new members upon registering, when administrative approval is required.') .' '. $email_token_help,
00294   );
00295   $form['email']['pending_approval']['user_mail_register_pending_approval_subject'] = array(
00296     '#type' => 'textfield',
00297     '#title' => t('Subject'),
00298     '#default_value' => _user_mail_text('register_pending_approval_subject'),
00299     '#maxlength' => 180,
00300   );
00301   $form['email']['pending_approval']['user_mail_register_pending_approval_body'] = array(
00302     '#type' => 'textarea',
00303     '#title' => t('Body'),
00304     '#default_value' => _user_mail_text('register_pending_approval_body'),
00305     '#rows' => 8,
00306   );
00307
00308   $form['email']['password_reset'] = array(
00309     '#type' => 'fieldset',
00310     '#title' => t('Password recovery email'),
00311     '#collapsible' => TRUE,
00312     '#collapsed' => TRUE,
00313     '#description' => t('Customize e-mail messages sent to users who request a new password.') .' '. $email_token_help,
00314   );
00315   $form['email']['password_reset']['user_mail_password_reset_subject'] = array(
00316     '#type' => 'textfield',
00317     '#title' => t('Subject'),
00318     '#default_value' => _user_mail_text('password_reset_subject'),
00319     '#maxlength' => 180,
00320   );
00321   $form['email']['password_reset']['user_mail_password_reset_body'] = array(
00322     '#type' => 'textarea',
00323     '#title' => t('Body'),
00324     '#default_value' => _user_mail_text('password_reset_body'),
00325     '#rows' => 12,
00326   );
00327
00328   $form['email']['activated'] = array(
00329     '#type' => 'fieldset',
00330     '#title' => t('Account activation email'),
00331     '#collapsible' => TRUE,
00332     '#collapsed' => TRUE,
00333     '#description' => t('Enable and customize e-mail messages sent to users upon account activation (when an administrator activates an account of a user who has already registered, on a site where administrative approval is required).') .' '. $email_token_help,
00334   );
00335   $form['email']['activated']['user_mail_status_activated_notify'] = array(
00336     '#type' => 'checkbox',
00337     '#title' => t('Notify user when account is activated.'),
00338     '#default_value' => variable_get('user_mail_status_activated_notify', TRUE),
00339   );
00340   $form['email']['activated']['user_mail_status_activated_subject'] = array(
00341     '#type' => 'textfield',
00342     '#title' => t('Subject'),
00343     '#default_value' => _user_mail_text('status_activated_subject'),
00344     '#maxlength' => 180,
00345   );
00346   $form['email']['activated']['user_mail_status_activated_body'] = array(
00347     '#type' => 'textarea',
00348     '#title' => t('Body'),
00349     '#default_value' => _user_mail_text('status_activated_body'),
00350     '#rows' => 15,
00351   );
00352
00353   $form['email']['blocked'] = array(
00354     '#type' => 'fieldset',
00355     '#title' => t('Account blocked email'),
00356     '#collapsible' => TRUE,
00357     '#collapsed' => TRUE,
00358     '#description' => t('Enable and customize e-mail messages sent to users when their accounts are blocked.') .' '. $email_token_help,
00359   );
00360   $form['email']['blocked']['user_mail_status_blocked_notify'] = array(
00361     '#type' => 'checkbox',
00362     '#title' => t('Notify user when account is blocked.'),
00363     '#default_value' => variable_get('user_mail_status_blocked_notify', FALSE),
00364   );
00365   $form['email']['blocked']['user_mail_status_blocked_subject'] = array(
00366     '#type' => 'textfield',
00367     '#title' => t('Subject'),
00368     '#default_value' => _user_mail_text('status_blocked_subject'),
00369     '#maxlength' => 180,
00370   );
00371   $form['email']['blocked']['user_mail_status_blocked_body'] = array(
00372     '#type' => 'textarea',
00373     '#title' => t('Body'),
00374     '#default_value' => _user_mail_text('status_blocked_body'),
00375     '#rows' => 3,
00376   );
00377
00378   $form['email']['deleted'] = array(
00379     '#type' => 'fieldset',
00380     '#title' => t('Account deleted email'),
00381     '#collapsible' => TRUE,
00382     '#collapsed' => TRUE,
00383     '#description' => t('Enable and customize e-mail messages sent to users when their accounts are deleted.') .' '. $email_token_help,
00384   );
00385   $form['email']['deleted']['user_mail_status_deleted_notify'] = array(
00386     '#type' => 'checkbox',
00387     '#title' => t('Notify user when account is deleted.'),
00388     '#default_value' => variable_get('user_mail_status_deleted_notify', FALSE),
00389   );
00390   $form['email']['deleted']['user_mail_status_deleted_subject'] = array(
00391     '#type' => 'textfield',
00392     '#title' => t('Subject'),
00393     '#default_value' => _user_mail_text('status_deleted_subject'),
00394     '#maxlength' => 180,
00395   );
00396   $form['email']['deleted']['user_mail_status_deleted_body'] = array(
00397     '#type' => 'textarea',
00398     '#title' => t('Body'),
00399     '#default_value' => _user_mail_text('status_deleted_body'),
00400     '#rows' => 3,
00401   );
00402
00403   // User signatures.
00404   $form['signatures'] = array(
00405     '#type' => 'fieldset',
00406     '#title' => t('Signatures'),
00407   );
00408   $form['signatures']['user_signatures'] = array(
00409     '#type' => 'radios',
00410     '#title' => t('Signature support'),
00411     '#default_value' => variable_get('user_signatures', 0),
00412     '#options' => array(t('Disabled'), t('Enabled')),
00413   );
00414
00415   // If picture support is enabled, check whether the picture directory exists:
00416   if (variable_get('user_pictures', 0)) {
00417     $picture_path = file_create_path(variable_get('user_picture_path', 'pictures'));
00418     file_check_directory($picture_path, 1, 'user_picture_path');
00419   }
00420
00421   $form['pictures'] = array(
00422     '#type' => 'fieldset',
00423     '#title' => t('Pictures'),
00424   );
00425   $picture_support = variable_get('user_pictures', 0);
00426   $form['pictures']['user_pictures'] = array(
00427     '#type' => 'radios',
00428     '#title' => t('Picture support'),
00429     '#default_value' => $picture_support,
00430     '#options' => array(t('Disabled'), t('Enabled')),
00431     '#prefix' => '<div class="user-admin-picture-radios">',
00432     '#suffix' => '</div>',
00433   );
00434   drupal_add_js(drupal_get_path('module', 'user') .'/user.js');
00435   // If JS is enabled, and the radio is defaulting to off, hide all
00436   // the settings on page load via .css using the js-hide class so
00437   // that there's no flicker.
00438   $css_class = 'user-admin-picture-settings';
00439   if (!$picture_support) {
00440     $css_class .= ' js-hide';
00441   }
00442   $form['pictures']['settings'] = array(
00443     '#prefix' => '<div class="'. $css_class .'">',
00444     '#suffix' => '</div>',
00445   );
00446   $form['pictures']['settings']['user_picture_path'] = array(
00447     '#type' => 'textfield',
00448     '#title' => t('Picture image path'),
00449     '#default_value' => variable_get('user_picture_path', 'pictures'),
00450     '#size' => 30,
00451     '#maxlength' => 255,
00452     '#description' => t('Subdirectory in the directory %dir where pictures will be stored.', array('%dir' => file_directory_path() .'/')),
00453   );
00454   $form['pictures']['settings']['user_picture_default'] = array(
00455     '#type' => 'textfield',
00456     '#title' => t('Default picture'),
00457     '#default_value' => variable_get('user_picture_default', ''),
00458     '#size' => 30,
00459     '#maxlength' => 255,
00460     '#description' => t('URL of picture to display for users with no custom picture selected. Leave blank for none.'),
00461   );
00462   $form['pictures']['settings']['user_picture_dimensions'] = array(
00463     '#type' => 'textfield',
00464     '#title' => t('Picture maximum dimensions'),
00465     '#default_value' => variable_get('user_picture_dimensions', '85x85'),
00466     '#size' => 15,
00467     '#maxlength' => 10,
00468     '#description' => t('Maximum dimensions for pictures, in pixels.'),
00469   );
00470   $form['pictures']['settings']['user_picture_file_size'] = array(
00471     '#type' => 'textfield',
00472     '#title' => t('Picture maximum file size'),
00473     '#default_value' => variable_get('user_picture_file_size', '30'),
00474     '#size' => 15,
00475     '#maxlength' => 10,
00476     '#description' => t('Maximum file size for pictures, in kB.'),
00477   );
00478   $form['pictures']['settings']['user_picture_guidelines'] = array(
00479     '#type' => 'textarea',
00480     '#title' => t('Picture guidelines'),
00481     '#default_value' => variable_get('user_picture_guidelines', ''),
00482     '#description' => t("This text is displayed at the picture upload form in addition to the default guidelines. It's useful for helping or instructing your users."),
00483   );
00484
00485   return system_settings_form($form);
00486 }
00487
00495 function user_admin_perm($form_state, $rid = NULL) {
00496   if (is_numeric($rid)) {
00497     $result = db_query('SELECT r.rid, p.perm FROM {role} r LEFT JOIN {permission} p ON r.rid = p.rid WHERE r.rid = %d', $rid);
00498   }
00499   else {
00500     $result = db_query('SELECT r.rid, p.perm FROM {role} r LEFT JOIN {permission} p ON r.rid = p.rid ORDER BY name');
00501   }
00502
00503   // Compile role array:
00504   // Add a comma at the end so when searching for a permission, we can
00505   // always search for "$perm," to make sure we do not confuse
00506   // permissions that are substrings of each other.
00507   while ($role = db_fetch_object($result)) {
00508     $role_permissions[$role->rid] = $role->perm .',';
00509   }
00510
00511   // Retrieve role names for columns.
00512   $role_names = user_roles();
00513   if (is_numeric($rid)) {
00514     $role_names = array($rid => $role_names[$rid]);
00515   }
00516
00517   // Render role/permission overview:
00518   $options = array();
00519   foreach (module_list(FALSE, FALSE, TRUE) as $module) {
00520     if ($permissions = module_invoke($module, 'perm')) {
00521       $form['permission'][] = array(
00522         '#value' => $module,
00523       );
00524       asort($permissions);
00525       foreach ($permissions as $perm) {
00526         $options[$perm] = '';
00527         $form['permission'][$perm] = array('#value' => t($perm));
00528         foreach ($role_names as $rid => $name) {
00529           // Builds arrays for checked boxes for each role
00530           if (strpos($role_permissions[$rid], $perm .',') !== FALSE) {
00531             $status[$rid][] = $perm;
00532           }
00533         }
00534       }
00535     }
00536   }
00537
00538   // Have to build checkboxes here after checkbox arrays are built
00539   foreach ($role_names as $rid => $name) {
00540     $form['checkboxes'][$rid] = array('#type' => 'checkboxes', '#options' => $options, '#default_value' => isset($status[$rid]) ? $status[$rid] : array());
00541     $form['role_names'][$rid] = array('#value' => $name, '#tree' => TRUE);
00542   }
00543   $form['submit'] = array('#type' => 'submit', '#value' => t('Save permissions'));
00544
00545   return $form;
00546 }
00547
00548 function user_admin_perm_submit($form, &$form_state) {
00549   // Save permissions:
00550   $result = db_query('SELECT * FROM {role}');
00551   while ($role = db_fetch_object($result)) {
00552     if (isset($form_state['values'][$role->rid])) {
00553       // Delete, so if we clear every checkbox we reset that role;
00554       // otherwise permissions are active and denied everywhere.
00555       db_query('DELETE FROM {permission} WHERE rid = %d', $role->rid);
00556       $form_state['values'][$role->rid] = array_filter($form_state['values'][$role->rid]);
00557       if (count($form_state['values'][$role->rid])) {
00558         db_query("INSERT INTO {permission} (rid, perm) VALUES (%d, '%s')", $role->rid, implode(', ', array_keys($form_state['values'][$role->rid])));
00559       }
00560     }
00561   }
00562
00563   drupal_set_message(t('The changes have been saved.'));
00564
00565   // Clear the cached pages
00566   cache_clear_all();
00567 }
00568
00574 function theme_user_admin_perm($form) {
00575   $roles = user_roles();
00576   foreach (element_children($form['permission']) as $key) {
00577     // Don't take form control structures
00578     if (is_array($form['permission'][$key])) {
00579       $row = array();
00580       // Module name
00581       if (is_numeric($key)) {
00582         $row[] = array('data' => t('@module module', array('@module' => drupal_render($form['permission'][$key]))), 'class' => 'module', 'id' => 'module-'. $form['permission'][$key]['#value'], 'colspan' => count($form['role_names']) + 1);
00583       }
00584       else {
00585         $row[] = array('data' => drupal_render($form['permission'][$key]), 'class' => 'permission');
00586         foreach (element_children($form['checkboxes']) as $rid) {
00587           if (is_array($form['checkboxes'][$rid])) {
00588             $row[] = array('data' => drupal_render($form['checkboxes'][$rid][$key]), 'class' => 'checkbox', 'title' => $roles[$rid] .' : '. t($key));
00589           }
00590         }
00591       }
00592       $rows[] = $row;
00593     }
00594   }
00595   $header[] = (t('Permission'));
00596   foreach (element_children($form['role_names']) as $rid) {
00597     if (is_array($form['role_names'][$rid])) {
00598       $header[] = array('data' => drupal_render($form['role_names'][$rid]), 'class' => 'checkbox');
00599     }
00600   }
00601   $output = theme('table', $header, $rows, array('id' => 'permissions'));
00602   $output .= drupal_render($form);
00603   return $output;
00604 }
00605
00614 function user_admin_role() {
00615   $rid = arg(4);
00616   if ($rid) {
00617     if ($rid == DRUPAL_ANONYMOUS_RID || $rid == DRUPAL_AUTHENTICATED_RID) {
00618       drupal_goto('admin/user/roles');
00619     }
00620     // Display the edit role form.
00621     $role = db_fetch_object(db_query('SELECT * FROM {role} WHERE rid = %d', $rid));
00622     $form['name'] = array(
00623       '#type' => 'textfield',
00624       '#title' => t('Role name'),
00625       '#default_value' => $role->name,
00626       '#size' => 30,
00627       '#required' => TRUE,
00628       '#maxlength' => 64,
00629       '#description' => t('The name for this role. Example: "moderator", "editorial board", "site architect".'),
00630     );
00631     $form['rid'] = array(
00632       '#type' => 'value',
00633       '#value' => $rid,
00634     );
00635     $form['submit'] = array(
00636       '#type' => 'submit',
00637       '#value' => t('Save role'),
00638     );
00639     $form['delete'] = array(
00640       '#type' => 'submit',
00641       '#value' => t('Delete role'),
00642     );
00643   }
00644   else {
00645     $form['name'] = array(
00646       '#type' => 'textfield',
00647       '#size' => 32,
00648       '#maxlength' => 64,
00649     );
00650     $form['submit'] = array(
00651       '#type' => 'submit',
00652       '#value' => t('Add role'),
00653     );
00654     $form['#submit'][] = 'user_admin_role_submit';
00655     $form['#validate'][] = 'user_admin_role_validate';
00656   }
00657   return $form;
00658 }
00659
00660 function user_admin_role_validate($form, &$form_state) {
00661   if ($form_state['values']['name']) {
00662     if ($form_state['values']['op'] == t('Save role')) {
00663       if (db_result(db_query("SELECT COUNT(*) FROM {role} WHERE name = '%s' AND rid != %d", $form_state['values']['name'], $form_state['values']['rid']))) {
00664         form_set_error('name', t('The role name %name already exists. Please choose another role name.', array('%name' => $form_state['values']['name'])));
00665       }
00666     }
00667     else if ($form_state['values']['op'] == t('Add role')) {
00668       if (db_result(db_query("SELECT COUNT(*) FROM {role} WHERE name = '%s'", $form_state['values']['name']))) {
00669         form_set_error('name', t('The role name %name already exists. Please choose another role name.', array('%name' => $form_state['values']['name'])));
00670       }
00671     }
00672   }
00673   else {
00674     form_set_error('name', t('You must specify a valid role name.'));
00675   }
00676 }
00677
00678 function user_admin_role_submit($form, &$form_state) {
00679   if ($form_state['values']['op'] == t('Save role')) {
00680     db_query("UPDATE {role} SET name = '%s' WHERE rid = %d", $form_state['values']['name'], $form_state['values']['rid']);
00681     drupal_set_message(t('The role has been renamed.'));
00682   }
00683   else if ($form_state['values']['op'] == t('Delete role')) {
00684     db_query('DELETE FROM {role} WHERE rid = %d', $form_state['values']['rid']);
00685     db_query('DELETE FROM {permission} WHERE rid = %d', $form_state['values']['rid']);
00686     // Update the users who have this role set:
00687     db_query('DELETE FROM {users_roles} WHERE rid = %d', $form_state['values']['rid']);
00688
00689     drupal_set_message(t('The role has been deleted.'));
00690   }
00691   else if ($form_state['values']['op'] == t('Add role')) {
00692     db_query("INSERT INTO {role} (name) VALUES ('%s')", $form_state['values']['name']);
00693     drupal_set_message(t('The role has been added.'));
00694   }
00695   $form_state['redirect'] = 'admin/user/roles';
00696   return;
00697 }
00698
00702 function user_admin_access_check() {
00703   $output = drupal_get_form('user_admin_check_user');
00704   $output .= drupal_get_form('user_admin_check_mail');
00705   $output .= drupal_get_form('user_admin_check_host');
00706   return $output;
00707 }
00708
00712 function user_admin_access_add($mask = NULL, $type = NULL) {
00713   if ($edit = $_POST) {
00714     if (!$edit['mask']) {
00715       form_set_error('mask', t('You must enter a mask.'));
00716     }
00717     else {
00718       db_query("INSERT INTO {access} (mask, type, status) VALUES ('%s', '%s', %d)", $edit['mask'], $edit['type'], $edit['status']);
00719       $aid = db_last_insert_id('access', 'aid');
00720       drupal_set_message(t('The access rule has been added.'));
00721       drupal_goto('admin/user/rules');
00722     }
00723   }
00724   else {
00725     $edit['mask'] = $mask;
00726     $edit['type'] = $type;
00727   }
00728   return drupal_get_form('user_admin_access_add_form', $edit, t('Add rule'));
00729 }
00730
00734 function user_admin_access_edit($aid = 0) {
00735   if ($edit = $_POST) {
00736     if (!$edit['mask']) {
00737       form_set_error('mask', t('You must enter a mask.'));
00738     }
00739     else {
00740       db_query("UPDATE {access} SET mask = '%s', type = '%s', status = '%s' WHERE aid = %d", $edit['mask'], $edit['type'], $edit['status'], $aid);
00741       drupal_set_message(t('The access rule has been saved.'));
00742       drupal_goto('admin/user/rules');
00743     }
00744   }
00745   else {
00746     $edit = db_fetch_array(db_query('SELECT aid, type, status, mask FROM {access} WHERE aid = %d', $aid));
00747   }
00748   return drupal_get_form('user_admin_access_edit_form', $edit, t('Save rule'));
00749 }
00750
00756 function user_admin_access_form(&$form_state, $edit, $submit) {
00757   $form['status'] = array(
00758     '#type' => 'radios',
00759     '#title' => t('Access type'),
00760     '#default_value' => isset($edit['status']) ? $edit['status'] : 0,
00761     '#options' => array('1' => t('Allow'), '0' => t('Deny')),
00762   );
00763   $type_options = array('user' => t('Username'), 'mail' => t('E-mail'), 'host' => t('Host'));
00764   $form['type'] = array(
00765     '#type' => 'radios',
00766     '#title' => t('Rule type'),
00767     '#default_value' => (isset($type_options[$edit['type']]) ? $edit['type'] : 'user'),
00768     '#options' => $type_options,
00769   );
00770   $form['mask'] = array(
00771     '#type' => 'textfield',
00772     '#title' => t('Mask'),
00773     '#size' => 30,
00774     '#maxlength' => 64,
00775     '#default_value' => $edit['mask'],
00776     '#description' => '%: '. t('Matches any number of characters, even zero characters') .'.<br />_: '. t('Matches exactly one character.'),
00777     '#required' => TRUE,
00778   );
00779   $form['submit'] = array('#type' => 'submit', '#value' => $submit);
00780
00781   return $form;
00782 }
00783
00784 function user_admin_access_check_validate($form, &$form_state) {
00785   if (empty($form_state['values']['test'])) {
00786     form_set_error($form_state['values']['type'], t('No value entered. Please enter a test string and try again.'));
00787   }
00788 }
00789
00790 function user_admin_check_user() {
00791   $form['user'] = array('#type' => 'fieldset', '#title' => t('Username'));
00792   $form['user']['test'] = array('#type' => 'textfield', '#title' => '', '#description' => t('Enter a username to check if it will be denied or allowed.'), '#size' => 30, '#maxlength' => USERNAME_MAX_LENGTH);
00793   $form['user']['type'] = array('#type' => 'hidden', '#value' => 'user');
00794   $form['user']['submit'] = array('#type' => 'submit', '#value' => t('Check username'));
00795   $form['#submit'][] = 'user_admin_access_check_submit';
00796   $form['#validate'][] = 'user_admin_access_check_validate';
00797   $form['#theme'] = 'user_admin_access_check';
00798   return $form;
00799 }
00800
00801 function user_admin_check_mail() {
00802   $form['mail'] = array('#type' => 'fieldset', '#title' => t('E-mail'));
00803   $form['mail']['test'] = array('#type' => 'textfield', '#title' => '', '#description' => t('Enter an e-mail address to check if it will be denied or allowed.'), '#size' => 30, '#maxlength' => EMAIL_MAX_LENGTH);
00804   $form['mail']['type'] = array('#type' => 'hidden', '#value' => 'mail');
00805   $form['mail']['submit'] = array('#type' => 'submit', '#value' => t('Check e-mail'));
00806   $form['#submit'][] = 'user_admin_access_check_submit';
00807   $form['#validate'][] = 'user_admin_access_check_validate';
00808   $form['#theme'] = 'user_admin_access_check';
00809   return $form;
00810 }
00811
00812 function user_admin_check_host() {
00813   $form['host'] = array('#type' => 'fieldset', '#title' => t('Hostname'));
00814   $form['host']['test'] = array('#type' => 'textfield', '#title' => '', '#description' => t('Enter a hostname or IP address to check if it will be denied or allowed.'), '#size' => 30, '#maxlength' => 64);
00815   $form['host']['type'] = array('#type' => 'hidden', '#value' => 'host');
00816   $form['host']['submit'] = array('#type' => 'submit', '#value' => t('Check hostname'));
00817   $form['#submit'][] = 'user_admin_access_check_submit';
00818   $form['#validate'][] = 'user_admin_access_check_validate';
00819   $form['#theme'] = 'user_admin_access_check';
00820   return $form;
00821 }
00822
00823 function user_admin_access_check_submit($form, &$form_state) {
00824   switch ($form_state['values']['type']) {
00825     case 'user':
00826       if (drupal_is_denied('user', $form_state['values']['test'])) {
00827         drupal_set_message(t('The username %name is not allowed.', array('%name' => $form_state['values']['test'])));
00828       }
00829       else {
00830         drupal_set_message(t('The username %name is allowed.', array('%name' => $form_state['values']['test'])));
00831       }
00832       break;
00833     case 'mail':
00834       if (drupal_is_denied('mail', $form_state['values']['test'])) {
00835         drupal_set_message(t('The e-mail address %mail is not allowed.', array('%mail' => $form_state['values']['test'])));
00836       }
00837       else {
00838         drupal_set_message(t('The e-mail address %mail is allowed.', array('%mail' => $form_state['values']['test'])));
00839       }
00840       break;
00841     case 'host':
00842       if (drupal_is_denied('host', $form_state['values']['test'])) {
00843         drupal_set_message(t('The hostname %host is not allowed.', array('%host' => $form_state['values']['test'])));
00844       }
00845       else {
00846         drupal_set_message(t('The hostname %host is allowed.', array('%host' => $form_state['values']['test'])));
00847       }
00848       break;
00849     default:
00850       break;
00851   }
00852 }
00853
00860 function user_admin_access_delete_confirm($form_state, $aid = 0) {
00861   $access_types = array('user' => t('username'), 'mail' => t('e-mail'), 'host' => t('host'));
00862   $edit = db_fetch_object(db_query('SELECT aid, type, status, mask FROM {access} WHERE aid = %d', $aid));
00863
00864   $form = array();
00865   $form['aid'] = array('#type' => 'hidden', '#value' => $aid);
00866   $output = confirm_form($form,
00867                   t('Are you sure you want to delete the @type rule for %rule?', array('@type' => $access_types[$edit->type], '%rule' => $edit->mask)),
00868                   'admin/user/rules',
00869                   t('This action cannot be undone.'),
00870                   t('Delete'),
00871                   t('Cancel'));
00872   return $output;
00873 }
00874
00875 function user_admin_access_delete_confirm_submit($form, &$form_state) {
00876   db_query('DELETE FROM {access} WHERE aid = %d', $form_state['values']['aid']);
00877   drupal_set_message(t('The access rule has been deleted.'));
00878   $form_state['redirect'] = 'admin/user/rules';
00879   return;
00880 }
00881
00885 function user_admin_access() {
00886   $header = array(array('data' => t('Access type'), 'field' => 'status'), array('data' => t('Rule type'), 'field' => 'type'), array('data' => t('Mask'), 'field' => 'mask'), array('data' => t('Operations'), 'colspan' => 2));
00887   $result = db_query("SELECT aid, type, status, mask FROM {access}". tablesort_sql($header));
00888   $access_types = array('user' => t('username'), 'mail' => t('e-mail'), 'host' => t('host'));
00889   $rows = array();
00890   while ($rule = db_fetch_object($result)) {
00891     $rows[] = array($rule->status ? t('allow') : t('deny'), $access_types[$rule->type], $rule->mask, l(t('edit'), 'admin/user/rules/edit/'. $rule->aid), l(t('delete'), 'admin/user/rules/delete/'. $rule->aid));
00892   }
00893   if (empty($rows)) {
00894     $rows[] = array(array('data' => '<em>'. t('There are currently no access rules.') .'</em>', 'colspan' => 5));
00895   }
00896   return theme('table', $header, $rows);
00897 }
00898
00904 function theme_user_admin_account($form) {
00905   // Overview table:
00906   $header = array(
00907     theme('table_select_header_cell'),
00908     array('data' => t('Username'), 'field' => 'u.name'),
00909     array('data' => t('Status'), 'field' => 'u.status'),
00910     t('Roles'),
00911     array('data' => t('Member for'), 'field' => 'u.created', 'sort' => 'desc'),
00912     array('data' => t('Last access'), 'field' => 'u.access'),
00913     t('Operations')
00914   );
00915
00916   $output = drupal_render($form['options']);
00917   if (isset($form['name']) && is_array($form['name'])) {
00918     foreach (element_children($form['name']) as $key) {
00919       $rows[] = array(
00920         drupal_render($form['accounts'][$key]),
00921         drupal_render($form['name'][$key]),
00922         drupal_render($form['status'][$key]),
00923         drupal_render($form['roles'][$key]),
00924         drupal_render($form['member_for'][$key]),
00925         drupal_render($form['last_access'][$key]),
00926         drupal_render($form['operations'][$key]),
00927       );
00928     }
00929   }
00930   else {
00931     $rows[] = array(array('data' => t('No users available.'), 'colspan' => '7'));
00932   }
00933
00934   $output .= theme('table', $header, $rows);
00935   if ($form['pager']['#value']) {
00936     $output .= drupal_render($form['pager']);
00937   }
00938
00939   $output .= drupal_render($form);
00940
00941   return $output;
00942 }
00943
00949 function theme_user_admin_new_role($form) {
00950   $header = array(t('Name'), array('data' => t('Operations'), 'colspan' => 2));
00951   foreach (user_roles() as $rid => $name) {
00952     $edit_permissions = l(t('edit permissions'), 'admin/user/permissions/'. $rid);
00953     if (!in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) {
00954       $rows[] = array($name, l(t('edit role'), 'admin/user/roles/edit/'. $rid), $edit_permissions);
00955     }
00956     else {
00957       $rows[] = array($name, t('locked'), $edit_permissions);
00958     }
00959   }
00960   $rows[] = array(drupal_render($form['name']), array('data' => drupal_render($form['submit']), 'colspan' => 2));
00961
00962   $output = drupal_render($form);
00963   $output .= theme('table', $header, $rows);
00964
00965   return $output;
00966 }
00967
00973 function theme_user_filter_form($form) {
00974   $output = '<div id="user-admin-filter">';
00975   $output .= drupal_render($form['filters']);
00976   $output .= '</div>';
00977   $output .= drupal_render($form);
00978   return $output;
00979 }
00980
00986 function theme_user_filters($form) {
00987   $output = '<ul class="clear-block">';
00988   if (!empty($form['current'])) {
00989     foreach (element_children($form['current']) as $key) {
00990       $output .= '<li>'. drupal_render($form['current'][$key]) .'</li>';
00991     }
00992   }
00993
00994   $output .= '<li><dl class="multiselect">'. (!empty($form['current']) ? '<dt><em>'. t('and') .'</em> '. t('where') .'</dt>' : '') .'<dd class="a">';
00995   foreach (element_children($form['filter']) as $key) {
00996     $output .= drupal_render($form['filter'][$key]);
00997   }
00998   $output .= '</dd>';
00999
01000   $output .= '<dt>'. t('is') .'</dt><dd class="b">';
01001
01002   foreach (element_children($form['status']) as $key) {
01003     $output .= drupal_render($form['status'][$key]);
01004   }
01005   $output .= '</dd>';
01006
01007   $output .= '</dl>';
01008   $output .= '<div class="container-inline" id="user-admin-buttons">'. drupal_render($form['buttons']) .'</div>';
01009   $output .= '</li></ul>';
01010
01011   return $output;
01012 }
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/user/user.install Source File

modules » user

user.install

Go to the documentation of this file.
00001 <?php
00002 // $Id: user.install,v 1.5 2008/01/08 07:46:41 goba Exp $
00003
00007 function user_schema() {
00008   $schema['access'] = array(
00009     'description' => t('Stores site access rules.'),
00010     'fields' => array(
00011       'aid' => array(
00012         'type' => 'serial',
00013         'not null' => TRUE,
00014         'description' => t('Primary Key: Unique access ID.'),
00015       ),
00016       'mask' => array(
00017         'type' => 'varchar',
00018         'length' => 255,
00019         'not null' => TRUE,
00020         'default' => '',
00021         'description' => t('Text mask used for filtering access.'),
00022       ),
00023       'type' => array(
00024         'type' => 'varchar',
00025         'length' => 255,
00026         'not null' => TRUE,
00027         'default' => '',
00028         'description' => t('Type of access rule: name, mail or host.'),
00029       ),
00030       'status' => array(
00031         'type' => 'int',
00032         'not null' => TRUE,
00033         'default' => 0,
00034         'size' => 'tiny',
00035         'description' => t('Whether rule is to allow(1) or deny(0) access.'),
00036       ),
00037     ),
00038     'primary key' => array('aid'),
00039   );
00040
00041   $schema['authmap'] = array(
00042     'description' => t('Stores distributed authentication mapping.'),
00043     'fields' => array(
00044       'aid' => array(
00045         'description' => t('Primary Key: Unique authmap ID.'),
00046         'type' => 'serial',
00047         'unsigned' => TRUE,
00048         'not null' => TRUE,
00049       ),
00050       'uid' => array(
00051         'type' => 'int',
00052         'not null' => TRUE,
00053         'default' => 0,
00054         'description' => t("User's {users}.uid."),
00055       ),
00056       'authname' => array(
00057         'type' => 'varchar',
00058         'length' => 128,
00059         'not null' => TRUE,
00060         'default' => '',
00061         'description' => t('Unique authentication name.'),
00062       ),
00063       'module' => array(
00064         'type' => 'varchar',
00065         'length' => 128,
00066         'not null' => TRUE,
00067         'default' => '',
00068         'description' => t('Module which is controlling the authentication.'),
00069       ),
00070     ),
00071     'unique keys' => array('authname' => array('authname')),
00072     'primary key' => array('aid'),
00073   );
00074
00075   $schema['permission'] = array(
00076     'description' => t('Stores permissions for users.'),
00077     'fields' => array(
00078       'pid' => array(
00079         'type' => 'serial',
00080         'not null' => TRUE,
00081         'description' => t('Primary Key: Unique permission ID.'),
00082       ),
00083       'rid' => array(
00084         'type' => 'int',
00085         'unsigned' => TRUE,
00086         'not null' => TRUE,
00087         'default' => 0,
00088         'description' => t('The {role}.rid to which the permissions are assigned.'),
00089       ),
00090       'perm' => array(
00091         'type' => 'text',
00092         'not null' => FALSE,
00093         'size' => 'big',
00094         'description' => t('List of permissions being assigned.'),
00095       ),
00096       'tid' => array(
00097         'type' => 'int',
00098         'unsigned' => TRUE,
00099         'not null' => TRUE,
00100         'default' => 0,
00101         'description' => t('Originally intended for taxonomy-based permissions, but never used.'),
00102       ),
00103     ),
00104     'primary key' => array('pid'),
00105     'indexes' => array('rid' => array('rid')),
00106   );
00107
00108   $schema['role'] = array(
00109     'description' => t('Stores user roles.'),
00110     'fields' => array(
00111       'rid' => array(
00112         'type' => 'serial',
00113         'unsigned' => TRUE,
00114         'not null' => TRUE,
00115         'description' => t('Primary Key: Unique role id.'),
00116       ),
00117       'name' => array(
00118         'type' => 'varchar',
00119         'length' => 64,
00120         'not null' => TRUE,
00121         'default' => '',
00122         'description' => t('Unique role name.'),
00123       ),
00124     ),
00125     'unique keys' => array('name' => array('name')),
00126     'primary key' => array('rid'),
00127   );
00128
00129   $schema['users'] = array(
00130     'description' => t('Stores user data.'),
00131     'fields' => array(
00132       'uid' => array(
00133         'type' => 'serial',
00134         'unsigned' => TRUE,
00135         'not null' => TRUE,
00136         'description' => t('Primary Key: Unique user ID.'),
00137       ),
00138       'name' => array(
00139         'type' => 'varchar',
00140         'length' => 60,
00141         'not null' => TRUE,
00142         'default' => '',
00143         'description' => t('Unique user name.'),
00144       ),
00145       'pass' => array(
00146         'type' => 'varchar',
00147         'length' => 32,
00148         'not null' => TRUE,
00149         'default' => '',
00150         'description' => t("User's password (md5 hash)."),
00151       ),
00152       'mail' => array(
00153         'type' => 'varchar',
00154         'length' => 64,
00155         'not null' => FALSE,
00156         'default' => '',
00157         'description' => t("User's email address."),
00158       ),
00159       'mode' => array(
00160         'type' => 'int',
00161         'not null' => TRUE,
00162         'default' => 0,
00163         'size' => 'tiny',
00164         'description' => t('Per-user comment display mode (threaded vs. flat), used by the {comment} module.'),
00165       ),
00166       'sort' => array(
00167         'type' => 'int',
00168         'not null' => FALSE,
00169         'default' => 0,
00170         'size' => 'tiny',
00171         'description' => t('Per-user comment sort order (newest vs. oldest first), used by the {comment} module.'),
00172       ),
00173       'threshold' => array(
00174         'type' => 'int',
00175         'not null' => FALSE,
00176         'default' => 0,
00177         'size' => 'tiny',
00178         'description' => t('Previously used by the {comment} module for per-user preferences; no longer used.'),
00179       ),
00180       'theme' => array(
00181         'type' => 'varchar',
00182         'length' => 255,
00183         'not null' => TRUE,
00184         'default' => '',
00185         'description' => t("User's default theme."),
00186       ),
00187       'signature' => array(
00188         'type' => 'varchar',
00189         'length' => 255,
00190         'not null' => TRUE,
00191         'default' => '',
00192         'description' => t("User's signature."),
00193       ),
00194       'created' => array(
00195         'type' => 'int',
00196         'not null' => TRUE,
00197         'default' => 0,
00198         'description' => t('Timestamp for when user was created.'),
00199       ),
00200       'access' => array(
00201         'type' => 'int',
00202         'not null' => TRUE,
00203         'default' => 0,
00204         'description' => t('Timestamp for previous time user accessed the site.'),
00205       ),
00206       'login' => array(
00207         'type' => 'int',
00208         'not null' => TRUE,
00209         'default' => 0,
00210         'description' => t("Timestamp for user's last login."),
00211       ),
00212       'status' => array(
00213         'type' => 'int',
00214         'not null' => TRUE,
00215         'default' => 0,
00216         'size' => 'tiny',
00217         'description' => t('Whether the user is active(1) or blocked(0).'),
00218       ),
00219       'timezone' => array(
00220         'type' => 'varchar',
00221         'length' => 8,
00222         'not null' => FALSE,
00223         'description' => t("User's timezone."),
00224       ),
00225       'language' => array(
00226         'type' => 'varchar',
00227         'length' => 12,
00228         'not null' => TRUE,
00229         'default' => '',
00230         'description' => t("User's default language."),
00231       ),
00232       'picture' => array(
00233         'type' => 'varchar',
00234         'length' => 255,
00235         'not null' => TRUE,
00236         'default' => '',
00237         'description' => t("Path to the user's uploaded picture."),
00238       ),
00239       'init' => array(
00240         'type' => 'varchar',
00241         'length' => 64,
00242         'not null' => FALSE,
00243         'default' => '',
00244         'description' => t('Email address used for initial account creation.'),
00245       ),
00246       'data' => array(
00247         'type' => 'text',
00248         'not null' => FALSE,
00249         'size' => 'big',
00250         'description' => t('A serialized array of name value pairs that are related to the user. Any form values posted during user edit are stored and are loaded into the $user object during user_load(). Use of this field is discouraged and it will likely disappear in a future version of Drupal.'),
00251       ),
00252     ),
00253     'indexes' => array(
00254       'access' => array('access'),
00255       'created' => array('created'),
00256       'mail' => array('mail'),
00257     ),
00258     'unique keys' => array(
00259       'name' => array('name'),
00260     ),
00261     'primary key' => array('uid'),
00262   );
00263
00264   $schema['users_roles'] = array(
00265     'description' => t('Maps users to roles.'),
00266     'fields' => array(
00267       'uid' => array(
00268         'type' => 'int',
00269         'unsigned' => TRUE,
00270         'not null' => TRUE,
00271         'default' => 0,
00272         'description' => t('Primary Key: {users}.uid for user.'),
00273       ),
00274       'rid' => array(
00275         'type' => 'int',
00276         'unsigned' => TRUE,
00277         'not null' => TRUE,
00278         'default' => 0,
00279         'description' => t('Primary Key: {role}.rid for role.'),
00280       ),
00281     ),
00282     'primary key' => array('uid', 'rid'),
00283     'indexes' => array(
00284       'rid' => array('rid'),
00285     ),
00286   );
00287
00288   return $schema;
00289 }
00290
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/user/user.module Source File

modules » user

user.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: user.module,v 1.892 2008/02/03 19:23:01 goba Exp $
00003
00009 define('USERNAME_MAX_LENGTH', 60);
00010 define('EMAIL_MAX_LENGTH', 64);
00011
00018 function user_module_invoke($type, &$array, &$user, $category = NULL) {
00019   foreach (module_list() as $module) {
00020     $function = $module .'_user';
00021     if (function_exists($function)) {
00022       $function($type, $array, $user, $category);
00023     }
00024   }
00025 }
00026
00030 function user_theme() {
00031   return array(
00032     'user_picture' => array(
00033       'arguments' => array('account' => NULL),
00034       'template' => 'user-picture',
00035     ),
00036     'user_profile' => array(
00037       'arguments' => array('account' => NULL),
00038       'template' => 'user-profile',
00039       'file' => 'user.pages.inc',
00040     ),
00041     'user_profile_category' => array(
00042       'arguments' => array('element' => NULL),
00043       'template' => 'user-profile-category',
00044       'file' => 'user.pages.inc',
00045     ),
00046     'user_profile_item' => array(
00047       'arguments' => array('element' => NULL),
00048       'template' => 'user-profile-item',
00049       'file' => 'user.pages.inc',
00050     ),
00051     'user_list' => array(
00052       'arguments' => array('users' => NULL, 'title' => NULL),
00053     ),
00054     'user_admin_perm' => array(
00055       'arguments' => array('form' => NULL),
00056       'file' => 'user.admin.inc',
00057     ),
00058     'user_admin_new_role' => array(
00059       'arguments' => array('form' => NULL),
00060       'file' => 'user.admin.inc',
00061     ),
00062     'user_admin_account' => array(
00063       'arguments' => array('form' => NULL),
00064       'file' => 'user.admin.inc',
00065     ),
00066     'user_filter_form' => array(
00067       'arguments' => array('form' => NULL),
00068       'file' => 'user.admin.inc',
00069     ),
00070     'user_filters' => array(
00071       'arguments' => array('form' => NULL),
00072       'file' => 'user.admin.inc',
00073     ),
00074     'user_signature' => array(
00075       'arguments' => array('signature' => NULL),
00076     ),
00077   );
00078 }
00079
00080 function user_external_load($authname) {
00081   $result = db_query("SELECT uid FROM {authmap} WHERE authname = '%s'", $authname);
00082
00083   if ($user = db_fetch_array($result)) {
00084     return user_load($user);
00085   }
00086   else {
00087     return 0;
00088   }
00089 }
00090
00108 function user_external_login($account, $edit = array()) {
00109   $form = drupal_get_form('user_login');
00110
00111   $state['values'] = $edit;
00112   if (empty($state['values']['name'])) {
00113     $state['values']['name'] = $account->name;
00114   }
00115
00116   // Check if user is blocked or denied by access rules.
00117   user_login_name_validate($form, $state, (array)$account);
00118   if (form_get_errors()) {
00119     // Invalid login.
00120     return FALSE;
00121   }
00122
00123   // Valid login.
00124   global $user;
00125   $user = $account;
00126   user_authenticate_finalize($state['values']);
00127   return TRUE;
00128 }
00129
00141 function user_load($array = array()) {
00142   // Dynamically compose a SQL query:
00143   $query = array();
00144   $params = array();
00145
00146   if (is_numeric($array)) {
00147     $array = array('uid' => $array);
00148   }
00149   elseif (!is_array($array)) {
00150     return FALSE;
00151   }
00152
00153   foreach ($array as $key => $value) {
00154     if ($key == 'uid' || $key == 'status') {
00155       $query[] = "$key = %d";
00156       $params[] = $value;
00157     }
00158     else if ($key == 'pass') {
00159       $query[] = "pass = '%s'";
00160       $params[] = md5($value);
00161     }
00162     else {
00163       $query[]= "LOWER($key) = LOWER('%s')";
00164       $params[] = $value;
00165     }
00166   }
00167   $result = db_query('SELECT * FROM {users} u WHERE '. implode(' AND ', $query), $params);
00168
00169   if ($user = db_fetch_object($result)) {
00170     $user = drupal_unpack($user);
00171
00172     $user->roles = array();
00173     if ($user->uid) {
00174       $user->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
00175     }
00176     else {
00177       $user->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user';
00178     }
00179     $result = db_query('SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d', $user->uid);
00180     while ($role = db_fetch_object($result)) {
00181       $user->roles[$role->rid] = $role->name;
00182     }
00183     user_module_invoke('load', $array, $user);
00184   }
00185   else {
00186     $user = FALSE;
00187   }
00188
00189   return $user;
00190 }
00191
00210 function user_save($account, $array = array(), $category = 'account') {
00211   // Dynamically compose a SQL query:
00212   $user_fields = user_fields();
00213   if (is_object($account) && $account->uid) {
00214     user_module_invoke('update', $array, $account, $category);
00215     $query = '';
00216     $data = unserialize(db_result(db_query('SELECT data FROM {users} WHERE uid = %d', $account->uid)));
00217     // Consider users edited by an administrator as logged in, if they haven't
00218     // already, so anonymous users can view the profile (if allowed).
00219     if (empty($array['access']) && empty($account->access) && user_access('administer users')) {
00220       $array['access'] = time();
00221     }
00222     foreach ($array as $key => $value) {
00223       if ($key == 'pass' && !empty($value)) {
00224         $query .= "$key = '%s', ";
00225         $v[] = md5($value);
00226       }
00227       else if ((substr($key, 0, 4) !== 'auth') && ($key != 'pass')) {
00228         if (in_array($key, $user_fields)) {
00229           // Save standard fields.
00230           $query .= "$key = '%s', ";
00231           $v[] = $value;
00232         }
00233         else if ($key != 'roles') {
00234           // Roles is a special case: it used below.
00235           if ($value === NULL) {
00236             unset($data[$key]);
00237           }
00238           else {
00239             $data[$key] = $value;
00240           }
00241         }
00242       }
00243     }
00244     $query .= "data = '%s' ";
00245     $v[] = serialize($data);
00246
00247     $success = db_query("UPDATE {users} SET $query WHERE uid = %d", array_merge($v, array($account->uid)));
00248     if (!$success) {
00249       // The query failed - better to abort the save than risk further data loss.
00250       return FALSE;
00251     }
00252
00253     // Reload user roles if provided.
00254     if (isset($array['roles']) && is_array($array['roles'])) {
00255       db_query('DELETE FROM {users_roles} WHERE uid = %d', $account->uid);
00256
00257       foreach (array_keys($array['roles']) as $rid) {
00258         if (!in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) {
00259           db_query('INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)', $account->uid, $rid);
00260         }
00261       }
00262     }
00263
00264     // Delete a blocked user's sessions to kick them if they are online.
00265     if (isset($array['status']) && $array['status'] == 0) {
00266       sess_destroy_uid($account->uid);
00267     }
00268
00269     // If the password changed, delete all open sessions and recreate
00270     // the current one.
00271     if (!empty($array['pass'])) {
00272       sess_destroy_uid($account->uid);
00273       sess_regenerate();
00274     }
00275
00276     // Refresh user object.
00277     $user = user_load(array('uid' => $account->uid));
00278
00279     // Send emails after we have the new user object.
00280     if (isset($array['status']) && $array['status'] != $account->status) {
00281       // The user's status is changing; conditionally send notification email.
00282       $op = $array['status'] == 1 ? 'status_activated' : 'status_blocked';
00283       _user_mail_notify($op, $user);
00284     }
00285
00286     user_module_invoke('after_update', $array, $user, $category);
00287   }
00288   else {
00289     // Allow 'created' to be set by the caller.
00290     if (!isset($array['created'])) {
00291       $array['created'] = time();
00292     }
00293     // Consider users created by an administrator as already logged in, so
00294     // anonymous users can view the profile (if allowed).
00295     if (empty($array['access']) && user_access('administer users')) {
00296       $array['access'] = time();
00297     }
00298
00299     // Note: we wait to save the data column to prevent module-handled
00300     // fields from being saved there. We cannot invoke hook_user('insert') here
00301     // because we don't have a fully initialized user object yet.
00302     foreach ($array as $key => $value) {
00303       switch ($key) {
00304         case 'pass':
00305           $fields[] = $key;
00306           $values[] = md5($value);
00307           $s[] = "'%s'";
00308           break;
00309         case 'mode':       case 'sort':     case 'timezone':
00310         case 'threshold':  case 'created':  case 'access':
00311         case 'login':      case 'status':
00312           $fields[] = $key;
00313           $values[] = $value;
00314           $s[] = "%d";
00315           break;
00316         default:
00317           if (substr($key, 0, 4) !== 'auth' && in_array($key, $user_fields)) {
00318             $fields[] = $key;
00319             $values[] = $value;
00320             $s[] = "'%s'";
00321           }
00322           break;
00323       }
00324     }
00325     $success = db_query('INSERT INTO {users} ('. implode(', ', $fields) .') VALUES ('. implode(', ', $s) .')', $values);
00326     if (!$success) {
00327       // On a failed INSERT some other existing user's uid may be returned.
00328       // We must abort to avoid overwriting their account.
00329       return FALSE;
00330     }
00331
00332     // Build the initial user object.
00333     $array['uid'] = db_last_insert_id('users', 'uid');
00334     $user = user_load(array('uid' => $array['uid']));
00335
00336     user_module_invoke('insert', $array, $user, $category);
00337
00338     // Build and save the serialized data field now.
00339     $data = array();
00340     foreach ($array as $key => $value) {
00341       if ((substr($key, 0, 4) !== 'auth') && ($key != 'roles') && (!in_array($key, $user_fields)) && ($value !== NULL)) {
00342         $data[$key] = $value;
00343       }
00344     }
00345     db_query("UPDATE {users} SET data = '%s' WHERE uid = %d", serialize($data), $user->uid);
00346
00347     // Save user roles (delete just to be safe).
00348     if (isset($array['roles']) && is_array($array['roles'])) {
00349       db_query('DELETE FROM {users_roles} WHERE uid = %d', $array['uid']);
00350       foreach (array_keys($array['roles']) as $rid) {
00351         if (!in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) {
00352           db_query('INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)', $array['uid'], $rid);
00353         }
00354       }
00355     }
00356
00357     // Build the finished user object.
00358     $user = user_load(array('uid' => $array['uid']));
00359   }
00360
00361   // Save distributed authentication mappings.
00362   $authmaps = array();
00363   foreach ($array as $key => $value) {
00364     if (substr($key, 0, 4) == 'auth') {
00365       $authmaps[$key] = $value;
00366     }
00367   }
00368   if (sizeof($authmaps) > 0) {
00369     user_set_authmaps($user, $authmaps);
00370   }
00371
00372   return $user;
00373 }
00374
00378 function user_validate_name($name) {
00379   if (!strlen($name)) return t('You must enter a username.');
00380   if (substr($name, 0, 1) == ' ') return t('The username cannot begin with a space.');
00381   if (substr($name, -1) == ' ') return t('The username cannot end with a space.');
00382   if (strpos($name, '  ') !== FALSE) return t('The username cannot contain multiple spaces in a row.');
00383   if (ereg("[^\x80-\xF7 [:alnum:]@_.-]", $name)) return t('The username contains an illegal character.');
00384   if (preg_match('/[\x{80}-\x{A0}'.          // Non-printable ISO-8859-1 + NBSP
00385                    '\x{AD}'.                 // Soft-hyphen
00386                    '\x{2000}-\x{200F}'.      // Various space characters
00387                    '\x{2028}-\x{202F}'.      // Bidirectional text overrides
00388                    '\x{205F}-\x{206F}'.      // Various text hinting characters
00389                    '\x{FEFF}'.               // Byte order mark
00390                    '\x{FF01}-\x{FF60}'.      // Full-width latin
00391                    '\x{FFF9}-\x{FFFD}'.      // Replacement characters
00392                    '\x{0}]/u',               // NULL byte
00393                    $name)) {
00394     return t('The username contains an illegal character.');
00395   }
00396   if (strpos($name, '@') !== FALSE && !eregi('@([0-9a-z](-?[0-9a-z])*.)+[a-z]{2}([zmuvtg]|fo|me)?$', $name)) return t('The username is not a valid authentication ID.');
00397   if (strlen($name) > USERNAME_MAX_LENGTH) return t('The username %name is too long: it must be %max characters or less.', array('%name' => $name, '%max' => USERNAME_MAX_LENGTH));
00398 }
00399
00400 function user_validate_mail($mail) {
00401   if (!$mail) return t('You must enter an e-mail address.');
00402   if (!valid_email_address($mail)) {
00403     return t('The e-mail address %mail is not valid.', array('%mail' => $mail));
00404   }
00405 }
00406
00407 function user_validate_picture(&$form, &$form_state) {
00408   // If required, validate the uploaded picture.
00409   $validators = array(
00410     'file_validate_is_image' => array(),
00411     'file_validate_image_resolution' => array(variable_get('user_picture_dimensions', '85x85')),
00412     'file_validate_size' => array(variable_get('user_picture_file_size', '30') * 1024),
00413   );
00414   if ($file = file_save_upload('picture_upload', $validators)) {
00415     // Remove the old picture.
00416     if (isset($form_state['values']['_account']->picture) && file_exists($form_state['values']['_account']->picture)) {
00417       file_delete($form_state['values']['_account']->picture);
00418     }
00419
00420     // The image was saved using file_save_upload() and was added to the
00421     // files table as a temporary file. We'll make a copy and let the garbage
00422     // collector delete the original upload.
00423     $info = image_get_info($file->filepath);
00424     $destination = variable_get('user_picture_path', 'pictures') .'/picture-'. $form['#uid'] .'.'. $info['extension'];
00425     if (file_copy($file, $destination, FILE_EXISTS_REPLACE)) {
00426       $form_state['values']['picture'] = $file->filepath;
00427     }
00428     else {
00429       form_set_error('picture_upload', t("Failed to upload the picture image; the %directory directory doesn't exist or is not writable.", array('%directory' => variable_get('user_picture_path', 'pictures'))));
00430     }
00431   }
00432 }
00433
00437 function user_password($length = 10) {
00438   // This variable contains the list of allowable characters for the
00439   // password. Note that the number 0 and the letter 'O' have been
00440   // removed to avoid confusion between the two. The same is true
00441   // of 'I', 1, and 'l'.
00442   $allowable_characters = 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789';
00443
00444   // Zero-based count of characters in the allowable list:
00445   $len = strlen($allowable_characters) - 1;
00446
00447   // Declare the password as a blank string.
00448   $pass = '';
00449
00450   // Loop the number of times specified by $length.
00451   for ($i = 0; $i < $length; $i++) {
00452
00453     // Each iteration, pick a random character from the
00454     // allowable string and append it to the password:
00455     $pass .= $allowable_characters[mt_rand(0, $len)];
00456   }
00457
00458   return $pass;
00459 }
00460
00480 function user_access($string, $account = NULL, $reset = FALSE) {
00481   global $user;
00482   static $perm = array();
00483
00484   if ($reset) {
00485     unset($perm);
00486   }
00487
00488   if (is_null($account)) {
00489     $account = $user;
00490   }
00491
00492   // User #1 has all privileges:
00493   if ($account->uid == 1) {
00494     return TRUE;
00495   }
00496
00497   // To reduce the number of SQL queries, we cache the user's permissions
00498   // in a static variable.
00499   if (!isset($perm[$account->uid])) {
00500     $result = db_query("SELECT p.perm FROM {role} r INNER JOIN {permission} p ON p.rid = r.rid WHERE r.rid IN (". db_placeholders($account->roles) .")", array_keys($account->roles));
00501
00502     $perms = array();
00503     while ($row = db_fetch_object($result)) {
00504       $perms += array_flip(explode(', ', $row->perm));
00505     }
00506     $perm[$account->uid] = $perms;
00507   }
00508
00509   return isset($perm[$account->uid][$string]);
00510 }
00511
00517 function user_is_blocked($name) {
00518   $deny = db_fetch_object(db_query("SELECT name FROM {users} WHERE status = 0 AND name = LOWER('%s')", $name));
00519
00520   return $deny;
00521 }
00522
00523 function user_fields() {
00524   static $fields;
00525
00526   if (!$fields) {
00527     $result = db_query('SELECT * FROM {users} WHERE uid = 1');
00528     if ($field = db_fetch_array($result)) {
00529       $fields = array_keys($field);
00530     }
00531     else {
00532       // Make sure we return the default fields at least.
00533       $fields = array('uid', 'name', 'pass', 'mail', 'picture', 'mode', 'sort', 'threshold', 'theme', 'signature', 'created', 'access', 'login', 'status', 'timezone', 'language', 'init', 'data');
00534     }
00535   }
00536
00537   return $fields;
00538 }
00539
00543 function user_perm() {
00544   return array('administer permissions', 'administer users', 'access user profiles', 'change own username');
00545 }
00546
00552 function user_file_download($file) {
00553   if (strpos($file, variable_get('user_picture_path', 'pictures') .'/picture-') === 0) {
00554     $info = image_get_info(file_create_path($file));
00555     return array('Content-type: '. $info['mime_type']);
00556   }
00557 }
00558
00562 function user_search($op = 'search', $keys = NULL, $skip_access_check = FALSE) {
00563   switch ($op) {
00564     case 'name':
00565       if ($skip_access_check || user_access('access user profiles')) {
00566         return t('Users');
00567       }
00568     case 'search':
00569       if (user_access('access user profiles')) {
00570         $find = array();
00571         // Replace wildcards with MySQL/PostgreSQL wildcards.
00572         $keys = preg_replace('!\*+!', '%', $keys);
00573         if (user_access('administer users')) {
00574           // Administrators can also search in the otherwise private email field.
00575           $result = pager_query("SELECT name, uid, mail FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%') OR LOWER(mail) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys, $keys);
00576           while ($account = db_fetch_object($result)) {
00577             $find[] = array('title' => $account->name .' ('. $account->mail .')', 'link' => url('user/'. $account->uid, array('absolute' => TRUE)));
00578           }
00579         }
00580         else {
00581           $result = pager_query("SELECT name, uid FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys);
00582           while ($account = db_fetch_object($result)) {
00583             $find[] = array('title' => $account->name, 'link' => url('user/'. $account->uid, array('absolute' => TRUE)));
00584           }
00585         }
00586         return $find;
00587       }
00588   }
00589 }
00590
00594 function user_elements() {
00595   return array(
00596     'user_profile_category' => array(),
00597     'user_profile_item' => array(),
00598   );
00599 }
00600
00604 function user_user($type, &$edit, &$account, $category = NULL) {
00605   if ($type == 'view') {
00606     $account->content['user_picture'] = array(
00607       '#value' => theme('user_picture', $account),
00608       '#weight' => -10,
00609     );
00610     if (!isset($account->content['summary'])) {
00611       $account->content['summary'] = array();
00612     }
00613     $account->content['summary'] += array(
00614       '#type' => 'user_profile_category',
00615       '#attributes' => array('class' => 'user-member'),
00616       '#weight' => 5,
00617       '#title' => t('History'),
00618     );
00619     $account->content['summary']['member_for'] =  array(
00620       '#type' => 'user_profile_item',
00621       '#title' => t('Member for'),
00622       '#value' => format_interval(time() - $account->created),
00623     );
00624   }
00625   if ($type == 'form' && $category == 'account') {
00626     $form_state = array();
00627     return user_edit_form($form_state, arg(1), $edit);
00628   }
00629
00630   if ($type == 'validate' && $category == 'account') {
00631     return _user_edit_validate(arg(1), $edit);
00632   }
00633
00634   if ($type == 'submit' && $category == 'account') {
00635     return _user_edit_submit(arg(1), $edit);
00636   }
00637
00638   if ($type == 'categories') {
00639     return array(array('name' => 'account', 'title' => t('Account settings'), 'weight' => 1));
00640   }
00641 }
00642
00643 function user_login_block() {
00644   $form = array(
00645     '#action' => url($_GET['q'], array('query' => drupal_get_destination())),
00646     '#id' => 'user-login-form',
00647     '#validate' => user_login_default_validators(),
00648     '#submit' => array('user_login_submit'),
00649   );
00650   $form['name'] = array('#type' => 'textfield',
00651     '#title' => t('Username'),
00652     '#maxlength' => USERNAME_MAX_LENGTH,
00653     '#size' => 15,
00654     '#required' => TRUE,
00655   );
00656   $form['pass'] = array('#type' => 'password',
00657     '#title' => t('Password'),
00658     '#maxlength' => 60,
00659     '#size' => 15,
00660     '#required' => TRUE,
00661   );
00662   $form['submit'] = array('#type' => 'submit',
00663     '#value' => t('Log in'),
00664   );
00665   $items = array();
00666   if (variable_get('user_register', 1)) {
00667     $items[] = l(t('Create new account'), 'user/register', array('title' => t('Create a new user account.')));
00668   }
00669   $items[] = l(t('Request new password'), 'user/password', array('title' => t('Request new password via e-mail.')));
00670   $form['links'] = array('#value' => theme('item_list', $items));
00671   return $form;
00672 }
00673
00677 function user_block($op = 'list', $delta = 0, $edit = array()) {
00678   global $user;
00679
00680   if ($op == 'list') {
00681     $blocks[0]['info'] = t('User login');
00682     // Not worth caching.
00683     $blocks[0]['cache'] = BLOCK_NO_CACHE;
00684
00685     $blocks[1]['info'] = t('Navigation');
00686     // Menu blocks can't be cached because each menu item can have
00687     // a custom access callback. menu.inc manages its own caching.
00688     $blocks[1]['cache'] = BLOCK_NO_CACHE;
00689
00690     $blocks[2]['info'] = t('Who\'s new');
00691
00692     // Too dynamic to cache.
00693     $blocks[3]['info'] = t('Who\'s online');
00694     $blocks[3]['cache'] = BLOCK_NO_CACHE;
00695     return $blocks;
00696   }
00697   else if ($op == 'configure' && $delta == 2) {
00698     $form['user_block_whois_new_count'] = array(
00699       '#type' => 'select',
00700       '#title' => t('Number of users to display'),
00701       '#default_value' => variable_get('user_block_whois_new_count', 5),
00702       '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)),
00703     );
00704     return $form;
00705   }
00706   else if ($op == 'configure' && $delta == 3) {
00707     $period = drupal_map_assoc(array(30, 60, 120, 180, 300, 600, 900, 1800, 2700, 3600, 5400, 7200, 10800, 21600, 43200, 86400), 'format_interval');
00708     $form['user_block_seconds_online'] = array('#type' => 'select', '#title' => t('User activity'), '#default_value' => variable_get('user_block_seconds_online', 900), '#options' => $period, '#description' => t('A user is considered online for this long after they have last viewed a page.'));
00709     $form['user_block_max_list_count'] = array('#type' => 'select', '#title' => t('User list length'), '#default_value' => variable_get('user_block_max_list_count', 10), '#options' => drupal_map_assoc(array(0, 5, 10, 15, 20, 25, 30, 40, 50, 75, 100)), '#description' => t('Maximum number of currently online users to display.'));
00710
00711     return $form;
00712   }
00713   else if ($op == 'save' && $delta == 2) {
00714     variable_set('user_block_whois_new_count', $edit['user_block_whois_new_count']);
00715   }
00716   else if ($op == 'save' && $delta == 3) {
00717     variable_set('user_block_seconds_online', $edit['user_block_seconds_online']);
00718     variable_set('user_block_max_list_count', $edit['user_block_max_list_count']);
00719   }
00720   else if ($op == 'view') {
00721     $block = array();
00722
00723     switch ($delta) {
00724       case 0:
00725         // For usability's sake, avoid showing two login forms on one page.
00726         if (!$user->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))) {
00727
00728           $block['subject'] = t('User login');
00729           $block['content'] = drupal_get_form('user_login_block');
00730         }
00731         return $block;
00732
00733       case 1:
00734         if ($menu = menu_tree()) {
00735           $block['subject'] = $user->uid ? check_plain($user->name) : t('Navigation');
00736           $block['content'] = $menu;
00737         }
00738         return $block;
00739
00740       case 2:
00741         if (user_access('access content')) {
00742           // Retrieve a list of new users who have subsequently accessed the site successfully.
00743           $result = db_query_range('SELECT uid, name FROM {users} WHERE status != 0 AND access != 0 ORDER BY created DESC', 0, variable_get('user_block_whois_new_count', 5));
00744           while ($account = db_fetch_object($result)) {
00745             $items[] = $account;
00746           }
00747           $output = theme('user_list', $items);
00748
00749           $block['subject'] = t('Who\'s new');
00750           $block['content'] = $output;
00751         }
00752         return $block;
00753
00754       case 3:
00755         if (user_access('access content')) {
00756           // Count users active within the defined period.
00757           $interval = time() - variable_get('user_block_seconds_online', 900);
00758
00759           // Perform database queries to gather online user lists.  We use s.timestamp
00760           // rather than u.access because it is much faster.
00761           $anonymous_count = sess_count($interval);
00762           $authenticated_users = db_query('SELECT DISTINCT u.uid, u.name, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', $interval);
00763           $authenticated_count = 0;
00764           $max_users = variable_get('user_block_max_list_count', 10);
00765           $items = array();
00766           while ($account = db_fetch_object($authenticated_users)) {
00767             if ($max_users > 0) {
00768               $items[] = $account;
00769               $max_users--;
00770             }
00771             $authenticated_count++;
00772           }
00773
00774           // Format the output with proper grammar.
00775           if ($anonymous_count == 1 && $authenticated_count == 1) {
00776             $output = t('There is currently %members and %visitors online.', array('%members' => format_plural($authenticated_count, '1 user', '@count users'), '%visitors' => format_plural($anonymous_count, '1 guest', '@count guests')));
00777           }
00778           else {
00779             $output = t('There are currently %members and %visitors online.', array('%members' => format_plural($authenticated_count, '1 user', '@count users'), '%visitors' => format_plural($anonymous_count, '1 guest', '@count guests')));
00780           }
00781
00782           // Display a list of currently online users.
00783           $max_users = variable_get('user_block_max_list_count', 10);
00784           if ($authenticated_count && $max_users) {
00785             $output .= theme('user_list', $items, t('Online users'));
00786           }
00787
00788           $block['subject'] = t('Who\'s online');
00789           $block['content'] = $output;
00790         }
00791         return $block;
00792     }
00793   }
00794 }
00795
00804 function template_preprocess_user_picture(&$variables) {
00805   $variables['picture'] = '';
00806   if (variable_get('user_pictures', 0)) {
00807     $account = $variables['account'];
00808     if (!empty($account->picture) && file_exists($account->picture)) {
00809       $picture = file_create_url($account->picture);
00810     }
00811     else if (variable_get('user_picture_default', '')) {
00812       $picture = variable_get('user_picture_default', '');
00813     }
00814
00815     if (isset($picture)) {
00816       $alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
00817       $variables['picture'] = theme('image', $picture, $alt, $alt, '', FALSE);
00818       if (!empty($account->uid) && user_access('access user profiles')) {
00819         $attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE);
00820         $variables['picture'] = l($variables['picture'], "user/$account->uid", $attributes);
00821       }
00822     }
00823   }
00824 }
00825
00836 function theme_user_list($users, $title = NULL) {
00837   if (!empty($users)) {
00838     foreach ($users as $user) {
00839       $items[] = theme('username', $user);
00840     }
00841   }
00842   return theme('item_list', $items, $title);
00843 }
00844
00845 function user_is_anonymous() {
00846   // Menu administrators can see items for anonymous when administering.
00847   return !$GLOBALS['user']->uid || !empty($GLOBALS['menu_admin']);
00848 }
00849
00850 function user_is_logged_in() {
00851   return (bool)$GLOBALS['user']->uid;
00852 }
00853
00854 function user_register_access() {
00855   return user_is_anonymous() && variable_get('user_register', 1);
00856 }
00857
00858 function user_view_access($account) {
00859   return $account && $account->uid &&
00860     (
00861       // Always let users view their own profile.
00862       ($GLOBALS['user']->uid == $account->uid) ||
00863       // Administrators can view all accounts.
00864       user_access('administer users') ||
00865       // The user is not blocked and logged in at least once.
00866       ($account->access && $account->status && user_access('access user profiles'))
00867     );
00868 }
00869
00870 function user_edit_access($account) {
00871   return (($GLOBALS['user']->uid == $account->uid) || user_access('administer users')) && $account->uid > 0;
00872 }
00873
00874 function user_load_self($arg) {
00875   $arg[1] = user_load($GLOBALS['user']->uid);
00876   return $arg;
00877 }
00878
00882 function user_menu() {
00883   $items['user/autocomplete'] = array(
00884     'title' => 'User autocomplete',
00885     'page callback' => 'user_autocomplete',
00886     'access callback' => 'user_access',
00887     'access arguments' => array('access user profiles'),
00888     'type' => MENU_CALLBACK,
00889     'file' => 'user.pages.inc',
00890   );
00891
00892   // Registration and login pages.
00893   $items['user'] = array(
00894     'title' => 'User account',
00895     'page callback' => 'user_page',
00896     'access callback' => TRUE,
00897     'type' => MENU_CALLBACK,
00898     'file' => 'user.pages.inc',
00899   );
00900
00901   $items['user/login'] = array(
00902     'title' => 'Log in',
00903     'access callback' => 'user_is_anonymous',
00904     'type' => MENU_DEFAULT_LOCAL_TASK,
00905   );
00906
00907   $items['user/register'] = array(
00908     'title' => 'Create new account',
00909     'page callback' => 'drupal_get_form',
00910     'page arguments' => array('user_register'),
00911     'access callback' => 'user_register_access',
00912     'type' => MENU_LOCAL_TASK,
00913     'file' => 'user.pages.inc',
00914   );
00915
00916   $items['user/password'] = array(
00917     'title' => 'Request new password',
00918     'page callback' => 'drupal_get_form',
00919     'page arguments' => array('user_pass'),
00920     'access callback' => 'user_is_anonymous',
00921     'type' => MENU_LOCAL_TASK,
00922     'file' => 'user.pages.inc',
00923   );
00924   $items['user/reset/%/%/%'] = array(
00925     'title' => 'Reset password',
00926     'page callback' => 'drupal_get_form',
00927     'page arguments' => array('user_pass_reset', 2, 3, 4),
00928     'access callback' => TRUE,
00929     'type' => MENU_CALLBACK,
00930     'file' => 'user.pages.inc',
00931   );
00932
00933   // Admin user pages.
00934   $items['admin/user'] = array(
00935     'title' => 'User management',
00936     'description' => "Manage your site's users, groups and access to site features.",
00937     'position' => 'left',
00938     'page callback' => 'system_admin_menu_block_page',
00939     'access arguments' => array('access administration pages'),
00940     'file' => 'system.admin.inc',
00941     'file path' => drupal_get_path('module', 'system'),
00942   );
00943   $items['admin/user/user'] = array(
00944     'title' => 'Users',
00945     'description' => 'List, add, and edit users.',
00946     'page callback' => 'user_admin',
00947     'page arguments' => array('list'),
00948     'access arguments' => array('administer users'),
00949     'file' => 'user.admin.inc',
00950   );
00951   $items['admin/user/user/list'] = array(
00952     'title' => 'List',
00953     'type' => MENU_DEFAULT_LOCAL_TASK,
00954     'weight' => -10,
00955   );
00956   $items['admin/user/user/create'] = array(
00957     'title' => 'Add user',
00958     'page arguments' => array('create'),
00959     'type' => MENU_LOCAL_TASK,
00960     'file' => 'user.admin.inc',
00961   );
00962   $items['admin/user/settings'] = array(
00963     'title' => 'User settings',
00964     'description' => 'Configure default behavior of users, including registration requirements, e-mails, and user pictures.',
00965     'page callback' => 'drupal_get_form',
00966     'page arguments' => array('user_admin_settings'),
00967     'access arguments' => array('administer users'),
00968     'file' => 'user.admin.inc',
00969   );
00970
00971   // Admin access pages.
00972   $items['admin/user/permissions'] = array(
00973     'title' => 'Permissions',
00974     'description' => 'Determine access to features by selecting permissions for roles.',
00975     'page callback' => 'drupal_get_form',
00976     'page arguments' => array('user_admin_perm'),
00977     'access arguments' => array('administer permissions'),
00978     'file' => 'user.admin.inc',
00979   );
00980   $items['admin/user/roles'] = array(
00981     'title' => 'Roles',
00982     'description' => 'List, edit, or add user roles.',
00983     'page callback' => 'drupal_get_form',
00984     'page arguments' => array('user_admin_new_role'),
00985     'access arguments' => array('administer permissions'),
00986     'file' => 'user.admin.inc',
00987   );
00988   $items['admin/user/roles/edit'] = array(
00989     'title' => 'Edit role',
00990     'page arguments' => array('user_admin_role'),
00991     'type' => MENU_CALLBACK,
00992     'file' => 'user.admin.inc',
00993   );
00994   $items['admin/user/rules'] = array(
00995     'title' => 'Access rules',
00996     'description' => 'List and create rules to disallow usernames, e-mail addresses, and IP addresses.',
00997     'page callback' => 'user_admin_access',
00998     'access arguments' => array('administer permissions'),
00999     'file' => 'user.admin.inc',
01000   );
01001   $items['admin/user/rules/list'] = array(
01002     'title' => 'List',
01003     'type' => MENU_DEFAULT_LOCAL_TASK,
01004     'weight' => -10,
01005   );
01006   $items['admin/user/rules/add'] = array(
01007     'title' => 'Add rule',
01008     'page callback' => 'user_admin_access_add',
01009     'type' => MENU_LOCAL_TASK,
01010     'file' => 'user.admin.inc',
01011   );
01012   $items['admin/user/rules/check'] = array(
01013     'title' => 'Check rules',
01014     'page callback' => 'user_admin_access_check',
01015     'type' => MENU_LOCAL_TASK,
01016     'file' => 'user.admin.inc',
01017   );
01018   $items['admin/user/rules/edit'] = array(
01019     'title' => 'Edit rule',
01020     'page callback' => 'user_admin_access_edit',
01021     'type' => MENU_CALLBACK,
01022     'file' => 'user.admin.inc',
01023   );
01024   $items['admin/user/rules/delete'] = array(
01025     'title' => 'Delete rule',
01026     'page callback' => 'drupal_get_form',
01027     'page arguments' => array('user_admin_access_delete_confirm'),
01028     'type' => MENU_CALLBACK,
01029     'file' => 'user.admin.inc',
01030   );
01031
01032   $items['logout'] = array(
01033     'title' => 'Log out',
01034     'access callback' => 'user_is_logged_in',
01035     'page callback' => 'user_logout',
01036     'weight' => 10,
01037     'file' => 'user.pages.inc',
01038   );
01039
01040   $items['user/%user_current'] = array(
01041     'title' => 'My account',
01042     'title callback' => 'user_page_title',
01043     'title arguments' => array(1),
01044     'page callback' => 'user_view',
01045     'page arguments' => array(1),
01046     'access callback' => 'user_view_access',
01047     'access arguments' => array(1),
01048     'parent' => '',
01049     'file' => 'user.pages.inc',
01050   );
01051
01052   $items['user/%user/view'] = array(
01053     'title' => 'View',
01054     'type' => MENU_DEFAULT_LOCAL_TASK,
01055     'weight' => -10,
01056   );
01057
01058   $items['user/%user/delete'] = array(
01059     'title' => 'Delete',
01060     'page callback' => 'drupal_get_form',
01061     'page arguments' => array('user_confirm_delete', 1),
01062     'access callback' => 'user_access',
01063     'access arguments' => array('administer users'),
01064     'type' => MENU_CALLBACK,
01065     'file' => 'user.pages.inc',
01066   );
01067
01068   $items['user/%user_category/edit'] = array(
01069     'title' => 'Edit',
01070     'page callback' => 'user_edit',
01071     'page arguments' => array(1),
01072     'access callback' => 'user_edit_access',
01073     'access arguments' => array(1),
01074     'type' => MENU_LOCAL_TASK,
01075     'load arguments' => array('%map', '%index'),
01076     'file' => 'user.pages.inc',
01077   );
01078
01079   $items['user/%user_category/edit/account'] = array(
01080     'title' => 'Account',
01081     'type' => MENU_DEFAULT_LOCAL_TASK,
01082     'load arguments' => array('%map', '%index'),
01083   );
01084
01085   $empty_account = new stdClass();
01086   if (($categories = _user_categories($empty_account)) && (count($categories) > 1)) {
01087     foreach ($categories as $key => $category) {
01088       // 'account' is already handled by the MENU_DEFAULT_LOCAL_TASK.
01089       if ($category['name'] != 'account') {
01090         $items['user/%user_category/edit/'. $category['name']] = array(
01091           'title callback' => 'check_plain',
01092           'title arguments' => array($category['title']),
01093           'page callback' => 'user_edit',
01094           'page arguments' => array(1, 3),
01095           'access callback' => isset($category['access callback']) ? $category['access callback'] : TRUE,
01096           'access arguments' => isset($category['access arguments']) ? $category['access arguments'] : array(),
01097           'type' => MENU_LOCAL_TASK,
01098           'weight' => $category['weight'],
01099           'load arguments' => array('%map', '%index'),
01100           'tab_parent' => 'user/%/edit',
01101           'file' => 'user.pages.inc',
01102         );
01103       }
01104     }
01105   }
01106   return $items;
01107 }
01108
01109 function user_init() {
01110   drupal_add_css(drupal_get_path('module', 'user') .'/user.css', 'module');
01111 }
01112
01113 function user_current_load($arg) {
01114   return user_load($arg ? $arg : $GLOBALS['user']->uid);
01115 }
01116
01120 function user_category_load($uid, &$map, $index) {
01121   static $user_categories, $accounts;
01122
01123   // Cache $account - this load function will get called for each profile tab.
01124   if (!isset($accounts[$uid])) {
01125     $accounts[$uid] = user_load($uid);
01126   }
01127   $valid = TRUE;
01128   if ($account = $accounts[$uid]) {
01129     // Since the path is like user/%/edit/category_name, the category name will
01130     // be at a position 2 beyond the index corresponding to the % wildcard.
01131     $category_index = $index + 2;
01132     // Valid categories may contain slashes, and hence need to be imploded.
01133     $category_path = implode('/', array_slice($map, $category_index));
01134     if ($category_path) {
01135       // Check that the requested category exists.
01136       $valid = FALSE;
01137       if (!isset($user_categories)) {
01138         $empty_account = new stdClass();
01139         $user_categories = _user_categories($empty_account);
01140       }
01141       foreach ($user_categories as $category) {
01142         if ($category['name'] == $category_path) {
01143           $valid = TRUE;
01144           // Truncate the map array in case the category name had slashes.
01145           $map = array_slice($map, 0, $category_index);
01146           // Assign the imploded category name to the last map element.
01147           $map[$category_index] = $category_path;
01148           break;
01149         }
01150       }
01151     }
01152   }
01153   return $valid ? $account : FALSE;
01154 }
01155
01159 function user_current_to_arg($arg) {
01160   // Give back the current user uid when called from eg. tracker, aka.
01161   // with an empty arg. Also use the current user uid when called from
01162   // the menu with a % for the current account link.
01163   return empty($arg) || $arg == '%' ? $GLOBALS['user']->uid : $arg;
01164 }
01165
01169 function user_page_title($account) {
01170   if ($account->uid == $GLOBALS['user']->uid) {
01171     return t('My account');
01172   }
01173   return $account->name;
01174 }
01175
01184 function user_get_authmaps($authname = NULL) {
01185   $result = db_query("SELECT authname, module FROM {authmap} WHERE authname = '%s'", $authname);
01186   $authmaps = array();
01187   $has_rows = FALSE;
01188   while ($authmap = db_fetch_object($result)) {
01189     $authmaps[$authmap->module] = $authmap->authname;
01190     $has_rows = TRUE;
01191   }
01192   return $has_rows ? $authmaps : 0;
01193 }
01194
01207 function user_set_authmaps($account, $authmaps) {
01208   foreach ($authmaps as $key => $value) {
01209     $module = explode('_', $key, 2);
01210     if ($value) {
01211       db_query("UPDATE {authmap} SET authname = '%s' WHERE uid = %d AND module = '%s'", $value, $account->uid, $module[1]);
01212       if (!db_affected_rows()) {
01213         db_query("INSERT INTO {authmap} (authname, uid, module) VALUES ('%s', %d, '%s')", $value, $account->uid, $module[1]);
01214       }
01215     }
01216     else {
01217       db_query("DELETE FROM {authmap} WHERE uid = %d AND module = '%s'", $account->uid, $module[1]);
01218     }
01219   }
01220 }
01221
01227 function user_login(&$form_state, $msg = '') {
01228   global $user;
01229
01230   // If we are already logged on, go to the user page instead.
01231   if ($user->uid) {
01232     drupal_goto('user/'. $user->uid);
01233   }
01234
01235   // Display login form:
01236   if ($msg) {
01237     $form['message'] = array('#value' => '<p>'. check_plain($msg) .'</p>');
01238   }
01239   $form['name'] = array('#type' => 'textfield',
01240     '#title' => t('Username'),
01241     '#size' => 60,
01242     '#maxlength' => USERNAME_MAX_LENGTH,
01243     '#required' => TRUE,
01244     '#attributes' => array('tabindex' => '1'),
01245   );
01246
01247   $form['name']['#description'] = t('Enter your @s username.', array('@s' => variable_get('site_name', 'Drupal')));
01248   $form['pass'] = array('#type' => 'password',
01249     '#title' => t('Password'),
01250     '#description' => t('Enter the password that accompanies your username.'),
01251     '#required' => TRUE,
01252     '#attributes' => array('tabindex' => '2'),
01253   );
01254   $form['#validate'] = user_login_default_validators();
01255   $form['submit'] = array('#type' => 'submit', '#value' => t('Log in'), '#weight' => 2, '#attributes' => array('tabindex' => '3'));
01256
01257   return $form;
01258 }
01259
01277 function user_login_default_validators() {
01278   return array('user_login_name_validate', 'user_login_authenticate_validate', 'user_login_final_validate');
01279 }
01280
01285 function user_login_name_validate($form, &$form_state) {
01286   if (isset($form_state['values']['name'])) {
01287     if (user_is_blocked($form_state['values']['name'])) {
01288       // blocked in user administration
01289       form_set_error('name', t('The username %name has not been activated or is blocked.', array('%name' => $form_state['values']['name'])));
01290     }
01291     else if (drupal_is_denied('user', $form_state['values']['name'])) {
01292       // denied by access controls
01293       form_set_error('name', t('The name %name is a reserved username.', array('%name' => $form_state['values']['name'])));
01294     }
01295   }
01296 }
01297
01302 function user_login_authenticate_validate($form, &$form_state) {
01303   user_authenticate($form_state['values']);
01304 }
01305
01310 function user_login_final_validate($form, &$form_state) {
01311   global $user;
01312   if (!$user->uid) {
01313     form_set_error('name', t('Sorry, unrecognized username or password. <a href="@password">Have you forgotten your password?</a>', array('@password' => url('user/password'))));
01314     watchdog('user', 'Login attempt failed for %user.', array('%user' => $form_state['values']['name']));
01315   }
01316 }
01317
01328 function user_authenticate($form_values = array()) {
01329   global $user;
01330
01331   // Name and pass keys are required.
01332   if (!empty($form_values['name']) && !empty($form_values['pass']) &&
01333       $account = user_load(array('name' => $form_values['name'], 'pass' => trim($form_values['pass']), 'status' => 1))) {
01334     $user = $account;
01335     user_authenticate_finalize($form_values);
01336     return $user;
01337   }
01338 }
01339
01349 function user_authenticate_finalize(&$edit) {
01350   global $user;
01351   watchdog('user', 'Session opened for %name.', array('%name' => $user->name));
01352   // Update the user table timestamp noting user has logged in.
01353   // This is also used to invalidate one-time login links.
01354   $user->login = time();
01355   db_query("UPDATE {users} SET login = %d WHERE uid = %d", $user->login, $user->uid);
01356   user_module_invoke('login', $edit, $user);
01357   sess_regenerate();
01358 }
01359
01366 function user_login_submit($form, &$form_state) {
01367   global $user;
01368   if ($user->uid) {
01369     $form_state['redirect'] = 'user/'. $user->uid;
01370     return;
01371   }
01372 }
01373
01379 function user_external_login_register($name, $module) {
01380   global $user;
01381
01382   $user = user_load(array('name' => $name));
01383   if (!isset($user->uid)) {
01384     // Register this new user.
01385     $userinfo = array(
01386       'name' => $name,
01387       'pass' => user_password(),
01388       'init' => $name,
01389       'status' => 1,
01390       "authname_$module" => $name,
01391       'access' => time()
01392     );
01393     $account = user_save('', $userinfo);
01394     // Terminate if an error occured during user_save().
01395     if (!$account) {
01396       drupal_set_message(t("Error saving user account."), 'error');
01397       return;
01398     }
01399     $user = $account;
01400     watchdog('user', 'New external user: %name using module %module.', array('%name' => $name, '%module' => $module), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $user->uid .'/edit'));
01401   }
01402 }
01403
01404 function user_pass_reset_url($account) {
01405   $timestamp = time();
01406   return url("user/reset/$account->uid/$timestamp/". user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE));
01407 }
01408
01409 function user_pass_rehash($password, $timestamp, $login) {
01410   return md5($timestamp . $password . $login);
01411 }
01412
01413 function user_edit_form(&$form_state, $uid, $edit, $register = FALSE) {
01414   _user_password_dynamic_validation();
01415   $admin = user_access('administer users');
01416
01417   // Account information:
01418   $form['account'] = array('#type' => 'fieldset',
01419     '#title' => t('Account information'),
01420     '#weight' => -10,
01421   );
01422   if (user_access('change own username') || $admin || $register) {
01423     $form['account']['name'] = array('#type' => 'textfield',
01424       '#title' => t('Username'),
01425       '#default_value' => $edit['name'],
01426       '#maxlength' => USERNAME_MAX_LENGTH,
01427       '#description' => t('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.'),
01428       '#required' => TRUE,
01429     );
01430   }
01431   $form['account']['mail'] = array('#type' => 'textfield',
01432     '#title' => t('E-mail address'),
01433     '#default_value' => $edit['mail'],
01434     '#maxlength' => EMAIL_MAX_LENGTH,
01435     '#description' => t('A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'),
01436     '#required' => TRUE,
01437   );
01438   if (!$register) {
01439     $form['account']['pass'] = array('#type' => 'password_confirm',
01440       '#description' => t('To change the current user password, enter the new password in both fields.'),
01441       '#size' => 25,
01442     );
01443   }
01444   elseif (!variable_get('user_email_verification', TRUE) || $admin) {
01445     $form['account']['pass'] = array(
01446       '#type' => 'password_confirm',
01447       '#description' => t('Provide a password for the new account in both fields.'),
01448       '#required' => TRUE,
01449       '#size' => 25,
01450     );
01451   }
01452   if ($admin) {
01453     $form['account']['status'] = array(
01454       '#type' => 'radios',
01455       '#title' => t('Status'),
01456       '#default_value' => isset($edit['status']) ? $edit['status'] : 1,
01457       '#options' => array(t('Blocked'), t('Active'))
01458     );
01459   }
01460   if (user_access('administer permissions')) {
01461     $roles = user_roles(TRUE);
01462
01463     // The disabled checkbox subelement for the 'authenticated user' role
01464     // must be generated separately and added to the checkboxes element,
01465     // because of a limitation in D6 FormAPI not supporting a single disabled
01466     // checkbox within a set of checkboxes.
01467     // TODO: This should be solved more elegantly. See issue #119038.
01468     $checkbox_authenticated = array(
01469       '#type' => 'checkbox',
01470       '#title' => $roles[DRUPAL_AUTHENTICATED_RID],
01471       '#default_value' => TRUE,
01472       '#disabled' => TRUE,
01473     );
01474
01475     unset($roles[DRUPAL_AUTHENTICATED_RID]);
01476     if ($roles) {
01477       $default = empty($edit['roles']) ? array() : array_keys($edit['roles']);
01478       $form['account']['roles'] = array(
01479         '#type' => 'checkboxes',
01480         '#title' => t('Roles'),
01481         '#default_value' => $default,
01482         '#options' => $roles,
01483         DRUPAL_AUTHENTICATED_RID => $checkbox_authenticated,
01484       );
01485     }
01486   }
01487
01488   // Signature:
01489   if (variable_get('user_signatures', 0) && module_exists('comment') && !$register) {
01490     $form['signature_settings'] = array(
01491       '#type' => 'fieldset',
01492       '#title' => t('Signature settings'),
01493       '#weight' => 1,
01494     );
01495     $form['signature_settings']['signature'] = array(
01496       '#type' => 'textarea',
01497       '#title' => t('Signature'),
01498       '#default_value' => $edit['signature'],
01499       '#description' => t('Your signature will be publicly displayed at the end of your comments.'),
01500     );
01501   }
01502
01503   // Picture/avatar:
01504   if (variable_get('user_pictures', 0) && !$register) {
01505     $form['picture'] = array('#type' => 'fieldset', '#title' => t('Picture'), '#weight' => 1);
01506     $picture = theme('user_picture', (object)$edit);
01507     if ($edit['picture']) {
01508       $form['picture']['current_picture'] = array('#value' => $picture);
01509       $form['picture']['picture_delete'] = array('#type' => 'checkbox', '#title' => t('Delete picture'), '#description' => t('Check this box to delete your current picture.'));
01510     }
01511     else {
01512       $form['picture']['picture_delete'] = array('#type' => 'hidden');
01513     }
01514     $form['picture']['picture_upload'] = array('#type' => 'file', '#title' => t('Upload picture'), '#size' => 48, '#description' => t('Your virtual face or picture. Maximum dimensions are %dimensions and the maximum size is %size kB.', array('%dimensions' => variable_get('user_picture_dimensions', '85x85'), '%size' => variable_get('user_picture_file_size', '30'))) .' '. variable_get('user_picture_guidelines', ''));
01515     $form['#validate'][] = 'user_validate_picture';
01516   }
01517   $form['#uid'] = $uid;
01518
01519   return $form;
01520 }
01521
01522 function _user_edit_validate($uid, &$edit) {
01523   $user = user_load(array('uid' => $uid));
01524   // Validate the username:
01525   if (user_access('change own username') || user_access('administer users') || !$user->uid) {
01526     if ($error = user_validate_name($edit['name'])) {
01527       form_set_error('name', $error);
01528     }
01529     else if (db_result(db_query("SELECT COUNT(*) FROM {users} WHERE uid != %d AND LOWER(name) = LOWER('%s')", $uid, $edit['name'])) > 0) {
01530       form_set_error('name', t('The name %name is already taken.', array('%name' => $edit['name'])));
01531     }
01532     else if (drupal_is_denied('user', $edit['name'])) {
01533       form_set_error('name', t('The name %name has been denied access.', array('%name' => $edit['name'])));
01534     }
01535   }
01536
01537   // Validate the e-mail address:
01538   if ($error = user_validate_mail($edit['mail'])) {
01539     form_set_error('mail', $error);
01540   }
01541   else if (db_result(db_query("SELECT COUNT(*) FROM {users} WHERE uid != %d AND LOWER(mail) = LOWER('%s')", $uid, $edit['mail'])) > 0) {
01542     form_set_error('mail', t('The e-mail address %email is already registered. <a href="@password">Have you forgotten your password?</a>', array('%email' => $edit['mail'], '@password' => url('user/password'))));
01543   }
01544   else if (drupal_is_denied('mail', $edit['mail'])) {
01545     form_set_error('mail', t('The e-mail address %email has been denied access.', array('%email' => $edit['mail'])));
01546   }
01547 }
01548
01549 function _user_edit_submit($uid, &$edit) {
01550   $user = user_load(array('uid' => $uid));
01551   // Delete picture if requested, and if no replacement picture was given.
01552   if (!empty($edit['picture_delete'])) {
01553     if ($user->picture && file_exists($user->picture)) {
01554       file_delete($user->picture);
01555     }
01556     $edit['picture'] = '';
01557   }
01558   if (isset($edit['roles'])) {
01559     $edit['roles'] = array_filter($edit['roles']);
01560   }
01561 }
01562
01569 function user_delete($edit, $uid) {
01570   $account = user_load(array('uid' => $uid));
01571   sess_destroy_uid($uid);
01572   _user_mail_notify('status_deleted', $account);
01573   db_query('DELETE FROM {users} WHERE uid = %d', $uid);
01574   db_query('DELETE FROM {users_roles} WHERE uid = %d', $uid);
01575   db_query('DELETE FROM {authmap} WHERE uid = %d', $uid);
01576   $variables = array('%name' => $account->name, '%email' => '<'. $account->mail .'>');
01577   watchdog('user', 'Deleted user: %name %email.', $variables, WATCHDOG_NOTICE);
01578   module_invoke_all('user', 'delete', $edit, $account);
01579 }
01580
01590 function user_build_content(&$account) {
01591   $edit = NULL;
01592   user_module_invoke('view', $edit, $account);
01593   // Allow modules to modify the fully-built profile.
01594   drupal_alter('profile', $account);
01595
01596   return $account->content;
01597 }
01598
01602 function user_mail($key, &$message, $params) {
01603   $language = $message['language'];
01604   $variables = user_mail_tokens($params['account'], $language);
01605   $message['subject'] .= _user_mail_text($key .'_subject', $language, $variables);
01606   $message['body'][] = _user_mail_text($key .'_body', $language, $variables);
01607 }
01608
01614 function _user_mail_text($key, $language = NULL, $variables = array()) {
01615   $langcode = isset($language) ? $language->language : NULL;
01616
01617   if ($admin_setting = variable_get('user_mail_'. $key, FALSE)) {
01618     // An admin setting overrides the default string.
01619     return strtr($admin_setting, $variables);
01620   }
01621   else {
01622     // No override, return default string.
01623     switch ($key) {
01624       case 'register_no_approval_required_subject':
01625         return t('Account details for !username at !site', $variables, $langcode);
01626       case 'register_no_approval_required_body':
01627         return t("!username,\n\nThank you for registering at !site. You may now log in to !login_uri using the following username and password:\n\nusername: !username\npassword: !password\n\nYou may also log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\n\n--  !site team", $variables, $langcode);
01628       case 'register_admin_created_subject':
01629         return t('An administrator created an account for you at !site', $variables, $langcode);
01630       case 'register_admin_created_body':
01631         return t("!username,\n\nA site administrator at !site has created an account for you. You may now log in to !login_uri using the following username and password:\n\nusername: !username\npassword: !password\n\nYou may also log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\n\n--  !site team", $variables, $langcode);
01632       case 'register_pending_approval_subject':
01633       case 'pending_approval_admin_subject':
01634         return t('Account details for !username at !site (pending admin approval)', $variables, $langcode);
01635       case 'register_pending_approval_body':
01636         return t("!username,\n\nThank you for registering at !site. Your application for an account is currently pending approval. Once it has been approved, you will receive another e-mail containing information about how to log in, set your password, and other details.\n\n\n--  !site team", $variables, $langcode);
01637       case 'register_pending_approval_admin_body':
01638         return t("!username has applied for an account.\n\n!edit_uri", $variables, $langcode);
01639       case 'password_reset_subject':
01640         return t('Replacement login information for !username at !site', $variables, $langcode);
01641       case 'password_reset_body':
01642         return t("!username,\n\nA request to reset the password for your account has been made at !site.\n\nYou may now log in to !uri_brief by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once. It expires after one day and nothing will happen if it's not used.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.", $variables, $langcode);
01643       case 'status_activated_subject':
01644         return t('Account details for !username at !site (approved)', $variables, $langcode);
01645       case 'status_activated_body':
01646         return t("!username,\n\nYour account at !site has been activated.\n\nYou may now log in by clicking on this link or copying and pasting it in your browser:\n\n!login_url\n\nThis is a one-time login, so it can be used only once.\n\nAfter logging in, you will be redirected to !edit_uri so you can change your password.\n\nOnce you have set your own password, you will be able to log in to !login_uri in the future using:\n\nusername: !username\n", $variables, $langcode);
01647       case 'status_blocked_subject':
01648         return t('Account details for !username at !site (blocked)', $variables, $langcode);
01649       case 'status_blocked_body':
01650         return t("!username,\n\nYour account on !site has been blocked.", $variables, $langcode);
01651       case 'status_deleted_subject':
01652         return t('Account details for !username at !site (deleted)', $variables, $langcode);
01653       case 'status_deleted_body':
01654         return t("!username,\n\nYour account on !site has been deleted.", $variables, $langcode);
01655     }
01656   }
01657 }
01658
01659 /*** Administrative features ***********************************************/
01660
01674 function user_roles($membersonly = FALSE, $permission = NULL) {
01675   // System roles take the first two positions.
01676   $roles = array(
01677     DRUPAL_ANONYMOUS_RID => NULL,
01678     DRUPAL_AUTHENTICATED_RID => NULL,
01679   );
01680
01681   if (!empty($permission)) {
01682     $result = db_query("SELECT r.* FROM {role} r INNER JOIN {permission} p ON r.rid = p.rid WHERE p.perm LIKE '%%%s%%' ORDER BY r.name", $permission);
01683   }
01684   else {
01685     $result = db_query('SELECT * FROM {role} ORDER BY name');
01686   }
01687
01688   while ($role = db_fetch_object($result)) {
01689     switch ($role->rid) {
01690       // We only translate the built in role names
01691       case DRUPAL_ANONYMOUS_RID:
01692         if (!$membersonly) {
01693           $roles[$role->rid] = t($role->name);
01694         }
01695         break;
01696       case DRUPAL_AUTHENTICATED_RID:
01697         $roles[$role->rid] = t($role->name);
01698         break;
01699       default:
01700         $roles[$role->rid] = $role->name;
01701     }
01702   }
01703
01704   // Filter to remove unmatched system roles.
01705   return array_filter($roles);
01706 }
01707
01711 function user_user_operations($form_state = array()) {
01712   $operations = array(
01713     'unblock' => array(
01714       'label' => t('Unblock the selected users'),
01715       'callback' => 'user_user_operations_unblock',
01716     ),
01717     'block' => array(
01718       'label' => t('Block the selected users'),
01719       'callback' => 'user_user_operations_block',
01720     ),
01721     'delete' => array(
01722       'label' => t('Delete the selected users'),
01723     ),
01724   );
01725
01726   if (user_access('administer permissions')) {
01727     $roles = user_roles(TRUE);
01728     unset($roles[DRUPAL_AUTHENTICATED_RID]);  // Can't edit authenticated role.
01729
01730     $add_roles = array();
01731     foreach ($roles as $key => $value) {
01732       $add_roles['add_role-'. $key] = $value;
01733     }
01734
01735     $remove_roles = array();
01736     foreach ($roles as $key => $value) {
01737       $remove_roles['remove_role-'. $key] = $value;
01738     }
01739
01740     if (count($roles)) {
01741       $role_operations = array(
01742         t('Add a role to the selected users') => array(
01743           'label' => $add_roles,
01744         ),
01745         t('Remove a role from the selected users') => array(
01746           'label' => $remove_roles,
01747         ),
01748       );
01749
01750       $operations += $role_operations;
01751     }
01752   }
01753
01754   // If the form has been posted, we need to insert the proper data for
01755   // role editing if necessary.
01756   if (!empty($form_state['submitted'])) {
01757     $operation_rid = explode('-', $form_state['values']['operation']);
01758     $operation = $operation_rid[0];
01759     if ($operation == 'add_role' || $operation == 'remove_role') {
01760       $rid = $operation_rid[1];
01761       if (user_access('administer permissions')) {
01762         $operations[$form_state['values']['operation']] = array(
01763           'callback' => 'user_multiple_role_edit',
01764           'callback arguments' => array($operation, $rid),
01765         );
01766       }
01767       else {
01768         watchdog('security', 'Detected malicious attempt to alter protected user fields.', array(), WATCHDOG_WARNING);
01769         return;
01770       }
01771     }
01772   }
01773
01774   return $operations;
01775 }
01776
01780 function user_user_operations_unblock($accounts) {
01781   foreach ($accounts as $uid) {
01782     $account = user_load(array('uid' => (int)$uid));
01783     // Skip unblocking user if they are already unblocked.
01784     if ($account !== FALSE && $account->status == 0) {
01785       user_save($account, array('status' => 1));
01786     }
01787   }
01788 }
01789
01793 function user_user_operations_block($accounts) {
01794   foreach ($accounts as $uid) {
01795     $account = user_load(array('uid' => (int)$uid));
01796     // Skip blocking user if they are already blocked.
01797     if ($account !== FALSE && $account->status == 1) {
01798       user_save($account, array('status' => 0));
01799     }
01800   }
01801 }
01802
01806 function user_multiple_role_edit($accounts, $operation, $rid) {
01807   // The role name is not necessary as user_save() will reload the user
01808   // object, but some modules' hook_user() may look at this first.
01809   $role_name = db_result(db_query('SELECT name FROM {role} WHERE rid = %d', $rid));
01810
01811   switch ($operation) {
01812     case 'add_role':
01813       foreach ($accounts as $uid) {
01814         $account = user_load(array('uid' => (int)$uid));
01815         // Skip adding the role to the user if they already have it.
01816         if ($account !== FALSE && !isset($account->roles[$rid])) {
01817           $roles = $account->roles + array($rid => $role_name);
01818           user_save($account, array('roles' => $roles));
01819         }
01820       }
01821       break;
01822     case 'remove_role':
01823       foreach ($accounts as $uid) {
01824         $account = user_load(array('uid' => (int)$uid));
01825         // Skip removing the role from the user if they already don't have it.
01826         if ($account !== FALSE && isset($account->roles[$rid])) {
01827           $roles = array_diff($account->roles, array($rid => $role_name));
01828           user_save($account, array('roles' => $roles));
01829         }
01830       }
01831       break;
01832   }
01833 }
01834
01835 function user_multiple_delete_confirm(&$form_state) {
01836   $edit = $form_state['post'];
01837
01838   $form['accounts'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
01839   // array_filter() returns only elements with TRUE values.
01840   foreach (array_filter($edit['accounts']) as $uid => $value) {
01841     $user = db_result(db_query('SELECT name FROM {users} WHERE uid = %d', $uid));
01842     $form['accounts'][$uid] = array('#type' => 'hidden', '#value' => $uid, '#prefix' => '<li>', '#suffix' => check_plain($user) ."</li>\n");
01843   }
01844   $form['operation'] = array('#type' => 'hidden', '#value' => 'delete');
01845
01846   return confirm_form($form,
01847                       t('Are you sure you want to delete these users?'),
01848                       'admin/user/user', t('This action cannot be undone.'),
01849                       t('Delete all'), t('Cancel'));
01850 }
01851
01852 function user_multiple_delete_confirm_submit($form, &$form_state) {
01853   if ($form_state['values']['confirm']) {
01854     foreach ($form_state['values']['accounts'] as $uid => $value) {
01855       user_delete($form_state['values'], $uid);
01856     }
01857     drupal_set_message(t('The users have been deleted.'));
01858   }
01859   $form_state['redirect'] = 'admin/user/user';
01860   return;
01861 }
01862
01866 function user_help($path, $arg) {
01867   global $user;
01868
01869   switch ($path) {
01870     case 'admin/help#user':
01871       $output = '<p>'. t('The user module allows users to register, login, and log out. Users benefit from being able to sign on because it associates content they create with their account and allows various permissions to be set for their roles. The user module supports user roles which establish fine grained permissions allowing each role to do only what the administrator wants them to. Each user is assigned to one or more roles. By default there are two roles <em>anonymous</em> - a user who has not logged in, and <em>authenticated</em> a user who has signed up and who has been authorized.') .'</p>';
01872       $output .= '<p>'. t("Users can use their own name or handle and can specify personal configuration settings through their individual <em>My account</em> page. Users must authenticate by supplying a local username and password or through their OpenID, an optional and secure method for logging into many websites with a single username and password. In some configurations, users may authenticate using a username and password from another Drupal site, or through some other site-specific mechanism.") .'</p>';
01873       $output .= '<p>'. t('A visitor accessing your website is assigned a unique ID, or session ID, which is stored in a cookie. The cookie does not contain personal information, but acts as a key to retrieve information from your site. Users should have cookies enabled in their web browser when using your site.') .'</p>';
01874       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@user">User module</a>.', array('@user' => 'http://drupal.org/handbook/modules/user/')) .'</p>';
01875       return $output;
01876     case 'admin/user/user':
01877       return '<p>'. t('Drupal allows users to register, login, log out, maintain user profiles, etc. Users of the site may not use their own names to post content until they have signed up for a user account.') .'</p>';
01878     case 'admin/user/user/create':
01879     case 'admin/user/user/account/create':
01880       return '<p>'. t("This web page allows administrators to register new users. Users' e-mail addresses and usernames must be unique.") .'</p>';
01881     case 'admin/user/rules':
01882       return '<p>'. t('Set up username and e-mail address access rules for new <em>and</em> existing accounts (currently logged in accounts will not be logged out). If a username or e-mail address for an account matches any deny rule, but not an allow rule, then the account will not be allowed to be created or to log in. A host rule is effective for every page view, not just registrations.') .'</p>';
01883     case 'admin/user/permissions':
01884       return '<p>'. t('Permissions let you control what users can do on your site. Each user role (defined on the <a href="@role">user roles page</a>) has its own set of permissions. For example, you could give users classified as "Administrators" permission to "administer nodes" but deny this power to ordinary, "authenticated" users. You can use permissions to reveal new features to privileged users (those with subscriptions, for example). Permissions also allow trusted users to share the administrative burden of running a busy site.', array('@role' => url('admin/user/roles'))) .'</p>';
01885     case 'admin/user/roles':
01886       return t('<p>Roles allow you to fine tune the security and administration of Drupal. A role defines a group of users that have certain privileges as defined in <a href="@permissions">user permissions</a>. Examples of roles include: anonymous user, authenticated user, moderator, administrator and so on. In this area you will define the <em>role names</em> of the various roles. To delete a role choose "edit".</p><p>By default, Drupal comes with two user roles:</p>
01887       <ul>
01888       <li>Anonymous user: this role is used for users that don\'t have a user account or that are not authenticated.</li>
01889       <li>Authenticated user: this role is automatically granted to all logged in users.</li>
01890       </ul>', array('@permissions' => url('admin/user/permissions')));
01891     case 'admin/user/search':
01892       return '<p>'. t('Enter a simple pattern ("*" may be used as a wildcard match) to search for a username or e-mail address. For example, one may search for "br" and Drupal might return "brian", "brad", and "brenda@example.com".') .'</p>';
01893   }
01894 }
01895
01899 function _user_categories($account) {
01900   $categories = array();
01901
01902   foreach (module_list() as $module) {
01903     if ($data = module_invoke($module, 'user', 'categories', NULL, $account, '')) {
01904       $categories = array_merge($data, $categories);
01905     }
01906   }
01907
01908   usort($categories, '_user_sort');
01909
01910   return $categories;
01911 }
01912
01913 function _user_sort($a, $b) {
01914   $a = (array)$a + array('weight' => 0, 'title' => '');
01915   $b = (array)$b + array('weight' => 0, 'title' => '');
01916   return $a['weight'] < $b['weight'] ? -1 : ($a['weight'] > $b['weight'] ? 1 : ($a['title'] < $b['title'] ? -1 : 1));
01917 }
01918
01922 function user_filters() {
01923   // Regular filters
01924   $filters = array();
01925   $roles = user_roles(TRUE);
01926   unset($roles[DRUPAL_AUTHENTICATED_RID]); // Don't list authorized role.
01927   if (count($roles)) {
01928     $filters['role'] = array(
01929       'title' => t('role'),
01930       'where' => "ur.rid = %d",
01931       'options' => $roles,
01932       'join' => '',
01933     );
01934   }
01935
01936   $options = array();
01937   foreach (module_list() as $module) {
01938     if ($permissions = module_invoke($module, 'perm')) {
01939       asort($permissions);
01940       foreach ($permissions as $permission) {
01941         $options[t('@module module', array('@module' => $module))][$permission] = t($permission);
01942       }
01943     }
01944   }
01945   ksort($options);
01946   $filters['permission'] = array(
01947     'title' => t('permission'),
01948     'join' => 'LEFT JOIN {permission} p ON ur.rid = p.rid',
01949     'where' => " ((p.perm IS NOT NULL AND p.perm LIKE '%%%s%%') OR u.uid = 1) ",
01950     'options' => $options,
01951   );
01952
01953   $filters['status'] = array(
01954     'title' => t('status'),
01955     'where' => 'u.status = %d',
01956     'join' => '',
01957     'options' => array(1 => t('active'), 0 => t('blocked')),
01958   );
01959   return $filters;
01960 }
01961
01965 function user_build_filter_query() {
01966   $filters = user_filters();
01967
01968   // Build query
01969   $where = $args = $join = array();
01970   foreach ($_SESSION['user_overview_filter'] as $filter) {
01971     list($key, $value) = $filter;
01972     // This checks to see if this permission filter is an enabled permission for
01973     // the authenticated role. If so, then all users would be listed, and we can
01974     // skip adding it to the filter query.
01975     if ($key == 'permission') {
01976       $account = new stdClass();
01977       $account->uid = 'user_filter';
01978       $account->roles = array(DRUPAL_AUTHENTICATED_RID => 1);
01979       if (user_access($value, $account)) {
01980         continue;
01981       }
01982     }
01983     $where[] = $filters[$key]['where'];
01984     $args[] = $value;
01985     $join[] = $filters[$key]['join'];
01986   }
01987   $where = !empty($where) ? 'AND '. implode(' AND ', $where) : '';
01988   $join = !empty($join) ? ' '. implode(' ', array_unique($join)) : '';
01989
01990   return array('where' => $where,
01991            'join' => $join,
01992            'args' => $args,
01993          );
01994 }
01995
01999 function user_forms() {
02000   $forms['user_admin_access_add_form']['callback'] = 'user_admin_access_form';
02001   $forms['user_admin_access_edit_form']['callback'] = 'user_admin_access_form';
02002   $forms['user_admin_new_role']['callback'] = 'user_admin_role';
02003   return $forms;
02004 }
02005
02009 function user_comment(&$comment, $op) {
02010   // Validate signature.
02011   if ($op == 'view') {
02012     if (variable_get('user_signatures', 0) && !empty($comment->signature)) {
02013       $comment->signature = check_markup($comment->signature, $comment->format);
02014     }
02015     else {
02016       $comment->signature = '';
02017     }
02018   }
02019 }
02020
02026 function theme_user_signature($signature) {
02027   $output = '';
02028   if ($signature) {
02029     $output .= '<div class="clear">';
02030     $output .= '<div>—</div>';
02031     $output .= $signature;
02032     $output .= '</div>';
02033   }
02034
02035   return $output;
02036 }
02037
02049 function user_mail_tokens($account, $language) {
02050   global $base_url;
02051   $tokens = array(
02052     '!username' => $account->name,
02053     '!site' => variable_get('site_name', 'Drupal'),
02054     '!login_url' => user_pass_reset_url($account),
02055     '!uri' => $base_url,
02056     '!uri_brief' => substr($base_url, strlen('http://')),
02057     '!mailto' => $account->mail,
02058     '!date' => format_date(time(), 'medium', '', NULL, $language->language),
02059     '!login_uri' => url('user', array('absolute' => TRUE, 'language' => $language)),
02060     '!edit_uri' => url('user/'. $account->uid .'/edit', array('absolute' => TRUE, 'language' => $language)),
02061   );
02062   if (!empty($account->password)) {
02063     $tokens['!password'] = $account->password;
02064   }
02065   return $tokens;
02066 }
02067
02081 function user_preferred_language($account, $default = NULL) {
02082   $language_list = language_list();
02083   if ($account->language && isset($language_list[$account->language])) {
02084     return $language_list[$account->language];
02085   }
02086   else {
02087     return $default ? $default : language_default();
02088   }
02089 }
02090
02116 function _user_mail_notify($op, $account, $language = NULL) {
02117   // By default, we always notify except for deleted and blocked.
02118   $default_notify = ($op != 'status_deleted' && $op != 'status_blocked');
02119   $notify = variable_get('user_mail_'. $op .'_notify', $default_notify);
02120   if ($notify) {
02121     $params['account'] = $account;
02122     $language = $language ? $language : user_preferred_language($account);
02123     $mail = drupal_mail('user', $op, $account->mail, $language, $params);
02124     if ($op == 'register_pending_approval') {
02125       // If a user registered requiring admin approval, notify the admin, too.
02126       // We use the site default language for this.
02127       drupal_mail('user', 'register_pending_approval_admin', variable_get('site_mail', ini_get('sendmail_from')), language_default(), $params);
02128     }
02129   }
02130   return empty($mail) ? NULL : $mail['result'];
02131 }
02132
02140 function _user_password_dynamic_validation() {
02141   static $complete = FALSE;
02142   global $user;
02143   // Only need to do once per page.
02144   if (!$complete) {
02145     drupal_add_js(drupal_get_path('module', 'user') .'/user.js', 'module');
02146
02147     drupal_add_js(array(
02148       'password' => array(
02149         'strengthTitle' => t('Password strength:'),
02150         'lowStrength' => t('Low'),
02151         'mediumStrength' => t('Medium'),
02152         'highStrength' => t('High'),
02153         'tooShort' => t('It is recommended to choose a password that contains at least six characters. It should include numbers, punctuation, and both upper and lowercase letters.'),
02154         'needsMoreVariation' => t('The password does not include enough variation to be secure. Try:'),
02155         'addLetters' => t('Adding both upper and lowercase letters.'),
02156         'addNumbers' => t('Adding numbers.'),
02157         'addPunctuation' => t('Adding punctuation.'),
02158         'sameAsUsername' => t('It is recommended to choose a password different from the username.'),
02159         'confirmSuccess' => t('Yes'),
02160         'confirmFailure' => t('No'),
02161         'confirmTitle' => t('Passwords match:'),
02162         'username' => (isset($user->name) ? $user->name : ''))),
02163       'setting');
02164     $complete = TRUE;
02165   }
02166 }
02167
02171 function user_hook_info() {
02172   return array(
02173     'user' => array(
02174       'user' => array(
02175         'insert' => array(
02176           'runs when' => t('After a user account has been created'),
02177         ),
02178         'update' => array(
02179           'runs when' => t("After a user's profile has been updated"),
02180         ),
02181         'delete' => array(
02182           'runs when' => t('After a user has been deleted')
02183         ),
02184         'login' => array(
02185           'runs when' => t('After a user has logged in')
02186         ),
02187         'logout' => array(
02188           'runs when' => t('After a user has logged out')
02189         ),
02190         'view' => array(
02191           'runs when' => t("When a user's profile is being viewed")
02192         ),
02193       ),
02194     ),
02195   );
02196 }
02197
02201 function user_action_info() {
02202   return array(
02203     'user_block_user_action' => array(
02204       'description' => t('Block current user'),
02205       'type' => 'user',
02206       'configurable' => FALSE,
02207       'hooks' => array(),
02208     ),
02209     'user_block_ip_action' => array(
02210       'description' => t('Ban IP address of current user'),
02211       'type' => 'user',
02212       'configurable' => FALSE,
02213       'hooks' => array(),
02214     ),
02215   );
02216 }
02217
02222 function user_block_user_action(&$object, $context = array()) {
02223   if (isset($object->uid)) {
02224     $uid = $object->uid;
02225   }
02226   elseif (isset($context['uid'])) {
02227     $uid = $context['uid'];
02228   }
02229   else {
02230     global $user;
02231     $uid = $user->uid;
02232   }
02233   db_query("UPDATE {users} SET status = 0 WHERE uid = %d", $uid);
02234   sess_destroy_uid($uid);
02235   watchdog('action', 'Blocked user %name.', array('%name' => check_plain($user->name)));
02236 }
02237
02242 function user_block_ip_action() {
02243   $ip = ip_address();
02244   db_query("INSERT INTO {access} (mask, type, status) VALUES ('%s', '%s', %d)", $ip, 'host', 0);
02245   watchdog('action', 'Banned IP address %ip', array('%ip' => $ip));
02246 }
02247
02254 function user_register_submit($form, &$form_state) {
02255   global $base_url;
02256   $admin = user_access('administer users');
02257
02258   $mail = $form_state['values']['mail'];
02259   $name = $form_state['values']['name'];
02260   if (!variable_get('user_email_verification', TRUE) || $admin) {
02261     $pass = $form_state['values']['pass'];
02262   }
02263   else {
02264     $pass = user_password();
02265   };
02266   $notify = isset($form_state['values']['notify']) ? $form_state['values']['notify'] : NULL;
02267   $from = variable_get('site_mail', ini_get('sendmail_from'));
02268   if (isset($form_state['values']['roles'])) {
02269     // Remove unset roles.
02270     $roles = array_filter($form_state['values']['roles']);
02271   }
02272   else {
02273     $roles = array();
02274   }
02275
02276   if (!$admin && array_intersect(array_keys($form_state['values']), array('uid', 'roles', 'init', 'session', 'status'))) {
02277     watchdog('security', 'Detected malicious attempt to alter protected user fields.', array(), WATCHDOG_WARNING);
02278     $form_state['redirect'] = 'user/register';
02279     return;
02280   }
02281   // The unset below is needed to prevent these form values from being saved as
02282   // user data.
02283   unset($form_state['values']['form_token'], $form_state['values']['submit'], $form_state['values']['op'], $form_state['values']['notify'], $form_state['values']['form_id'], $form_state['values']['affiliates'], $form_state['values']['destination']);
02284
02285   $merge_data = array('pass' => $pass, 'init' => $mail, 'roles' => $roles);
02286   if (!$admin) {
02287     // Set the user's status because it was not displayed in the form.
02288     $merge_data['status'] = variable_get('user_register', 1) == 1;
02289   }
02290   $account = user_save('', array_merge($form_state['values'], $merge_data));
02291   // Terminate if an error occured during user_save().
02292   if (!$account) {
02293     drupal_set_message(t("Error saving user account."), 'error');
02294     $form_state['redirect'] = '';
02295     return;
02296   }
02297   $form_state['user'] = $account;
02298
02299   watchdog('user', 'New user: %name (%email).', array('%name' => $name, '%email' => $mail), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $account->uid .'/edit'));
02300
02301   // The first user may login immediately, and receives a customized welcome e-mail.
02302   if ($account->uid == 1) {
02303     drupal_set_message(t('Welcome to Drupal. You are now logged in as user #1, which gives you full control over your website.'));
02304     if (variable_get('user_email_verification', TRUE)) {
02305       drupal_set_message(t('</p><p> Your password is <strong>%pass</strong>. You may change your password below.</p>', array('%pass' => $pass)));
02306     }
02307
02308     user_authenticate(array_merge($form_state['values'], $merge_data));
02309
02310     $form_state['redirect'] = 'user/1/edit';
02311     return;
02312   }
02313   else {
02314     // Add plain text password into user account to generate mail tokens.
02315     $account->password = $pass;
02316     if ($admin && !$notify) {
02317       drupal_set_message(t('Created a new user account for <a href="@url">%name</a>. No e-mail has been sent.', array('@url' => url("user/$account->uid"), '%name' => $account->name)));
02318     }
02319     else if (!variable_get('user_email_verification', TRUE) && $account->status && !$admin) {
02320       // No e-mail verification is required, create new user account, and login
02321       // user immediately.
02322       _user_mail_notify('register_no_approval_required', $account);
02323       if (user_authenticate(array_merge($form_state['values'], $merge_data))) {
02324         drupal_set_message(t('Registration successful. You are now logged in.'));
02325       }
02326       $form_state['redirect'] = '';
02327       return;
02328     }
02329     else if ($account->status || $notify) {
02330       // Create new user account, no administrator approval required.
02331       $op = $notify ? 'register_admin_created' : 'register_no_approval_required';
02332       _user_mail_notify($op, $account);
02333       if ($notify) {
02334         drupal_set_message(t('Password and further instructions have been e-mailed to the new user <a href="@url">%name</a>.', array('@url' => url("user/$account->uid"), '%name' => $account->name)));
02335       }
02336       else {
02337         drupal_set_message(t('Your password and further instructions have been sent to your e-mail address.'));
02338         $form_state['redirect'] = '';
02339         return;
02340       }
02341     }
02342     else {
02343       // Create new user account, administrator approval required.
02344       _user_mail_notify('register_pending_approval', $account);
02345       drupal_set_message(t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />In the meantime, a welcome message with further instructions has been sent to your e-mail address.'));
02346       $form_state['redirect'] = '';
02347       return;
02348
02349     }
02350   }
02351 }
02352
02360 function user_register() {
02361   global $user;
02362
02363   $admin = user_access('administer users');
02364
02365   // If we aren't admin but already logged on, go to the user page instead.
02366   if (!$admin && $user->uid) {
02367     drupal_goto('user/'. $user->uid);
02368   }
02369
02370   $form = array();
02371
02372   // Display the registration form.
02373   if (!$admin) {
02374     $form['user_registration_help'] = array('#value' => filter_xss_admin(variable_get('user_registration_help', '')));
02375   }
02376
02377   // Merge in the default user edit fields.
02378   $form = array_merge($form, user_edit_form($form_state, NULL, NULL, TRUE));
02379   if ($admin) {
02380     $form['account']['notify'] = array(
02381      '#type' => 'checkbox',
02382      '#title' => t('Notify user of new account')
02383     );
02384     // Redirect back to page which initiated the create request;
02385     // usually admin/user/user/create.
02386     $form['destination'] = array('#type' => 'hidden', '#value' => $_GET['q']);
02387   }
02388
02389   // Create a dummy variable for pass-by-reference parameters.
02390   $null = NULL;
02391   $extra = _user_forms($null, NULL, NULL, 'register');
02392
02393   // Remove form_group around default fields if there are no other groups.
02394   if (!$extra) {
02395     foreach (array('name', 'mail', 'pass', 'status', 'roles', 'notify') as $key) {
02396       if (isset($form['account'][$key])) {
02397         $form[$key] = $form['account'][$key];
02398       }
02399     }
02400     unset($form['account']);
02401   }
02402   else {
02403     $form = array_merge($form, $extra);
02404   }
02405
02406   if (variable_get('configurable_timezones', 1)) {
02407     // Override field ID, so we only change timezone on user registration,
02408     // and never touch it on user edit pages.
02409     $form['timezone'] = array(
02410       '#type' => 'hidden',
02411       '#default_value' => variable_get('date_default_timezone', NULL),
02412       '#id' => 'edit-user-register-timezone',
02413     );
02414
02415     // Add the JavaScript callback to automatically set the timezone.
02416     drupal_add_js('
02417 // Global Killswitch
02418 if (Drupal.jsEnabled) {
02419   $(document).ready(function() {
02420     Drupal.setDefaultTimezone();
02421   });
02422 }', 'inline');
02423   }
02424
02425   $form['submit'] = array('#type' => 'submit', '#value' => t('Create new account'), '#weight' => 30);
02426   $form['#validate'][] = 'user_register_validate';
02427
02428   return $form;
02429 }
02430
02431 function user_register_validate($form, &$form_state) {
02432   user_module_invoke('validate', $form_state['values'], $form_state['values'], 'account');
02433 }
02434
02438 function _user_forms(&$edit, $account, $category, $hook = 'form') {
02439   $groups = array();
02440   foreach (module_list() as $module) {
02441     if ($data = module_invoke($module, 'user', $hook, $edit, $account, $category)) {
02442       $groups = array_merge_recursive($data, $groups);
02443     }
02444   }
02445   uasort($groups, '_user_sort');
02446
02447   return empty($groups) ? FALSE : $groups;
02448 }
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/user/user.pages.inc Source File

modules » user

user.pages.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: user.pages.inc,v 1.11 2008/01/08 10:35:43 goba Exp $
00003
00012 function user_autocomplete($string = '') {
00013   $matches = array();
00014   if ($string) {
00015     $result = db_query_range("SELECT name FROM {users} WHERE LOWER(name) LIKE LOWER('%s%%')", $string, 0, 10);
00016     while ($user = db_fetch_object($result)) {
00017       $matches[$user->name] = check_plain($user->name);
00018     }
00019   }
00020
00021   drupal_json($matches);
00022 }
00023
00031 function user_pass() {
00032   $form['name'] = array(
00033     '#type' => 'textfield',
00034     '#title' => t('Username or e-mail address'),
00035     '#size' => 60,
00036     '#maxlength' => max(USERNAME_MAX_LENGTH, EMAIL_MAX_LENGTH),
00037     '#required' => TRUE,
00038   );
00039   $form['submit'] = array('#type' => 'submit', '#value' => t('E-mail new password'));
00040
00041   return $form;
00042 }
00043
00044 function user_pass_validate($form, &$form_state) {
00045   $name = trim($form_state['values']['name']);
00046   // Try to load by email.
00047   $account = user_load(array('mail' => $name, 'status' => 1));
00048   if (!$account) {
00049     // No success, try to load by name.
00050     $account = user_load(array('name' => $name, 'status' => 1));
00051   }
00052   if (isset($account->uid)) {
00053     form_set_value(array('#parents' => array('account')), $account, $form_state);
00054   }
00055   else {
00056     form_set_error('name', t('Sorry, %name is not recognized as a user name or an e-mail address.', array('%name' => $name)));
00057   }
00058 }
00059
00060 function user_pass_submit($form, &$form_state) {
00061   global $language;
00062
00063   $account = $form_state['values']['account'];
00064   // Mail one time login URL and instructions using current language.
00065   _user_mail_notify('password_reset', $account, $language);
00066   watchdog('user', 'Password reset instructions mailed to %name at %email.', array('%name' => $account->name, '%email' => $account->mail));
00067   drupal_set_message(t('Further instructions have been sent to your e-mail address.'));
00068
00069   $form_state['redirect'] = 'user';
00070   return;
00071 }
00072
00076 function user_pass_reset(&$form_state, $uid, $timestamp, $hashed_pass, $action = NULL) {
00077   global $user;
00078
00079   // Check if the user is already logged in. The back button is often the culprit here.
00080   if ($user->uid) {
00081     drupal_set_message(t('You have already used this one-time login link. It is not necessary to use this link to login anymore. You are already logged in.'));
00082     drupal_goto();
00083   }
00084   else {
00085     // Time out, in seconds, until login URL expires. 24 hours = 86400 seconds.
00086     $timeout = 86400;
00087     $current = time();
00088     // Some redundant checks for extra security ?
00089     if ($timestamp < $current && $account = user_load(array('uid' => $uid, 'status' => 1)) ) {
00090       // No time out for first time login.
00091       if ($account->login && $current - $timestamp > $timeout) {
00092         drupal_set_message(t('You have tried to use a one-time login link that has expired. Please request a new one using the form below.'));
00093         drupal_goto('user/password');
00094       }
00095       else if ($account->uid && $timestamp > $account->login && $timestamp < $current && $hashed_pass == user_pass_rehash($account->pass, $timestamp, $account->login)) {
00096         // First stage is a confirmation form, then login
00097         if ($action == 'login') {
00098           watchdog('user', 'User %name used one-time login link at time %timestamp.', array('%name' => $account->name, '%timestamp' => $timestamp));
00099           // Set the new user.
00100           $user = $account;
00101           // user_authenticate_finalize() also updates the login timestamp of the
00102           // user, which invalidates further use of the one-time login link.
00103           user_authenticate_finalize($form_state['values']);
00104           drupal_set_message(t('You have just used your one-time login link. It is no longer necessary to use this link to login. Please change your password.'));
00105           drupal_goto('user/'. $user->uid .'/edit');
00106         }
00107         else {
00108           $form['message'] = array('#value' => t('<p>This is a one-time login for %user_name and will expire on %expiration_date.</p><p>Click on this button to login to the site and change your password.</p>', array('%user_name' => $account->name, '%expiration_date' => format_date($timestamp + $timeout))));
00109           $form['help'] = array('#value' => '<p>'. t('This login can be used only once.') .'</p>');
00110           $form['submit'] = array('#type' => 'submit', '#value' => t('Log in'));
00111           $form['#action'] = url("user/reset/$uid/$timestamp/$hashed_pass/login");
00112           return $form;
00113         }
00114       }
00115       else {
00116         drupal_set_message(t('You have tried to use a one-time login link which has either been used or is no longer valid. Please request a new one using the form below.'));
00117         drupal_goto('user/password');
00118       }
00119     }
00120     else {
00121       // Deny access, no more clues.
00122       // Everything will be in the watchdog's URL for the administrator to check.
00123       drupal_access_denied();
00124     }
00125   }
00126 }
00127
00131 function user_logout() {
00132   global $user;
00133
00134   watchdog('user', 'Session closed for %name.', array('%name' => $user->name));
00135
00136   // Destroy the current session:
00137   session_destroy();
00138   module_invoke_all('user', 'logout', NULL, $user);
00139
00140   // Load the anonymous user
00141   $user = drupal_anonymous_user();
00142
00143   drupal_goto();
00144 }
00145
00149 function user_view($account) {
00150   drupal_set_title(check_plain($account->name));
00151   // Retrieve all profile fields and attach to $account->content.
00152   user_build_content($account);
00153
00154   // To theme user profiles, copy modules/user/user_profile.tpl.php
00155   // to your theme directory, and edit it as instructed in that file's comments.
00156   return theme('user_profile', $account);
00157 }
00158
00167 function template_preprocess_user_profile(&$variables) {
00168   $variables['profile'] = array();
00169   // Sort sections by weight
00170   uasort($variables['account']->content, 'element_sort');
00171   // Provide keyed variables so themers can print each section independantly.
00172   foreach (element_children($variables['account']->content) as $key) {
00173     $variables['profile'][$key] = drupal_render($variables['account']->content[$key]);
00174   }
00175   // Collect all profiles to make it easier to print all items at once.
00176   $variables['user_profile'] = implode($variables['profile']);
00177 }
00178
00187 function template_preprocess_user_profile_item(&$variables) {
00188   $variables['title'] = $variables['element']['#title'];
00189   $variables['value'] = $variables['element']['#value'];
00190   $variables['attributes'] = '';
00191   if (isset($variables['element']['#attributes'])) {
00192     $variables['attributes'] = drupal_attributes($variables['element']['#attributes']);
00193   }
00194 }
00195
00204 function template_preprocess_user_profile_category(&$variables) {
00205   $variables['title'] = check_plain($variables['element']['#title']);
00206   $variables['profile_items'] = $variables['element']['#children'];
00207   $variables['attributes'] = '';
00208   if (isset($variables['element']['#attributes'])) {
00209     $variables['attributes'] = drupal_attributes($variables['element']['#attributes']);
00210   }
00211 }
00212
00220 function user_edit($account, $category = 'account') {
00221   drupal_set_title(check_plain($account->name));
00222   return drupal_get_form('user_profile_form', $account, $category);
00223 }
00224
00233 function user_profile_form($form_state, $account, $category = 'account') {
00234
00235   $edit = (empty($form_state['values'])) ? (array)$account : $form_state['values'];
00236
00237   $form = _user_forms($edit, $account, $category);
00238   $form['_category'] = array('#type' => 'value', '#value' => $category);
00239   $form['_account'] = array('#type' => 'value', '#value' => $account);
00240   $form['submit'] = array('#type' => 'submit', '#value' => t('Save'), '#weight' => 30);
00241   if (user_access('administer users')) {
00242     $form['delete'] = array(
00243       '#type' => 'submit',
00244       '#value' => t('Delete'),
00245       '#weight' => 31,
00246       '#submit' => array('user_edit_delete_submit'),
00247     );
00248   }
00249   $form['#attributes']['enctype'] = 'multipart/form-data';
00250
00251   return $form;
00252 }
00253
00257 function user_profile_form_validate($form, &$form_state) {
00258   user_module_invoke('validate', $form_state['values'], $form_state['values']['_account'], $form_state['values']['_category']);
00259   // Validate input to ensure that non-privileged users can't alter protected data.
00260   if ((!user_access('administer users') && array_intersect(array_keys($form_state['values']), array('uid', 'init', 'session'))) || (!user_access('administer permissions') && isset($form_state['values']['roles']))) {
00261     watchdog('security', 'Detected malicious attempt to alter protected user fields.', array(), WATCHDOG_WARNING);
00262     // set this to a value type field
00263     form_set_error('category', t('Detected malicious attempt to alter protected user fields.'));
00264   }
00265 }
00266
00270 function user_profile_form_submit($form, &$form_state) {
00271   $account = $form_state['values']['_account'];
00272   $category = $form_state['values']['_category'];
00273   unset($form_state['values']['_account'], $form_state['values']['op'], $form_state['values']['submit'], $form_state['values']['delete'], $form_state['values']['form_token'], $form_state['values']['form_id'], $form_state['values']['_category']);
00274   user_module_invoke('submit', $form_state['values'], $account, $category);
00275   user_save($account, $form_state['values'], $category);
00276
00277   // Clear the page cache because pages can contain usernames and/or profile information:
00278   cache_clear_all();
00279
00280   drupal_set_message(t('The changes have been saved.'));
00281   return;
00282 }
00283
00287 function user_edit_delete_submit($form, &$form_state) {
00288   $destination = '';
00289   if (isset($_REQUEST['destination'])) {
00290     $destination = drupal_get_destination();
00291     unset($_REQUEST['destination']);
00292   }
00293   // Note: We redirect from user/uid/edit to user/uid/delete to make the tabs disappear.
00294   $form_state['redirect'] = array("user/". $form_state['values']['_account']->uid ."/delete", $destination);
00295 }
00296
00303 function user_confirm_delete(&$form_state, $account) {
00304
00305   $form['_account'] = array('#type' => 'value', '#value' => $account);
00306
00307   return confirm_form($form,
00308     t('Are you sure you want to delete the account %name?', array('%name' => $account->name)),
00309     'user/'. $account->uid,
00310     t('All submissions made by this user will be attributed to the anonymous account. This action cannot be undone.'),
00311     t('Delete'), t('Cancel'));
00312 }
00313
00317 function user_confirm_delete_submit($form, &$form_state) {
00318   user_delete($form_state['values'], $form_state['values']['_account']->uid);
00319   drupal_set_message(t('%name has been deleted.', array('%name' => $form_state['values']['_account']->name)));
00320
00321   if (!isset($_REQUEST['destination'])) {
00322     $form_state['redirect'] = 'admin/user/user';
00323   }
00324 }
00325
00326 function user_edit_validate($form, &$form_state) {
00327   user_module_invoke('validate', $form_state['values'], $form_state['values']['_account'], $form_state['values']['_category']);
00328   // Validate input to ensure that non-privileged users can't alter protected data.
00329   if ((!user_access('administer users') && array_intersect(array_keys($form_state['values']), array('uid', 'init', 'session'))) || (!user_access('administer permissions') && isset($form_state['values']['roles']))) {
00330     watchdog('security', 'Detected malicious attempt to alter protected user fields.', array(), WATCHDOG_WARNING);
00331     // set this to a value type field
00332     form_set_error('category', t('Detected malicious attempt to alter protected user fields.'));
00333   }
00334 }
00335
00336 function user_edit_submit($form, &$form_state) {
00337   $account = $form_state['values']['_account'];
00338   $category = $form_state['values']['_category'];
00339   unset($form_state['values']['_account'], $form_state['values']['op'], $form_state['values']['submit'], $form_state['values']['delete'], $form_state['values']['form_token'], $form_state['values']['form_id'], $form_state['values']['_category']);
00340   user_module_invoke('submit', $form_state['values'], $account, $category);
00341   user_save($account, $form_state['values'], $category);
00342
00343   // Clear the page cache because pages can contain usernames and/or profile information:
00344   cache_clear_all();
00345
00346   drupal_set_message(t('The changes have been saved.'));
00347   return;
00348 }
00349
00356 function user_page() {
00357   global $user;
00358   if ($user->uid) {
00359     menu_set_active_item('user/'. $user->uid);
00360     return menu_execute_active_handler();
00361   }
00362   else {
00363     return drupal_get_form('user_login');
00364   }
00365 }
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/xmlrpc.inc Source File

includes

xmlrpc.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: xmlrpc.inc,v 1.47 2008/01/09 21:52:43 goba Exp $
00003
00023 function xmlrpc_value($data, $type = FALSE) {
00024   $xmlrpc_value = new stdClass();
00025   $xmlrpc_value->data = $data;
00026   if (!$type) {
00027     $type = xmlrpc_value_calculate_type($xmlrpc_value);
00028   }
00029   $xmlrpc_value->type = $type;
00030   if ($type == 'struct') {
00031     // Turn all the values in the array into new xmlrpc_values
00032     foreach ($xmlrpc_value->data as $key => $value) {
00033       $xmlrpc_value->data[$key] = xmlrpc_value($value);
00034     }
00035   }
00036   if ($type == 'array') {
00037     for ($i = 0, $j = count($xmlrpc_value->data); $i < $j; $i++) {
00038       $xmlrpc_value->data[$i] = xmlrpc_value($xmlrpc_value->data[$i]);
00039     }
00040   }
00041   return $xmlrpc_value;
00042 }
00043
00054 function xmlrpc_value_calculate_type(&$xmlrpc_value) {
00055   // http://www.php.net/gettype: Never use gettype() to test for a certain type [...] Instead, use the is_* functions.
00056   if (is_bool($xmlrpc_value->data)) {
00057     return 'boolean';
00058   }
00059   if (is_double($xmlrpc_value->data)) {
00060     return 'double';
00061   }
00062   if (is_int($xmlrpc_value->data)) {
00063       return 'int';
00064   }
00065   if (is_array($xmlrpc_value->data)) {
00066     // empty or integer-indexed arrays are 'array', string-indexed arrays 'struct'
00067     return empty($xmlrpc_value->data) || range(0, count($xmlrpc_value->data) - 1) === array_keys($xmlrpc_value->data) ? 'array' : 'struct';
00068   }
00069   if (is_object($xmlrpc_value->data)) {
00070     if ($xmlrpc_value->data->is_date) {
00071       return 'date';
00072     }
00073     if ($xmlrpc_value->data->is_base64) {
00074       return 'base64';
00075     }
00076     $xmlrpc_value->data = get_object_vars($xmlrpc_value->data);
00077     return 'struct';
00078   }
00079   // default
00080   return 'string';
00081 }
00082
00090 function xmlrpc_value_get_xml($xmlrpc_value) {
00091   switch ($xmlrpc_value->type) {
00092     case 'boolean':
00093       return '<boolean>'. (($xmlrpc_value->data) ? '1' : '0') .'</boolean>';
00094       break;
00095     case 'int':
00096       return '<int>'. $xmlrpc_value->data .'</int>';
00097       break;
00098     case 'double':
00099       return '<double>'. $xmlrpc_value->data .'</double>';
00100       break;
00101     case 'string':
00102       // Note: we don't escape apostrophes because of the many blogging clients
00103       // that don't support numerical entities (and XML in general) properly.
00104       return '<string>'. htmlspecialchars($xmlrpc_value->data) .'</string>';
00105       break;
00106     case 'array':
00107       $return = '<array><data>'."\n";
00108       foreach ($xmlrpc_value->data as $item) {
00109         $return .= '  <value>'. xmlrpc_value_get_xml($item) ."</value>\n";
00110       }
00111       $return .= '</data></array>';
00112       return $return;
00113       break;
00114     case 'struct':
00115       $return = '<struct>'."\n";
00116       foreach ($xmlrpc_value->data as $name => $value) {
00117         $return .= "  <member><name>". check_plain($name) ."</name><value>";
00118         $return .= xmlrpc_value_get_xml($value) ."</value></member>\n";
00119       }
00120       $return .= '</struct>';
00121       return $return;
00122       break;
00123     case 'date':
00124       return xmlrpc_date_get_xml($xmlrpc_value->data);
00125       break;
00126     case 'base64':
00127       return xmlrpc_base64_get_xml($xmlrpc_value->data);
00128       break;
00129   }
00130   return FALSE;
00131 }
00132
00141 function xmlrpc_message($message) {
00142   $xmlrpc_message = new stdClass();
00143   $xmlrpc_message->array_structs = array();   // The stack used to keep track of the current array/struct
00144   $xmlrpc_message->array_structs_types = array(); // The stack used to keep track of if things are structs or array
00145   $xmlrpc_message->current_struct_name = array();  // A stack as well
00146   $xmlrpc_message->message = $message;
00147   return $xmlrpc_message;
00148 }
00149
00159 function xmlrpc_message_parse(&$xmlrpc_message) {
00160   // First remove the XML declaration
00161   $xmlrpc_message->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $xmlrpc_message->message);
00162   if (trim($xmlrpc_message->message) == '') {
00163     return FALSE;
00164   }
00165   $xmlrpc_message->_parser = xml_parser_create();
00166   // Set XML parser to take the case of tags into account.
00167   xml_parser_set_option($xmlrpc_message->_parser, XML_OPTION_CASE_FOLDING, FALSE);
00168   // Set XML parser callback functions
00169   xml_set_element_handler($xmlrpc_message->_parser, 'xmlrpc_message_tag_open', 'xmlrpc_message_tag_close');
00170   xml_set_character_data_handler($xmlrpc_message->_parser, 'xmlrpc_message_cdata');
00171   xmlrpc_message_set($xmlrpc_message);
00172   if (!xml_parse($xmlrpc_message->_parser, $xmlrpc_message->message)) {
00173     return FALSE;
00174   }
00175   xml_parser_free($xmlrpc_message->_parser);
00176   // Grab the error messages, if any
00177   $xmlrpc_message = xmlrpc_message_get();
00178   if ($xmlrpc_message->messagetype == 'fault') {
00179     $xmlrpc_message->fault_code = $xmlrpc_message->params[0]['faultCode'];
00180     $xmlrpc_message->fault_string = $xmlrpc_message->params[0]['faultString'];
00181   }
00182   return TRUE;
00183 }
00184
00193 function xmlrpc_message_set($value = NULL) {
00194   static $xmlrpc_message;
00195   if ($value) {
00196     $xmlrpc_message = $value;
00197   }
00198   return $xmlrpc_message;
00199 }
00200
00201 function xmlrpc_message_get() {
00202   return xmlrpc_message_set();
00203 }
00204
00205 function xmlrpc_message_tag_open($parser, $tag, $attr) {
00206   $xmlrpc_message = xmlrpc_message_get();
00207   $xmlrpc_message->current_tag_contents = '';
00208   $xmlrpc_message->last_open = $tag;
00209   switch ($tag) {
00210     case 'methodCall':
00211     case 'methodResponse':
00212     case 'fault':
00213       $xmlrpc_message->messagetype = $tag;
00214       break;
00215     // Deal with stacks of arrays and structs
00216     case 'data':
00217       $xmlrpc_message->array_structs_types[] = 'array';
00218       $xmlrpc_message->array_structs[] = array();
00219       break;
00220     case 'struct':
00221       $xmlrpc_message->array_structs_types[] = 'struct';
00222       $xmlrpc_message->array_structs[] = array();
00223       break;
00224   }
00225   xmlrpc_message_set($xmlrpc_message);
00226 }
00227
00228 function xmlrpc_message_cdata($parser, $cdata) {
00229   $xmlrpc_message = xmlrpc_message_get();
00230   $xmlrpc_message->current_tag_contents .= $cdata;
00231   xmlrpc_message_set($xmlrpc_message);
00232 }
00233
00234 function xmlrpc_message_tag_close($parser, $tag) {
00235   $xmlrpc_message = xmlrpc_message_get();
00236   $value_flag = FALSE;
00237   switch ($tag) {
00238     case 'int':
00239     case 'i4':
00240       $value = (int)trim($xmlrpc_message->current_tag_contents);
00241       $value_flag = TRUE;
00242       break;
00243     case 'double':
00244       $value = (double)trim($xmlrpc_message->current_tag_contents);
00245       $value_flag = TRUE;
00246       break;
00247     case 'string':
00248       $value = $xmlrpc_message->current_tag_contents;
00249       $value_flag = TRUE;
00250       break;
00251     case 'dateTime.iso8601':
00252       $value = xmlrpc_date(trim($xmlrpc_message->current_tag_contents));
00253       // $value = $iso->getTimestamp();
00254       $value_flag = TRUE;
00255       break;
00256     case 'value':
00257       // If no type is indicated, the type is string
00258       // We take special care for empty values
00259       if (trim($xmlrpc_message->current_tag_contents) != '' || $xmlrpc_message->last_open == 'value') {
00260         $value = (string)$xmlrpc_message->current_tag_contents;
00261         $value_flag = TRUE;
00262       }
00263       unset($xmlrpc_message->last_open);
00264       break;
00265     case 'boolean':
00266       $value = (boolean)trim($xmlrpc_message->current_tag_contents);
00267       $value_flag = TRUE;
00268       break;
00269     case 'base64':
00270       $value = base64_decode(trim($xmlrpc_message->current_tag_contents));
00271       $value_flag = TRUE;
00272       break;
00273     // Deal with stacks of arrays and structs
00274     case 'data':
00275     case 'struct':
00276       $value = array_pop($xmlrpc_message->array_structs );
00277       array_pop($xmlrpc_message->array_structs_types);
00278       $value_flag = TRUE;
00279       break;
00280     case 'member':
00281       array_pop($xmlrpc_message->current_struct_name);
00282       break;
00283     case 'name':
00284       $xmlrpc_message->current_struct_name[] = trim($xmlrpc_message->current_tag_contents);
00285       break;
00286     case 'methodName':
00287       $xmlrpc_message->methodname = trim($xmlrpc_message->current_tag_contents);
00288       break;
00289   }
00290   if ($value_flag) {
00291     if (count($xmlrpc_message->array_structs ) > 0) {
00292       // Add value to struct or array
00293       if ($xmlrpc_message->array_structs_types[count($xmlrpc_message->array_structs_types)-1] == 'struct') {
00294         // Add to struct
00295         $xmlrpc_message->array_structs [count($xmlrpc_message->array_structs )-1][$xmlrpc_message->current_struct_name[count($xmlrpc_message->current_struct_name)-1]] = $value;
00296       }
00297       else {
00298         // Add to array
00299         $xmlrpc_message->array_structs [count($xmlrpc_message->array_structs )-1][] = $value;
00300       }
00301     }
00302     else {
00303       // Just add as a parameter
00304       $xmlrpc_message->params[] = $value;
00305     }
00306   }
00307   if (!in_array($tag, array("data", "struct", "member"))) {
00308     $xmlrpc_message->current_tag_contents = '';
00309   }
00310   xmlrpc_message_set($xmlrpc_message);
00311 }
00312
00323 function xmlrpc_request($method, $args) {
00324   $xmlrpc_request = new stdClass();
00325   $xmlrpc_request->method = $method;
00326   $xmlrpc_request->args = $args;
00327   $xmlrpc_request->xml = <<<EOD
00328 <?xml version="1.0"?>
00329 <methodCall>
00330 <methodName>{$xmlrpc_request->method}</methodName>
00331 <params>
00332
00333 EOD;
00334   foreach ($xmlrpc_request->args as $arg) {
00335     $xmlrpc_request->xml .= '<param><value>';
00336     $v = xmlrpc_value($arg);
00337     $xmlrpc_request->xml .= xmlrpc_value_get_xml($v);
00338     $xmlrpc_request->xml .= "</value></param>\n";
00339   }
00340   $xmlrpc_request->xml .= '</params></methodCall>';
00341   return $xmlrpc_request;
00342 }
00343
00344
00345 function xmlrpc_error($code = NULL, $message = NULL) {
00346   static $xmlrpc_error;
00347   if (isset($code)) {
00348     $xmlrpc_error = new stdClass();
00349     $xmlrpc_error->is_error = TRUE;
00350     $xmlrpc_error->code = $code;
00351     $xmlrpc_error->message = $message;
00352     module_invoke('system', 'check_http_request');
00353   }
00354   return $xmlrpc_error;
00355 }
00356
00357 function xmlrpc_error_get_xml($xmlrpc_error) {
00358   return <<<EOD
00359 <methodResponse>
00360   <fault>
00361   <value>
00362     <struct>
00363     <member>
00364       <name>faultCode</name>
00365       <value><int>{$xmlrpc_error->code}</int></value>
00366     </member>
00367     <member>
00368       <name>faultString</name>
00369       <value><string>{$xmlrpc_error->message}</string></value>
00370     </member>
00371     </struct>
00372   </value>
00373   </fault>
00374 </methodResponse>
00375
00376 EOD;
00377 }
00378
00379 function xmlrpc_date($time) {
00380   $xmlrpc_date = new stdClass();
00381   $xmlrpc_date->is_date = TRUE;
00382   // $time can be a PHP timestamp or an ISO one
00383   if (is_numeric($time)) {
00384     $xmlrpc_date->year = date('Y', $time);
00385     $xmlrpc_date->month = date('m', $time);
00386     $xmlrpc_date->day = date('d', $time);
00387     $xmlrpc_date->hour = date('H', $time);
00388     $xmlrpc_date->minute = date('i', $time);
00389     $xmlrpc_date->second = date('s', $time);
00390     $xmlrpc_date->iso8601 = date('Ymd\TH:i:s', $time);
00391   }
00392   else {
00393     $xmlrpc_date->iso8601 = $time;
00394     $time = str_replace(array('-', ':'), '', $time);
00395     $xmlrpc_date->year = substr($time, 0, 4);
00396     $xmlrpc_date->month = substr($time, 4, 2);
00397     $xmlrpc_date->day = substr($time, 6, 2);
00398     $xmlrpc_date->hour = substr($time, 9, 2);
00399     $xmlrpc_date->minute = substr($time, 11, 2);
00400     $xmlrpc_date->second = substr($time, 13, 2);
00401   }
00402   return $xmlrpc_date;
00403 }
00404
00405 function xmlrpc_date_get_xml($xmlrpc_date) {
00406   return '<dateTime.iso8601>'. $xmlrpc_date->year . $xmlrpc_date->month . $xmlrpc_date->day .'T'. $xmlrpc_date->hour .':'. $xmlrpc_date->minute .':'. $xmlrpc_date->second .'</dateTime.iso8601>';
00407 }
00408
00409 function xmlrpc_base64($data) {
00410   $xmlrpc_base64 = new stdClass();
00411   $xmlrpc_base64->is_base64 = TRUE;
00412   $xmlrpc_base64->data = $data;
00413   return $xmlrpc_base64;
00414 }
00415
00416 function xmlrpc_base64_get_xml($xmlrpc_base64) {
00417   return '<base64>'. base64_encode($xmlrpc_base64->data) .'</base64>';
00418 }
00419
00427 function _xmlrpc() {
00428   $args = func_get_args();
00429   $url = array_shift($args);
00430   if (is_array($args[0])) {
00431     $method = 'system.multicall';
00432     $multicall_args = array();
00433     foreach ($args[0] as $call) {
00434       $multicall_args[] = array('methodName' => array_shift($call), 'params' => $call);
00435     }
00436     $args = array($multicall_args);
00437   }
00438   else {
00439     $method = array_shift($args);
00440   }
00441   $xmlrpc_request = xmlrpc_request($method, $args);
00442   $result = drupal_http_request($url, array("Content-Type" => "text/xml"), 'POST', $xmlrpc_request->xml);
00443   if ($result->code != 200) {
00444     xmlrpc_error($result->code, $result->error);
00445     return FALSE;
00446   }
00447   $message = xmlrpc_message($result->data);
00448   // Now parse what we've got back
00449   if (!xmlrpc_message_parse($message)) {
00450     // XML error
00451     xmlrpc_error(-32700, t('Parse error. Not well formed'));
00452     return FALSE;
00453   }
00454   // Is the message a fault?
00455   if ($message->messagetype == 'fault') {
00456     xmlrpc_error($message->fault_code, $message->fault_string);
00457     return FALSE;
00458   }
00459   // Message must be OK
00460   return $message->params[0];
00461 }
00462
00466 function xmlrpc_errno() {
00467   $error = xmlrpc_error();
00468   return $error->code;
00469 }
00470
00474 function xmlrpc_error_msg() {
00475   $error = xmlrpc_error();
00476   return $error->message;
00477 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: xmlrpc.php Source File

xmlrpc.php

Go to the documentation of this file.
00001 <?php
00002 // $Id: xmlrpc.php,v 1.15 2005/12/10 19:26:47 dries Exp $
00003
00009 include_once './includes/bootstrap.inc';
00010 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
00011 include_once './includes/xmlrpc.inc';
00012 include_once './includes/xmlrpcs.inc';
00013
00014 xmlrpc_server(module_invoke_all('xmlrpc'));
Generated on Tue Feb 12 15:30:42 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: docs/examples/xmlrpc_example.module Source File

docs » examples

xmlrpc_example.module

Go to the documentation of this file.
00001 <?php
00002 // $Id: xmlrpc_example.module,v 1.3 2006/02/19 23:04:56 JonBob Exp $
00003
00019 function xmlrpc_example_xmlrpc() {
00020   return (array(
00021     'validator1.arrayOfStructsTest' => 'xmlrpc_example_arrayOfStructsTest',
00022     'validator1.countTheEntities' => 'xmlrpc_example_countTheEntities',
00023     'validator1.easyStructTest' => 'xmlrpc_example_easyStructTest',
00024     'validator1.echoStructTest' => 'xmlrpc_example_echoStructTest',
00025     'validator1.manyTypesTest' => 'xmlrpc_example_manyTypesTest',
00026     'validator1.moderateSizeArrayCheck' => 'xmlrpc_example_moderateSizeArrayCheck',
00027     'validator1.nestedStructTest' => 'xmlrpc_example_nestedStructTest',
00028     'validator1.simpleStructReturnTest' => 'xmlrpc_example_simpleStructReturnTest'
00029   ));
00030 }
00031
00032 function xmlrpc_example_arrayOfStructsTest($array) {
00033   $sum = 0;
00034   foreach ($array as $struct) {
00035     $sum += $struct['curly'];
00036   }
00037   return $sum;
00038 }
00039
00040 function xmlrpc_example_countTheEntities($string) {
00041   return array(
00042     'ctLeftAngleBrackets' => substr_count($string, '<'),
00043     'ctRightAngleBrackets' => substr_count($string, '>'),
00044     'ctAmpersands' => substr_count($string, '&'),
00045     'ctApostrophes' => substr_count($string, "'"),
00046     'ctQuotes' => substr_count($string, '"'),
00047     );
00048 }
00049
00050 function xmlrpc_example_easyStructTest($array) {
00051   return $array["curly"] + $array["moe"] + $array["larry"];
00052 }
00053
00054 function xmlrpc_example_echoStructTest($array) {
00055   return $array;
00056 }
00057
00058 function xmlrpc_example_manyTypesTest($args) {
00059   $timestamp = mktime($args[4]->hour, $args[4]->minute, $args[4]->second, $args[4]->month, $args[4]->day, $args[4]->year);
00060   return array($args[0], $args[1], $args[2], $args[3], xmlrpc_date($timestamp), xmlrpc_base64($args[5]));
00061 }
00062
00063 function xmlrpc_example_moderateSizeArrayCheck($array) {
00064   return array_shift($array) . array_pop($array);
00065 }
00066
00067 function xmlrpc_example_nestedStructTest($array) {
00068   return $array["2000"]["04"]["01"]["larry"] + $array["2000"]["04"]["01"]["moe"] + $array["2000"]["04"]["01"]["curly"];
00069 }
00070
00071 function xmlrpc_example_simpleStructReturnTest($number) {
00072   return array("times10" => ($number*10), "times100" => ($number*100), "times1000" => ($number*1000));
00073 }
00074
Generated on Tue Feb 12 15:30:38 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: includes/xmlrpcs.inc Source File

includes

xmlrpcs.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: xmlrpcs.inc,v 1.24 2007/12/31 08:54:36 dries Exp $
00003
00010 function xmlrpc_server($callbacks) {
00011   $xmlrpc_server = new stdClass();
00012   // Define built-in XML-RPC method names
00013   $defaults = array(
00014       'system.multicall' => 'xmlrpc_server_multicall',
00015     array(
00016       'system.methodSignature',
00017       'xmlrpc_server_method_signature',
00018       array('array', 'string'),
00019       'Returns an array describing the return type and required parameters of a method.'
00020     ),
00021     array(
00022       'system.getCapabilities',
00023       'xmlrpc_server_get_capabilities',
00024       array('struct'),
00025       'Returns a struct describing the XML-RPC specifications supported by this server.'
00026     ),
00027     array(
00028       'system.listMethods',
00029       'xmlrpc_server_list_methods',
00030       array('array'),
00031       'Returns an array of available methods on this server.'),
00032     array(
00033       'system.methodHelp',
00034       'xmlrpc_server_method_help',
00035       array('string', 'string'),
00036       'Returns a documentation string for the specified method.')
00037   );
00038   // We build an array of all method names by combining the built-ins
00039   // with those defined by modules implementing the _xmlrpc hook.
00040   // Built-in methods are overridable.
00041   foreach (array_merge($defaults, (array)$callbacks) as $key => $callback) {
00042     // we could check for is_array($callback)
00043     if (is_int($key)) {
00044       $method = $callback[0];
00045       $xmlrpc_server->callbacks[$method] = $callback[1];
00046       $xmlrpc_server->signatures[$method] = $callback[2];
00047       $xmlrpc_server->help[$method] = $callback[3];
00048     }
00049     else {
00050       $xmlrpc_server->callbacks[$key] = $callback;
00051       $xmlrpc_server->signatures[$key] = '';
00052       $xmlrpc_server->help[$key] = '';
00053     }
00054   }
00055
00056   $data = file_get_contents('php://input');
00057   if (!$data) {
00058     die('XML-RPC server accepts POST requests only.');
00059   }
00060   $xmlrpc_server->message = xmlrpc_message($data);
00061   if (!xmlrpc_message_parse($xmlrpc_server->message)) {
00062     xmlrpc_server_error(-32700, t('Parse error. Request not well formed.'));
00063   }
00064   if ($xmlrpc_server->message->messagetype != 'methodCall') {
00065     xmlrpc_server_error(-32600, t('Server error. Invalid XML-RPC. Request must be a methodCall.'));
00066   }
00067   xmlrpc_server_set($xmlrpc_server);
00068   $result = xmlrpc_server_call($xmlrpc_server, $xmlrpc_server->message->methodname, $xmlrpc_server->message->params);
00069
00070   if ($result->is_error) {
00071     xmlrpc_server_error($result);
00072   }
00073   // Encode the result
00074   $r = xmlrpc_value($result);
00075   // Create the XML
00076   $xml = '
00077 <methodResponse>
00078   <params>
00079   <param>
00080     <value>'.
00081     xmlrpc_value_get_xml($r)
00082     .'</value>
00083   </param>
00084   </params>
00085 </methodResponse>
00086
00087 ';
00088   // Send it
00089   xmlrpc_server_output($xml);
00090 }
00091
00100 function xmlrpc_server_error($error, $message = FALSE) {
00101   if ($message && !is_object($error)) {
00102     $error = xmlrpc_error($error, $message);
00103   }
00104   xmlrpc_server_output(xmlrpc_error_get_xml($error));
00105 }
00106
00107 function xmlrpc_server_output($xml) {
00108   $xml = '<?xml version="1.0"?>'."\n". $xml;
00109   header('Connection: close');
00110   header('Content-Length: '. strlen($xml));
00111   header('Content-Type: text/xml');
00112   header('Date: '. date('r'));
00113   echo $xml;
00114   exit;
00115 }
00116
00123 function xmlrpc_server_set($xmlrpc_server = NULL) {
00124   static $server;
00125   if (!isset($server)) {
00126     $server = $xmlrpc_server;
00127   }
00128   return $server;
00129 }
00130
00131 // Retrieve the stored request.
00132 function xmlrpc_server_get() {
00133   return xmlrpc_server_set();
00134 }
00135
00145 function xmlrpc_server_call($xmlrpc_server, $methodname, $args) {
00146   // Make sure parameters are in an array
00147   if ($args && !is_array($args)) {
00148     $args = array($args);
00149   }
00150   // Has this method been mapped to a Drupal function by us or by modules?
00151   if (!isset($xmlrpc_server->callbacks[$methodname])) {
00152     return xmlrpc_error(-32601, t('Server error. Requested method %methodname not specified.', array("%methodname" => $xmlrpc_server->message->methodname)));
00153   }
00154   $method = $xmlrpc_server->callbacks[$methodname];
00155   $signature = $xmlrpc_server->signatures[$methodname];
00156
00157   // If the method has a signature, validate the request against the signature
00158   if (is_array($signature)) {
00159     $ok = TRUE;
00160     $return_type = array_shift($signature);
00161     // Check the number of arguments
00162     if (count($args) != count($signature)) {
00163       return xmlrpc_error(-32602, t('Server error. Wrong number of method parameters.'));
00164     }
00165     // Check the argument types
00166     foreach ($signature as $key => $type) {
00167       $arg = $args[$key];
00168       switch ($type) {
00169         case 'int':
00170         case 'i4':
00171           if (is_array($arg) || !is_int($arg)) {
00172             $ok = FALSE;
00173           }
00174           break;
00175         case 'base64':
00176         case 'string':
00177           if (!is_string($arg)) {
00178             $ok = FALSE;
00179           }
00180           break;
00181         case 'boolean':
00182           if ($arg !== FALSE && $arg !== TRUE) {
00183             $ok = FALSE;
00184           }
00185           break;
00186         case 'float':
00187         case 'double':
00188           if (!is_float($arg)) {
00189             $ok = FALSE;
00190           }
00191           break;
00192         case 'date':
00193         case 'dateTime.iso8601':
00194           if (!$arg->is_date) {
00195             $ok = FALSE;
00196           }
00197           break;
00198       }
00199       if (!$ok) {
00200         return xmlrpc_error(-32602, t('Server error. Invalid method parameters.'));
00201       }
00202     }
00203   }
00204
00205   if (!function_exists($method)) {
00206     return xmlrpc_error(-32601, t('Server error. Requested function %method does not exist.', array("%method" => $method)));
00207   }
00208   // Call the mapped function
00209   return call_user_func_array($method, $args);
00210 }
00211
00212 function xmlrpc_server_multicall($methodcalls) {
00213   // See http://www.xmlrpc.com/discuss/msgReader$1208
00214   $return = array();
00215   $xmlrpc_server = xmlrpc_server_get();
00216   foreach ($methodcalls as $call) {
00217     $ok = TRUE;
00218     if (!isset($call['methodName']) || !isset($call['params'])) {
00219       $result = xmlrpc_error(3, t('Invalid syntax for system.multicall.'));
00220       $ok = FALSE;
00221     }
00222     $method = $call['methodName'];
00223     $params = $call['params'];
00224     if ($method == 'system.multicall') {
00225       $result = xmlrpc_error(-32600, t('Recursive calls to system.multicall are forbidden.'));
00226     }
00227     elseif ($ok) {
00228       $result = xmlrpc_server_call($xmlrpc_server, $method, $params);
00229     }
00230     if ($result->is_error) {
00231       $return[] = array(
00232         'faultCode' => $result->code,
00233         'faultString' => $result->message
00234       );
00235     }
00236     else {
00237       $return[] = $result;
00238     }
00239   }
00240   return $return;
00241 }
00242
00243
00247 function xmlrpc_server_list_methods() {
00248   $xmlrpc_server = xmlrpc_server_get();
00249   return array_keys($xmlrpc_server->callbacks);
00250 }
00251
00256 function xmlrpc_server_get_capabilities() {
00257   return array(
00258     'xmlrpc' => array(
00259       'specUrl' => 'http://www.xmlrpc.com/spec',
00260       'specVersion' => 1
00261     ),
00262     'faults_interop' => array(
00263       'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
00264       'specVersion' => 20010516
00265     ),
00266     'system.multicall' => array(
00267       'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
00268       'specVersion' => 1
00269     ),
00270     'introspection' => array(
00271     'specUrl' => 'http://scripts.incutio.com/xmlrpc/introspection.html',
00272     'specVersion' => 1
00273     )
00274   );
00275 }
00276
00288 function xmlrpc_server_method_signature($methodname) {
00289   $xmlrpc_server = xmlrpc_server_get();
00290   if (!isset($xmlrpc_server->callbacks[$methodname])) {
00291     return xmlrpc_error(-32601, t('Server error. Requested method %methodname not specified.', array("%methodname" => $methodname)));
00292   }
00293   if (!is_array($xmlrpc_server->signatures[$methodname])) {
00294     return xmlrpc_error(-32601, t('Server error. Requested method %methodname signature not specified.', array("%methodname" => $methodname)));
00295   }
00296   // We array of types
00297   $return = array();
00298   foreach ($xmlrpc_server->signatures[$methodname] as $type) {
00299     $return[] = $type;
00300   }
00301   return $return;
00302 }
00303
00310 function xmlrpc_server_method_help($method) {
00311   $xmlrpc_server = xmlrpc_server_get();
00312   return $xmlrpc_server->help[$method];
00313 }
Generated on Tue Feb 12 15:30:39 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal


Drupal 6: modules/openid/xrds.inc Source File

modules » openid

xrds.inc

Go to the documentation of this file.
00001 <?php
00002 // $Id: xrds.inc,v 1.2 2007/10/15 09:40:42 goba Exp $
00003
00004 // Global variables to track parsing state
00005 $xrds_open_elements = array();
00006 $xrds_services = array();
00007 $xrds_current_service = array();
00008
00012 function xrds_parse($xml) {
00013   global $xrds_services;
00014
00015   $parser = xml_parser_create_ns();
00016   xml_set_element_handler($parser, '_xrds_element_start', '_xrds_element_end');
00017   xml_set_character_data_handler($parser, '_xrds_cdata');
00018
00019   xml_parse($parser, $xml);
00020   xml_parser_free($parser);
00021
00022   return $xrds_services;
00023 }
00024
00028 function _xrds_element_start(&$parser, $name, $attribs) {
00029   global $xrds_open_elements;
00030
00031   $xrds_open_elements[] = _xrds_strip_namespace($name);
00032 }
00033
00034 function _xrds_element_end(&$parser, $name) {
00035   global $xrds_open_elements, $xrds_services, $xrds_current_service;
00036
00037   $name = _xrds_strip_namespace($name);
00038   if ($name == 'SERVICE') {
00039     if (in_array(OPENID_NS_2_0 .'/signon', $xrds_current_service['types']) ||
00040         in_array(OPENID_NS_2_0 .'/server', $xrds_current_service['types'])) {
00041       $xrds_current_service['version'] = 2;
00042     }
00043     elseif (in_array(OPENID_NS_1_1, $xrds_current_service['types']) ||
00044             in_array(OPENID_NS_1_0, $xrds_current_service['types'])) {
00045       $xrds_current_service['version'] = 1;
00046     }
00047     if (!empty($xrds_current_service['version'])) {
00048       $xrds_services[] = $xrds_current_service;
00049     }
00050     $xrds_current_service = array();
00051   }
00052   array_pop($xrds_open_elements);
00053 }
00054
00055 function _xrds_cdata(&$parser, $data) {
00056   global $xrds_open_elements, $xrds_services, $xrds_current_service;
00057   $path = strtoupper(implode('/', $xrds_open_elements));
00058   switch ($path) {
00059     case 'XRDS/XRD/SERVICE/TYPE':
00060       $xrds_current_service['types'][] = $data;
00061       break;
00062     case 'XRDS/XRD/SERVICE/URI':
00063       $xrds_current_service['uri'] = $data;
00064       break;
00065     case 'XRDS/XRD/SERVICE/DELEGATE':
00066       $xrds_current_service['delegate'] = $data;
00067       break;
00068     case 'XRDS/XRD/SERVICE/LOCALID':
00069       $xrds_current_service['localid'] = $data;
00070       break;
00071   }
00072 }
00073
00074 function _xrds_strip_namespace($name) {
00075   // Strip namespacing.
00076   $pos = strrpos($name, ':');
00077   if ($pos !== FALSE) {
00078     $name = substr($name, $pos + 1, strlen($name));
00079   }
00080
00081   return $name;
00082 }
Generated on Tue Feb 12 15:30:40 2008 for Drupal 6 by doxygen 1.5.5-AX_PHP_Drupal