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
|
|
|
*
|
2004-07-22 16:06:54 +00:00
|
|
|
* @return
|
|
|
|
* The name of the currently selected theme.
|
2003-12-08 06:32:19 +00:00
|
|
|
*/
|
2003-11-26 16:17:13 +00:00
|
|
|
function init_theme() {
|
2004-08-20 07:51:27 +00:00
|
|
|
global $user, $custom_theme, $theme_engine, $theme_key;
|
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.
|
2004-08-21 10:16:13 +00:00
|
|
|
$theme = $user->theme && $themes[$user->theme]->status ? $user->theme : variable_get('theme_default', 'bluemarine');
|
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.
|
|
|
|
// Also load the stylesheet using drupal_set_html_head().
|
|
|
|
// 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
|
2004-08-20 17:21:37 +00:00
|
|
|
theme_add_style($themes[$theme]->filename);
|
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')) {
|
2004-08-20 17:21:37 +00:00
|
|
|
theme_add_style($stylesheet);
|
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')) {
|
|
|
|
// file is a theme; include it
|
|
|
|
include_once($themes[$theme]->filename);
|
|
|
|
}
|
|
|
|
elseif (strpos($themes[$theme]->description, '.engine')) {
|
|
|
|
// file is a template; include its engine
|
|
|
|
include_once($themes[$theme]->description);
|
|
|
|
$theme_engine = basename($themes[$theme]->description, '.engine');
|
|
|
|
if (function_exists($theme_engine .'_init')) {
|
|
|
|
call_user_func($theme_engine .'_init', $themes[$theme]);
|
|
|
|
}
|
|
|
|
}
|
2004-08-20 09:34:53 +00:00
|
|
|
|
2003-11-26 16:17:13 +00:00
|
|
|
return $theme;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
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();
|
2005-08-18 22:07:14 +00:00
|
|
|
$result = db_query("SELECT * FROM {system} WHERE type = 'theme' AND status = 1");
|
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() {
|
2005-03-29 21:01:47 +00:00
|
|
|
global $theme, $theme_engine;
|
|
|
|
|
2005-07-27 01:58:43 +00:00
|
|
|
if ($theme === NULL) {
|
2005-03-29 21:01:47 +00:00
|
|
|
// Initialize the enabled theme.
|
|
|
|
$theme = init_theme();
|
|
|
|
}
|
2003-11-26 16:17:13 +00:00
|
|
|
|
|
|
|
$args = func_get_args();
|
|
|
|
$function = array_shift($args);
|
|
|
|
|
2004-08-20 07:51:27 +00:00
|
|
|
if (($theme != '') && function_exists($theme .'_'. $function)) {
|
|
|
|
// call theme function
|
2004-07-22 16:06:54 +00:00
|
|
|
return call_user_func_array($theme .'_'. $function, $args);
|
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
|
|
|
|
return call_user_func_array($theme_engine .'_'. $function, $args);
|
|
|
|
}
|
2004-07-22 16:06:54 +00:00
|
|
|
elseif (function_exists('theme_'. $function)){
|
2004-08-20 07:51:27 +00:00
|
|
|
// call Drupal function
|
2004-07-22 16:06:54 +00:00
|
|
|
return call_user_func_array('theme_'. $function, $args);
|
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
|
|
|
|
|
|
|
$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(
|
2005-05-04 18:12:18 +00:00
|
|
|
'primary_links' => array(),
|
|
|
|
'secondary_links' => array(),
|
2004-08-20 07:51:27 +00:00
|
|
|
'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_primary_links' => 1,
|
|
|
|
'toggle_secondary_links' => 1,
|
|
|
|
'toggle_node_user_picture' => 0,
|
|
|
|
'toggle_comment_user_picture' => 0,
|
|
|
|
);
|
|
|
|
|
2005-04-13 17:59:39 +00:00
|
|
|
if (module_exist('node')) {
|
- Patch #29785 by Chx: multiple node types were broken so we refactored
part of the node system! If you have a module that implements node
types, you'll have to udpate its CVS HEAD version.
We replaced _node_name() and _node_types() by _node(). The new _node()
hook let's you define one or more node types, including their names.
The implementation of the _node() hook needs to:
return array($type1 => array('name' => $name1, 'base' => $base1),
$type2 => array('name' => $name2, 'base' => $base2));
where $type is the node type, $name is the human readable name of the type
and $base is used instead of <hook> for <hook>_load, <hook>_view, etc.
For example, the story module's node hook looks like this:
function story_node() {
return array('story' => array('name' => t('story'), 'base' => 'story'));
}
The page module's node hook module like:
function page_node() {
return array('page' => array('name' => t('page'), 'base' => 'page'));
}
However, more complex node modules like the project module and the
flexinode module can use the 'base' parameter to specify a different base.
The project module implements two node types, proejcts and issues, so it
can do:
function project_node() {
return array(
array('project_project' => array('name' => t('project'), 'base' => 'project'),
array('project_issue' => array('name' => t('issue'), 'base' => 'project_issue'));
}
In the flexinode module's case there can only one base ...
This hook will simplify the CCK, and will make it easy (or easier) to merge
the story and page module.
In addition, node_list() became node_get_types(). In addition, we created
the following functions: node_get_name($type) and node_get_base($type).
2005-08-28 15:29:34 +00:00
|
|
|
foreach (node_get_types() as $type) {
|
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.
|
|
|
|
if (!module_exist('search')) {
|
|
|
|
$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) {
|
2004-08-20 07:51:27 +00:00
|
|
|
global $theme_key;
|
|
|
|
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']) {
|
2004-08-20 09:34:53 +00:00
|
|
|
$settings['logo'] = dirname($theme_object->filename) .'/logo.png';
|
2004-08-20 07:51:27 +00:00
|
|
|
}
|
|
|
|
elseif ($settings['logo_path']) {
|
|
|
|
$settings['logo'] = $settings['logo_path'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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')) {
|
|
|
|
$settings['favicon'] = $favicon;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$settings['favicon'] = 'misc/favicon.ico';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif ($settings['favicon_path']) {
|
|
|
|
$settings['favicon'] = $settings['favicon_path'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-05 07:35:58 +00:00
|
|
|
foreach (array('primary', 'secondary') as $type) {
|
|
|
|
// Get the data to populate the textfields, if the variable is not an array .. try to parse the old-style link format.
|
|
|
|
$value = $settings[$type . '_links'];
|
|
|
|
|
|
|
|
// Clear out existing (internal) values
|
|
|
|
$settings[$type .'_links'] = array();
|
|
|
|
|
|
|
|
// Get the amount of links to show, possibly expanding if there are more links defined than the count specifies.
|
|
|
|
$count = variable_get($type . '_link_count', 5);
|
|
|
|
$count = ($count > sizeof($value['link'])) ? $count : sizeof($value['link']);
|
|
|
|
|
|
|
|
if ($settings['toggle_' . $type . '_links']) {
|
|
|
|
for ($i =0; $i < $count; $i++) {
|
|
|
|
unset($attributes);
|
|
|
|
if (!empty($value['text'][$i])) {
|
|
|
|
if (!empty($value['description'][$i])) {
|
|
|
|
$attributes['title'] = $value['description'][$i];
|
|
|
|
}
|
|
|
|
$text = $value['text'][$i];
|
|
|
|
$link = $value['link'][$i];
|
|
|
|
if (substr($link, 0, 7) == 'http://') {
|
2005-05-18 21:12:17 +00:00
|
|
|
$settings[$type .'_links'][] = '<a href="'. check_url($link) .'"'. drupal_attributes($attributes) .'>'. check_plain($text) .'</a>';
|
2005-05-05 07:35:58 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$settings[$type .'_links'][] = l($text, $link, $attributes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($settings[$type .'_links'] == array()) {
|
|
|
|
$settings[$type .'_links'] = array(l(t('edit %type links', array('%type' => $type)),'admin/themes/settings'));
|
|
|
|
}
|
|
|
|
}
|
2004-08-20 07:51:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return isset($settings[$setting_name]) ? $settings[$setting_name] : NULL;
|
|
|
|
}
|
|
|
|
|
2004-08-20 17:21:37 +00:00
|
|
|
/**
|
|
|
|
* Add a theme stylesheet to be included later. This is handled separately from
|
|
|
|
* drupal_set_html_head() to enforce the correct CSS cascading order.
|
|
|
|
*/
|
2005-08-05 00:22:03 +00:00
|
|
|
function theme_add_style($path = '', $media = 'all') {
|
2004-08-20 17:21:37 +00:00
|
|
|
static $styles = array();
|
2005-08-05 00:22:03 +00:00
|
|
|
if ($path) {
|
|
|
|
$style = new stdClass();
|
|
|
|
$style->path = $path;
|
|
|
|
$style->media = $media;
|
2004-08-20 17:21:37 +00:00
|
|
|
$styles[] = $style;
|
|
|
|
}
|
|
|
|
return $styles;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the HTML for a theme's stylesheets.
|
|
|
|
*/
|
|
|
|
function theme_get_styles() {
|
|
|
|
$output = '';
|
|
|
|
foreach (theme_add_style() as $style) {
|
2005-08-05 00:22:03 +00:00
|
|
|
$output .= theme('stylesheet_import', $style->path, $style->media);
|
2004-08-20 17:21:37 +00:00
|
|
|
}
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Format a dynamic text string for emphasised display in a placeholder.
|
|
|
|
*
|
|
|
|
* E.g. t('Added term %term', array('%term' => theme('placeholder', $term)))
|
|
|
|
*
|
|
|
|
* @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) {
|
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>';
|
2005-03-31 09:25:33 +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();
|
2004-08-20 17:21:37 +00:00
|
|
|
$output .= theme_get_styles();
|
2003-11-10 09:03:53 +00:00
|
|
|
|
2004-07-22 16:06:54 +00:00
|
|
|
$output .= ' </head>';
|
|
|
|
$output .= ' <body style="background-color: #fff; color: #000;"'. theme('onload_attribute'). '">';
|
|
|
|
$output .= '<table border="0" cellspacing="4" cellpadding="4"><tr><td style="vertical-align: top; width: 170px;">';
|
2003-11-08 11:56:33 +00:00
|
|
|
|
2004-07-22 16:06:54 +00:00
|
|
|
$output .= theme('blocks', 'all');
|
|
|
|
$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;
|
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>';
|
2004-01-26 19:05:21 +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;
|
|
|
|
}
|
|
|
|
|
2005-07-27 01:58:43 +00:00
|
|
|
function theme_maintenance_page($content) {
|
|
|
|
drupal_set_header('Content-Type: text/html; charset=utf-8');
|
|
|
|
theme('add_style', 'misc/maintenance.css');
|
|
|
|
$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>'. drupal_get_title() .'</title>';
|
2005-07-29 07:49:43 +00:00
|
|
|
$output .= drupal_get_html_head();
|
2005-07-27 01:58:43 +00:00
|
|
|
$output .= theme_get_styles();
|
|
|
|
$output .= '</head>';
|
|
|
|
$output .= '<body>';
|
|
|
|
$output .= '<h1>' . drupal_get_title() . '</h1>';
|
|
|
|
|
|
|
|
$output .= theme('status_messages');
|
|
|
|
|
|
|
|
$output .= "\n<!-- begin content -->\n";
|
|
|
|
$output .= $content;
|
|
|
|
$output .= "\n<!-- end content -->\n";
|
|
|
|
|
|
|
|
$output .= '</body></html>';
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
2004-07-08 16:04:07 +00:00
|
|
|
/**
|
|
|
|
* Returns themed set of status and/or error messages. The messages are grouped
|
|
|
|
* by type.
|
|
|
|
*
|
2004-07-22 16:06:54 +00:00
|
|
|
* @return
|
|
|
|
* A string containing the messages.
|
2004-07-08 16:04:07 +00:00
|
|
|
*/
|
|
|
|
function theme_status_messages() {
|
|
|
|
if ($data = drupal_get_messages()) {
|
|
|
|
$output = '';
|
|
|
|
foreach ($data as $type => $messages) {
|
|
|
|
$output .= "<div class=\"messages $type\">\n";
|
|
|
|
if (count($messages) > 1) {
|
|
|
|
$output .= " <ul>\n";
|
|
|
|
foreach($messages as $message) {
|
2004-08-06 20:15:32 +00:00
|
|
|
$output .= ' <li>'. $message ."</li>\n";
|
2004-07-08 16:04:07 +00:00
|
|
|
}
|
|
|
|
$output .= " </ul>\n";
|
|
|
|
}
|
|
|
|
else {
|
2004-08-06 20:15:32 +00:00
|
|
|
$output .= $messages[0];
|
2004-07-08 16:04:07 +00:00
|
|
|
}
|
|
|
|
$output .= "</div>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-09 23:27:22 +00:00
|
|
|
/**
|
2004-07-22 16:06:54 +00:00
|
|
|
* Return a themed set of links.
|
|
|
|
*
|
|
|
|
* @param $links
|
|
|
|
* An array of links to be themed.
|
|
|
|
* @param $delimiter
|
|
|
|
* A string used to separate the links.
|
|
|
|
* @return
|
|
|
|
* A string containing the themed links.
|
2003-12-08 06:32:19 +00:00
|
|
|
*/
|
2004-07-22 16:06:54 +00:00
|
|
|
function theme_links($links, $delimiter = ' | ') {
|
2003-11-08 11:56:33 +00:00
|
|
|
return implode($delimiter, $links);
|
|
|
|
}
|
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
|
|
|
|
* The path of the image file.
|
|
|
|
* @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
|
|
|
|
* 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);
|
2005-05-31 21:14:27 +00:00
|
|
|
return '<img src="'. check_url($path) .'" 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) {
|
2005-07-30 12:52:54 +00:00
|
|
|
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) {
|
|
|
|
if (module_exist('taxonomy')) {
|
|
|
|
$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) {
|
2005-08-01 05:14:05 +00:00
|
|
|
$output = '<h2 class="title">'. check_plain($node->title) .'</h2> by '. theme('username', $node);
|
2003-11-25 19:26:21 +00:00
|
|
|
}
|
|
|
|
else {
|
2005-08-01 05:14:05 +00:00
|
|
|
$output = 'by '. 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
|
|
|
|
2003-11-09 23:27:22 +00:00
|
|
|
return $output;
|
2003-11-08 11:56:33 +00:00
|
|
|
}
|
|
|
|
|
2003-11-17 19:16:55 +00:00
|
|
|
/**
|
2004-07-22 16:06:54 +00:00
|
|
|
* Return a themed form element.
|
2003-12-08 06:32:19 +00:00
|
|
|
*
|
|
|
|
* @param $title the form element's title
|
|
|
|
* @param $value the form element's data
|
|
|
|
* @param $description the form element's description or explanation
|
2003-12-22 15:38:07 +00:00
|
|
|
* @param $id the form element's ID used by the <label> tag
|
2004-05-31 09:40:56 +00:00
|
|
|
* @param $required a boolean to indicate whether this is a required field or not
|
|
|
|
* @param $error a string with an error message filed against this form element
|
2003-12-08 06:32:19 +00:00
|
|
|
*
|
2004-02-10 19:28:39 +00:00
|
|
|
* @return a string representing the form element
|
2003-12-08 06:32:19 +00:00
|
|
|
*/
|
2004-05-31 09:40:56 +00:00
|
|
|
function theme_form_element($title, $value, $description = NULL, $id = NULL, $required = FALSE, $error = FALSE) {
|
2004-04-24 15:39:31 +00:00
|
|
|
|
2005-05-25 03:50:25 +00:00
|
|
|
$output = '<div class="form-item">'."\n";
|
2005-01-30 09:53:19 +00:00
|
|
|
$required = $required ? '<span class="form-required">*</span>' : '';
|
2003-12-22 14:45:00 +00:00
|
|
|
|
|
|
|
if ($title) {
|
|
|
|
if ($id) {
|
2005-05-25 03:50:25 +00:00
|
|
|
$output .= ' <label for="'. form_clean_id($id) .'">'. $title .':</label>'. $required ."<br />\n";
|
2003-12-22 14:45:00 +00:00
|
|
|
}
|
|
|
|
else {
|
2005-05-25 03:50:25 +00:00
|
|
|
$output .= ' <label>'. $title .':</label>'. $required ."<br />\n";
|
2003-12-22 14:45:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-24 15:39:31 +00:00
|
|
|
$output .= " $value\n";
|
|
|
|
|
2003-12-22 14:45:00 +00:00
|
|
|
if ($description) {
|
2005-05-25 03:50:25 +00:00
|
|
|
$output .= ' <div class="description">'. $description ."</div>\n";
|
2003-12-22 14:45:00 +00:00
|
|
|
}
|
|
|
|
|
2004-04-24 15:39:31 +00:00
|
|
|
$output .= "</div>\n";
|
|
|
|
|
|
|
|
return $output;
|
2003-11-17 19:16:55 +00:00
|
|
|
}
|
2003-11-13 19:52:54 +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.
|
|
|
|
* - 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.
|
|
|
|
* @return
|
|
|
|
* An HTML string representing the table.
|
2003-12-08 06:32:19 +00:00
|
|
|
*/
|
2004-01-31 21:07:54 +00:00
|
|
|
function theme_table($header, $rows, $attributes = NULL) {
|
2003-11-13 19:52:54 +00:00
|
|
|
|
2004-08-21 16:21:56 +00:00
|
|
|
$output = '<table'. drupal_attributes($attributes) .">\n";
|
2003-11-13 19:52:54 +00:00
|
|
|
|
2004-07-22 16:06:54 +00:00
|
|
|
// Format the table header:
|
2005-06-19 08:13:14 +00:00
|
|
|
if (count($header)) {
|
2004-05-29 17:38:54 +00:00
|
|
|
$ts = tablesort_init($header);
|
2004-07-22 16:06:54 +00:00
|
|
|
$output .= ' <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);
|
2003-11-13 19:52:54 +00:00
|
|
|
$output .= _theme_table_cell($cell, 1);
|
|
|
|
}
|
|
|
|
$output .= " </tr>\n";
|
|
|
|
}
|
|
|
|
|
2004-07-22 16:06:54 +00:00
|
|
|
// Format the table rows:
|
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++);
|
2003-11-13 19:52:54 +00:00
|
|
|
$output .= _theme_table_cell($cell, 0);
|
|
|
|
}
|
|
|
|
$output .= " </tr>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$output .= "</table>\n";
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
2005-07-02 12:32:09 +00:00
|
|
|
/**
|
|
|
|
* Return a themed sort icon.
|
|
|
|
*
|
|
|
|
* @param $style
|
|
|
|
* Set to either asc or desc. This sets which icon to show.
|
|
|
|
* @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) {
|
|
|
|
return '<span class="marker">'. t('new') .'</span>';
|
|
|
|
}
|
|
|
|
else if ($type == MARK_UPDATED) {
|
|
|
|
return '<span class="marker">'. t('updated') .'</span>';
|
|
|
|
}
|
2005-01-30 09:53:19 +00:00
|
|
|
}
|
2002-10-22 18:46:43 +00:00
|
|
|
}
|
|
|
|
|
2004-08-20 07:51:27 +00:00
|
|
|
/**
|
|
|
|
* Import a stylesheet using @import.
|
2004-08-20 09:34:53 +00:00
|
|
|
*
|
2005-08-05 00:22:03 +00:00
|
|
|
* @param $path
|
|
|
|
* The path to the stylesheet.
|
2004-08-20 07:51:27 +00:00
|
|
|
*
|
|
|
|
* @param $media
|
|
|
|
* The media type to specify for the stylesheet
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* A string containing the HTML for the stylesheet import.
|
|
|
|
*/
|
2005-08-05 00:22:03 +00:00
|
|
|
function theme_stylesheet_import($path, $media = 'all') {
|
|
|
|
return '<style type="text/css" media="'. $media .'">@import "'. $path .'";</style>';
|
2004-08-20 07:51:27 +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
|
|
|
|
* An array of items to be displayed in the list.
|
|
|
|
* @param $title
|
|
|
|
* The title of the list.
|
|
|
|
* @return
|
|
|
|
* A string containing the list output.
|
2003-12-08 06:32:19 +00:00
|
|
|
*/
|
2002-11-09 20:50:50 +00:00
|
|
|
function theme_item_list($items = array(), $title = 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
|
|
|
}
|
|
|
|
|
2002-11-09 20:12:03 +00:00
|
|
|
if (isset($items)) {
|
2004-07-22 16:06:54 +00:00
|
|
|
$output .= '<ul>';
|
2002-11-09 20:12:03 +00:00
|
|
|
foreach ($items as $item) {
|
2004-07-22 16:06:54 +00:00
|
|
|
$output .= '<li>'. $item .'</li>';
|
2002-11-09 20:12:03 +00:00
|
|
|
}
|
2004-07-22 16:06:54 +00:00
|
|
|
$output .= '</ul>';
|
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) {
|
2005-05-18 21:12:17 +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'))) {
|
2005-05-26 19:08:14 +00:00
|
|
|
return '<span class="xml-icon"><a href="'. check_url($url) .'">'. $image. '</a></span>';
|
2004-08-04 20:40:01 +00:00
|
|
|
}
|
2004-01-11 15:05:21 +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);
|
2005-07-30 12:52:54 +00:00
|
|
|
return implode("\n", $footer);
|
2003-04-21 13:56:09 +00:00
|
|
|
}
|
|
|
|
|
2003-11-09 23:27:22 +00:00
|
|
|
/**
|
2004-07-22 16:06:54 +00:00
|
|
|
* Call hook_onload() in all modules to enable modules to insert JavaScript that
|
2003-12-08 06:32:19 +00:00
|
|
|
* will get run once the page has been loaded by the browser.
|
|
|
|
*
|
2004-07-22 16:06:54 +00:00
|
|
|
* @param $theme_onloads
|
|
|
|
* Additional onload directives.
|
|
|
|
* @return
|
|
|
|
* A string containing the onload attributes.
|
2003-12-08 06:32:19 +00:00
|
|
|
*/
|
2003-11-09 23:27:22 +00:00
|
|
|
function theme_onload_attribute($theme_onloads = array()) {
|
|
|
|
if (!is_array($theme_onloads)) {
|
|
|
|
$theme_onloads = array($theme_onloads);
|
2003-03-11 23:08:01 +00:00
|
|
|
}
|
2003-11-09 23:27:22 +00:00
|
|
|
// Merge theme onloads (javascript rollovers, image preloads, etc.)
|
|
|
|
// with module onloads (htmlarea, etc.)
|
2004-07-22 16:06:54 +00:00
|
|
|
$onloads = array_merge(module_invoke_all('onload'), $theme_onloads);
|
2003-11-09 23:27:22 +00:00
|
|
|
if (count($onloads)) {
|
2004-07-22 16:06:54 +00:00
|
|
|
return ' onload="' . implode('; ', $onloads) . '"';
|
2001-01-21 19:41:11 +00:00
|
|
|
}
|
2004-02-08 21:04:08 +00:00
|
|
|
return '';
|
2001-01-21 19:41:11 +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
|
|
|
|
|
|
|
if ($list = module_invoke('block', 'list', $region)) {
|
|
|
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* Output a confirmation form
|
|
|
|
*
|
|
|
|
* This function outputs 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.
|
|
|
|
*
|
|
|
|
* You should use $_POST['edit'][$name] (where $name is usually 'confirm') to
|
2005-03-31 21:18:08 +00:00
|
|
|
* check if the confirmation was successful.
|
2005-03-03 20:51:27 +00:00
|
|
|
*
|
|
|
|
* @param $question
|
|
|
|
* The question to ask the user (e.g. "Are you sure you want to delete the
|
|
|
|
* block <em>foo</em>?").
|
|
|
|
* @param $path
|
|
|
|
* The page to go to if the user denies the action.
|
|
|
|
* @param $description
|
|
|
|
* Additional text to display (defaults to "This action cannot be undone.").
|
|
|
|
* @param $yes
|
|
|
|
* A caption for the button which confirms the action (e.g. "Delete",
|
|
|
|
* "Replace", ...).
|
|
|
|
* @param $no
|
|
|
|
* A caption for the link which denies the action (e.g. "Cancel").
|
|
|
|
* @param $extra
|
|
|
|
* Additional HTML to inject into the form, for example form_hidden()s.
|
|
|
|
* @param $name
|
|
|
|
* The internal name used to refer to the confirmation item.
|
|
|
|
* @return
|
|
|
|
* A themed HTML string representing the form.
|
|
|
|
*/
|
|
|
|
function theme_confirm($question, $path, $description = NULL, $yes = NULL, $no = NULL, $extra = NULL, $name = 'confirm') {
|
|
|
|
drupal_set_title($question);
|
|
|
|
|
|
|
|
if (is_null($description)) {
|
|
|
|
$description = t('This action cannot be undone.');
|
|
|
|
}
|
|
|
|
|
|
|
|
$output .= '<p>'. $description ."</p>\n";
|
|
|
|
if (!is_null($extra)) {
|
|
|
|
$output .= $extra;
|
|
|
|
}
|
|
|
|
$output .= '<div class="container-inline">';
|
|
|
|
$output .= form_submit($yes ? $yes : t('Confirm'));
|
|
|
|
$output .= l($no ? $no : t('Cancel'), $path);
|
|
|
|
$output .= "</div>\n";
|
|
|
|
|
|
|
|
$output .= form_hidden($name, 1);
|
|
|
|
return form($output, 'post', NULL, array('class' => 'confirmation'));
|
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
$output = $name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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) {
|
|
|
|
$output = '<a href="'. $object->homepage .'">'. $object->name .'</a>';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$output = $object->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
$output .= ' ('. t('not verified') .')';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$output = variable_get('anonymous', 'Anonymous');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
2005-03-03 20:51:27 +00:00
|
|
|
|
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
|
|
|
|
2003-11-26 16:17:13 +00:00
|
|
|
function _theme_table_cell($cell, $header = 0) {
|
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'];
|
2003-11-26 16:17:13 +00:00
|
|
|
foreach ($cell as $key => $value) {
|
2004-02-08 21:04:08 +00:00
|
|
|
if ($key != 'data') {
|
2003-11-26 16:17:13 +00:00
|
|
|
$attributes .= " $key=\"$value\"";
|
2003-11-09 23:27:22 +00:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|