/** * Entry script to process a form that needs to be emailed. */ function form_to_email_entry_script() { require_lang('mail'); form_to_email(); global $PAGE_NAME_CACHE; $PAGE_NAME_CACHE = '_form_to_email'; $title = get_page_title('MAIL_SENT'); $text = do_lang_tempcode('MAIL_SENT_TEXT', escape_html(post_param('to_written_name', get_site_name()))); $redirect = get_param('redirect', NULL); if (!is_null($redirect)) { require_code('site2'); $GLOBALS['NON_PAGE_SCRIPT'] = 0; $tpl = redirect_screen($title, $redirect, $text); } else { $tpl = do_template('INFORM_SCREEN', array('_GUID' => 'e577a4df79eefd9064c14240cc99e947', 'TITLE' => $title, 'TEXT' => $text)); } $echo = globalise($tpl, NULL, '', true); $echo->evaluate_echo(); }
/** * Standard modular run function. * * @param array A map of parameters. * @return tempcode The result of execution. */ function run($map) { $catalogue_name = array_key_exists('param', $map) ? $map['param'] : ''; if ($catalogue_name == '') { $catalogue_name = $GLOBALS['SITE_DB']->query_value('catalogues', 'c_name'); } // Random/arbitrary (first one that comes out of the DB) $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title')); if (post_param('subject', '') != '') { require_code('mail'); $to_email = array_key_exists('to', $map) ? $map['to'] : ''; if ($to_email == '') { $to_email = NULL; } form_to_email(NULL, '', NULL, $to_email); attach_message(do_lang_tempcode('SUCCESS')); } require_code('form_templates'); $fields = new ocp_tempcode(); $special_fields = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => $catalogue_name), 'ORDER BY cf_order'); $field_groups = array(); $hidden = new ocp_tempcode(); require_code('fields'); foreach ($special_fields as $field_num => $field) { $ob = get_fields_hook($field['cf_type']); $default = $field['cf_default']; $_cf_name = get_translated_text($field['cf_name']); $field_cat = ''; $matches = array(); if (strpos($_cf_name, ': ') !== false) { $field_cat = substr($_cf_name, 0, strpos($_cf_name, ': ')); if ($field_cat . ': ' == $_cf_name) { $_cf_name = $field_cat; // Just been pulled out as heading, nothing after ": " } else { $_cf_name = substr($_cf_name, strpos($_cf_name, ': ') + 2); } } if (!array_key_exists($field_cat, $field_groups)) { $field_groups[$field_cat] = new ocp_tempcode(); } $_cf_description = escape_html(get_translated_text($field['cf_description'])); $GLOBALS['NO_DEBUG_MODE_FULLSTOP_CHECK'] = true; $result = $ob->get_field_inputter($_cf_name, $_cf_description, $field, $default, true, !array_key_exists($field_num + 1, $special_fields)); $GLOBALS['NO_DEBUG_MODE_FULLSTOP_CHECK'] = false; if (is_null($result)) { continue; } if (is_array($result)) { $field_groups[$field_cat]->attach($result[0]); } else { $field_groups[$field_cat]->attach($result); } $hidden->attach(form_input_hidden('label_for__field_' . strval($field['id']), $_cf_name)); unset($result); unset($ob); } if (array_key_exists('', $field_groups)) { $field_groups_blank = $field_groups['']; unset($field_groups['']); $field_groups = array_merge(array($field_groups_blank), $field_groups); } foreach ($field_groups as $field_group_title => $extra_fields) { if (is_integer($field_group_title)) { $field_group_title = $field_group_title == 0 ? '' : strval($field_group_title); } if ($field_group_title != '') { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => $field_group_title))); } $fields->attach($extra_fields); } $hidden->attach(form_input_hidden('subject', $catalogue_title)); $url = get_self_url(); return do_template('FORM', array('FIELDS' => $fields, 'HIDDEN' => $hidden, 'SUBMIT_NAME' => do_lang_tempcode('SEND'), 'URL' => $url, 'TEXT' => '')); }