/** * Returns the body of the mail. * * @param bool $html Whether to return (X)HTML. * * @return string * * @global array The configuration of the core. */ protected function getBody($html) { global $cf; $o = ''; if ($html) { if ($cf['xhtml']['endtags'] == 'true') { $o .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional' . '//EN"' . ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . PHP_EOL . '<html xmlns="http://www.w3.org/1999/xhtml">' . PHP_EOL; } else { $o .= '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional' . '//EN"' . ' "http://www.w3.org/TR/html4/loose.dtd">' . PHP_EOL . '<html>' . PHP_EOL; } $o .= '<head>' . PHP_EOL . '<style type="text/css">' . PHP_EOL; $o .= $this->getMailCSS($this->pluginFolder . 'css/stylesheet.css'); $fn = Data::folder() . 'css/' . $this->form->getName() . '.css'; if (file_exists($fn)) { $o .= $this->getMailCSS($fn); } $o .= '</style>' . PHP_EOL . '</head>' . PHP_EOL . '<body>' . PHP_EOL; } $view = MailView::make($this->form, !$this->isConfirmation, $html); $o .= $view->render(); if ($html) { $o .= '</body>' . PHP_EOL . '</html>' . PHP_EOL; } return $o; }
/** * Main plugin call. * * @param string $id A form ID. * * @return string (X)HTML. * * @global array The configuration of the plugins. * @global array The localization of the plugins. * @global string The script name. * @global string The (X)HTML fragment containing error messages. * @global array The paths of system files and folders. */ public static function main($id) { global $plugin_cf, $plugin_tx, $sn, $e, $pth; $pcf = $plugin_cf['advancedform']; $ptx = $plugin_tx['advancedform']; $fn = $pth['folder']['plugins'] . $pcf['captcha_plugin'] . '/captcha.php'; if (file_exists($fn)) { include_once $fn; } else { e('cntopen', 'file', $fn); } $hooks = Data::folder() . $id . '.inc' . ($pcf['php_extension'] ? '.php' : ''); if (file_exists($hooks)) { include $hooks; } $form = Data::fetchForm($id); if (!isset($form)) { $e .= '<li>' . sprintf($ptx['error_form_missing'], $id) . '</li>' . PHP_EOL; return ''; } if (isset($_POST['advfrm']) && $_POST['advfrm'] == $id) { $validator = new FormValidator($form); if (($res = $validator->validate()) === true) { if ($form->isStored()) { self::appendCsv($id); } if (!self::mail($form, false)) { return self::formView($form); } if (function_exists('advfrm_custom_thanks_page')) { self::fields($fields); $thanks = advfrm_custom_thanks_page($id, $fields); } if (empty($thanks)) { $thanks = $form->getThanksPage(); } if (!empty($thanks)) { if (!self::mail($form, true)) { return self::formView($form); } header('Location: ' . $sn . '?' . $thanks); // FIXME: exit()? } else { $view = MailView::make($form, false, true); return $view->render(); } } else { return $res . self::formView($form); } } return self::formView($form); }
/** * Initializes a new instance. * * @param Form $form A form. * @param bool $show_hidden Whether to show hidden fields. */ protected function __construct(Form $form, $show_hidden) { parent::__construct($form, $show_hidden); }