You are here

function phpexcel_settings_form_validate in PHPExcel 8.3

Same name and namespace in other branches
  1. 7.3 phpexcel.module \phpexcel_settings_form_validate()

Validate the settings form.

File

./phpexcel.module, line 148
The module file.

Code

function phpexcel_settings_form_validate($form, $form_state) {
  switch ($form_state['values']['phpexcel_cache_mechanism']) {
    case 'cache_to_phpTemp':
      if (!preg_match('/^[0-9]+$/', $form_state['values']['phpexcel_phptemp_limit'])) {
        form_set_error('phpexcel_phptemp_limit', t("You must provide an integer value. The unit is in megabytes. Defaults to 1 (recommended)."));
      }
      break;
    case 'cache_to_apc':
      if (!preg_match('/^[0-9]+$/', $form_state['values']['phpexcel_apc_cachetime'])) {
        form_set_error('phpexcel_apc_cachetime', t("You must provide an integer value. The unit is in seconds. Defaults to 600 (recommended). Remember that all cells cached in APC will get cleared at the end of the script run."));
      }
      break;
    case 'cache_to_memcache':
      if (empty($form_state['values']['phpexcel_memcache_host'])) {
        form_set_error('phpexcel_memcache_host', t("You must provide a host for Memcache. Defaults to 'localhost'."));
      }
      if (!preg_match('/^[0-9]+$/', $form_state['values']['phpexcel_memcache_port'])) {
        form_set_error('phpexcel_memcache_port', t("You must provide a port for Memcache. Defaults to '11211'."));
      }
      if (!preg_match('/^[0-9]+$/', $form_state['values']['phpexcel_memcache_cachetime'])) {
        form_set_error('phpexcel_memcache_cachetime', t("You must provide an integer value. The unit is in seconds. Defaults to 600 (recommended). Remember that all cells cached in Memcache will get cleared at the end of the script run."));
      }
      break;
  }
}