本文整理汇总了PHP中String::restoreBasicEntities方法的典型用法代码示例。如果您正苦于以下问题:PHP String::restoreBasicEntities方法的具体用法?PHP String::restoreBasicEntities怎么用?PHP String::restoreBasicEntities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::restoreBasicEntities方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
// 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 = 'NC-TAG-OPEN-' . $strHash;
$strTagCloseReplacement = 'NC-TAG-CLOSE-' . $strHash;
$arrOriginal = array('<', '>');
$arrReplacement = array($strTagOpenReplacement, $strTagCloseReplacement);
$strText = str_replace($arrOriginal, $arrReplacement, $strText);
// first parse the tokens as they might have if-else clauses
$strBuffer = \String::parseSimpleTokens($strText, $arrTokens);
$strBuffer = str_replace($arrReplacement, $arrOriginal, $strBuffer);
// then replace the insert tags
$strBuffer = \Haste\Haste::getInstance()->call('replaceInsertTags', array($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);
}
$strBuffer = \String::restoreBasicEntities($strBuffer);
if ($intTextFlags > 0) {
$strBuffer = static::convertToText($strBuffer, $intTextFlags);
}
return $strBuffer;
}
示例2: recursiveReplaceTokensAndTags
/**
* Recursively replace simple tokens and insert tags
*
* @param string $strText
* @param array $arrTokens Array of Tokens
*
* @return string
*/
public static function recursiveReplaceTokensAndTags($text, $tokens)
{
// Must decode, tokens could be encoded
$text = \String::decodeEntities($text);
// Replace all opening and closing tags with a hash so they don't get stripped
// by parseSimpleTokens()
$hash = md5($text);
$openTagReplacement = 'LEADS-TAG-OPEN-' . $hash;
$closeTagReplacement = 'LEADS-TAG-CLOSE-' . $hash;
$original = array('<', '>');
$replacement = array($openTagReplacement, $closeTagReplacement);
$text = str_replace($original, $replacement, $text);
// first parse the tokens as they might have if-else clauses
$buffer = \String::parseSimpleTokens($text, $tokens);
// Restore tags
$buffer = str_replace($replacement, $original, $buffer);
// Replace the Insert Tags
$buffer = \Haste\Haste::getInstance()->call('replaceInsertTags', array($buffer, false));
// Check if the Insert Tags have returned a Simple Token or an Insert Tag to parse
if ((strpos($buffer, '##') !== false || strpos($buffer, '{{') !== false) && $buffer != $text) {
$buffer = static::recursiveReplaceTokensAndTags($buffer, $tokens);
}
$buffer = \String::restoreBasicEntities($buffer);
return $buffer;
}
示例3: parseContent
/**
* @param RecipientInterface $recipient
* @param array $additionalData
*
* @return string
* @SuppressWarnings(PHPMD.Superglobals)
* @SuppressWarnings(PHPMD.LongVariable)
*/
protected function parseContent(RecipientInterface $recipient, array $additionalData = array())
{
/** @var EventDispatcher $eventDispatcher */
$eventDispatcher = $GLOBALS['container']['event-dispatcher'];
$content = $this->getContent();
// dispatch a pre render event
$event = new PreRenderMessageContentEvent($this->message, $this, $recipient, $additionalData, $content);
$eventDispatcher->dispatch(AvisotaMessageEvents::PRE_RENDER_MESSAGE_CONTENT, $event);
$content = $event->getContent();
if (is_string($content)) {
$additionalData['message'] = $this->message;
if (!isset($additionalData['recipient'])) {
/** @var SynonymizerService $synonymizer */
$synonymizer = $GLOBALS['container']['avisota.recipient.synonymizer'];
$additionalData['recipient'] = $synonymizer->expandDetailsWithSynonyms($recipient);
}
$additionalData['_recipient'] = $recipient;
/** @var TagReplacementService $tagReplacementService */
$tagReplacementService = $GLOBALS['container']['avisota.message.tagReplacementEngine'];
$content = $tagReplacementService->parse($content, $additionalData);
$content = \String::restoreBasicEntities($content);
}
// dispatch a post render event
$event = new PostRenderMessageContentEvent($this->message, $this, $recipient, $additionalData, $content);
$eventDispatcher->dispatch(AvisotaMessageEvents::POST_RENDER_MESSAGE_CONTENT, $event);
return $event->getContent();
}
示例4: replaceForbiddenCharacters
/**
* Replaces all "forbidden" characters in the given filename
*
* @param string $strFile
*
* @return string
*/
protected function replaceForbiddenCharacters($strFile)
{
$info = pathinfo($strFile);
$newFilename = substr($info['filename'], 0, 32);
$newFilename = standardize(\String::restoreBasicEntities($newFilename));
$newFilename = $this->replaceUnderscores($newFilename);
return $info['dirname'] . '/' . $newFilename . '.' . strtolower($info['extension']);
}
示例5: rename
public function rename($varValue)
{
if (!$GLOBALS['TL_CONFIG']['checkFilenames']) {
return $varValue;
}
$varValue = standardize(\String::restoreBasicEntities($varValue));
return $varValue;
}
示例6: generateAlias
public function generateAlias($varValue, $objItem)
{
$t = static::$strTable;
$varValue = standardize(\String::restoreBasicEntities($varValue));
$objAlias = \Database::getInstance()->prepare("SELECT id FROM {$t} WHERE alias=? AND id != ?")->execute($varValue, $objItem->id);
// Add ID to alias
if ($objAlias->numRows > 0) {
$varValue .= '-' . $objItem->id;
}
return $varValue;
}
示例7: generateAlias
public function generateAlias($varValue, DataContainer $dc)
{
// Generate an alias if there is none
if ($varValue == '') {
$varValue = standardize(String::restoreBasicEntities($dc->activeRecord->label));
}
$objAlias = $this->Database->prepare("SELECT id FROM tl_metafields WHERE id=? OR alias=?")->execute($dc->id, $varValue);
// Check whether the alias exists
if ($objAlias->numRows > 1) {
throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue));
}
return $varValue;
}
示例8: generateAlias
public function generateAlias()
{
$varValue = standardize(\String::restoreBasicEntities($this->title));
$objAlias = static::findBy('alias', $varValue);
// Check whether the alias exists
if ($objAlias !== null) {
if (!$this->id) {
return $this;
}
$varValue .= '-' . $this->id;
}
$this->alias = $varValue;
return $this;
}
示例9: 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;
}
示例10: checkoutForm
/**
* HTML form for checkout
* @param IsotopeProductCollection The order being places
* @param Module The checkout module instance
* @return mixed
*/
public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule)
{
$i = 0;
$arrData = array('aid' => $this->payone_aid, 'portalid' => $this->payone_portalid, 'mode' => $this->debug ? 'test' : 'live', 'request' => $this->trans_type == 'auth' ? 'preauthorization' : 'authorization', 'encoding' => 'UTF-8', 'clearingtype' => $this->payone_clearingtype, 'reference' => $objOrder->id, 'display_name' => 'no', 'display_address' => 'no', 'successurl' => \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder), 'backurl' => \Environment::get('base') . $objModule->generateUrlForStep('failed'), 'amount' => $objOrder->getTotal() * 100, 'currency' => $objOrder->currency, 'param' => 'paymentMethodPayone' . $this->id);
foreach ($objOrder->getItems() as $objItem) {
// Set the active product for insert tags replacement
if ($objItem->hasProduct()) {
Product::setActive($objItem->getProduct());
}
$strConfig = '';
$arrConfig = $objItem->getConfiguration();
if (!empty($arrConfig)) {
array_walk($arrConfig, function (&$option) {
$option = $option['label'] . ': ' . (string) $option;
});
$strConfig = ' (' . implode(', ', $arrConfig) . ')';
}
$arrData['id[' . ++$i . ']'] = $objItem->getSku();
$arrData['pr[' . $i . ']'] = round($objItem->getPrice(), 2) * 100;
$arrData['no[' . $i . ']'] = $objItem->quantity;
$arrData['de[' . $i . ']'] = specialchars(\String::restoreBasicEntities($objItem->getName() . $strConfig), true);
}
foreach ($objOrder->getSurcharges() as $k => $objSurcharge) {
if (!$objSurcharge->addToTotal) {
continue;
}
$arrData['id[' . ++$i . ']'] = 'surcharge' . $k;
$arrData['pr[' . $i . ']'] = $objSurcharge->total_price * 100;
$arrData['no[' . $i . ']'] = '1';
$arrData['de[' . $i . ']'] = $objSurcharge->label;
}
ksort($arrData);
// Do not urlencode values because Payone does not properly decode POST values (whatever...)
$strHash = md5(implode('', $arrData) . $this->payone_key);
$objTemplate = new \Isotope\Template('iso_payment_payone');
$objTemplate->id = $this->id;
$objTemplate->data = $arrData;
$objTemplate->hash = $strHash;
$objTemplate->billing_address = $objOrder->getBillingAddress()->row();
$objTemplate->headline = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][0]);
$objTemplate->message = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][1]);
$objTemplate->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][2]);
$objTemplate->noscript = specialchars($GLOBALS['TL_LANG']['MSC']['pay_with_redirect'][3]);
return $objTemplate->parse();
}
示例11: generateCookiesName
/**
* Auto-generate the cookie name
*/
public function generateCookiesName($varValue, DataContainer $dc)
{
$autoAlias = false;
// Generate alias if there is none
if ($varValue == '') {
$autoAlias = true;
$varValue = standardize(String::restoreBasicEntities('tabControllCookie-' . $dc->activeRecord->id));
}
$objAlias = $this->Database->prepare("SELECT id FROM tl_content WHERE tabControlCookies=?")->execute($varValue);
// Check whether the cookies name alias exists
if ($objAlias->numRows > 1 && !$autoAlias) {
throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue));
}
// Add ID to cookies name
if ($objAlias->numRows && $autoAlias) {
$varValue .= '-' . $dc->id;
}
return $varValue;
}
示例12: prepareFISParams
/**
* Prepare FIS params
* @param Order
* @return array
*/
private function prepareFISParams($objOrder)
{
$objBillingAddress = $objOrder->getBillingAddress();
$objShippingAddress = $objOrder->getShippingAddress();
$arrInvoice = array('ECOM_BILLTO_POSTAL_NAME_FIRST' => substr($objBillingAddress->firstname, 0, 50), 'ECOM_BILLTO_POSTAL_NAME_LAST' => substr($objBillingAddress->lastname, 0, 50), 'ECOM_SHIPTO_POSTAL_STREET_LINE1' => $objShippingAddress->street_1, 'ECOM_SHIPTO_POSTAL_POSTALCODE' => $objShippingAddress->postal, 'ECOM_SHIPTO_POSTAL_CITY' => $objShippingAddress->city, 'ECOM_SHIPTO_POSTAL_COUNTRYCODE' => strtoupper($objShippingAddress->country), 'ECOM_SHIPTO_DOB' => date('d/m/Y', $objShippingAddress->dateOfBirth), 'REF_CUSTOMERID' => substr('psp_' . $this->id . '_' . $objOrder->id . '_' . $objOrder->uniqid, 0, 17), 'ECOM_CONSUMER_GENDER' => $objBillingAddress->gender == 'male' ? 'M' : 'F');
$arrOrder = array();
$i = 1;
// Need to take the items from the cart as they're not transferred to the order here yet
// @todo this is no longer true, and the price should probably be taken from the collection item ($objItem->getPrice())
foreach (Isotope::getCart()->getItems() as $objItem) {
$objPrice = $objItem->getProduct()->getPrice();
$fltVat = Isotope::roundPrice(100 / $objPrice->getNetAmount() * $objPrice->getGrossAmount() - 100, false);
$arrOrder['ITEMID' . $i] = $objItem->id;
$arrOrder['ITEMNAME' . $i] = substr(\String::restoreBasicEntities($objItem->getName()), 40);
$arrOrder['ITEMPRICE' . $i] = $objPrice->getNetAmount();
$arrOrder['ITEMQUANT' . $i] = $objItem->quantity;
$arrOrder['ITEMVATCODE' . $i] = $fltVat . '%';
$arrOrder['ITEMVAT' . $i] = Isotope::roundPrice($objPrice->getGrossAmount() - $objPrice->getNetAmount(), false);
$arrOrder['FACEXCL' . $i] = $objPrice->getNetAmount();
$arrOrder['FACTOTAL' . $i] = $objPrice->getGrossAmount();
++$i;
}
return array_merge($arrInvoice, $arrOrder);
}
示例13: generateAlias
/**
* Auto-generate an article alias if it has not been set yet
* @param mixed
* @param \DataContainer
* @return string
* @throws \Exception
*/
public function generateAlias($varValue, DataContainer $dc)
{
$autoAlias = false;
// Generate an alias if there is none
if ($varValue == '') {
$autoAlias = true;
//@todo make configureable for each category in dca category
$varValue = $dc->activeRecord->name . '-' . $dc->activeRecord->postal . '-' . $dc->activeRecord->city;
$varValue = standardize(String::restoreBasicEntities($varValue));
}
$objAlias = $this->Database->prepare("SELECT id FROM tl_anystores WHERE id=? OR alias=?")->execute($dc->id, $varValue);
// Check whether the page alias exists
if ($objAlias->numRows > 1) {
if (!$autoAlias) {
throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue));
}
$varValue = $dc->id . '-' . $varValue;
}
return $varValue;
}
示例14: 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);
}
示例15: save
/**
* Save the current value
* @param mixed
*/
protected function save($varValue)
{
if (\Input::post('FORM_SUBMIT') != $this->strTable) {
return;
}
$arrData = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField];
// Make sure that checkbox values are boolean
if ($arrData['inputType'] == 'checkbox' && !$arrData['eval']['multiple']) {
$varValue = $varValue ? true : false;
}
// Convert date formats into timestamps
if ($varValue != '' && in_array($arrData['eval']['rgxp'], array('date', 'time', 'datim'))) {
$objDate = new \Date($varValue, $GLOBALS['TL_CONFIG'][$arrData['eval']['rgxp'] . 'Format']);
$varValue = $objDate->tstamp;
}
// Handle entities
if ($arrData['inputType'] == 'text' || $arrData['inputType'] == 'textarea') {
$varValue = deserialize($varValue);
if (!is_array($varValue)) {
$varValue = \String::restoreBasicEntities($varValue);
} else {
foreach ($varValue as $k => $v) {
$varValue[$k] = \String::restoreBasicEntities($v);
}
$varValue = serialize($varValue);
}
}
// Trigger the save_callback
if (is_array($arrData['save_callback'])) {
foreach ($arrData['save_callback'] as $callback) {
$this->import($callback[0]);
$varValue = $this->{$callback}[0]->{$callback}[1]($varValue, $this);
}
}
$strCurrent = $this->varValue;
// Handle arrays and strings
if (is_array($strCurrent)) {
$strCurrent = serialize($strCurrent);
} elseif (is_string($strCurrent)) {
$strCurrent = html_entity_decode($this->varValue, ENT_QUOTES, $GLOBALS['TL_CONFIG']['characterSet']);
}
// Save the value if there was no error
if ((strlen($varValue) || !$arrData['eval']['doNotSaveEmpty']) && $strCurrent != $varValue) {
$strKey = sprintf("\$GLOBALS['TL_CONFIG']['%s']", $this->strField);
$this->Config->update($strKey, $varValue);
$deserialize = deserialize($varValue);
$prior = is_bool($GLOBALS['TL_CONFIG'][$this->strField]) ? $GLOBALS['TL_CONFIG'][$this->strField] ? 'true' : 'false' : $GLOBALS['TL_CONFIG'][$this->strField];
// Add a log entry
if (!is_array(deserialize($prior)) && !is_array($deserialize)) {
if ($arrData['inputType'] == 'password' || $arrData['inputType'] == 'textStore') {
$this->log('The global configuration variable "' . $this->strField . '" has been changed', 'DC_File save()', TL_CONFIGURATION);
} else {
$this->log('The global configuration variable "' . $this->strField . '" has been changed from "' . $prior . '" to "' . $varValue . '"', 'DC_File save()', TL_CONFIGURATION);
}
}
// Set the new value so the input field can show it
$this->varValue = $deserialize;
$GLOBALS['TL_CONFIG'][$this->strField] = $deserialize;
}
}