| 1 |
<?php |
<?php |
| 2 |
// $Id$ |
// $Id: awesome_install.module,v 1.1 2008/03/05 21:15:51 cwgordon7 Exp $ |
| 3 |
|
|
| 4 |
define('AWESOME_INSTALL_SETTINGS', 0); |
define('AWESOME_INSTALL_SETTINGS', 0); |
| 5 |
define('AWESOME_INSTALL_BLOCKS', 1); |
define('AWESOME_INSTALL_BLOCKS', 1); |
| 10 |
* Implementation of hook_form_alter(). |
* Implementation of hook_form_alter(). |
| 11 |
*/ |
*/ |
| 12 |
function awesome_install_form_alter(&$form, $form_state, $form_id) { |
function awesome_install_form_alter(&$form, $form_state, $form_id) { |
| 13 |
|
//drupal_set_message(print_r($form_state, TRUE)); |
| 14 |
if ($form_id == 'system_modules') { |
if ($form_id == 'system_modules') { |
| 15 |
if (isset($form_state['storage']['form'])) { |
if (isset($form_state['storage']['form'])) { |
| 16 |
$form = $form_state['storage']['form']; |
$form = $form_state['storage']['form']; |
| 39 |
} |
} |
| 40 |
$form_state['storage']['modsleft'] = $status; |
$form_state['storage']['modsleft'] = $status; |
| 41 |
} |
} |
|
$continue = TRUE; |
|
|
// Stop various settings forms from redirecting. |
|
| 42 |
$form_state['redirect'] = FALSE; |
$form_state['redirect'] = FALSE; |
| 43 |
|
$continue = TRUE; |
| 44 |
while ($continue) { |
while ($continue) { |
| 45 |
$continue = FALSE; |
$continue = FALSE; |
| 46 |
$module = first($form_state['storage']['modsleft']); |
$module = reset($form_state['storage']['modsleft']); |
| 47 |
if (!$module) { |
if (!$module) { |
| 48 |
unset($form_state['storage']); |
unset($form_state['storage']['form']); |
| 49 |
return; |
return; |
| 50 |
} |
} |
| 51 |
if (empty($form_state['storage']['install_step'])) { |
if (empty($form_state['storage']['install_step'])) { |
| 52 |
$form_state['storage']['install_step'] = AWESOME_INSTALL_SETTINGS; |
$form_state['storage']['install_step'] = AWESOME_INSTALL_SETTINGS; |
| 53 |
} |
} |
| 54 |
$form_state['storage']['install_step']++; |
$modulepath = db_result(db_query("SELECT filename FROM {system} WHERE name = '%s' AND type = 'module'", $module)); |
| 55 |
// This is basically the next step. We prepare for it, or we skip it. |
// This is basically the next step. We prepare for it, or we skip it. |
| 56 |
switch ($form_state['storage']['install_step']) { |
switch ($form_state['storage']['install_step']) { |
| 57 |
case AWESOME_INSTALL_SETTINGS: |
case AWESOME_INSTALL_SETTINGS: |
| 58 |
|
$form_state['storage']['install_step']++; |
| 59 |
$form = awesome_install_find_settings_form($module); |
$form = awesome_install_find_settings_form($module); |
| 60 |
if (!empty($form)) { |
if (!empty($form)) { |
| 61 |
// $form_state['storage']['form'] = drupal_retrieve_form($form, NULL); |
$null = array('storage' => NULL, 'submitted' => FALSE, 'post' => array()); |
| 62 |
// $form_state['storage']['title'] = t('Configure @module', array('@module' => $module)); |
$form_state['storage']['form'] = drupal_retrieve_form($form, $null); |
| 63 |
|
$form_state['storage']['title'] = t('Configure @module', array('@module' => $module)); |
| 64 |
break; |
break; |
| 65 |
} |
} |
| 66 |
|
|
| 67 |
case AWESOME_INSTALL_BLOCKS: |
case AWESOME_INSTALL_BLOCKS: |
| 68 |
|
$form_state['storage']['install_step']++; |
| 69 |
if (module_hook($module, 'block')) { |
if (module_hook($module, 'block')) { |
| 70 |
// @TODO: Do stuff here. |
// @TODO: Do stuff here. |
| 71 |
break; |
break; |
| 72 |
} |
} |
| 73 |
|
|
| 74 |
case AWESOME_INSTALL_PERMS: |
case AWESOME_INSTALL_PERMS: |
| 75 |
|
$form_state['storage']['install_step']++; |
| 76 |
if (module_hook($module, 'perm')) { |
if (module_hook($module, 'perm')) { |
| 77 |
// @TODO: Do stuff here. |
// @TODO: Do stuff here. |
| 78 |
break; |
break; |
| 79 |
} |
} |
| 80 |
|
|
| 81 |
case AWESOME_INSTALL_FINAL: |
case AWESOME_INSTALL_FINAL: |
| 82 |
drupal_set_message(t('Install process for @module completed successfully.', array('@module' => $module)); |
drupal_set_message(t('Install process for @module completed successfully.', array('@module' => $module))); |
| 83 |
foreach ($form_state['storage']['modsleft'] as $key => $mod) { |
foreach ($form_state['storage']['modsleft'] as $key => $mod) { |
| 84 |
if ($mod == $module) { |
if ($mod == $module) { |
| 85 |
unset($form_state['storage']['modsleft'][$key]); |
unset($form_state['storage']['modsleft'][$key]); |
| 98 |
if (strpos($callback, 'admin/') === 0) { |
if (strpos($callback, 'admin/') === 0) { |
| 99 |
if ($item['page callback'] == 'drupal_get_form') { |
if ($item['page callback'] == 'drupal_get_form') { |
| 100 |
// @TODO: More than one config form? |
// @TODO: More than one config form? |
| 101 |
return first($item['page arguments']); |
$filepath = !empty($item['file path']) ? $item['file path'] : drupal_get_path('module', $module); |
| 102 |
|
require_once $filepath .'/'. $item['file']; |
| 103 |
|
return reset($item['page arguments']); |
| 104 |
} |
} |
| 105 |
} |
} |
| 106 |
} |
} |