2001-03-10 11:07:52 +00:00
< ? php
2005-08-11 12:57:41 +00:00
// $Id$
2003-11-26 16:17:13 +00:00
2002-04-14 19:34:04 +00:00
/**
2003-12-08 06:32:19 +00:00
* @ file
2004-07-22 16:06:54 +00:00
* The theme system , which controls the output of Drupal .
2003-12-08 06:32:19 +00:00
*
* The theme system allows for nearly all output of the Drupal system to be
* customized by user themes .
*
2004-06-18 15:04:37 +00:00
* @ see < a href = " http://drupal.org/node/253 " > Theme system </ a >
2003-12-08 06:32:19 +00:00
* @ see themeable
*/
2001-10-20 13:35:12 +00:00
2005-01-30 09:53:19 +00:00
/**
* @ name Content markers
* @ {
* Markers used by theme_mark () and node_mark () to designate content .
* @ see theme_mark (), node_mark ()
*/
define ( 'MARK_READ' , 0 );
define ( 'MARK_NEW' , 1 );
define ( 'MARK_UPDATED' , 2 );
/**
* @ } End of " Content markers " .
*/
2003-11-26 16:17:13 +00:00
/**
2004-01-02 16:24:28 +00:00
* Initialize the theme system by loading the theme .
2003-12-08 06:32:19 +00:00
*
*/
2003-11-26 16:17:13 +00:00
function init_theme () {
2006-01-06 07:25:44 +00:00
global $theme , $user , $custom_theme , $theme_engine , $theme_key ;
// If $theme is already set, assume the others are set, too, and do nothing
if ( isset ( $theme )) {
return ;
}
2003-11-26 16:17:13 +00:00
2005-07-23 05:57:27 +00:00
drupal_bootstrap ( DRUPAL_BOOTSTRAP_DATABASE );
2003-11-26 16:17:13 +00:00
$themes = list_themes ();
2004-07-22 16:06:54 +00:00
// Only select the user selected theme if it is available in the
// list of enabled themes.
2006-11-08 19:24:11 +00:00
$theme = $user -> theme && $themes [ $user -> theme ] -> status ? $user -> theme : variable_get ( 'theme_default' , 'garland' );
2004-08-20 07:51:27 +00:00
// Allow modules to override the present theme... only select custom theme
2005-03-16 19:41:12 +00:00
// if it is available in the list of installed themes.
2004-08-22 14:43:49 +00:00
$theme = $custom_theme && $themes [ $custom_theme ] ? $custom_theme : $theme ;
2004-08-20 07:51:27 +00:00
// Store the identifier for retrieving theme settings with.
$theme_key = $theme ;
// If we're using a style, load its appropriate theme,
// which is stored in the style's description field.
2006-08-03 07:06:36 +00:00
// Also add the stylesheet using drupal_add_css().
2004-08-20 07:51:27 +00:00
// Otherwise, load the theme.
if ( strpos ( $themes [ $theme ] -> filename , '.css' )) {
2004-08-20 17:21:37 +00:00
// File is a style; loads its CSS.
2004-08-20 07:51:27 +00:00
// Set theme to its template/theme
2006-08-03 07:06:36 +00:00
drupal_add_css ( $themes [ $theme ] -> filename , 'theme' );
2004-12-01 22:41:19 +00:00
$theme = basename ( dirname ( $themes [ $theme ] -> description ));
2004-08-20 07:51:27 +00:00
}
else {
// File is a template/theme
2004-08-20 17:21:37 +00:00
// Load its CSS, if it exists
2004-08-20 07:51:27 +00:00
if ( file_exists ( $stylesheet = dirname ( $themes [ $theme ] -> filename ) . '/style.css' )) {
2006-08-03 07:06:36 +00:00
drupal_add_css ( $stylesheet , 'theme' );
2004-08-20 07:51:27 +00:00
}
}
2003-11-26 16:17:13 +00:00
2004-08-20 07:51:27 +00:00
if ( strpos ( $themes [ $theme ] -> filename , '.theme' )) {
2006-03-07 11:28:22 +00:00
// file is a theme; include it
2005-09-08 19:19:01 +00:00
include_once './' . $themes [ $theme ] -> filename ;
2004-08-20 07:51:27 +00:00
}
elseif ( strpos ( $themes [ $theme ] -> description , '.engine' )) {
// file is a template; include its engine
2006-03-07 11:28:22 +00:00
include_once './' . $themes [ $theme ] -> description ;
2004-08-20 07:51:27 +00:00
$theme_engine = basename ( $themes [ $theme ] -> description , '.engine' );
if ( function_exists ( $theme_engine . '_init' )) {
call_user_func ( $theme_engine . '_init' , $themes [ $theme ]);
}
}
2003-11-26 16:17:13 +00:00
}
/**
2003-12-08 06:32:19 +00:00
* Provides a list of currently available themes .
*
* @ param $refresh
2004-07-22 16:06:54 +00:00
* Whether to reload the list of themes from the database .
* @ return
* An array of the currently available themes .
2003-12-08 06:32:19 +00:00
*/
2004-07-22 16:06:54 +00:00
function list_themes ( $refresh = FALSE ) {
2003-11-26 16:17:13 +00:00
static $list ;
if ( $refresh ) {
unset ( $list );
}
if ( ! $list ) {
$list = array ();
2006-01-04 09:32:28 +00:00
$result = db_query ( " SELECT * FROM { system} WHERE type = 'theme' " );
2003-11-26 16:17:13 +00:00
while ( $theme = db_fetch_object ( $result )) {
if ( file_exists ( $theme -> filename )) {
$list [ $theme -> name ] = $theme ;
}
}
}
return $list ;
}
2004-08-20 07:51:27 +00:00
/**
* Provides a list of currently available theme engines
*
* @ param $refresh
* Whether to reload the list of themes from the database .
* @ return
* An array of the currently available theme engines .
*/
function list_theme_engines ( $refresh = FALSE ) {
static $list ;
if ( $refresh ) {
unset ( $list );
}
if ( ! $list ) {
$list = array ();
2004-08-21 16:21:56 +00:00
$result = db_query ( " SELECT * FROM { system} WHERE type = 'theme_engine' AND status = '1' ORDER BY name " );
2004-08-20 07:51:27 +00:00
while ( $engine = db_fetch_object ( $result )) {
if ( file_exists ( $engine -> filename )) {
$list [ $engine -> name ] = $engine ;
}
}
}
return $list ;
}
2003-11-26 16:17:13 +00:00
/**
2004-07-22 16:06:54 +00:00
* Generate the themed representation of a Drupal object .
2003-12-08 06:32:19 +00:00
*
* All requests for themed functions must go through this function . It examines
* the request and routes it to the appropriate theme function . If the current
2004-08-20 07:51:27 +00:00
* theme does not implement the requested function , then the current theme
* engine is checked . If neither the engine nor theme implement the requested
* function , then the base theme function is called .
2004-07-22 16:06:54 +00:00
*
* For example , to retrieve the HTML that is output by theme_page ( $output ), a
* module should call theme ( 'page' , $output ) .
2003-12-08 06:32:19 +00:00
*
2004-07-22 16:06:54 +00:00
* @ param $function
* The name of the theme function to call .
* @ param ...
* Additional arguments to pass along to the theme function .
* @ return
* An HTML string that generates the themed output .
2003-12-08 06:32:19 +00:00
*/
2003-11-26 16:17:13 +00:00
function theme () {
2006-01-10 19:37:27 +00:00
$args = func_get_args ();
$function = array_shift ( $args );
if ( $func = theme_get_function ( $function )) {
return call_user_func_array ( $func , $args );
}
}
/**
* Determine if a theme function exists , and if so return which one was found .
*
* @ param $function
* The name of the theme function to test .
* @ return
2006-07-05 11:45:51 +00:00
* The name of the theme function that should be used , or FALSE if no function exists .
2006-01-10 19:37:27 +00:00
*/
function theme_get_function ( $function ) {
2005-03-29 21:01:47 +00:00
global $theme , $theme_engine ;
2006-01-06 07:25:44 +00:00
// Because theme() is called a lot, calling init_theme() only to have it
2006-05-07 00:08:36 +00:00
// smartly return is a noticeable performance hit. Don't do it.
2006-01-06 07:25:44 +00:00
if ( ! isset ( $theme )) {
init_theme ();
2005-03-29 21:01:47 +00:00
}
2003-11-26 16:17:13 +00:00
2004-08-20 07:51:27 +00:00
if (( $theme != '' ) && function_exists ( $theme . '_' . $function )) {
// call theme function
2006-01-10 19:37:27 +00:00
return $theme . '_' . $function ;
2003-11-26 16:17:13 +00:00
}
2004-08-20 07:51:27 +00:00
elseif (( $theme != '' ) && isset ( $theme_engine ) && function_exists ( $theme_engine . '_' . $function )) {
// call engine function
2006-01-10 19:37:27 +00:00
return $theme_engine . '_' . $function ;
2004-08-20 07:51:27 +00:00
}
2004-07-22 16:06:54 +00:00
elseif ( function_exists ( 'theme_' . $function )){
2004-08-20 07:51:27 +00:00
// call Drupal function
2006-01-10 19:37:27 +00:00
return 'theme_' . $function ;
2003-11-26 16:17:13 +00:00
}
2006-07-05 11:45:51 +00:00
return FALSE ;
2003-11-26 16:17:13 +00:00
}
/**
2004-07-22 16:06:54 +00:00
* Return the path to the currently selected theme .
2003-12-08 06:32:19 +00:00
*/
2003-11-26 16:17:13 +00:00
function path_to_theme () {
global $theme ;
2004-01-02 16:24:28 +00:00
2006-11-28 10:13:11 +00:00
if ( ! isset ( $theme )) {
init_theme ();
}
2004-01-02 16:24:28 +00:00
$themes = list_themes ();
return dirname ( $themes [ $theme ] -> filename );
2003-11-26 16:17:13 +00:00
}
2004-08-20 07:51:27 +00:00
/**
* Retrieve an associative array containing the settings for a theme .
*
2004-08-20 09:34:53 +00:00
* The final settings are arrived at by merging the default settings ,
2004-08-20 07:51:27 +00:00
* 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 .
*
* @ param $key
* The template / style value for a given theme .
*
* @ return
* An associative array containing theme settings .
*/
2004-08-20 17:21:37 +00:00
function theme_get_settings ( $key = NULL ) {
2004-08-20 07:51:27 +00:00
$defaults = array (
'mission' => '' ,
'default_logo' => 1 ,
'logo_path' => '' ,
2005-05-25 06:03:18 +00:00
'default_favicon' => 1 ,
'favicon_path' => '' ,
2004-08-20 07:51:27 +00:00
'toggle_logo' => 1 ,
2005-05-25 06:03:18 +00:00
'toggle_favicon' => 1 ,
2004-08-20 07:51:27 +00:00
'toggle_name' => 1 ,
'toggle_search' => 1 ,
'toggle_slogan' => 0 ,
'toggle_mission' => 1 ,
'toggle_node_user_picture' => 0 ,
'toggle_comment_user_picture' => 0 ,
);
2006-08-20 05:57:41 +00:00
if ( module_exists ( 'node' )) {
2006-06-23 07:54:00 +00:00
foreach ( node_get_types () as $type => $name ) {
2005-04-13 17:59:39 +00:00
$defaults [ 'toggle_node_info_' . $type ] = 1 ;
}
2004-08-20 07:51:27 +00:00
}
$settings = array_merge ( $defaults , variable_get ( 'theme_settings' , array ()));
if ( $key ) {
$settings = array_merge ( $settings , variable_get ( str_replace ( '/' , '_' , 'theme_' . $key . '_settings' ), array ()));
}
2004-10-14 02:38:33 +00:00
// Only offer search box if search.module is enabled.
2006-08-20 05:57:41 +00:00
if ( ! module_exists ( 'search' ) || ! user_access ( 'search content' )) {
2004-10-14 02:38:33 +00:00
$settings [ 'toggle_search' ] = 0 ;
}
2004-08-20 07:51:27 +00:00
return $settings ;
}
/**
* 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 )
*
* @ param $setting_name
* The name of the setting to be retrieved .
*
* @ param $refresh
* Whether to reload the cache of settings .
*
* @ return
* The value of the requested setting , NULL if the setting does not exist .
*/
2004-08-20 17:21:37 +00:00
function theme_get_setting ( $setting_name , $refresh = FALSE ) {
2006-02-02 12:44:57 +00:00
global $theme_key ;
2004-08-20 07:51:27 +00:00
static $settings ;
if ( empty ( $settings ) || $refresh ) {
2004-08-20 17:21:37 +00:00
$settings = theme_get_settings ( $theme_key );
2004-08-20 07:51:27 +00:00
$themes = list_themes ();
$theme_object = $themes [ $theme_key ];
if ( $settings [ 'mission' ] == '' ) {
$settings [ 'mission' ] = variable_get ( 'site_mission' , '' );
}
if ( ! $settings [ 'toggle_mission' ]) {
$settings [ 'mission' ] = '' ;
}
if ( $settings [ 'toggle_logo' ]) {
if ( $settings [ 'default_logo' ]) {
2006-04-04 23:31:04 +00:00
$settings [ 'logo' ] = base_path () . dirname ( $theme_object -> filename ) . '/logo.png' ;
2004-08-20 07:51:27 +00:00
}
elseif ( $settings [ 'logo_path' ]) {
2006-04-04 23:31:04 +00:00
$settings [ 'logo' ] = base_path () . $settings [ 'logo_path' ];
2004-08-20 07:51:27 +00:00
}
}
2005-05-25 06:03:18 +00:00
if ( $settings [ 'toggle_favicon' ]) {
if ( $settings [ 'default_favicon' ]) {
if ( file_exists ( $favicon = dirname ( $theme_object -> filename ) . '/favicon.ico' )) {
2006-04-06 02:35:57 +00:00
$settings [ 'favicon' ] = base_path () . $favicon ;
2005-05-25 06:03:18 +00:00
}
else {
2006-04-06 02:35:57 +00:00
$settings [ 'favicon' ] = base_path () . 'misc/favicon.ico' ;
2005-05-25 06:03:18 +00:00
}
}
elseif ( $settings [ 'favicon_path' ]) {
2006-04-06 02:35:57 +00:00
$settings [ 'favicon' ] = base_path () . $settings [ 'favicon_path' ];
2005-05-25 06:03:18 +00:00
}
}
2004-08-20 07:51:27 +00:00
}
return isset ( $settings [ $setting_name ]) ? $settings [ $setting_name ] : NULL ;
}
2004-01-28 11:36:29 +00:00
/**
* @ defgroup themeable Themeable functions
* @ {
2004-09-09 05:51:08 +00:00
* Functions that display HTML , and which can be customized by themes .
2004-01-28 11:36:29 +00:00
*
2004-07-22 16:06:54 +00:00
* All functions that produce HTML for display should be themeable . This means
* that they should be named with the theme_ prefix , and invoked using theme ()
* rather than being called directly . This allows themes to override the display
* of any Drupal object .
2004-01-28 11:36:29 +00:00
*
2004-09-09 05:51:08 +00:00
* The theme system is described and defined in theme . inc .
2004-01-28 11:36:29 +00:00
*/
2005-03-31 21:18:08 +00:00
2005-03-31 09:25:33 +00:00
/**
2006-08-18 12:17:00 +00:00
* Formats text for emphasized display in a placeholder inside a sentence .
* Used automatically by t () .
2005-03-31 09:25:33 +00:00
*
* @ param $text
* The text to format ( plain - text ) .
* @ return
* The formatted text ( html ) .
*/
function theme_placeholder ( $text ) {
return '<em>' . check_plain ( $text ) . '</em>' ;
}
2004-01-26 19:05:21 +00:00
2003-11-26 16:17:13 +00:00
/**
2004-07-22 16:06:54 +00:00
* Return an entire Drupal page displaying the supplied content .
*
* @ param $content
* A string to display in the main content area of the page .
* @ return
* A string containing the entire HTML page .
2003-12-08 06:32:19 +00:00
*/
2004-12-15 21:19:42 +00:00
function theme_page ( $content ) {
2006-11-29 06:36:12 +00:00
// Get blocks before so that they can alter the header (JavaScript, Stylesheets etc.)
$blocks = theme ( 'blocks' , 'all' );
2003-11-08 11:56:33 +00:00
$output = " <!DOCTYPE html PUBLIC \" -//W3C//DTD XHTML 1.0 Transitional//EN \" \" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd \" > \n " ;
2004-07-22 16:06:54 +00:00
$output .= '<html xmlns="http://www.w3.org/1999/xhtml">' ;
$output .= '<head>' ;
2006-10-22 08:28:47 +00:00
$output .= ' <title>' . ( drupal_get_title () ? strip_tags ( drupal_get_title ()) : variable_get ( 'site_name' , 'Drupal' )) . '</title>' ;
2004-01-14 22:30:09 +00:00
$output .= drupal_get_html_head ();
2006-08-03 07:06:36 +00:00
$output .= drupal_get_css ();
2006-08-22 09:00:31 +00:00
$output .= drupal_get_js ();
2003-11-10 09:03:53 +00:00
2004-07-22 16:06:54 +00:00
$output .= ' </head>' ;
2006-01-20 08:54:07 +00:00
$output .= ' <body style="background-color: #fff; color: #000;">' ;
2004-07-22 16:06:54 +00:00
$output .= '<table border="0" cellspacing="4" cellpadding="4"><tr><td style="vertical-align: top; width: 170px;">' ;
2003-11-08 11:56:33 +00:00
2006-11-29 06:36:12 +00:00
$output .= $blocks ;
2004-07-22 16:06:54 +00:00
$output .= '</td><td style="vertical-align: top;">' ;
2003-11-09 23:27:22 +00:00
2004-07-22 16:06:54 +00:00
$output .= theme ( 'breadcrumb' , drupal_get_breadcrumb ());
$output .= '<h1>' . drupal_get_title () . '</h1>' ;
2004-06-18 15:04:37 +00:00
if ( $tabs = theme ( 'menu_local_tasks' )) {
$output .= $tabs ;
}
2005-04-30 17:47:57 +00:00
$output .= theme ( 'help' );
2003-11-23 10:41:04 +00:00
2005-04-30 17:47:57 +00:00
$output .= theme ( 'status_messages' );
2004-07-08 16:08:21 +00:00
2004-01-26 19:05:21 +00:00
$output .= " \n <!-- begin content --> \n " ;
2003-11-25 19:26:21 +00:00
$output .= $content ;
2006-08-23 05:55:38 +00:00
$output .= drupal_get_feeds ();
2004-01-26 19:05:21 +00:00
$output .= " \n <!-- end content --> \n " ;
2004-07-22 16:06:54 +00:00
$output .= '</td></tr></table>' ;
2006-09-05 10:11:29 +00:00
$output .= theme ( 'closure' );
2004-07-22 16:06:54 +00:00
$output .= '</body></html>' ;
2003-11-25 19:26:21 +00:00
return $output ;
}
2006-03-28 09:29:23 +00:00
function theme_maintenance_page ( $content , $messages = TRUE , $partial = FALSE ) {
2005-07-27 01:58:43 +00:00
drupal_set_header ( 'Content-Type: text/html; charset=utf-8' );
2006-08-05 22:17:31 +00:00
drupal_add_css ( 'misc/maintenance.css' , 'core' );
2006-02-02 12:44:57 +00:00
drupal_set_html_head ( '<link rel="shortcut icon" href="' . base_path () . 'misc/favicon.ico" type="image/x-icon" />' );
2006-03-28 09:29:23 +00:00
2005-07-27 01:58:43 +00:00
$output = " <!DOCTYPE html PUBLIC \" -//W3C//DTD XHTML 1.0 Transitional//EN \" \" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd \" > \n " ;
$output .= '<html xmlns="http://www.w3.org/1999/xhtml">' ;
$output .= '<head>' ;
2006-07-13 13:14:25 +00:00
$output .= ' <title>' . strip_tags ( drupal_get_title ()) . '</title>' ;
2005-07-29 07:49:43 +00:00
$output .= drupal_get_html_head ();
2006-08-03 07:06:36 +00:00
$output .= drupal_get_css ();
2006-08-22 09:00:31 +00:00
$output .= drupal_get_js ();
2005-07-27 01:58:43 +00:00
$output .= '</head>' ;
$output .= '<body>' ;
$output .= '<h1>' . drupal_get_title () . '</h1>' ;
2006-03-28 09:29:23 +00:00
if ( $messages ) {
2006-04-07 10:40:55 +00:00
$output .= theme ( 'status_messages' );
2006-03-28 09:29:23 +00:00
}
2005-07-27 01:58:43 +00:00
$output .= " \n <!-- begin content --> \n " ;
$output .= $content ;
$output .= " \n <!-- end content --> \n " ;
2006-03-28 09:29:23 +00:00
if ( ! $partial ) {
2006-04-07 10:40:55 +00:00
$output .= '</body></html>' ;
2006-03-28 09:29:23 +00:00
}
2005-07-27 01:58:43 +00:00
return $output ;
}
2006-07-13 13:14:25 +00:00
function theme_install_page ( $content ) {
drupal_set_header ( 'Content-Type: text/html; charset=utf-8' );
2006-08-05 22:17:31 +00:00
drupal_add_css ( 'misc/maintenance.css' , 'core' );
2006-07-13 13:14:25 +00:00
drupal_set_html_head ( '<link rel="shortcut icon" href="' . base_path () . 'misc/favicon.ico" type="image/x-icon" />' );
$output = " <!DOCTYPE html PUBLIC \" -//W3C//DTD XHTML 1.0 Transitional//EN \" \" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd \" > \n " ;
$output .= '<html xmlns="http://www.w3.org/1999/xhtml">' ;
$output .= '<head>' ;
$output .= ' <title>' . strip_tags ( drupal_get_title ()) . '</title>' ;
$output .= drupal_get_html_head ();
2006-08-03 07:06:36 +00:00
$output .= drupal_get_css ();
2006-08-22 09:00:31 +00:00
$output .= drupal_get_js ();
2006-07-13 13:14:25 +00:00
$output .= '</head>' ;
$output .= '<body>' ;
$output .= '<h1>' . drupal_get_title () . '</h1>' ;
$messages = drupal_set_message ();
if ( isset ( $messages [ 'error' ])) {
$errors = count ( $messages [ 'error' ]) > 1 ? 'errors' : 'error' ;
$output .= " <h3>The following $errors must be resolved before you can continue the installation process:</h3> " ;
$output .= theme ( 'status_messages' , 'error' );
}
if ( isset ( $messages [ 'status' ])) {
$warnings = count ( $messages [ 'status' ]) > 1 ? 'warnings' : 'warning' ;
$output .= " <h4>The following installation $warnings should be carefully reviewed, but in most cases may be safely ignored:</h4> " ;
$output .= theme ( 'status_messages' , 'status' );
}
2006-09-01 08:44:53 +00:00
$output .= " \n <!-- begin content --> \n " ;
$output .= $content ;
$output .= " \n <!-- end content --> \n " ;
2006-07-13 13:14:25 +00:00
$output .= '</body></html>' ;
return $output ;
}
2004-07-08 16:04:07 +00:00
/**
2006-07-13 13:14:25 +00:00
* Return a themed set of status and / or error messages . The messages are grouped
2004-07-08 16:04:07 +00:00
* by type .
*
2006-07-13 13:14:25 +00:00
* @ param $display
* ( optional ) Set to 'status' or 'error' to display only messages of that type .
*
2004-07-22 16:06:54 +00:00
* @ return
* A string containing the messages .
2004-07-08 16:04:07 +00:00
*/
2006-07-13 13:14:25 +00:00
function theme_status_messages ( $display = NULL ) {
$output = '' ;
foreach ( drupal_get_messages ( $display ) as $type => $messages ) {
$output .= " <div class= \" messages $type\ " > \n " ;
if ( count ( $messages ) > 1 ) {
$output .= " <ul> \n " ;
foreach ( $messages as $message ) {
$output .= ' <li>' . $message . " </li> \n " ;
2004-07-08 16:04:07 +00:00
}
2006-07-13 13:14:25 +00:00
$output .= " </ul> \n " ;
2004-07-08 16:04:07 +00:00
}
2006-07-13 13:14:25 +00:00
else {
$output .= $messages [ 0 ];
}
$output .= " </div> \n " ;
2004-07-08 16:04:07 +00:00
}
2006-07-13 13:14:25 +00:00
return $output ;
2004-07-08 16:04:07 +00:00
}
2003-11-09 23:27:22 +00:00
/**
2004-07-22 16:06:54 +00:00
* Return a themed set of links .
*
* @ param $links
2006-05-18 14:58:57 +00:00
* A keyed array of links to be themed .
2006-08-30 07:37:14 +00:00
* @ param $attributes
* A keyed array of attributes
2004-07-22 16:06:54 +00:00
* @ return
2006-08-30 07:37:14 +00:00
* A string containing an unordered list of links .
2003-12-08 06:32:19 +00:00
*/
2006-08-30 07:37:14 +00:00
function theme_links ( $links , $attributes = array ( 'class' => 'links' )) {
$output = '' ;
2006-05-18 14:58:57 +00:00
2006-11-21 19:41:57 +00:00
if ( count ( $links ) > 0 ) {
2006-08-30 07:37:14 +00:00
$output = '<ul' . drupal_attributes ( $attributes ) . '>' ;
$num_links = count ( $links );
$i = 1 ;
2006-05-18 14:58:57 +00:00
foreach ( $links as $key => $link ) {
2006-08-30 07:37:14 +00:00
$class = '' ;
// Automatically add a class to each link and also to each LI
2006-07-04 08:59:05 +00:00
if ( isset ( $link [ 'attributes' ]) && isset ( $link [ 'attributes' ][ 'class' ])) {
2006-08-30 07:37:14 +00:00
$link [ 'attributes' ][ 'class' ] .= ' ' . $key ;
$class = $key ;
2006-05-18 14:58:57 +00:00
}
else {
2006-08-30 07:37:14 +00:00
$link [ 'attributes' ][ 'class' ] = $key ;
$class = $key ;
2006-05-18 14:58:57 +00:00
}
2006-08-30 07:37:14 +00:00
// Add first and last classes to the list of links to help out themers
$extra_class = ( $i == 1 ) ? 'first ' : (( $i == $num_links ) ? 'last ' : '' );
$output .= '<li class="' . $extra_class . $class . '">' ;
2006-10-18 18:00:40 +00:00
// Is the title HTML?
$html = isset ( $link [ 'html' ]) && $link [ 'html' ];
2006-11-26 23:14:59 +00:00
// Initialize fragment and query variables.
$link [ 'query' ] = isset ( $link [ 'query' ]) ? $link [ 'query' ] : NULL ;
$link [ 'fragment' ] = isset ( $link [ 'fragment' ]) ? $link [ 'fragment' ] : NULL ;
2006-11-29 20:39:37 +00:00
if ( isset ( $link [ 'href' ])) {
2006-10-18 18:00:40 +00:00
$output .= l ( $link [ 'title' ], $link [ 'href' ], $link [ 'attributes' ], $link [ 'query' ], $link [ 'fragment' ], FALSE , $html );
2006-05-18 14:58:57 +00:00
}
2006-07-04 08:59:05 +00:00
else if ( $link [ 'title' ]) {
2006-05-18 14:58:57 +00:00
//Some links are actually not links, but we wrap these in <span> for adding title and class attributes
2006-10-18 18:00:40 +00:00
if ( ! $html ) {
$link [ 'title' ] = check_plain ( $link [ 'title' ]);
}
$output .= '<span' . drupal_attributes ( $link [ 'attributes' ]) . '>' . $link [ 'title' ] . '</span>' ;
2006-05-18 14:58:57 +00:00
}
2006-08-30 07:37:14 +00:00
$i ++ ;
2006-10-17 08:38:16 +00:00
$output .= " </li> \n " ;
2006-05-18 14:58:57 +00:00
}
2006-08-30 07:37:14 +00:00
$output .= '</ul>' ;
2005-11-03 19:33:37 +00:00
}
2006-05-18 14:58:57 +00:00
2006-08-30 07:37:14 +00:00
return $output ;
2003-11-08 11:56:33 +00:00
}
2003-02-09 17:39:40 +00:00
2003-11-09 23:27:22 +00:00
/**
2004-07-22 16:06:54 +00:00
* Return a themed image .
2003-12-08 06:32:19 +00:00
*
2004-08-04 20:40:01 +00:00
* @ param $path
2006-08-24 00:04:44 +00:00
* Either the path of the image file ( relative to base_path ()) or a full URL .
2004-08-04 20:40:01 +00:00
* @ param $alt
* The alternative text for text - based browsers .
* @ param $title
* The title text is displayed when the image is hovered in some popular browsers .
2005-05-06 09:01:46 +00:00
* @ param $attributes
* Associative array of attributes to be placed in the img tag .
2004-08-20 04:35:33 +00:00
* @ param $getsize
2006-07-05 11:45:51 +00:00
* If set to TRUE , the image ' s dimension are fetched and added as width / height attributes .
2004-07-22 16:06:54 +00:00
* @ return
2004-08-04 20:40:01 +00:00
* A string containing the image tag .
2003-12-08 06:32:19 +00:00
*/
2005-05-06 09:01:46 +00:00
function theme_image ( $path , $alt = '' , $title = '' , $attributes = NULL , $getsize = TRUE ) {
2005-06-19 08:59:06 +00:00
if ( ! $getsize || ( is_file ( $path ) && ( list ( $width , $height , $type , $image_attributes ) = @ getimagesize ( $path )))) {
2005-05-06 09:01:46 +00:00
$attributes = drupal_attributes ( $attributes );
2006-08-24 00:04:44 +00:00
$url = ( url ( $path ) == $path ) ? $path : ( base_path () . $path );
return '<img src="' . check_url ( $url ) . '" alt="' . check_plain ( $alt ) . '" title="' . check_plain ( $title ) . '" ' . $image_attributes . $attributes . ' />' ;
2004-08-04 20:40:01 +00:00
}
2003-11-08 11:56:33 +00:00
}
2003-02-09 17:39:40 +00:00
2003-11-09 23:27:22 +00:00
/**
2004-07-22 16:06:54 +00:00
* Return a themed breadcrumb trail .
2003-12-08 06:32:19 +00:00
*
2004-07-22 16:06:54 +00:00
* @ param $breadcrumb
* An array containing the breadcrumb links .
* @ return a string containing the breadcrumb output .
2003-12-08 06:32:19 +00:00
*/
2003-11-08 11:56:33 +00:00
function theme_breadcrumb ( $breadcrumb ) {
2006-01-18 19:02:34 +00:00
if ( ! empty ( $breadcrumb )) {
return '<div class="breadcrumb">' . implode ( ' » ' , $breadcrumb ) . '</div>' ;
}
2003-11-08 11:56:33 +00:00
}
2001-10-20 13:35:12 +00:00
2005-04-30 17:47:57 +00:00
/**
* Return a themed help message .
*
* @ return a string containing the helptext for the current page .
*/
function theme_help () {
if ( $help = menu_get_active_help ()) {
return '<div class="help">' . $help . '</div>' ;
}
}
2003-11-09 23:27:22 +00:00
/**
2004-07-22 16:06:54 +00:00
* Return a themed node .
*
* @ param $node
* An object providing all relevant information for displaying a node :
* - $node -> nid : The ID of the node .
* - $node -> type : The content type ( story , blog , forum ... ) .
* - $node -> title : The title of the node .
* - $node -> created : The creation date , as a UNIX timestamp .
* - $node -> teaser : A shortened version of the node body .
* - $node -> body : The entire node contents .
* - $node -> changed : The last modification date , as a UNIX timestamp .
* - $node -> uid : The ID of the author .
* - $node -> username : The username of the author .
* @ param $teaser
* Whether to display the teaser only , as on the main page .
* @ param $page
* Whether to display the node as a standalone page . If TRUE , do not display
* the title because it will be provided by the menu system .
* @ return
* A string containing the node output .
2003-12-08 06:32:19 +00:00
*/
2004-07-22 16:06:54 +00:00
function theme_node ( $node , $teaser = FALSE , $page = FALSE ) {
2006-04-15 04:07:18 +00:00
if ( ! $node -> status ) {
2006-04-17 20:48:26 +00:00
$output = '<div class="node-unpublished">' ;
2006-04-15 04:07:18 +00:00
}
2006-08-20 05:57:41 +00:00
if ( module_exists ( 'taxonomy' )) {
2004-07-22 16:06:54 +00:00
$terms = taxonomy_link ( 'taxonomy terms' , $node );
2001-10-07 12:27:58 +00:00
}
2003-11-25 19:26:21 +00:00
if ( $page == 0 ) {
2006-08-18 12:17:00 +00:00
$output .= t ( '!title by !name' , array ( '!title' => '<h2 class="title">' . check_plain ( $node -> title ) . '</h2>' , '!name' => theme ( 'username' , $node )));
2003-11-25 19:26:21 +00:00
}
else {
2006-08-18 12:17:00 +00:00
$output .= t ( 'by !name' , array ( '!name' => theme ( 'username' , $node )));
2003-11-25 19:26:21 +00:00
}
2003-11-08 11:56:33 +00:00
if ( count ( $terms )) {
2004-07-22 16:06:54 +00:00
$output .= ' <small>(' . theme ( 'links' , $terms ) . ')</small><br />' ;
2001-10-20 13:35:12 +00:00
}
2004-07-22 16:06:54 +00:00
if ( $teaser && $node -> teaser ) {
2003-11-08 11:56:33 +00:00
$output .= $node -> teaser ;
}
else {
$output .= $node -> body ;
2003-02-01 19:54:19 +00:00
}
2004-11-23 23:11:59 +00:00
if ( $node -> links ) {
$output .= '<div class="links">' . theme ( 'links' , $node -> links ) . '</div>' ;
2001-10-20 13:35:12 +00:00
}
2003-11-08 11:56:33 +00:00
2006-04-15 04:07:18 +00:00
if ( ! $node -> status ) {
$output .= '</div>' ;
}
2003-11-09 23:27:22 +00:00
return $output ;
2003-11-08 11:56:33 +00:00
}
2004-06-18 15:04:37 +00:00
/**
2004-07-22 16:06:54 +00:00
* Return a themed submenu , typically displayed under the tabs .
2004-06-18 15:04:37 +00:00
*
2004-07-22 16:06:54 +00:00
* @ param $links
* An array of links .
2004-06-18 15:04:37 +00:00
*/
function theme_submenu ( $links ) {
2004-07-22 16:06:54 +00:00
return '<div class="submenu">' . implode ( ' | ' , $links ) . '</div>' ;
2004-06-18 15:04:37 +00:00
}
2003-11-13 19:52:54 +00:00
/**
2004-07-22 16:06:54 +00:00
* Return a themed table .
*
* @ param $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 .
* @ param $rows
2004-09-14 20:01:00 +00:00
* 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 :
2004-07-22 16:06:54 +00:00
* - " data " : The string to display in the table cell .
2006-08-03 20:37:52 +00:00
* - " header " : Indicates this cell is a header .
2004-07-22 16:06:54 +00:00
* - Any HTML attributes , such as " colspan " , to apply to the table cell .
2004-09-14 20:01:00 +00:00
*
* Here ' s an example for $rows :
* @ verbatim
* $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'
* )
* );
* @ endverbatim
*
2004-07-22 16:06:54 +00:00
* @ param $attributes
* An array of HTML attributes to apply to the table tag .
2005-09-06 20:32:53 +00:00
* @ param $caption
* A localized string to use for the < caption > tag .
2004-07-22 16:06:54 +00:00
* @ return
* An HTML string representing the table .
2003-12-08 06:32:19 +00:00
*/
2006-11-17 06:53:31 +00:00
function theme_table ( $header , $rows , $attributes = array (), $caption = NULL ) {
2004-08-21 16:21:56 +00:00
$output = '<table' . drupal_attributes ( $attributes ) . " > \n " ;
2003-11-13 19:52:54 +00:00
2005-09-06 20:32:53 +00:00
if ( isset ( $caption )) {
$output .= '<caption>' . $caption . " </caption> \n " ;
}
2004-07-22 16:06:54 +00:00
// Format the table header:
2005-06-19 08:13:14 +00:00
if ( count ( $header )) {
2006-11-17 06:53:31 +00:00
$ts = tablesort_init ( $header );
2005-09-15 20:58:17 +00:00
$output .= ' <thead><tr>' ;
2003-11-13 19:52:54 +00:00
foreach ( $header as $cell ) {
2004-06-02 05:35:51 +00:00
$cell = tablesort_header ( $cell , $header , $ts );
2006-08-03 20:37:52 +00:00
$output .= _theme_table_cell ( $cell , TRUE );
2003-11-13 19:52:54 +00:00
}
2005-09-15 20:58:17 +00:00
$output .= " </tr></thead> \n " ;
2003-11-13 19:52:54 +00:00
}
2004-07-22 16:06:54 +00:00
// Format the table rows:
2005-09-15 20:58:17 +00:00
$output .= " <tbody> \n " ;
2005-06-19 08:13:14 +00:00
if ( count ( $rows )) {
2003-11-13 19:52:54 +00:00
foreach ( $rows as $number => $row ) {
2004-09-14 20:01:00 +00:00
$attributes = array ();
// Check if we're dealing with a simple or complex row
if ( isset ( $row [ 'data' ])) {
foreach ( $row as $key => $value ) {
if ( $key == 'data' ) {
$cells = $value ;
}
else {
$attributes [ $key ] = $value ;
}
}
}
else {
$cells = $row ;
}
2005-06-19 08:50:46 +00:00
// Add odd/even class
$class = ( $number % 2 == 1 ) ? 'even' : 'odd' ;
2004-09-14 20:01:00 +00:00
if ( isset ( $attributes [ 'class' ])) {
$attributes [ 'class' ] .= ' ' . $class ;
2003-11-13 19:52:54 +00:00
}
else {
2004-09-14 20:01:00 +00:00
$attributes [ 'class' ] = $class ;
2003-11-13 19:52:54 +00:00
}
2004-09-14 20:01:00 +00:00
// Build row
$output .= ' <tr' . drupal_attributes ( $attributes ) . '>' ;
2004-07-22 16:06:54 +00:00
$i = 0 ;
2004-09-14 20:01:00 +00:00
foreach ( $cells as $cell ) {
$cell = tablesort_cell ( $cell , $header , $ts , $i ++ );
2006-08-03 20:37:52 +00:00
$output .= _theme_table_cell ( $cell );
2003-11-13 19:52:54 +00:00
}
$output .= " </tr> \n " ;
}
}
2005-09-15 20:58:17 +00:00
$output .= " </tbody></table> \n " ;
2003-11-13 19:52:54 +00:00
return $output ;
}
2006-11-21 08:16:39 +00:00
/**
* Returns a header cell for tables that have a select all functionality .
*/
function theme_table_select_header_cell () {
drupal_add_js ( array ( 'tableSelect' => array ( 'selectAll' => t ( 'Select all rows in this table' ), 'selectNone' => t ( 'Deselect all rows in this table' ))), 'setting' );
drupal_add_js ( 'misc/tableselect.js' );
return array ( 'class' => 'select-all' );
}
2005-07-02 12:32:09 +00:00
/**
* Return a themed sort icon .
*
* @ param $style
2006-05-07 00:08:36 +00:00
* Set to either asc or desc . This sets which icon to show .
2005-07-02 12:32:09 +00:00
* @ return
* A themed sort icon .
*/
function theme_tablesort_indicator ( $style ) {
if ( $style == " asc " ){
return theme ( 'image' , 'misc/arrow-asc.png' , t ( 'sort icon' ), t ( 'sort ascending' ));
}
else {
return theme ( 'image' , 'misc/arrow-desc.png' , t ( 'sort icon' ), t ( 'sort descending' ));
}
}
2003-11-09 23:27:22 +00:00
/**
2004-07-22 16:06:54 +00:00
* Return a themed box .
*
* @ param $title
* The subject of the box .
* @ param $content
* The content of the box .
* @ param $region
* The region in which the box is displayed .
* @ return
* A string containing the box output .
2003-12-08 06:32:19 +00:00
*/
2004-02-08 21:04:08 +00:00
function theme_box ( $title , $content , $region = 'main' ) {
2004-07-22 16:06:54 +00:00
$output = '<h2 class="title">' . $title . '</h2><div>' . $content . '</div>' ;
2003-11-09 23:27:22 +00:00
return $output ;
2003-11-08 11:56:33 +00:00
}
/**
2004-07-22 16:06:54 +00:00
* Return a themed block .
2003-12-08 06:32:19 +00:00
*
* You can style your blocks by defining . block ( all blocks ),
* . block -< i > module </ i > ( all blocks of module < i > module </ i > ), and
* \ #block-<i>module</i>-<i>delta</i> (specific block of module <i>module</i>
* with delta < i > delta </ i > ) in your theme ' s CSS .
*
2004-07-22 16:06:54 +00:00
* @ param $block
* An object populated with fields from the " blocks " database table
2005-08-16 18:06:18 +00:00
* ( $block -> module , $block -> delta ... ) and fields returned by
2004-07-22 16:06:54 +00:00
* < i > module </ i > _block ( 'view' ) ( $block -> subject , $block -> content , ... ) .
* @ return
* A string containing the block output .
2003-12-08 06:32:19 +00:00
*/
2003-11-08 11:56:33 +00:00
function theme_block ( $block ) {
2003-12-16 21:06:34 +00:00
$output = " <div class= \" block block- $block->module\ " id = \ " block- $block->module - $block->delta\ " > \n " ;
$output .= " <h2 class= \" title \" > $block->subject </h2> \n " ;
$output .= " <div class= \" content \" > $block->content </div> \n " ;
$output .= " </div> \n " ;
2003-11-09 23:27:22 +00:00
return $output ;
2003-11-08 11:56:33 +00:00
}
2001-10-20 13:35:12 +00:00
2003-10-31 19:34:03 +00:00
/**
2005-01-30 09:53:19 +00:00
* Return a themed marker , useful for marking new or updated
* content .
2003-12-08 06:32:19 +00:00
*
2005-01-27 12:57:08 +00:00
* @ param $type
2005-01-30 09:53:19 +00:00
* Number representing the marker type to display
* @ see MARK_NEW , MARK_UPDATED , MARK_READ
2004-07-22 16:06:54 +00:00
* @ return
* A string containing the marker .
2003-12-08 06:32:19 +00:00
*/
2005-01-30 09:53:19 +00:00
function theme_mark ( $type = MARK_NEW ) {
global $user ;
2005-04-24 16:22:30 +00:00
if ( $user -> uid ) {
if ( $type == MARK_NEW ) {
2005-09-29 08:02:55 +00:00
return ' <span class="marker">' . t ( 'new' ) . '</span>' ;
2005-04-24 16:22:30 +00:00
}
else if ( $type == MARK_UPDATED ) {
2005-09-29 08:02:55 +00:00
return ' <span class="marker">' . t ( 'updated' ) . '</span>' ;
2005-04-24 16:22:30 +00:00
}
2005-01-30 09:53:19 +00:00
}
2002-10-22 18:46:43 +00:00
}
2003-10-31 19:34:03 +00:00
/**
2004-07-22 16:06:54 +00:00
* Return a themed list of items .
*
* @ param $items
2006-07-02 00:25:40 +00:00
* 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
2006-08-17 06:55:26 +00:00
* 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 .
2004-07-22 16:06:54 +00:00
* @ param $title
* The title of the list .
2006-05-20 01:24:30 +00:00
* @ param $attributes
* The attributes applied to the list element .
2005-10-18 14:45:09 +00:00
* @ param $type
* The type of list to return ( e . g . " ul " , " ol " )
2004-07-22 16:06:54 +00:00
* @ return
* A string containing the list output .
2003-12-08 06:32:19 +00:00
*/
2006-05-20 01:24:30 +00:00
function theme_item_list ( $items = array (), $title = NULL , $type = 'ul' , $attributes = NULL ) {
2004-07-22 16:06:54 +00:00
$output = '<div class="item-list">' ;
2002-11-09 20:12:03 +00:00
if ( isset ( $title )) {
2004-07-22 16:06:54 +00:00
$output .= '<h3>' . $title . '</h3>' ;
2002-11-09 13:59:36 +00:00
}
2005-11-24 20:08:54 +00:00
if ( ! empty ( $items )) {
2006-05-20 01:24:30 +00:00
$output .= " < $type " . drupal_attributes ( $attributes ) . '>' ;
2002-11-09 20:12:03 +00:00
foreach ( $items as $item ) {
2006-07-02 00:25:40 +00:00
$attributes = array ();
2006-08-17 06:55:26 +00:00
$children = array ();
2006-07-02 00:25:40 +00:00
if ( is_array ( $item )) {
foreach ( $item as $key => $value ) {
if ( $key == 'data' ) {
$data = $value ;
}
2006-08-17 06:55:26 +00:00
elseif ( $key == 'children' ) {
$children = $value ;
}
2006-07-02 00:25:40 +00:00
else {
$attributes [ $key ] = $value ;
}
}
}
else {
$data = $item ;
}
2006-08-17 06:55:26 +00:00
if ( count ( $children ) > 0 ) {
$data .= theme_item_list ( $children , NULL , $type , $attributes ); // Render nested list
}
2006-07-02 00:25:40 +00:00
$output .= '<li' . drupal_attributes ( $attributes ) . '>' . $data . '</li>' ;
2002-11-09 20:12:03 +00:00
}
2005-10-18 14:45:09 +00:00
$output .= " </ $type > " ;
2002-11-09 13:59:36 +00:00
}
2004-07-22 16:06:54 +00:00
$output .= '</div>' ;
2002-11-09 13:59:36 +00:00
return $output ;
}
2003-10-31 19:34:03 +00:00
/**
2005-05-05 22:22:46 +00:00
* Returns code that emits the 'more help' - link .
2003-12-08 06:32:19 +00:00
*/
2004-08-10 05:44:17 +00:00
function theme_more_help_link ( $url ) {
2006-08-18 12:17:00 +00:00
return '<div class="more-help-link">' . t ( '[<a href="@link">more help...</a>]' , array ( '@link' => check_url ( $url ))) . '</div>' ;
2004-08-10 05:44:17 +00:00
}
2004-01-11 15:05:21 +00:00
/**
2004-07-22 16:06:54 +00:00
* Return code that emits an XML icon .
2004-01-11 15:05:21 +00:00
*/
function theme_xml_icon ( $url ) {
2004-08-04 20:40:01 +00:00
if ( $image = theme ( 'image' , 'misc/xml.png' , t ( 'XML feed' ), t ( 'XML feed' ))) {
2006-01-16 20:57:53 +00:00
return '<a href="' . check_url ( $url ) . '" class="xml-icon">' . $image . '</a>' ;
2004-08-04 20:40:01 +00:00
}
2004-01-11 15:05:21 +00:00
}
2005-12-29 04:46:40 +00:00
/**
* Return code that emits an feed icon .
*/
function theme_feed_icon ( $url ) {
if ( $image = theme ( 'image' , 'misc/feed.png' , t ( 'Syndicate content' ), t ( 'Syndicate content' ))) {
2006-01-16 20:57:53 +00:00
return '<a href="' . check_url ( $url ) . '" class="feed-icon">' . $image . '</a>' ;
2005-12-29 04:46:40 +00:00
}
}
2003-10-31 19:34:03 +00:00
/**
2004-07-22 16:06:54 +00:00
* Execute hook_footer () which is run at the end of the page right before the
* close of the body tag .
2003-12-08 06:32:19 +00:00
*
* @ param $main ( optional )
*
2004-07-22 16:06:54 +00:00
* @ return
* A string containing the results of the hook_footer () calls .
2003-12-08 06:32:19 +00:00
*/
2003-11-08 11:56:33 +00:00
function theme_closure ( $main = 0 ) {
2004-02-08 21:04:08 +00:00
$footer = module_invoke_all ( 'footer' , $main );
2006-08-22 09:00:31 +00:00
return implode ( " \n " , $footer ) . drupal_get_js ( 'footer' );
2003-04-21 13:56:09 +00:00
}
2003-02-01 19:54:19 +00:00
/**
2004-07-22 16:06:54 +00:00
* Return a set of blocks available for the current user .
2003-11-19 16:13:07 +00:00
*
2004-07-22 16:06:54 +00:00
* @ param $region
* Which set of blocks to retrieve .
* @ return
* A string containing the themed blocks for this region .
2003-11-19 16:13:07 +00:00
*/
function theme_blocks ( $region ) {
2004-02-08 21:04:08 +00:00
$output = '' ;
2003-11-19 16:13:07 +00:00
2006-06-29 20:40:26 +00:00
if ( $list = block_list ( $region )) {
2003-11-19 16:13:07 +00:00
foreach ( $list as $key => $block ) {
// $key == <i>module</i>_<i>delta</i>
$output .= theme ( 'block' , $block );
2000-12-23 23:25:28 +00:00
}
}
2005-08-16 18:06:18 +00:00
// Add any content assigned to this region through drupal_set_content() calls.
$output .= drupal_get_content ( $region );
2003-11-09 23:27:22 +00:00
return $output ;
2000-12-23 23:25:28 +00:00
}
2005-03-03 20:51:27 +00:00
2005-08-01 05:14:05 +00:00
/**
* Format a username .
*
* @ param $object
* The user object to format , usually returned from user_load () .
* @ return
* 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 .
*/
function theme_username ( $object ) {
if ( $object -> uid && $object -> name ) {
// Shorten the name when it is too long or it will break many tables.
if ( drupal_strlen ( $object -> name ) > 20 ) {
$name = drupal_substr ( $object -> name , 0 , 15 ) . '...' ;
}
else {
$name = $object -> name ;
}
if ( user_access ( 'access user profiles' )) {
$output = l ( $name , 'user/' . $object -> uid , array ( 'title' => t ( 'View user profile.' )));
}
else {
2006-03-13 21:42:35 +00:00
$output = check_plain ( $name );
2005-08-01 05:14:05 +00:00
}
}
else if ( $object -> name ) {
// Sometimes modules display content composed by people who are
// not registered members of the site (e.g. mailing list or news
// aggregator modules). This clause enables modules to display
// the true author of the content.
if ( $object -> homepage ) {
2006-03-13 21:42:35 +00:00
$output = l ( $object -> name , $object -> homepage );
2005-08-01 05:14:05 +00:00
}
else {
2006-03-13 21:42:35 +00:00
$output = check_plain ( $object -> name );
2005-08-01 05:14:05 +00:00
}
$output .= ' (' . t ( 'not verified' ) . ')' ;
}
else {
2006-11-24 09:01:57 +00:00
$output = variable_get ( 'anonymous' , t ( 'Anonymous' ));
2005-08-01 05:14:05 +00:00
}
return $output ;
}
2005-03-03 20:51:27 +00:00
2005-12-06 09:25:22 +00:00
function theme_progress_bar ( $percent , $message ) {
$output = '<div id="progress" class="progress">' ;
$output .= '<div class="percentage">' . $percent . '%</div>' ;
$output .= '<div class="status">' . $message . '</div>' ;
$output .= '<div class="bar"><div class="filled" style="width: ' . $percent . '%"></div></div>' ;
$output .= '</div>' ;
return $output ;
}
2004-07-22 16:06:54 +00:00
/**
2004-09-09 05:51:08 +00:00
* @ } End of " defgroup themeable " .
2004-07-22 16:06:54 +00:00
*/
2001-10-22 12:55:41 +00:00
2006-08-03 20:37:52 +00:00
function _theme_table_cell ( $cell , $header = FALSE ) {
2004-07-02 18:46:42 +00:00
$attributes = '' ;
2003-11-26 16:17:13 +00:00
if ( is_array ( $cell )) {
2004-02-08 21:04:08 +00:00
$data = $cell [ 'data' ];
2006-08-03 20:37:52 +00:00
$header |= isset ( $cell [ 'header' ]);
unset ( $cell [ 'data' ]);
unset ( $cell [ 'header' ]);
$attributes = drupal_attributes ( $cell );
2002-10-22 18:46:43 +00:00
}
2003-11-26 16:17:13 +00:00
else {
$data = $cell ;
2002-06-23 13:31:30 +00:00
}
2003-11-09 23:27:22 +00:00
2003-11-26 16:17:13 +00:00
if ( $header ) {
$output = " <th $attributes > $data </th> " ;
2003-04-21 13:56:09 +00:00
}
2003-11-26 16:17:13 +00:00
else {
$output = " <td $attributes > $data </td> " ;
2003-04-21 13:56:09 +00:00
}
2003-11-24 22:54:49 +00:00
2003-11-26 16:17:13 +00:00
return $output ;
}
2005-08-25 21:14:17 +00:00