当安装程序检查自己的状态,它发现当前任务仍然是philosopherbios_pick_theme,因此它将再次调用philosopherbios_profile_tasks() 函数,这一次 $task 的值为philosopherbios_pick_theme。
让我们回到 profile 任务函数,看一看第二条 if 语句:
/** * Walk through final installation tasks */ function philosopherbios_profile_tasks(&$task, $url) { if ($task == 'profile') { // ... Other stuff.... // Do the form: $task = 'philosopherbios_pick_theme'; $form = drupal_get_form('philosopherbios_theme_form', $url); return $form; } if ($task == 'philosopherbios_pick_theme') { $form = drupal_get_form('philosopherbios_theme_form', $url); // See if the form was processed: if (variable_get('philosopherbios_theme', false)) { variable_del('philosopherbios_theme'); $task = 'profile-finished'; } else { return $form; // try again. } } }
这个代码片段省略了一些我们前面看过的代码。我们感兴趣的主要代码用高亮显示出来。这就是当 $task 变量被设置为 philosopherbios_pick_theme 时将要执行的条件语句。
第一行取出表单。不过这一次,它将遇到表单提交处理函数。在继续之前,我们先看看那个函数。