summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurits Lawende2012-12-06 15:44:29 (GMT)
committer Maurits Lawende2012-12-06 15:44:29 (GMT)
commit32a0936cccdfec6c76ed935974c6e44e7f08242e (patch)
tree809a1662ac816edc8186f1d173c72c3ddb37ac75
parent95def435e9cac01cc02c14d27a4618e1527682dd (diff)
Add configuration option to choose domain on 'add domain' action
-rw-r--r--domain/hansel_domain.install9
-rw-r--r--domain/hansel_domain.module54
2 files changed, 59 insertions, 4 deletions
diff --git a/domain/hansel_domain.install b/domain/hansel_domain.install
new file mode 100644
index 0000000..1b64b0b
--- /dev/null
+++ b/domain/hansel_domain.install
@@ -0,0 +1,9 @@
+<?php
+
+/**
+ * Rename "add domain" to "add current domain"
+ * Enter description here ...
+ */
+function hansel_domain_update_7100() {
+
+} \ No newline at end of file
diff --git a/domain/hansel_domain.module b/domain/hansel_domain.module
index 5ca03bd..9decb0b 100644
--- a/domain/hansel_domain.module
+++ b/domain/hansel_domain.module
@@ -14,6 +14,7 @@ function hansel_domain_hansel_action_types() {
'add domain' => array(
'get crumbs' => 'hansel_domain_action_add_domain_get_crumbs',
'info' => 'hansel_domain_action_add_domain_info',
+ 'config form' => 'hansel_domain_action_add_domain_config_form',
),
);
}
@@ -31,11 +32,19 @@ function hansel_domain_action_add_domain_get_crumbs($arguments) {
// This happens only if the domain module is not installed correctly
return array();
}
-
+ $domain_id = isset($arguments['domain_id']) ? $arguments['domain_id'] : 0;
+ if ($domain_id == 0 || $domain_id == $_domain['domain_id']) {
+ $domain = $_domain;
+ }
+ else {
+ if (!$domain = domain_load($domain_id)) {
+ return array();
+ }
+ }
return array(
array(
- 'title' => $_domain['sitename'],
- 'href' => $_domain['path'],
+ 'title' => $domain['sitename'],
+ 'href' => $domain['path'],
)
);
}
@@ -47,7 +56,44 @@ function hansel_domain_action_add_domain_get_crumbs($arguments) {
* @return string
*/
function hansel_domain_action_add_domain_info($arguments) {
- return t('Add domain');
+ if (empty($arguments['domain_id'])) {
+ return t('Add current domain');
+ }
+ elseif ($domain = domain_load($arguments['domain_id'])) {
+ return t('Add domain %name', array('%name' => $domain['sitename']));
+ }
+ else {
+ return t('Add domain (broken)');
+ }
+}
+
+/**
+ * Callback for "add domain" action to generate the config form.
+ *
+ * @param array $arguments
+ * @return array
+ */
+function hansel_domain_action_add_domain_config_form($arguments) {
+ $form = array();
+
+ $options = array(0 => t('Current domain'));
+ $domains = db_select('domain', 'd')
+ ->fields('d', array('domain_id', 'sitename'))
+ ->orderBy('d.is_default', 'desc')
+ ->orderBy('d.sitename', 'asc')
+ ->execute()
+ ->fetchAllKeyed();
+ foreach ($domains as $domain_id => $sitename) {
+ $options[$domain_id] = $sitename;
+ }
+ $form['domain_id'] = array(
+ '#type' => 'select',
+ '#title' => t('Domain'),
+ '#options' => $options,
+ '#default_value' => empty($arguments['domain_id']) ? 0 : $arguments['domain_id'],
+ );
+
+ return $form;
}
/**