diff --git a/includes/config.inc b/includes/config.inc
index dd6b4df..cb538d7 100644
--- a/includes/config.inc
+++ b/includes/config.inc
@@ -72,45 +72,6 @@ function kalatheme_bootstrap_library_form() {
return $form;
}
-/**
- * Form constructor for Bootstrap library selection form
- *
- * @return array
- */
-function kalatheme_backend_check_form() {
- $form = array();
-
- if (isset($_SERVER['PANTHEON_ENVIRONMENT'])) {
- $form['pantheon_check'] = array(
- '#weight' => -100,
- '#prefix' => '
',
- '#markup' => t("You are on Pantheon. You need to set the connection mode to SFTP to allow for custom Bootstrap libraries and subtheme generation!"),
- '#suffix' => '
',
- );
- }
- else {
- if (kalatheme_backend_check()) {
- $form['backend_check'] = array(
- '#weight' => -100,
- '#prefix' => '',
- '#markup' => t("Your webserver is correctly configured to allow for custom Bootstrap libraries and subtheme generation!"),
- '#suffix' => '
',
- );
- }
- else {
- $form['backend_check'] = array(
- '#weight' => -100,
- '#prefix' => '',
- '#markup' => t("If you want Kalatheme to be able to use custom Bootstrap libraries or generate subthemes automatically please properly configure your webserver."),
- // @todo add link to docs here
- '#suffix' => '
',
- );
- }
- }
-
- return $form;
-}
-
/**
* Form constructor for subtheme selection form
*
diff --git a/includes/utils.inc b/includes/utils.inc
index f340992..2887ee2 100644
--- a/includes/utils.inc
+++ b/includes/utils.inc
@@ -316,22 +316,97 @@ function kalatheme_use_libraries() {
* True if all good, message if no good
*/
function kalatheme_backend_check() {
- // Verify FTP support
- $ftp_installed = extension_loaded('ftp');
- // Verify SSH support
- $ssh_installed = extension_loaded('ssh2');
- // Verify web server write permissions
- $install_permissions = kalatheme_has_write_access();
- // Verify update module is enabled
- $updates_module = module_exists('update');
+ $info = kalatheme_backend_check_info();
+ $messages = drupal_get_messages(NULL, FALSE);
- return (($ftp_installed || $ssh_installed || $install_permissions) && $updates_module);
+ // Output messages for each of the checks.
+ foreach ($info as $type => $check) {
+ if (isset($check['messages']) && !empty($check['messages'])) {
+ $bool = $check['bool'];
+ if (isset($check['messages'][$bool])) {
+ $message = $check['messages'][$bool];
+ $status = $check['bool'] ? 'status' : 'error';
+ $status = $type == 'pantheon' ? 'warning' : $status;
+
+ // Make sure we don't set a message twice.
+ $already_set = FALSE;
+ if (isset($messages[$status])) {
+ foreach ($messages[$status] as $existing) {
+ if ($existing == $message) {
+ $already_set = TRUE;
+ break;
+ }
+ }
+ }
+
+ if (!$already_set) {
+ drupal_set_message($message, $status);
+ }
+ }
+ }
+ }
+
+ return ($info['install_permissions']['bool'] && $info['updates_module']['bool']);
+}
+
+/**
+ * Store and return info about backend features that we might need for Kalatheme
+ * to work properly.
+ */
+function kalatheme_backend_check_info(){
+ $info = array(
+ // Check if we're on Pantheon.
+ 'pantheon' => array(
+ 'bool' => isset($_SERVER['PANTHEON_ENVIRONMENT']),
+ 'messages' => array(
+ TRUE => t('You are on Pantheon. !strong_openYou need to set the connection mode to SFTP!strong_close to allow for custom Bootstrap libraries and subtheme generation!', array('!strong_open' => '', '!strong_close' => '')),
+ ),
+ ),
+ // Verify FTP support
+ 'ftp' => array(
+ 'bool' => extension_loaded('ftp'),
+ 'messages' => array(),
+ ),
+ // Verify SSH support
+ 'ssh' => array(
+ 'bool' => extension_loaded('ssh2'),
+ 'messages' => array(),
+ ),
+ // Verify web server write permissions
+ 'write_access' => array(
+ 'bool' => kalatheme_has_write_access(),
+ 'messages' => array(
+ FALSE => t('Your webserver permissions are not configured correctly to facilitate subtheme generation. See !the_wiki for help.', array('!the_wiki' => l('the wiki', 'https://github.com/drupalprojects/kalatheme/wiki/Configuring-Server-for-Automatic-Kalatheme-installation'))),
+ ),
+ ),
+ // Verify update module is enabled
+ 'updates_module' => array(
+ 'bool' => module_exists('update'),
+ 'messages' => array(
+ FALSE => t('The Updates module needs be enabled for subtheme generation. Please visit the !modules_page to enable it.', array('!modules_page' => l('modules page', 'admin/modules'))),
+ ),
+ ),
+ );
+
+ $info['install_permissions'] = array('bool' => TRUE);
+ if (!isset($_SERVER['PANTHEON_ENVIRONMENT'])) {
+ // This one is a conglomerate of some of the others.
+ $info['install_permissions'] = array(
+ 'bool' => $info['ftp']['bool'] || $info['ssh']['bool'] || $info['write_access']['bool'],
+ 'messages' => array(
+ TRUE => t('Your webserver is correctly configured to allow for custom Bootstrap libraries and subtheme generation!'),
+ FALSE => t('Kalatheme needs FTP, SSH or write access in order to generate a subtheme.'),
+ ),
+ );
+ }
+
+ return $info;
}
/**
* Check whether Kalatheme has write access to libraries and modules directories.
*
- * This check indicates whether we have enough access to be able to use
+ * This check indicates whether we have enough access to be able to use
* authorize.php and the updater.
*
* @return boolean
diff --git a/theme-settings.php b/theme-settings.php
index 66559ea..ec45dbf 100644
--- a/theme-settings.php
+++ b/theme-settings.php
@@ -32,7 +32,7 @@ function kalatheme_form_system_theme_settings_alter(&$form, &$form_state) {
}
// Subtheme backend checks
- $form = array_merge($form, kalatheme_backend_check_form());
+ kalatheme_backend_check();
// Kalatheme settings
$form = array_merge($form, kalatheme_bootstrap_library_form());