Skip to content
Snippets Groups Projects
Commit 67df17b6 authored by Ken Rickard's avatar Ken Rickard
Browse files

Changes file domain_form.inc to domain_conf_form.inc.

-- Adds the Domain Theme module.
-- Some function documentation cleanup.
-- Beta4 release.
parent 6d57e54a
No related branches found
Tags 8.x-2.0-alpha8
No related merge requests found
......@@ -40,6 +40,11 @@
* @defgroup content Domain Content : administer nodes
* Configurable navigation block based on active domains.
*/
/**
* @defgroup theme Domain Theme: manage themes
* Switch themes based on active domain.
*/
/**
* @defgroup themes Theme functions
......
// $Id$
28-OCT-2007 (3)
-- Changes file domain_form.inc to domain_conf_form.inc.
-- Adds the Domain Theme module.
-- Some function documentation cleanup.
-- Beta4 release.
28-OCT-2007 (2)
-- Checked a few of the API hooks for proper functionality.
......
......@@ -297,7 +297,7 @@ function domain_admin($action, $id = NULL) {
* The string representation of a {domain} entry. Optional.
* @return
* An array containing the requested row from the {domain} table, plus the
* absolute path to the domain $base_url. Returns -1 on failure.
* elements added by hook_domainload(). Returns -1 on failure.
*
* @ingroup domain
*/
......@@ -326,6 +326,8 @@ function domain_lookup($domain_id = NULL, $subdomain = NULL) {
* Assigns the default settings to domain 0, the root domain.
*
* This value is used throughout the modules, so needed abstraction.
*
* @ingroup domain
*/
function domain_default() {
static $default;
......@@ -343,6 +345,8 @@ function domain_default() {
/**
* Return all active domains (including the default) as an array.
*
* @ingroup domain
*/
function domain_domains() {
static $domains;
......@@ -361,6 +365,10 @@ function domain_domains() {
/**
* Implements hook_domainload()
*
* Adds the home page 'path' and 'site_grant' boolean.
*
* @ingroup domain
*/
function domain_domainload($domain) {
// Get the path to the home page for this domain.
......@@ -373,6 +381,11 @@ function domain_domainload($domain) {
/**
* Determine an absolute path for a domain
*
* @param $domain
* The currently active $domain array, privided by domain_lookup().
*
* @ingroup domain
*/
function domain_get_path($domain) {
global $base_url;
......@@ -400,7 +413,7 @@ function domain_get_uri($domain) {
* domain.
*
* @param $domain
* The currently active $domain array, privided by domain_lookup().
* The currently active $domain array, provided by domain_lookup().
*
* @ingroup domain
*/
......
......@@ -63,7 +63,8 @@ function domain_conf_page($domain_id) {
if ($domain['domain_id']) {
// Ensure we are on the proper domain.
domain_goto($domain);
include_once('domain_form.inc');
include_once('domain_conf_form.inc');
drupal_set_title(t('!site : Domain site settings', array('!site' => $domain['sitename'])));
return drupal_get_form('system_site_information_settings');
}
else {
......
File moved
// $Id$
/**
* @file
* README file for Domain Theme
*/
Domain Access: Theme
Assign themes to domains created by the Domain Access modules.
CONTENTS
--------
1. Introduction
1.1 Contributors
2. Installation
2.1 Dependencies
3. Configuration Options
4. Developer Notes
4.1 Database Schema
----
1. Introduction
The Domain Theme module is a small module that allows you to assign
different themes for each active domain created with the Domain Access
module.
----
1.1 Contributors
Drupal user 'canen' http://drupal.org/user/16188 wrote the first implementation
of this module. The current release version is based on that work.
----
2. Installation
The Domain Theme module is included in the Domain Access download.
To install, untar the domain package and place the entire folder in your modules
directory.
When you enable the module, it will create a {domain_theme} table in your Drupal
database.
----
2.1 Dependencies
Domain Theme requires the Domain Access module be installed and active.
----
3. Configuration Options
When active, the Domain Theme module will add a 'theme' link to the Domain List
screen.
When you click the 'theme' link for a domain record, you can set the default
theme for use by that domain. This form works just like the default system
theme selection form, with the following notes:
-- You cannot enable themes from this screen.
-- You must configure each theme's settings globally. There are currently
no domain-specific settings for themes.
----
4. Developer Notes
We intend to enable domain-specific theme settings in a later release. If you
are interested in helping, see http://drupal.org/node/180264.
----
4.1 Database Schema
Installing the module creates a {domain_theme} table that contains:
- domain_id
Integer, unique
The lookup key for this record, foreign key to the {domain} table.
- theme
String, unique
The theme name assigned as the default for this domain.
- settings
Blob (bytea)
A serialized array of theme settings for this domain. Currently not used.
\ No newline at end of file
;$Id$
name = Domain Theme
description = Assign themes to domains created by the Domain Access module
package = Domain Access
dependencies = domain
<?php
// $Id$
/**
* @file
* Install file for the Domain Theme module
*/
/**
* Implements hook_install()
*
* @ingroup drupal
*/
function domain_theme_install() {
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
db_query("CREATE TABLE IF NOT EXISTS {domain_theme} (
domain_id int(11) NOT NULL default '0',
theme varchar(32) NOT NULL default '',
settings blob,
PRIMARY KEY (domain_id)
) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
break;
case 'pgsql':
db_query("CREATE TABLE {domain_theme} (
domain_id integer NOT NULL default 0,
theme varchar(32) NOT NULL default '',
settings bytea,
PRIMARY KEY (domain_id)
)");
break;
}
}
/**
* Implements hook_uninstall()
*/
function domain_theme_uninstall() {
db_query("DROP TABLE {domain_theme}");
}
<?php
// $Id$
/**
* @file
* Domain Theme module for the Domain Access module group.
*
* Originally written by canen; http://drupal.org/user/16188.
*/
/**
* Implements hook_init()
*
* @ingroup drupal
*/
function domain_theme_init() {
global $_domain, $custom_theme;
$theme = domain_theme_lookup($_domain['domain_id']);
$custom_theme = $theme['theme'];
}
/**
* Implements hook_menu()
*
* @ingroup drupal
*/
function domain_theme_menu($may_cache) {
$items = array();
if (!$may_cache) {
$items[] = array(
'title' => t('Domain theme settings'),
'path' => 'admin/build/domain/theme',
'access' => user_access('administer domains'),
'type' => MENU_CALLBACK,
'callback' => 'domain_theme_page',
'callback arguments' => array(arg(4))
);
}
return $items;
}
/**
* The domain theme page callback router.
*
* @param $domain_id
* The unique identifier for this domain, taken from {domain}.
*
* @ingroup theme
*/
function domain_theme_page($domain_id) {
global $_domain;
$domain = domain_lookup($domain_id);
if ($domain['domain_id']) {
// Ensure we are on the proper domain.
domain_goto($domain);
drupal_set_title(t('!site : Domain theme settings', array('!site' => $domain['sitename'])));
include_once('domain_theme_form.inc');
return drupal_get_form('system_themes');
}
else {
return t('Invalid domain request.');
}
}
/**
* Get domain theme information
*
* @param $domain_id
* The domain_id taken from {domain}. Optional.
* @param $theme
* The string representation of a {domain_theme} entry. Optional.
* @return
* An array containing the requested row from the {domain_theme} table.
* Returns -1 on failure.
*
* @ingroup theme
*/
function domain_theme_lookup($domain_id = NULL, $theme = NULL) {
if (!is_null($domain_id)) {
$return = db_fetch_array(db_query("SELECT domain_id, theme, settings FROM {domain_theme} WHERE domain_id = %d", $domain_id));
}
else if (!is_null($theme)) {
$return = db_fetch_array(db_query("SELECT domain_id, theme, settings FROM {domain_theme} WHERE theme= '%s'", $theme));
}
else {
$return = -1;
}
return $return;
}
/**
* Implements hook_domainlinks()
*
* @ingroup theme
*/
function domain_theme_domainlinks($domain) {
$links[] = array(
'title' => t('theme'),
'path' => 'admin/build/domain/theme/'. $domain['domain_id']
);
return $links;
}
\ No newline at end of file
<?php
// $Id$
/**
* @file
* Include file to handle theme configration screen
*/
/**
* Implements hook_form_alter()
*/
function domain_theme_form_alter($form_id, &$form) {
if ($form_id == 'system_themes') {
// The domain_goto() function assures that we are on the right domain.
global $_domain;
// Get the current $theme for this domain, if available.
$theme = domain_theme_lookup($_domain['domain_id']);
if ($theme['theme']) {
$form['theme_default']['#default_value'] = $theme['theme'];
}
// Unset options that are not allowed.
$available = $form['status']['#options'];
$allowed = $form['status']['#default_value'];
foreach ($available as $key => $value) {
if (!in_array($key, $allowed)) {
// If the theme was disabled, then we have to use the default
if ($key == $theme['theme']) {
$form['theme_default']['#default_value'] = variable_get('theme_default', 'garland');
}
unset($form[$key]);
unset($form['status']['#options'][$key]);
unset($form['theme_default']['#options'][$key]);
}
else {
$form['status']['#disabled'] = TRUE;
}
}
// Use our own submit buttons.
$unset = array('buttons', '#submit',);
foreach ($unset as $key) {
unset($form[$key]);
}
// Message to users.
$form['intro'] = array(
'#value' => t('<p>Select the default theme for this domain. Theme-specific settings must be configured at <a href="!url">the system theme settings page</a>.</p>', array('!url' => url('admin/build/themes'))),
);
// Which domain are we editing?
$form['domain_id'] = array(
'#type' => 'value',
'#value' => $_domain['domain_id'],
);
// Our submit handlers.
$form['#submit']['domain_theme_submit'] = array();
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Set domain theme'),
);
}
}
/**
* FormsAPI submut handler for the theme settings
*/
function domain_theme_submit($form_id, $form_values) {
$theme = $form_values['theme_default'];
$id = $form_values['domain_id'];
$settings = NULL; // This is a placeholder for advanced functions.
$check = domain_theme_lookup($id);
if ($check == -1) {
db_query("INSERT INTO {domain_theme} VALUES (%d, '%s', %b)", $id, $theme, $settings);
}
else {
db_query("UPDATE {domain_theme} SET theme = '%s', settings = %b WHERE domain_id = %d", $theme, $settings, $id);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment