本文整理汇总了PHP中StringUtil::decodeEntities方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::decodeEntities方法的具体用法?PHP StringUtil::decodeEntities怎么用?PHP StringUtil::decodeEntities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtil
的用法示例。
在下文中一共展示了StringUtil::decodeEntities方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compile
/**
* Generate the module
*/
protected function compile()
{
$this->Template->src = $this->singleSRC;
$this->Template->href = $this->source == 'external' ? $this->url : $this->singleSRC;
$this->Template->alt = $this->altContent;
$this->Template->var = 'swf' . $this->id;
$this->Template->transparent = $this->transparent ? true : false;
$this->Template->interactive = $this->interactive ? true : false;
$this->Template->flashId = $this->flashID ?: 'swf_' . $this->id;
$this->Template->fsCommand = ' ' . preg_replace('/[\\n\\r]/', "\n ", \StringUtil::decodeEntities($this->flashJS));
$this->Template->flashvars = 'URL=' . \Environment::get('base');
$this->Template->version = $this->version ?: '6.0.0';
$size = \StringUtil::deserialize($this->size);
$this->Template->width = $size[0];
$this->Template->height = $size[1];
$intMaxWidth = TL_MODE == 'BE' ? 320 : \Config::get('maxImageWidth');
// Adjust movie size
if ($intMaxWidth > 0 && $size[0] > $intMaxWidth) {
$this->Template->width = $intMaxWidth;
$this->Template->height = floor($intMaxWidth * $size[1] / $size[0]);
}
if (strlen($this->flashvars)) {
$this->Template->flashvars .= '&' . \StringUtil::decodeEntities($this->flashvars);
}
}
示例2: get
/**
* Get a translation of a value using the translation label
*
* @param mixed $varLabel
* @param string $strLanguage
*
* @return mixed
*/
public static function get($varLabel, $strLanguage = null)
{
if (!\Database::getInstance()->tableExists(Label::getTable())) {
return $varLabel;
}
if (null === $strLanguage) {
$strLanguage = $GLOBALS['TL_LANGUAGE'];
}
// Convert Language Tag to Locale ID
$strLanguage = str_replace('-', '_', $strLanguage);
// Recursively translate label array
if (is_array($varLabel)) {
foreach ($varLabel as $k => $v) {
$varLabel[$k] = static::get($v, $strLanguage);
}
return $varLabel;
}
// Load labels
static::initialize($strLanguage);
if (isset(static::$arrLabels[$strLanguage][$varLabel])) {
static::$arrLabels[$strLanguage][$varLabel] = \StringUtil::decodeEntities(static::$arrLabels[$strLanguage][$varLabel]);
return static::$arrLabels[$strLanguage][$varLabel];
}
return $varLabel;
}
示例3: recursiveReplaceTokensAndTags
/**
* Recursively replace simple tokens and insert tags
*
* @param string $strText
* @param array $arrTokens Array of Tokens
* @param int $intTextFlags Filters the tokens and the text for a given set of options
*
* @return string
*/
public static function recursiveReplaceTokensAndTags($strText, $arrTokens, $intTextFlags = 0)
{
if ($intTextFlags > 0) {
$arrTokens = static::convertToText($arrTokens, $intTextFlags);
}
// PHP 7 compatibility
// See #309 (https://github.com/contao/core-bundle/issues/309)
if (version_compare(VERSION . '.' . BUILD, '3.5.1', '>=')) {
// Must decode, tokens could be encoded
$strText = \StringUtil::decodeEntities($strText);
} else {
// Must decode, tokens could be encoded
$strText = \String::decodeEntities($strText);
}
// Replace all opening and closing tags with a hash so they don't get stripped
// by parseSimpleTokens() - this is useful e.g. for XML content
$strHash = md5($strText);
$strTagOpenReplacement = 'HASTE-TAG-OPEN-' . $strHash;
$strTagCloseReplacement = 'HASTE-TAG-CLOSE-' . $strHash;
$arrOriginal = array('<', '>');
$arrReplacement = array($strTagOpenReplacement, $strTagCloseReplacement);
$strBuffer = str_replace($arrOriginal, $arrReplacement, $strText);
// PHP 7 compatibility
// See #309 (https://github.com/contao/core-bundle/issues/309)
if (version_compare(VERSION . '.' . BUILD, '3.5.1', '>=')) {
// first parse the tokens as they might have if-else clauses
$strBuffer = \StringUtil::parseSimpleTokens($strBuffer, $arrTokens);
} else {
// first parse the tokens as they might have if-else clauses
$strBuffer = \String::parseSimpleTokens($strBuffer, $arrTokens);
}
$strBuffer = str_replace($arrReplacement, $arrOriginal, $strBuffer);
// then replace the insert tags
$strBuffer = \Controller::replaceInsertTags($strBuffer, false);
// check if the inserttags have returned a simple token or an insert tag to parse
if ((strpos($strBuffer, '##') !== false || strpos($strBuffer, '{{') !== false) && $strBuffer != $strText) {
$strBuffer = static::recursiveReplaceTokensAndTags($strBuffer, $arrTokens, $intTextFlags);
}
// PHP 7 compatibility
// See #309 (https://github.com/contao/core-bundle/issues/309)
if (version_compare(VERSION . '.' . BUILD, '3.5.1', '>=')) {
$strBuffer = \StringUtil::restoreBasicEntities($strBuffer);
} else {
$strBuffer = \String::restoreBasicEntities($strBuffer);
}
if ($intTextFlags > 0) {
$strBuffer = static::convertToText($strBuffer, $intTextFlags);
}
return $strBuffer;
}
示例4: getFieldMappingDbValue
protected function getFieldMappingDbValue($arrSourceConfig, $arrTargetConfig, $strForeignKey = '')
{
$t = $this->dbSourceTable;
$strValue = $arrSourceConfig['name'];
switch ($arrSourceConfig['type']) {
case 'timestamp':
if ($arrTargetConfig['type'] == 'int') {
$strValue = "UNIX_TIMESTAMP({$t}.{$strValue})";
}
break;
default:
$strValue = $this->dbSourceTable . '.' . $strValue;
}
if ($strForeignKey != '' && preg_match('#(?<PK>.*)=(?<TABLE>.*)[.](?<COLUMN>.*)#', \StringUtil::decodeEntities($strForeignKey), $arrForeignKey)) {
if (isset($arrForeignKey['PK']) && $arrForeignKey['TABLE'] && $arrForeignKey['COLUMN']) {
$strValue = sprintf("(SELECT %s FROM %s WHERE %s=%s)", $arrForeignKey['COLUMN'], $arrForeignKey['TABLE'], $arrForeignKey['PK'], $strValue);
}
}
return $strValue;
}
示例5: generate
/**
* Should only return the field value
* @return string
*/
public function generate()
{
$arrData = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strName];
$value = FormSubmission::prepareSpecialValueForPrint($this->varValue, $arrData, $this->strTable, $this, $this->activeRecord);
switch ($this->type) {
case 'multifileupload':
if ($this->fieldType == 'checkbox') {
$value = '<ul class="download-list">' . implode('', array_map(function ($val) {
return '<li>{{download::' . str_replace(\Environment::get('url') . '/', '', $val) . '}}</li>';
}, explode(', ', $value))) . '</ul>';
break;
}
$value = '{{download::' . str_replace(\Environment::get('url') . '/', '', $value) . '}}';
break;
}
$value = class_exists('Contao\\StringUtil') ? \StringUtil::decodeEntities(\Controller::replaceInsertTags($value)) : \String::decodeEntities(\Controller::replaceInsertTags($value));
if (!$value) {
$value = '-';
}
return $value;
}
示例6: loadDynamicPaletteByParentTable
public static function loadDynamicPaletteByParentTable($strAct, $strTable, &$dc)
{
switch ($strAct) {
case 'create':
$strParentTable = FieldPalette::getParentTableFromRequest();
$strPalette = FieldPalette::getPaletteFromRequest();
break;
case 'cut':
case 'edit':
case 'show':
case 'delete':
case 'toggle':
$id = strlen(\Input::get('id')) ? \Input::get('id') : CURRENT_ID;
$objModel = \HeimrichHannot\FieldPalette\FieldPaletteModel::findByPk($id);
if ($objModel === null) {
break;
}
$strParentTable = FieldPalette::getParentTable($objModel, $objModel->id);
$strPalette = $objModel->pfield;
// set back link from request
if (\Input::get('popup') && \Input::get('popupReferer')) {
$arrSession = \Session::getInstance()->getData();
if (class_exists('\\Contao\\StringUtil')) {
$arrSession['popupReferer'][TL_REFERER_ID]['current'] = \StringUtil::decodeEntities(rawurldecode(\Input::get('popupReferer')));
} else {
$arrSession['popupReferer'][TL_REFERER_ID]['current'] = \String::decodeEntities(rawurldecode(\Input::get('popupReferer')));
}
\Session::getInstance()->setData($arrSession);
}
break;
}
if (!$strParentTable || !$strPalette) {
return false;
}
if ($strTable !== $strParentTable) {
\Controller::loadDataContainer($strParentTable);
}
static::registerFieldPalette($dc, $strParentTable, $strTable, $strPalette);
}
示例7: processFormData
/**
* Process form data, store it in the session and redirect to the jumpTo page
*
* @param array $arrSubmitted
* @param array $arrLabels
* @param array $arrFields
*/
protected function processFormData($arrSubmitted, $arrLabels, $arrFields)
{
// HOOK: prepare form data callback
if (isset($GLOBALS['TL_HOOKS']['prepareFormData']) && is_array($GLOBALS['TL_HOOKS']['prepareFormData'])) {
foreach ($GLOBALS['TL_HOOKS']['prepareFormData'] as $callback) {
$this->import($callback[0]);
$this->{$callback}[0]->{$callback}[1]($arrSubmitted, $arrLabels, $arrFields, $this);
}
}
// Send form data via e-mail
if ($this->sendViaEmail) {
$keys = array();
$values = array();
$fields = array();
$message = '';
foreach ($arrSubmitted as $k => $v) {
if ($k == 'cc') {
continue;
}
$v = deserialize($v);
// Skip empty fields
if ($this->skipEmpty && !is_array($v) && !strlen($v)) {
continue;
}
// Add field to message
$message .= (isset($arrLabels[$k]) ? $arrLabels[$k] : ucfirst($k)) . ': ' . (is_array($v) ? implode(', ', $v) : $v) . "\n";
// Prepare XML file
if ($this->format == 'xml') {
$fields[] = array('name' => $k, 'values' => is_array($v) ? $v : array($v));
}
// Prepare CSV file
if ($this->format == 'csv') {
$keys[] = $k;
$values[] = is_array($v) ? implode(',', $v) : $v;
}
}
$recipients = \StringUtil::splitCsv($this->recipient);
// Format recipients
foreach ($recipients as $k => $v) {
$recipients[$k] = str_replace(array('[', ']', '"'), array('<', '>', ''), $v);
}
$email = new \Email();
// Get subject and message
if ($this->format == 'email') {
$message = $arrSubmitted['message'];
$email->subject = $arrSubmitted['subject'];
}
// Set the admin e-mail as "from" address
$email->from = $GLOBALS['TL_ADMIN_EMAIL'];
$email->fromName = $GLOBALS['TL_ADMIN_NAME'];
// Get the "reply to" address
if (strlen(\Input::post('email', true))) {
$replyTo = \Input::post('email', true);
// Add name
if (strlen(\Input::post('name'))) {
$replyTo = '"' . \Input::post('name') . '" <' . $replyTo . '>';
}
$email->replyTo($replyTo);
}
// Fallback to default subject
if (!strlen($email->subject)) {
$email->subject = $this->replaceInsertTags($this->subject, false);
}
// Send copy to sender
if (strlen($arrSubmitted['cc'])) {
$email->sendCc(\Input::post('email', true));
unset($_SESSION['FORM_DATA']['cc']);
}
// Attach XML file
if ($this->format == 'xml') {
/** @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 : '';
//.........这里部分代码省略.........
示例8: renderCommentForm
/**
* Add a form to create new comments
*
* @param \FrontendTemplate|object $objTemplate
* @param \stdClass $objConfig
* @param string $strSource
* @param integer $intParent
* @param mixed $varNotifies
*/
protected function renderCommentForm(\FrontendTemplate $objTemplate, \stdClass $objConfig, $strSource, $intParent, $varNotifies)
{
$this->import('FrontendUser', 'User');
// Access control
if ($objConfig->requireLogin && !BE_USER_LOGGED_IN && !FE_USER_LOGGED_IN) {
$objTemplate->requireLogin = true;
$objTemplate->login = $GLOBALS['TL_LANG']['MSC']['com_login'];
return;
}
// Confirm or remove a subscription
if (\Input::get('token')) {
static::changeSubscriptionStatus($objTemplate);
return;
}
// Form fields
$arrFields = array('name' => array('name' => 'name', 'label' => $GLOBALS['TL_LANG']['MSC']['com_name'], 'value' => trim($this->User->firstname . ' ' . $this->User->lastname), 'inputType' => 'text', 'eval' => array('mandatory' => true, 'maxlength' => 64)), 'email' => array('name' => 'email', 'label' => $GLOBALS['TL_LANG']['MSC']['com_email'], 'value' => $this->User->email, 'inputType' => 'text', 'eval' => array('rgxp' => 'email', 'mandatory' => true, 'maxlength' => 128, 'decodeEntities' => true)), 'website' => array('name' => 'website', 'label' => $GLOBALS['TL_LANG']['MSC']['com_website'], 'inputType' => 'text', 'eval' => array('rgxp' => 'url', 'maxlength' => 128, 'decodeEntities' => true)));
// Captcha
if (!$objConfig->disableCaptcha) {
$arrFields['captcha'] = array('name' => 'captcha', 'inputType' => 'captcha', 'eval' => array('mandatory' => true));
}
// Comment field
$arrFields['comment'] = array('name' => 'comment', 'label' => $GLOBALS['TL_LANG']['MSC']['com_comment'], 'inputType' => 'textarea', 'eval' => array('mandatory' => true, 'rows' => 4, 'cols' => 40, 'preserveTags' => true));
// Notify me of new comments
$arrFields['notify'] = array('name' => 'notify', 'label' => '', 'inputType' => 'checkbox', 'options' => array(1 => $GLOBALS['TL_LANG']['MSC']['com_notify']));
$doNotSubmit = false;
$arrWidgets = array();
$strFormId = 'com_' . $strSource . '_' . $intParent;
// Initialize the widgets
foreach ($arrFields as $arrField) {
/** @var \Widget $strClass */
$strClass = $GLOBALS['TL_FFL'][$arrField['inputType']];
// Continue if the class is not defined
if (!class_exists($strClass)) {
continue;
}
$arrField['eval']['required'] = $arrField['eval']['mandatory'];
/** @var \Widget $objWidget */
$objWidget = new $strClass($strClass::getAttributesFromDca($arrField, $arrField['name'], $arrField['value']));
// Validate the widget
if (\Input::post('FORM_SUBMIT') == $strFormId) {
$objWidget->validate();
if ($objWidget->hasErrors()) {
$doNotSubmit = true;
}
}
$arrWidgets[$arrField['name']] = $objWidget;
}
$objTemplate->fields = $arrWidgets;
$objTemplate->submit = $GLOBALS['TL_LANG']['MSC']['com_submit'];
$objTemplate->action = ampersand(\Environment::get('request'));
$objTemplate->messages = '';
// Backwards compatibility
$objTemplate->formId = $strFormId;
$objTemplate->hasError = $doNotSubmit;
// Do not index or cache the page with the confirmation message
if ($_SESSION['TL_COMMENT_ADDED']) {
/** @var \PageModel $objPage */
global $objPage;
$objPage->noSearch = 1;
$objPage->cache = 0;
$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['com_confirm'];
$_SESSION['TL_COMMENT_ADDED'] = false;
}
// Store the comment
if (!$doNotSubmit && \Input::post('FORM_SUBMIT') == $strFormId) {
$strWebsite = $arrWidgets['website']->value;
// Add http:// to the website
if ($strWebsite != '' && !preg_match('@^(https?://|ftp://|mailto:|#)@i', $strWebsite)) {
$strWebsite = 'http://' . $strWebsite;
}
// Do not parse any tags in the comment
$strComment = specialchars(trim($arrWidgets['comment']->value));
$strComment = str_replace(array('&', '<', '>'), array('[&]', '[lt]', '[gt]'), $strComment);
// Remove multiple line feeds
$strComment = preg_replace('@\\n\\n+@', "\n\n", $strComment);
// Parse BBCode
if ($objConfig->bbcode) {
$strComment = $this->parseBbCode($strComment);
}
// Prevent cross-site request forgeries
$strComment = preg_replace('/(href|src|on[a-z]+)="[^"]*(contao\\/main\\.php|typolight\\/main\\.php|javascript|vbscri?pt|script|alert|document|cookie|window)[^"]*"+/i', '$1="#"', $strComment);
$time = time();
// Prepare the record
$arrSet = array('tstamp' => $time, 'source' => $strSource, 'parent' => $intParent, 'name' => $arrWidgets['name']->value, 'email' => $arrWidgets['email']->value, 'website' => $strWebsite, 'comment' => $this->convertLineFeeds($strComment), 'ip' => $this->anonymizeIp(\Environment::get('ip')), 'date' => $time, 'published' => $objConfig->moderate ? '' : 1);
// Store the comment
$objComment = new \CommentsModel();
$objComment->setRow($arrSet)->save();
// Store the subscription
if ($arrWidgets['notify']->value) {
static::addCommentsSubscription($objComment);
}
//.........这里部分代码省略.........
示例9: doReplace
//.........这里部分代码省略.........
$ua = \Environment::get('agent');
if ($elements[1] != '') {
$arrCache[$strTag] = $ua->{$elements[1]};
} else {
$arrCache[$strTag] = '';
}
break;
// Abbreviations
// Abbreviations
case 'abbr':
case 'acronym':
if ($elements[1] != '') {
$arrCache[$strTag] = '<abbr title="' . $elements[1] . '">';
} else {
$arrCache[$strTag] = '</abbr>';
}
break;
// Images
// Images
case 'image':
case 'picture':
$width = null;
$height = null;
$alt = '';
$class = '';
$rel = '';
$strFile = $elements[1];
$mode = '';
$size = null;
$strTemplate = 'picture_default';
// Take arguments
if (strpos($elements[1], '?') !== false) {
$arrChunks = explode('?', urldecode($elements[1]), 2);
$strSource = \StringUtil::decodeEntities($arrChunks[1]);
$strSource = str_replace('[&]', '&', $strSource);
$arrParams = explode('&', $strSource);
foreach ($arrParams as $strParam) {
list($key, $value) = explode('=', $strParam);
switch ($key) {
case 'width':
$width = $value;
break;
case 'height':
$height = $value;
break;
case 'alt':
$alt = \StringUtil::specialchars($value);
break;
case 'class':
$class = $value;
break;
case 'rel':
$rel = $value;
break;
case 'mode':
$mode = $value;
break;
case 'size':
$size = (int) $value;
break;
case 'template':
$strTemplate = preg_replace('/[^a-z0-9_]/i', '', $value);
break;
}
}
$strFile = $arrChunks[0];
示例10: renderTestimonialForm
/**
* Add a form to create new testimonials
* @param \FrontendTemplate
* @param \stdClass
* @param string
* @param integer
* @param array
*/
protected function renderTestimonialForm(\FrontendTemplate $objTemplate, \stdClass $objConfig, $intParent)
{
$this->import('FrontendUser', 'User');
// Access control
if ($objConfig->requireLogin && !BE_USER_LOGGED_IN && !FE_USER_LOGGED_IN) {
$objTemplate->requireLogin = true;
return;
}
// Form fields
$arrFields = array('name' => array('name' => 'name', 'label' => $GLOBALS['TL_LANG']['MSC']['tm_name'], 'value' => trim($this->User->firstname . ' ' . $this->User->lastname), 'inputType' => 'text', 'eval' => array('mandatory' => true, 'maxlength' => 64, 'placeholder' => $GLOBALS['TL_LANG']['MSC']['tm_name'])), 'email' => array('name' => 'email', 'label' => $GLOBALS['TL_LANG']['MSC']['tm_email'], 'value' => $this->User->email, 'inputType' => 'text', 'eval' => array('rgxp' => 'email', 'mandatory' => true, 'maxlength' => 128, 'decodeEntities' => true, 'placeholder' => $GLOBALS['TL_LANG']['MSC']['tm_email'])), 'url' => array('name' => 'url', 'label' => $GLOBALS['TL_LANG']['MSC']['tm_url'], 'inputType' => 'text', 'eval' => array('rgxp' => 'url', 'maxlength' => 128, 'decodeEntities' => true, 'placeholder' => $GLOBALS['TL_LANG']['MSC']['tm_url'])), 'company' => array('name' => 'company', 'label' => $GLOBALS['TL_LANG']['MSC']['tm_company'], 'inputType' => 'text', 'eval' => array('maxlength' => 128, 'placeholder' => $GLOBALS['TL_LANG']['MSC']['tm_company'])), 'title' => array('name' => 'title', 'label' => $GLOBALS['TL_LANG']['MSC']['tm_title'], 'inputType' => 'text', 'eval' => array('maxlength' => 128, 'placeholder' => $GLOBALS['TL_LANG']['MSC']['tm_title'])));
if ($objConfig->enableVoteField1 && $objConfig->addVote) {
$arrFields['votefield1'] = array('name' => 'votefield1', 'label' => &$GLOBALS['TL_LANG']['MSC']['votefield1'], 'default' => '0.0', 'inputType' => 'text', 'eval' => array('style' => 'display: none;'));
}
if ($objConfig->enableVoteField2 && $objConfig->addVote) {
$arrFields['votefield2'] = array('name' => 'votefield2', 'label' => &$GLOBALS['TL_LANG']['MSC']['votefield2'], 'default' => '0.0', 'inputType' => 'text', 'eval' => array('style' => 'display: none;'));
}
if ($objConfig->enableVoteField3 && $objConfig->addVote) {
$arrFields['votefield3'] = array('name' => 'votefield3', 'label' => &$GLOBALS['TL_LANG']['MSC']['votefield3'], 'default' => '0.0', 'inputType' => 'text', 'eval' => array('style' => 'display: none;'));
}
if ($objConfig->enableVoteField4 && $objConfig->addVote) {
$arrFields['votefield4'] = array('name' => 'votefield4', 'label' => &$GLOBALS['TL_LANG']['MSC']['votefield4'], 'default' => '0.0', 'inputType' => 'text', 'eval' => array('style' => 'display: none;'));
}
if ($objConfig->enableVoteField5 && $objConfig->addVote) {
$arrFields['votefield5'] = array('name' => 'votefield5', 'label' => &$GLOBALS['TL_LANG']['MSC']['votefield5'], 'default' => '0.0', 'inputType' => 'text', 'eval' => array('style' => 'display: none;'));
}
if ($objConfig->enableVoteField6 && $objConfig->addVote) {
$arrFields['votefield6'] = array('name' => 'votefield6', 'label' => &$GLOBALS['TL_LANG']['MSC']['votefield6'], 'default' => '0.0', 'inputType' => 'text', 'eval' => array('style' => 'display: none;'));
}
// Captcha
if (!$objConfig->disableCaptcha) {
$arrFields['captcha'] = array('name' => 'captcha', 'inputType' => 'captcha', 'eval' => array('mandatory' => true));
}
// Testimonial field
$arrFields['testimonial'] = array('name' => 'testimonial', 'label' => $GLOBALS['TL_LANG']['MSC']['tm_testimonial'], 'inputType' => 'textarea', 'eval' => array('mandatory' => true, 'rows' => 15, 'cols' => 40, 'preserveTags' => true));
$doNotSubmit = false;
$arrWidgets = array();
$strFormId = 'jedo_testimonials_' . $intParent;
// Initialize the widgets
foreach ($arrFields as $arrField) {
$strClass = $GLOBALS['TL_FFL'][$arrField['inputType']];
// Continue if the class is not defined
if (!class_exists($strClass)) {
continue;
}
$arrField['eval']['required'] = $arrField['eval']['mandatory'];
$objWidget = new $strClass($this->prepareForWidget($arrField, $arrField['name'], $arrField['value']));
// Validate the widget
if (\Input::post('FORM_SUBMIT') == $strFormId) {
$objWidget->validate();
if ($objWidget->hasErrors()) {
$doNotSubmit = true;
}
}
$arrWidgets[$arrField['name']] = $objWidget;
}
$objTemplate->fields = $arrWidgets;
$objTemplate->submit = $GLOBALS['TL_LANG']['MSC']['com_submit'];
$objTemplate->action = ampersand(\Environment::get('request'));
$objTemplate->messages = '';
// Backwards compatibility
$objTemplate->formId = $strFormId;
$objTemplate->hasError = $doNotSubmit;
// Do not index or cache the page with the confirmation message
if ($_SESSION['TL_TESTIMONIAL_ADDED']) {
global $objPage;
$objPage->noSearch = 1;
$objPage->cache = 0;
$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['com_confirm'];
$_SESSION['TL_TESTIMONIAL_ADDED'] = false;
}
// Store the testimonial
if (!$doNotSubmit && \Input::post('FORM_SUBMIT') == $strFormId) {
$strWebsite = $arrWidgets['url']->value;
if ($strWebsite == $GLOBALS['TL_LANG']['MSC']['tm_url']) {
$strWebsite = '';
}
// Add http:// to the website
if ($strWebsite != '' && !preg_match('@^(https?://|ftp://|mailto:|#)@i', $strWebsite)) {
$strWebsite = 'http://' . $strWebsite;
}
// Do not parse any tags in the testimonial
$strTestimonial = htmlspecialchars(trim($arrWidgets['testimonial']->value));
$strTestimonial = str_replace(array('&', '<', '>'), array('[&]', '[lt]', '[gt]'), $strTestimonial);
// Remove multiple line feeds
$strTestimonial = preg_replace('@\\n\\n+@', "\n\n", $strTestimonial);
// Parse BBCode
if ($objConfig->bbcode) {
$strTestimonial = $this->parseBbCode($strTestimonial);
}
// Prevent cross-site request forgeries
$strTestimonial = preg_replace('/(href|src|on[a-z]+)="[^"]*(contao\\/main\\.php|typolight\\/main\\.php|javascript|vbscri?pt|script|alert|document|cookie|window)[^"]*"+/i', '$1="#"', $strTestimonial);
$time = time();
//.........这里部分代码省略.........
示例11: compileDefinition
/**
* Compile format definitions and return them as string
*
* @param array $row
* @param boolean $blnWriteToFile
* @param array $vars
* @param array $parent
* @param boolean $export
*
* @return string
*/
public function compileDefinition($row, $blnWriteToFile = false, $vars = array(), $parent = array(), $export = false)
{
if ($blnWriteToFile) {
$strGlue = '../../';
$lb = '';
$return = '';
} elseif ($export) {
$strGlue = '';
$lb = "\n ";
$return = '';
} else {
$strGlue = '';
$lb = "\n ";
$return = "\n" . '<pre' . ($row['invisible'] ? ' class="disabled"' : '') . '>';
}
// Comment
if ((!$blnWriteToFile || $export) && $row['comment'] != '') {
$search = array('@^\\s*/\\*+@', '@\\*+/\\s*$@');
$comment = preg_replace($search, '', $row['comment']);
if ($export) {
$return .= "\n/* " . $comment . " */\n";
} else {
$comment = wordwrap(trim($comment), 72);
$return .= "\n" . '<span class="comment">' . $comment . '</span>' . "\n";
}
}
// Selector
$arrSelector = trimsplit(',', \StringUtil::decodeEntities($row['selector']));
$return .= implode($blnWriteToFile ? ',' : ",\n", $arrSelector) . ($blnWriteToFile ? '' : ' ') . '{';
// Size
if ($row['size']) {
// Width
$row['width'] = deserialize($row['width']);
if (isset($row['width']['value']) && $row['width']['value'] != '') {
$return .= $lb . 'width:' . $row['width']['value'] . ($row['width']['value'] == 'auto' ? '' : $row['width']['unit']) . ';';
}
// Height
$row['height'] = deserialize($row['height']);
if (isset($row['height']['value']) && $row['height']['value'] != '') {
$return .= $lb . 'height:' . $row['height']['value'] . ($row['height']['value'] == 'auto' ? '' : $row['height']['unit']) . ';';
}
// Min-width
$row['minwidth'] = deserialize($row['minwidth']);
if (isset($row['minwidth']['value']) && $row['minwidth']['value'] != '') {
$return .= $lb . 'min-width:' . $row['minwidth']['value'] . ($row['minwidth']['value'] == 'inherit' ? '' : $row['minwidth']['unit']) . ';';
}
// Min-height
$row['minheight'] = deserialize($row['minheight']);
if (isset($row['minheight']['value']) && $row['minheight']['value'] != '') {
$return .= $lb . 'min-height:' . $row['minheight']['value'] . ($row['minheight']['value'] == 'inherit' ? '' : $row['minheight']['unit']) . ';';
}
// Max-width
$row['maxwidth'] = deserialize($row['maxwidth']);
if (isset($row['maxwidth']['value']) && $row['maxwidth']['value'] != '') {
$return .= $lb . 'max-width:' . $row['maxwidth']['value'] . ($row['maxwidth']['value'] == 'inherit' || $row['maxwidth']['value'] == 'none' ? '' : $row['maxwidth']['unit']) . ';';
}
// Max-height
$row['maxheight'] = deserialize($row['maxheight']);
if (isset($row['maxheight']['value']) && $row['maxheight']['value'] != '') {
$return .= $lb . 'max-height:' . $row['maxheight']['value'] . ($row['maxheight']['value'] == 'inherit' || $row['maxheight']['value'] == 'none' ? '' : $row['maxheight']['unit']) . ';';
}
}
// Position
if ($row['positioning']) {
// Top/right/bottom/left
$row['trbl'] = deserialize($row['trbl']);
if (is_array($row['trbl'])) {
foreach ($row['trbl'] as $k => $v) {
if ($v != '' && $k != 'unit') {
$return .= $lb . $k . ':' . $v . ($v == 'auto' || $v === '0' ? '' : $row['trbl']['unit']) . ';';
}
}
}
// Position
if ($row['position'] != '') {
$return .= $lb . 'position:' . $row['position'] . ';';
}
// Overflow
if ($row['overflow'] != '') {
$return .= $lb . 'overflow:' . $row['overflow'] . ';';
}
// Float
if ($row['floating'] != '') {
$return .= $lb . 'float:' . $row['floating'] . ';';
}
// Clear
if ($row['clear'] != '') {
$return .= $lb . 'clear:' . $row['clear'] . ';';
}
//.........这里部分代码省略.........
示例12: addCopyrightToTemplate
protected static function addCopyrightToTemplate(&$objTemplate, $objFilesModel, $objModule)
{
$arrCopyright = deserialize($objFilesModel->copyright, true);
$arrList = array();
foreach ($arrCopyright as $strCopyright) {
$strCopyright = \StringUtil::decodeEntities(\String::restoreBasicEntities($strCopyright));
if ($objModule->creditsPrefix != '') {
$strPrefix = \StringUtil::decodeEntities(\String::restoreBasicEntities($objModule->creditsPrefix));
if (!($strPrefix === "" || strrpos($strCopyright, $strPrefix, -strlen($strCopyright)) !== false)) {
$strCopyright = $strPrefix . trim(ltrim($strCopyright, $strPrefix));
}
}
$arrList[] = $strCopyright;
}
$objTemplate->copyright = implode(', ', $arrList);
}
示例13: __set
/**
* Set an object property
*
* @param string $strKey The property name
* @param mixed $varValue The property value
*
* @throws \Exception If $strKey is unknown
*/
public function __set($strKey, $varValue)
{
switch ($strKey) {
case 'subject':
$this->strSubject = preg_replace(array('/[\\t]+/', '/[\\n\\r]+/'), array(' ', ''), $varValue);
break;
case 'text':
$this->strText = \StringUtil::decodeEntities($varValue);
break;
case 'html':
$this->strHtml = $varValue;
break;
case 'from':
$this->strSender = $varValue;
break;
case 'fromName':
$this->strSenderName = $varValue;
break;
case 'priority':
switch ($varValue) {
case 1:
case 'highest':
$this->intPriority = 1;
break;
case 2:
case 'high':
$this->intPriority = 2;
break;
case 3:
case 'normal':
$this->intPriority = 3;
break;
case 4:
case 'low':
$this->intPriority = 4;
break;
case 5:
case 'lowest':
$this->intPriority = 5;
break;
}
break;
case 'charset':
$this->strCharset = $varValue;
break;
case 'imageDir':
$this->strImageDir = $varValue;
break;
case 'embedImages':
$this->blnEmbedImages = $varValue;
break;
case 'logFile':
$this->strLogFile = $varValue;
break;
default:
throw new \Exception(sprintf('Invalid argument "%s"', $strKey));
break;
}
}
示例14: searchFor
/**
* Search the index and return the result object
*
* @param string $strKeywords The keyword string
* @param boolean $blnOrSearch If true, the result can contain any keyword
* @param array $arrPid An optional array of page IDs to limit the result to
* @param integer $intRows An optional maximum number of result rows
* @param integer $intOffset An optional result offset
* @param boolean $blnFuzzy If true, the search will be fuzzy
*
* @return \Database\Result The database result object
*
* @throws \Exception If the cleaned keyword string is empty
*/
public static function searchFor($strKeywords, $blnOrSearch = false, $arrPid = array(), $intRows = 0, $intOffset = 0, $blnFuzzy = false)
{
// Clean the keywords
$strKeywords = utf8_strtolower($strKeywords);
$strKeywords = \StringUtil::decodeEntities($strKeywords);
if (function_exists('mb_eregi_replace')) {
$strKeywords = mb_eregi_replace('[^[:alnum:] \\*\\+\'"\\.:,_-]|\\. |\\.$|: |:$|, |,$', ' ', $strKeywords);
} else {
$strKeywords = preg_replace(array('/\\. /', '/\\.$/', '/: /', '/:$/', '/, /', '/,$/', '/[^\\w\' *+".:,-]/u'), ' ', $strKeywords);
}
// Check keyword string
if (!strlen($strKeywords)) {
throw new \Exception('Empty keyword string');
}
// Split keywords
$arrChunks = array();
preg_match_all('/"[^"]+"|[\\+\\-]?[^ ]+\\*?/', $strKeywords, $arrChunks);
$arrPhrases = array();
$arrKeywords = array();
$arrWildcards = array();
$arrIncluded = array();
$arrExcluded = array();
foreach ($arrChunks[0] as $strKeyword) {
if (substr($strKeyword, -1) == '*' && strlen($strKeyword) > 1) {
$arrWildcards[] = str_replace('*', '%', $strKeyword);
continue;
}
switch (substr($strKeyword, 0, 1)) {
// Phrases
case '"':
if (($strKeyword = trim(substr($strKeyword, 1, -1))) != false) {
$arrPhrases[] = '[[:<:]]' . str_replace(array(' ', '*'), array('[^[:alnum:]]+', ''), $strKeyword) . '[[:>:]]';
}
break;
// Included keywords
// Included keywords
case '+':
if (($strKeyword = trim(substr($strKeyword, 1))) != false) {
$arrIncluded[] = $strKeyword;
}
break;
// Excluded keywords
// Excluded keywords
case '-':
if (($strKeyword = trim(substr($strKeyword, 1))) != false) {
$arrExcluded[] = $strKeyword;
}
break;
// Wildcards
// Wildcards
case '*':
if (strlen($strKeyword) > 1) {
$arrWildcards[] = str_replace('*', '%', $strKeyword);
}
break;
// Normal keywords
// Normal keywords
default:
$arrKeywords[] = $strKeyword;
break;
}
}
// Fuzzy search
if ($blnFuzzy) {
foreach ($arrKeywords as $strKeyword) {
$arrWildcards[] = '%' . $strKeyword . '%';
}
$arrKeywords = array();
}
// Count keywords
$intPhrases = count($arrPhrases);
$intWildcards = count($arrWildcards);
$intIncluded = count($arrIncluded);
$intExcluded = count($arrExcluded);
$intKeywords = 0;
$arrValues = array();
// Remember found words so we can highlight them later
$strQuery = "SELECT tl_search_index.pid AS sid, GROUP_CONCAT(word) AS matches";
// Get the number of wildcard matches
if (!$blnOrSearch && $intWildcards) {
$strQuery .= ", (SELECT COUNT(*) FROM tl_search_index WHERE (" . implode(' OR ', array_fill(0, $intWildcards, 'word LIKE ?')) . ") AND pid=sid) AS wildcards";
$arrValues = array_merge($arrValues, $arrWildcards);
}
// Count the number of matches
$strQuery .= ", COUNT(*) AS count";
// Get the relevance
//.........这里部分代码省略.........
示例15: decodeValue
/**
* @param $varValue
* @return mixed|string
*/
private function decodeValue($varValue)
{
if (class_exists('StringUtil')) {
$varValue = \StringUtil::decodeEntities($varValue);
} else {
// backwards compatible
$varValue = \Input::decodeEntities($varValue);
}
return $varValue;
}