本文整理匯總了PHP中Contao\Input::postHtml方法的典型用法代碼示例。如果您正苦於以下問題:PHP Input::postHtml方法的具體用法?PHP Input::postHtml怎麽用?PHP Input::postHtml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Contao\Input
的用法示例。
在下文中一共展示了Input::postHtml方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: processFormData
//.........這裏部分代碼省略.........
/** @var FrontendTemplate|object $objTemplate */
$objTemplate = new \FrontendTemplate('form_xml');
$objTemplate->fields = $fields;
$objTemplate->charset = \Config::get('characterSet');
$email->attachFileFromString($objTemplate->parse(), 'form.xml', 'application/xml');
}
// Attach CSV file
if ($this->format == 'csv') {
$email->attachFileFromString(\StringUtil::decodeEntities('"' . implode('";"', $keys) . '"' . "\n" . '"' . implode('";"', $values) . '"'), 'form.csv', 'text/comma-separated-values');
}
$uploaded = '';
// Attach uploaded files
if (!empty($_SESSION['FILES'])) {
foreach ($_SESSION['FILES'] as $file) {
// Add a link to the uploaded file
if ($file['uploaded']) {
$uploaded .= "\n" . \Environment::get('base') . str_replace(TL_ROOT . '/', '', dirname($file['tmp_name'])) . '/' . rawurlencode($file['name']);
continue;
}
$email->attachFileFromString(file_get_contents($file['tmp_name']), $file['name'], $file['type']);
}
}
$uploaded = strlen(trim($uploaded)) ? "\n\n---\n" . $uploaded : '';
$email->text = \StringUtil::decodeEntities(trim($message)) . $uploaded . "\n\n";
// Send the e-mail
try {
$email->sendTo($recipients);
} catch (\Swift_SwiftException $e) {
$this->log('Form "' . $this->title . '" could not be sent: ' . $e->getMessage(), __METHOD__, TL_ERROR);
}
}
// Store the values in the database
if ($this->storeValues && $this->targetTable != '') {
$arrSet = array();
// Add the timestamp
if ($this->Database->fieldExists('tstamp', $this->targetTable)) {
$arrSet['tstamp'] = time();
}
// Fields
foreach ($arrSubmitted as $k => $v) {
if ($k != 'cc' && $k != 'id') {
$arrSet[$k] = $v;
// Convert date formats into timestamps (see #6827)
if ($arrSet[$k] != '' && in_array($arrFields[$k]->rgxp, array('date', 'time', 'datim'))) {
$objDate = new \Date($arrSet[$k], \Date::getFormatFromRgxp($arrFields[$k]->rgxp));
$arrSet[$k] = $objDate->tstamp;
}
}
}
// Files
if (!empty($_SESSION['FILES'])) {
foreach ($_SESSION['FILES'] as $k => $v) {
if ($v['uploaded']) {
$arrSet[$k] = str_replace(TL_ROOT . '/', '', $v['tmp_name']);
}
}
}
// HOOK: store form data callback
if (isset($GLOBALS['TL_HOOKS']['storeFormData']) && is_array($GLOBALS['TL_HOOKS']['storeFormData'])) {
foreach ($GLOBALS['TL_HOOKS']['storeFormData'] as $callback) {
$this->import($callback[0]);
$arrSet = $this->{$callback[0]}->{$callback[1]}($arrSet, $this);
}
}
// Set the correct empty value (see #6284, #6373)
foreach ($arrSet as $k => $v) {
if ($v === '') {
$arrSet[$k] = \Widget::getEmptyValueByFieldType($GLOBALS['TL_DCA'][$this->targetTable]['fields'][$k]['sql']);
}
}
// Do not use Models here (backwards compatibility)
$this->Database->prepare("INSERT INTO " . $this->targetTable . " %s")->set($arrSet)->execute();
}
// Store all values in the session
foreach (array_keys($_POST) as $key) {
$_SESSION['FORM_DATA'][$key] = $this->allowTags ? \Input::postHtml($key, true) : \Input::post($key, true);
}
$arrFiles = $_SESSION['FILES'];
// HOOK: process form data callback
if (isset($GLOBALS['TL_HOOKS']['processFormData']) && is_array($GLOBALS['TL_HOOKS']['processFormData'])) {
foreach ($GLOBALS['TL_HOOKS']['processFormData'] as $callback) {
$this->import($callback[0]);
$this->{$callback[0]}->{$callback[1]}($arrSubmitted, $this->arrData, $arrFiles, $arrLabels, $this);
}
}
$_SESSION['FILES'] = array();
// DO NOT CHANGE
// Add a log entry
if (FE_USER_LOGGED_IN) {
$this->import('FrontendUser', 'User');
$this->log('Form "' . $this->title . '" has been submitted by "' . $this->User->username . '".', __METHOD__, TL_FORMS);
} else {
$this->log('Form "' . $this->title . '" has been submitted by ' . \System::anonymizeIp(\Environment::get('ip')) . '.', __METHOD__, TL_FORMS);
}
// Check whether there is a jumpTo page
if (($objJumpTo = $this->objModel->getRelated('jumpTo')) instanceof PageModel) {
$this->jumpToOrReload($objJumpTo->row());
}
$this->reload();
}