本文整理汇总了PHP中StringUtil::restoreBasicEntities方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::restoreBasicEntities方法的具体用法?PHP StringUtil::restoreBasicEntities怎么用?PHP StringUtil::restoreBasicEntities使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtil
的用法示例。
在下文中一共展示了StringUtil::restoreBasicEntities方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateAlias
/**
* Auto-generate the member alias if it has not been set yet
* @param mixed
* @param \DataContainer
* @return string
* @throws \Exception
*/
public function generateAlias($varValue, DataContainer $objDc)
{
$autoAlias = false;
// Generate alias if there is none
if ($varValue == '') {
$autoAlias = true;
$arrTitle = \HeimrichHannot\MemberPlus\MemberPlus::getCombinedTitle($objDc->activeRecord);
$varValue = standardize(\StringUtil::restoreBasicEntities($arrTitle));
}
$objAlias = \Database::getInstance()->prepare("SELECT id FROM tl_member WHERE alias=? AND id!=?")->execute($varValue, $objDc->activeRecord->id);
// Check whether the news alias exists
if ($objAlias->numRows > 1 && !$autoAlias) {
throw new Exception(sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $varValue));
}
// Add ID to alias
if ($objAlias->numRows && $autoAlias) {
$varValue .= '-' . $objDc->id;
}
return $varValue;
}
示例2: 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(\StringUtil::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);
}
示例3: checkoutForm
/**
* Return the PayPal form.
*
* @param IsotopeProductCollection|Order $objOrder The order being places
* @param \Module|Checkout $objModule The checkout module instance
*
* @return string
*/
public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule)
{
$arrData = array();
$fltDiscount = 0;
$i = 0;
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['item_number_' . ++$i] = $objItem->getSku();
$arrData['item_name_' . $i] = \StringUtil::restoreBasicEntities($objItem->getName() . $strConfig);
$arrData['amount_' . $i] = $objItem->getPrice();
$arrData['quantity_' . $i] = $objItem->quantity;
}
foreach ($objOrder->getSurcharges() as $objSurcharge) {
if (!$objSurcharge->addToTotal) {
continue;
}
// PayPal does only support one single discount item
if ($objSurcharge->total_price < 0) {
$fltDiscount -= $objSurcharge->total_price;
continue;
}
$arrData['item_name_' . ++$i] = $objSurcharge->label;
$arrData['amount_' . $i] = $objSurcharge->total_price;
}
$objTemplate = new \Isotope\Template('iso_payment_paypal');
$objTemplate->setData($this->arrData);
$objTemplate->id = $this->id;
$objTemplate->action = 'https://www.' . ($this->debug ? 'sandbox.' : '') . 'paypal.com/cgi-bin/webscr';
$objTemplate->invoice = $objOrder->id;
$objTemplate->data = array_map('specialchars', $arrData);
$objTemplate->discount = $fltDiscount;
$objTemplate->address = $objOrder->getBillingAddress();
$objTemplate->currency = $objOrder->currency;
$objTemplate->return = \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder);
$objTemplate->cancel_return = \Environment::get('base') . $objModule->generateUrlForStep('failed');
$objTemplate->notify_url = \Environment::get('base') . 'system/modules/isotope/postsale.php?mod=pay&id=' . $this->id;
$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();
}
示例4: source
/**
* Load the source editor
*
* @return string
*/
public function source()
{
$this->isValid($this->intId);
if (is_dir(TL_ROOT . '/' . $this->intId)) {
$this->log('Folder "' . $this->intId . '" cannot be edited', __METHOD__, TL_ERROR);
$this->redirect('contao/main.php?act=error');
} elseif (!file_exists(TL_ROOT . '/' . $this->intId)) {
$this->log('File "' . $this->intId . '" does not exist', __METHOD__, TL_ERROR);
$this->redirect('contao/main.php?act=error');
}
$this->import('BackendUser', 'User');
// Check user permission
if (!$this->User->hasAccess('f5', 'fop')) {
$this->log('Not enough permissions to edit the file source of file "' . $this->intId . '"', __METHOD__, TL_ERROR);
$this->redirect('contao/main.php?act=error');
}
$objFile = new \File($this->intId, true);
// Check whether file type is editable
if (!in_array($objFile->extension, trimsplit(',', strtolower(\Config::get('editableFiles'))))) {
$this->log('File type "' . $objFile->extension . '" (' . $this->intId . ') is not allowed to be edited', __METHOD__, TL_ERROR);
$this->redirect('contao/main.php?act=error');
}
$objMeta = null;
$objVersions = null;
// Add the versioning routines
if ($this->blnIsDbAssisted && \Dbafs::shouldBeSynchronized($this->intId)) {
$objMeta = \FilesModel::findByPath($objFile->value);
if ($objMeta === null) {
$objMeta = \Dbafs::addResource($objFile->value);
}
$objVersions = new \Versions($this->strTable, $objMeta->id);
if (!$GLOBALS['TL_DCA'][$this->strTable]['config']['hideVersionMenu']) {
// Compare versions
if (\Input::get('versions')) {
$objVersions->compare();
}
// Restore a version
if (\Input::post('FORM_SUBMIT') == 'tl_version' && \Input::post('version') != '') {
$objVersions->restore(\Input::post('version'));
// Purge the script cache (see #7005)
if ($objFile->extension == 'css' || $objFile->extension == 'scss' || $objFile->extension == 'less') {
$this->import('Automator');
$this->Automator->purgeScriptCache();
}
$this->reload();
}
}
$objVersions->initialize();
}
$strContent = $objFile->getContent();
if ($objFile->extension == 'svgz') {
$strContent = gzdecode($strContent);
}
// Process the request
if (\Input::post('FORM_SUBMIT') == 'tl_files') {
// Restore the basic entities (see #7170)
$strSource = \StringUtil::restoreBasicEntities(\Input::postRaw('source'));
// Save the file
if (md5($strContent) != md5($strSource)) {
if ($objFile->extension == 'svgz') {
$strSource = gzencode($strSource);
}
// Write the file
$objFile->write($strSource);
$objFile->close();
// Update the database
if ($this->blnIsDbAssisted && $objMeta !== null) {
/** @var \FilesModel $objMeta */
$objMeta->hash = $objFile->hash;
$objMeta->save();
$objVersions->create();
}
// Purge the script cache (see #7005)
if ($objFile->extension == 'css' || $objFile->extension == 'scss' || $objFile->extension == 'less') {
$this->import('Automator');
$this->Automator->purgeScriptCache();
}
}
if (\Input::post('saveNclose')) {
\System::setCookie('BE_PAGE_OFFSET', 0, 0);
$this->redirect($this->getReferer());
}
$this->reload();
}
$codeEditor = '';
// Prepare the code editor
if (\Config::get('useCE')) {
$selector = 'ctrl_source';
$type = $objFile->extension;
// Load the code editor configuration
ob_start();
include TL_ROOT . '/system/config/ace.php';
$codeEditor = ob_get_contents();
ob_end_clean();
unset($selector, $type);
//.........这里部分代码省略.........
示例5: doReplace
/**
* Replace insert tags with their values
*
* @param string $strBuffer The text with the tags to be replaced
* @param boolean $blnCache If false, non-cacheable tags will be replaced
*
* @return string The text with the replaced tags
*/
protected function doReplace($strBuffer, $blnCache)
{
/** @var PageModel $objPage */
global $objPage;
// Preserve insert tags
if (\Config::get('disableInsertTags')) {
return \StringUtil::restoreBasicEntities($strBuffer);
}
$tags = preg_split('/{{([^{}]+)}}/', $strBuffer, -1, PREG_SPLIT_DELIM_CAPTURE);
if (count($tags) < 2) {
return \StringUtil::restoreBasicEntities($strBuffer);
}
$strBuffer = '';
// Create one cache per cache setting (see #7700)
static $arrItCache;
$arrCache =& $arrItCache[$blnCache];
for ($_rit = 0, $_cnt = count($tags); $_rit < $_cnt; $_rit += 2) {
$strBuffer .= $tags[$_rit];
$strTag = $tags[$_rit + 1];
// Skip empty tags
if ($strTag == '') {
continue;
}
$flags = explode('|', $strTag);
$tag = array_shift($flags);
$elements = explode('::', $tag);
// Load the value from cache
if (isset($arrCache[$strTag]) && !in_array('refresh', $flags)) {
$strBuffer .= $arrCache[$strTag];
continue;
}
// Skip certain elements if the output will be cached
if ($blnCache) {
if ($elements[0] == 'date' || $elements[0] == 'ua' || $elements[0] == 'post' || $elements[0] == 'file' || $elements[1] == 'back' || $elements[1] == 'referer' || $elements[0] == 'request_token' || $elements[0] == 'toggle_view' || strncmp($elements[0], 'cache_', 6) === 0 || in_array('uncached', $flags)) {
$strBuffer .= '{{' . $strTag . '}}';
continue;
}
}
$arrCache[$strTag] = '';
// Replace the tag
switch (strtolower($elements[0])) {
// Date
case 'date':
$arrCache[$strTag] = \Date::parse($elements[1] ?: \Config::get('dateFormat'));
break;
// Accessibility tags
// Accessibility tags
case 'lang':
if ($elements[1] == '') {
$arrCache[$strTag] = '</span>';
} else {
$arrCache[$strTag] = $arrCache[$strTag] = '<span lang="' . $elements[1] . '">';
}
break;
// Line break
// Line break
case 'br':
$arrCache[$strTag] = '<br>';
break;
// E-mail addresses
// E-mail addresses
case 'email':
case 'email_open':
case 'email_url':
if ($elements[1] == '') {
$arrCache[$strTag] = '';
break;
}
$strEmail = \StringUtil::encodeEmail($elements[1]);
// Replace the tag
switch (strtolower($elements[0])) {
case 'email':
$arrCache[$strTag] = '<a href="mailto:' . $strEmail . '" class="email">' . preg_replace('/\\?.*$/', '', $strEmail) . '</a>';
break;
case 'email_open':
$arrCache[$strTag] = '<a href="mailto:' . $strEmail . '" title="' . $strEmail . '" class="email">';
break;
case 'email_url':
$arrCache[$strTag] = $strEmail;
break;
}
break;
// Label tags
// Label tags
case 'label':
$keys = explode(':', $elements[1]);
if (count($keys) < 2) {
$arrCache[$strTag] = '';
break;
}
$file = $keys[0];
// Map the key (see #7217)
//.........这里部分代码省略.........
示例6: save
/**
* Save the current value
*
* @param mixed $varValue
*/
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;
}
if ($varValue != '') {
// Convert binary UUIDs (see #6893)
if ($arrData['inputType'] == 'fileTree') {
$varValue = deserialize($varValue);
if (!is_array($varValue)) {
$varValue = \StringUtil::binToUuid($varValue);
} else {
$varValue = serialize(array_map('StringUtil::binToUuid', $varValue));
}
}
// Convert date formats into timestamps
if ($varValue != '' && in_array($arrData['eval']['rgxp'], array('date', 'time', 'datim'))) {
$objDate = new \Date($varValue, \Date::getFormatFromRgxp($arrData['eval']['rgxp']));
$varValue = $objDate->tstamp;
}
// Handle entities
if ($arrData['inputType'] == 'text' || $arrData['inputType'] == 'textarea') {
$varValue = deserialize($varValue);
if (!is_array($varValue)) {
$varValue = \StringUtil::restoreBasicEntities($varValue);
} else {
$varValue = serialize(array_map('StringUtil::restoreBasicEntities', $varValue));
}
}
}
// Trigger the save_callback
if (is_array($arrData['save_callback'])) {
foreach ($arrData['save_callback'] as $callback) {
if (is_array($callback)) {
$this->import($callback[0]);
$varValue = $this->{$callback[0]}->{$callback[1]}($varValue, $this);
} elseif (is_callable($callback)) {
$varValue = $callback($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, \Config::get('characterSet'));
}
// Save the value if there was no error
if ((strlen($varValue) || !$arrData['eval']['doNotSaveEmpty']) && $strCurrent != $varValue) {
\Config::persist($this->strField, $varValue);
$deserialize = deserialize($varValue);
$prior = is_bool(\Config::get($this->strField)) ? \Config::get($this->strField) ? 'true' : 'false' : \Config::get($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', __METHOD__, TL_CONFIGURATION);
} else {
$this->log('The global configuration variable "' . $this->strField . '" has been changed from "' . $prior . '" to "' . $varValue . '"', __METHOD__, TL_CONFIGURATION);
}
}
// Set the new value so the input field can show it
$this->varValue = $deserialize;
\Config::set($this->strField, $deserialize);
}
}
示例7: convertToText
/**
* Convert the given array or string to plain text using given options
*
* @param mixed $varValue
* @param int $options
*
* @return mixed
*/
public static function convertToText($varValue, $options)
{
if (is_array($varValue)) {
foreach ($varValue as $k => $v) {
$varValue[$k] = static::convertToText($v, $options);
}
return $varValue;
}
if ($options & static::NO_ENTITIES) {
$varValue = \StringUtil::restoreBasicEntities($varValue);
$varValue = html_entity_decode($varValue);
// Convert non-breaking to regular white space
$varValue = str_replace(" ", ' ', $varValue);
// Remove invisible control characters and unused code points
$varValue = preg_replace('/[\\pC]/u', '', $varValue);
}
// Replace friendly email before stripping tags
if (!($options & static::NO_EMAILS)) {
$arrEmails = array();
preg_match_all('{<.+@.+\\.[A-Za-z]+>}', $varValue, $arrEmails);
if (!empty($arrEmails[0])) {
foreach ($arrEmails[0] as $k => $v) {
$varValue = str_replace($v, '%email' . $k . '%', $varValue);
}
}
}
// Remove HTML tags but keep line breaks for <br> and <p>
if ($options & static::NO_TAGS) {
$varValue = strip_tags(preg_replace('{(?!^)<(br|p|/p).*?/?>\\n?(?!$)}is', "\n", $varValue));
}
if ($options & static::NO_INSERTTAGS) {
$varValue = strip_insert_tags($varValue);
}
// Remove line breaks (e.g. for subject)
if ($options & static::NO_BREAKS) {
$varValue = str_replace(array("\r", "\n"), '', $varValue);
}
// Restore friendly email after stripping tags
if (!($options & static::NO_EMAILS) && !empty($arrEmails[0])) {
foreach ($arrEmails[0] as $k => $v) {
$varValue = str_replace('%email' . $k . '%', $v, $varValue);
}
}
return $varValue;
}
示例8: restoreBasicEntities
/**
* Restore basic entities
*
* @param string $strBuffer The string with the tags to be replaced
*
* @return string The string with the original entities
*
* @deprecated Use StringUtil::restoreBasicEntities() instead
*/
public static function restoreBasicEntities($strBuffer)
{
return \StringUtil::restoreBasicEntities($strBuffer);
}
示例9: checkoutForm
/**
* HTML form for checkout
*
* @param IsotopeProductCollection|Order $objOrder The order being places
* @param \Module|Checkout $objModule 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(\StringUtil::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();
}