You are here

function pdf_using_mpdf_config_validate in PDF using mPDF 7.2

Same name and namespace in other branches
  1. 7 pdf_using_mpdf.admin.inc \pdf_using_mpdf_config_validate()

Configuration form Validation check.

File

./pdf_using_mpdf.admin.inc, line 302
Contains the administrative functions of the PDF conversion module.

Code

function pdf_using_mpdf_config_validate($form, $form_state) {

  // Checking mPDF library existence.
  if (pdf_using_mpdf_library_exist() == TRUE) {
    if (isset($form_state['values']['remove_pwd'])) {
      if ($form_state['values']['remove_pwd'] == '1') {
        variable_set('pdf_using_mpdf_pdf_password', NULL);
      }
    }
    if (!(is_numeric($form_state['values']['pdf_using_mpdf_pdf_font_size']) && $form_state['values']['pdf_using_mpdf_pdf_font_size'] > 1)) {
      form_set_error('font_size', t('Font size should be numeric and greater than 1.'));
    }
    if (!(is_numeric($form_state['values']['pdf_using_mpdf_margin_top']) && $form_state['values']['pdf_using_mpdf_margin_top'] >= 0)) {
      form_set_error('pdf_using_mpdf_margin_top', t('PDF top margin should be numeric and greater than -1.'));
    }
    if (!(is_numeric($form_state['values']['pdf_using_mpdf_margin_right']) && $form_state['values']['pdf_using_mpdf_margin_right'] >= 0)) {
      form_set_error('pdf_using_mpdf_margin_right', t('PDF right margin should be numeric and greater than -1.'));
    }
    if (!(is_numeric($form_state['values']['pdf_using_mpdf_margin_bottom']) && $form_state['values']['pdf_using_mpdf_margin_bottom'] >= 0)) {
      form_set_error('pdf_using_mpdf_margin_bottom', t('PDF bottom margin should be numeric and greater than -1.'));
    }
    if (!(is_numeric($form_state['values']['pdf_using_mpdf_margin_left']) && $form_state['values']['pdf_using_mpdf_margin_left'] >= 0)) {
      form_set_error('pdf_using_mpdf_margin_left', t('PDF left margin should be numeric and greater than -1.'));
    }
    if (!(is_numeric($form_state['values']['pdf_using_mpdf_margin_header']) && $form_state['values']['pdf_using_mpdf_margin_header'] >= 0)) {
      form_set_error('pdf_using_mpdf_margin_header', t('PDF header margin should be numeric and greater than -1.'));
    }
    if (!(is_numeric($form_state['values']['pdf_using_mpdf_margin_footer']) && $form_state['values']['pdf_using_mpdf_margin_footer'] >= 0)) {
      form_set_error('pdf_using_mpdf_margin_footer', t('PDF footer margin should be numeric and greater than -1.'));
    }
    if (!(is_numeric($form_state['values']['pdf_using_mpdf_dpi']) && $form_state['values']['pdf_using_mpdf_dpi'] > 0)) {
      form_set_error('pdf_using_mpdf_dpi', t('Document DPI should be numeric and greater than 0.'));
    }
    if (!(is_numeric($form_state['values']['pdf_using_mpdf_img_dpi']) && $form_state['values']['pdf_using_mpdf_img_dpi'] > 0)) {
      form_set_error('pdf_using_mpdf_img_dpi', t('Image DPI should be numeric and greater than 0.'));
    }
  }
}