Draw the currency input displayed in the BackOffice
allowing Admin to set its Coupon Conditions

@param string $inputKey Input key (ex: self::INPUT1)

@return string HTML string
762477
protected function drawBackOfficeCurrencyInput($inputKey)
    {
        $currencies = CurrencyQuery::create()->find();

        $cleanedCurrencies = [];

        /** @var Currency $currency */
        foreach ($currencies as $currency) {
            $cleanedCurrencies[$currency->getCode()] = $currency->getSymbol();
        }

        return $this->facade->getParser()->render(
            'coupon/condition-fragments/currency-selector.html',
            [
                'currencies' => $cleanedCurrencies,
                'value'      => isset($this->values[$inputKey]) ? $this->values[$inputKey] : '',
                'inputKey'   => $inputKey
            ]
        );
    }
730971
public static function spanLtrRtl(string $inputText): string
    {
        if ($inputText === '') {
            // Nothing to do
            return '';
        }

        $workingText = str_replace("\n", '<br>', $inputText);
        $workingText = str_replace([
            '<span class="starredname"><br>',
            '<span<br>class="starredname">',
        ], '<br><span class="starredname">', $workingText); // Reposition some incorrectly placed line breaks
        $workingText = self::stripLrmRlm($workingText); // Get rid of any existing UTF8 control codes

        self::$previousState = '';
        self::$currentState  = strtoupper(I18N::direction());
        $numberState         = false; // Set when we're inside a numeric string
        $result              = '';
        self::$waitingText   = '';
        $openParDirection    = [];

        self::beginCurrentSpan($result);

        while ($workingText != '') {
            $charArray     = self::getChar($workingText, 0); // Get the next ASCII or UTF-8 character
            $currentLetter = $charArray['letter'];
            $currentLen    = $charArray['length'];

            $openParIndex  = strpos(self::OPEN_PARENTHESES, $currentLetter); // Which opening parenthesis is this?
            $closeParIndex = strpos(self::CLOSE_PARENTHESES, $currentLetter); // Which closing parenthesis is this?

            switch ($currentLetter) {
                case '<':
                    // Assume this '<' starts an HTML element
                    $endPos = strpos($workingText, '>'); // look for the terminating '>'
                    if ($endPos === false) {
                        $endPos = 0;
                    }
                    $currentLen += $endPos;
                    $element    = substr($workingText, 0, $currentLen);
                    $temp       = strtolower(substr($element, 0, 3));
                    if (strlen($element) < 7 && $temp === '<br') {
                        if ($numberState) {
                            $numberState = false;
                            if (self::$currentState === 'RTL') {
                                self::$waitingText .= self::UTF8_PDF;
                            }
                        }
                        self::breakCurrentSpan($result);
                    } elseif (self::$waitingText == '') {
                        $result .= $element;
                    } else {
                        self::$waitingText .= $element;
                    }
                    $workingText = substr($workingText, $currentLen);
                    break;
                case '&':
                    // Assume this '&' starts an HTML entity
                    $endPos = strpos($workingText, ';'); // look for the terminating ';'
                    if ($endPos === false) {
                        $endPos = 0;
                    }
                    $currentLen += $endPos;
                    $entity     = substr($workingText, 0, $currentLen);
                    if (strtolower($entity) === '&nbsp;') {
                        $entity .= '&nbsp;'; // Ensure consistent case for this entity
                    }
                    if (self::$waitingText == '') {
                        $result .= $entity;
                    } else {
                        self::$waitingText .= $entity;
                    }
                    $workingText = substr($workingText, $currentLen);
                    break;
                case '{':
                    if (substr($workingText, 1, 1) === '{') {
                        // Assume this '{{' starts a TCPDF directive
                        $endPos = strpos($workingText, '}}'); // look for the terminating '}}'
                        if ($endPos === false) {
                            $endPos = 0;
                        }
                        $currentLen        = $endPos + 2;
                        $directive         = substr($workingText, 0, $currentLen);
                        $workingText       = substr($workingText, $currentLen);
                        $result            = $result . self::$waitingText . $directive;
                        self::$waitingText = '';
                        break;
                    }
                    // no break
                default:
                    // Look for strings of numbers with optional leading or trailing + or -
                    // and with optional embedded numeric punctuation
                    if ($numberState) {
                        // If we're inside a numeric string, look for reasons to end it
                        $offset    = 0; // Be sure to look at the current character first
                        $charArray = self::getChar($workingText . "\n", $offset);
                        if (strpos(self::NUMBERS, $charArray['letter']) === false) {
                            // This is not a digit. Is it numeric punctuation?
                            if (substr($workingText . "\n", $offset, 6) === '&nbsp;') {
                                $offset += 6; // This could be numeric punctuation
                            } elseif (strpos(self::NUMBER_PUNCTUATION, $charArray['letter']) !== false) {
                                $offset += $charArray['length']; // This could be numeric punctuation
                            }
                            // If the next character is a digit, the current character is numeric punctuation
                            $charArray = self::getChar($workingText . "\n", $offset);
                            if (strpos(self::NUMBERS, $charArray['letter']) === false) {
                                // This is not a digit. End the run of digits and punctuation.
                                $numberState = false;
                                if (self::$currentState === 'RTL') {
                                    if (strpos(self::NUMBER_PREFIX, $currentLetter) === false) {
                                        $currentLetter = self::UTF8_PDF . $currentLetter;
                                    } else {
                                        $currentLetter .= self::UTF8_PDF; // Include a trailing + or - in the run
                                    }
                                }
                            }
                        }
                    } else {
                        // If we're outside a numeric string, look for reasons to start it
                        if (strpos(self::NUMBER_PREFIX, $currentLetter) !== false) {
                            // This might be a number lead-in
                            $offset   = $currentLen;
                            $nextChar = substr($workingText . "\n", $offset, 1);
                            if (strpos(self::NUMBERS, $nextChar) !== false) {
                                $numberState = true; // We found a digit: the lead-in is therefore numeric
                                if (self::$currentState === 'RTL') {
                                    $currentLetter = self::UTF8_LRE . $currentLetter;
                                }
                            }
                        } elseif (strpos(self::NUMBERS, $currentLetter) !== false) {
                            $numberState = true; // The current letter is a digit
                            if (self::$currentState === 'RTL') {
                                $currentLetter = self::UTF8_LRE . $currentLetter;
                            }
                        }
                    }

                    // Determine the directionality of the current UTF-8 character
                    $newState = self::$currentState;
                    while (true) {
                        if (I18N::scriptDirection(I18N::textScript($currentLetter)) === 'rtl') {
                            if (self::$currentState == '') {
                                $newState = 'RTL';
                                break;
                            }

                            if (self::$currentState === 'RTL') {
                                break;
                            }
                            // Switch to RTL only if this isn't a solitary RTL letter
                            $tempText = substr($workingText, $currentLen);
                            while ($tempText != '') {
                                $nextCharArray = self::getChar($tempText, 0);
                                $nextLetter    = $nextCharArray['letter'];
                                $nextLen       = $nextCharArray['length'];
                                $tempText      = substr($tempText, $nextLen);

                                if (I18N::scriptDirection(I18N::textScript($nextLetter)) === 'rtl') {
                                    $newState = 'RTL';
                                    break 2;
                                }

                                if (strpos(self::PUNCTUATION, $nextLetter) !== false || strpos(self::OPEN_PARENTHESES, $nextLetter) !== false) {
                                    $newState = 'RTL';
                                    break 2;
                                }

                                if ($nextLetter === ' ') {
                                    break;
                                }
                                $nextLetter .= substr($tempText . "\n", 0, 5);
                                if ($nextLetter === '&nbsp;') {
                                    break;
                                }
                            }
                            // This is a solitary RTL letter : wrap it in UTF8 control codes to force LTR directionality
                            $currentLetter = self::UTF8_LRO . $currentLetter . self::UTF8_PDF;
                            $newState      = 'LTR';
                            break;
                        }
                        if (($currentLen != 1) || ($currentLetter >= 'A' && $currentLetter <= 'Z') || ($currentLetter >= 'a' && $currentLetter <= 'z')) {
                            // Since it’s neither Hebrew nor Arabic, this UTF-8 character or ASCII letter must be LTR
                            $newState = 'LTR';
                            break;
                        }
                        if ($closeParIndex !== false) {
                            // This closing parenthesis has to inherit the matching opening parenthesis' directionality
                            if (!empty($openParDirection[$closeParIndex]) && $openParDirection[$closeParIndex] !== '?') {
                                $newState = $openParDirection[$closeParIndex];
                            }
                            $openParDirection[$closeParIndex] = '';
                            break;
                        }
                        if ($openParIndex !== false) {
                            // Opening parentheses always inherit the following directionality
                            self::$waitingText .= $currentLetter;
                            $workingText = substr($workingText, $currentLen);
                            while (true) {
                                if ($workingText === '') {
                                    break;
                                }
                                if (substr($workingText, 0, 1) === ' ') {
                                    // Spaces following this left parenthesis inherit the following directionality too
                                    self::$waitingText .= ' ';
                                    $workingText = substr($workingText, 1);
                                    continue;
                                }
                                if (substr($workingText, 0, 6) === '&nbsp;') {
                                    // Spaces following this left parenthesis inherit the following directionality too
                                    self::$waitingText .= '&nbsp;';
                                    $workingText = substr($workingText, 6);
                                    continue;
                                }
                                break;
                            }
                            $openParDirection[$openParIndex] = '?';
                            break 2; // double break because we're waiting for more information
                        }

                        // We have a digit or a "normal" special character.
                        //
                        // When this character is not at the start of the input string, it inherits the preceding directionality;
                        // at the start of the input string, it assumes the following directionality.
                        //
                        // Exceptions to this rule will be handled later during final clean-up.
                        //
                        self::$waitingText .= $currentLetter;
                        $workingText = substr($workingText, $currentLen);
                        if (self::$currentState != '') {
                            $result .= self::$waitingText;
                            self::$waitingText = '';
                        }
                        break 2; // double break because we're waiting for more information
                    }
                    if ($newState != self::$currentState) {
                        // A direction change has occurred
                        self::finishCurrentSpan($result);
                        self::$previousState = self::$currentState;
                        self::$currentState  = $newState;
                        self::beginCurrentSpan($result);
                    }
                    self::$waitingText .= $currentLetter;
                    $workingText       = substr($workingText, $currentLen);
                    $result            .= self::$waitingText;
                    self::$waitingText = '';

                    foreach ($openParDirection as $index => $value) {
                        // Since we now know the proper direction, remember it for all waiting opening parentheses
                        if ($value === '?') {
                            $openParDirection[$index] = self::$currentState;
                        }
                    }

                    break;
            }
        }

        // We're done. Finish last <span> if necessary
        if ($numberState) {
            if (self::$waitingText === '') {
                if (self::$currentState === 'RTL') {
                    $result .= self::UTF8_PDF;
                }
            } else {
                if (self::$currentState === 'RTL') {
                    self::$waitingText .= self::UTF8_PDF;
                }
            }
        }
        self::finishCurrentSpan($result, true);

        // Get rid of any waiting text
        if (self::$waitingText != '') {
            if (I18N::direction() === 'rtl' && self::$currentState === 'LTR') {
                $result .= self::START_RTL;
                $result .= self::$waitingText;
                $result .= self::END_RTL;
            } else {
                $result .= self::START_LTR;
                $result .= self::$waitingText;
                $result .= self::END_LTR;
            }
            self::$waitingText = '';
        }

        // Lastly, do some more cleanups

        // Move leading RTL numeric strings to following LTR text
        // (this happens when the page direction is RTL and the original text begins with a number and is followed by LTR text)
        while (substr($result, 0, self::LENGTH_START + 3) === self::START_RTL . self::UTF8_LRE) {
            $spanEnd = strpos($result, self::END_RTL . self::START_LTR);
            if ($spanEnd === false) {
                break;
            }
            $textSpan = self::stripLrmRlm(substr($result, self::LENGTH_START + 3, $spanEnd - self::LENGTH_START - 3));
            if (I18N::scriptDirection(I18N::textScript($textSpan)) === 'rtl') {
                break;
            }
            $result = self::START_LTR . substr($result, self::LENGTH_START, $spanEnd - self::LENGTH_START) . substr($result, $spanEnd + self::LENGTH_START + self::LENGTH_END);
            break;
        }

        // On RTL pages, put trailing "." in RTL numeric strings into its own RTL span
        if (I18N::direction() === 'rtl') {
            $result = str_replace(self::UTF8_PDF . '.' . self::END_RTL, self::UTF8_PDF . self::END_RTL . self::START_RTL . '.' . self::END_RTL, $result);
        }

        // Trim trailing blanks preceding <br> in LTR text
        while (self::$previousState !== 'RTL') {
            if (strpos($result, ' <LTRbr>') !== false) {
                $result = str_replace(' <LTRbr>', '<LTRbr>', $result);
                continue;
            }
            if (strpos($result, '&nbsp;<LTRbr>') !== false) {
                $result = str_replace('&nbsp;<LTRbr>', '<LTRbr>', $result);
                continue;
            }
            if (strpos($result, ' <br>') !== false) {
                $result = str_replace(' <br>', '<br>', $result);
                continue;
            }
            if (strpos($result, '&nbsp;<br>') !== false) {
                $result = str_replace('&nbsp;<br>', '<br>', $result);
                continue;
            }
            break; // Neither space nor &nbsp; : we're done
        }

        // Trim trailing blanks preceding <br> in RTL text
        while (true) {
            if (strpos($result, ' <RTLbr>') !== false) {
                $result = str_replace(' <RTLbr>', '<RTLbr>', $result);
                continue;
            }
            if (strpos($result, '&nbsp;<RTLbr>') !== false) {
                $result = str_replace('&nbsp;<RTLbr>', '<RTLbr>', $result);
                continue;
            }
            break; // Neither space nor &nbsp; : we're done
        }

        // Convert '<LTRbr>' and '<RTLbr'
        $result = str_replace([
            '<LTRbr>',
            '<RTLbr>',
        ], [
            self::END_LTR . '<br>' . self::START_LTR,
            self::END_RTL . '<br>' . self::START_RTL,
        ], $result);

        // Include leading indeterminate directional text in whatever follows
        if (substr($result . "\n", 0, self::LENGTH_START) != self::START_LTR && substr($result . "\n", 0, self::LENGTH_START) != self::START_RTL && substr($result . "\n", 0, 4) !== '<br>') {
            $leadingText = '';
            while (true) {
                if ($result == '') {
                    $result = $leadingText;
                    break;
                }
                if (substr($result . "\n", 0, self::LENGTH_START) != self::START_LTR && substr($result . "\n", 0, self::LENGTH_START) != self::START_RTL) {
                    $leadingText .= substr($result, 0, 1);
                    $result = substr($result, 1);
                    continue;
                }
                $result = substr($result, 0, self::LENGTH_START) . $leadingText . substr($result, self::LENGTH_START);
                break;
            }
        }

        // Include solitary "-" and "+" in surrounding RTL text
        $result = str_replace([
            self::END_RTL . self::START_LTR . '-' . self::END_LTR . self::START_RTL,
            self::END_RTL . self::START_LTR . '-' . self::END_LTR . self::START_RTL,
        ], [
            '-',
            '+',
        ], $result);

        // Remove empty spans
        $result = str_replace([
            self::START_LTR . self::END_LTR,
            self::START_RTL . self::END_RTL,
        ], '', $result);

        // Finally, correct '<LTR>', '</LTR>', '<RTL>', and '</RTL>'
        // LTR text: <span dir="ltr"> text </span>
        // RTL text: <span dir="rtl"> text </span>

        $result = str_replace([
            self::START_LTR,
            self::END_LTR,
            self::START_RTL,
            self::END_RTL,
        ], [
            '<span dir="ltr">',
            '</span>',
            '<span dir="rtl">',
            '</span>',
        ], $result);

        return $result;
    }
693651
public function formatMoney($amount, $currency = '€')
    {
        $symbols = array('€', '$', '£', '¥', '₤', 'kr', '₺');

        switch ($this->locale) {

            case 'de':
            case 'tr':
            case 'pt':
                $amount = number_format($amount, 2, ',', '.');
                $space = ' ';
                $format = is_string($currency) ? $amount.$space.$currency : $amount;
                break;

            case 'it':
            case 'nl':
                $amount = number_format($amount, 2, ',', '.');
                $space = ' ';
                $format = is_string($currency) ? $currency.$space.$amount : $amount;
                break;

            case 'fr':
                $amount = number_format($amount, 2, ',', ' ');
                $space = ' ';
                $format = is_string($currency) ? $amount.$space.$currency : $amount;
                break;            

            case 'ru':
                $amount = number_format($amount, 2, ',', ' ');
                $space = in_array($currency, $symbols) ? '' : ' ';
                $format = is_string($currency) ? $amount.$space.$currency : $amount;
                break;

            default:
            case 'en':
                $amount = number_format($amount, 2, '.', ',');
                $space = in_array($currency, $symbols) ? '' : ' ';
                $format = is_string($currency) ? $currency.$space.$amount : $amount;
                break;
        }

        return $format;
    }
1080419
protected function selectOption( $optionKey )
	{
		return sprintf( '<option value="%s"%s>%s</option>',
			$optionKey,
			selected( $this->args['value'], $optionKey, false ),
			$this->args['options'][ $optionKey ]
		);
	}
1307920
public function money($amount, $decimals = 2, $sourceCurrency = null)
    {
        return str_replace(
            ['{number}', '{currency}'],
            [$this->number($decimals), $this->currency()],
            $this->get('money')['format']
        );
    }
538472
protected function renderInput($key, array $input)
    {
        $html = '';
        switch ($input[ 'type' ]) {
            case 'label':
                $html .= $this->form_label($key);

                break;
            case 'legend':
                $html .= $this->form_legend($key);

                break;
            case 'select':
                $html .= $this->form_select($key);

                break;
            case 'textarea':
                $html .= $this->form_textarea($key);

                break;
            case 'group':
                $html .= $this->form_group($key);

                break;
            case 'html':
                $html .= $this->form_html($key);

                break;
            default:
                if (in_array($input[ 'type' ], $this->typeInputBasic)) {
                    $html .= $this->form_input($key);
                }
        }

        return $html;
    }
757558
public function _($translateKey, $defaultTranslation = "", $placeholders = null)
	{
		$translation = $translateKey;
		
		if (is_array($defaultTranslation) && $placeholders === null) {
			$placeholders = $defaultTranslation;
		} else {
			if ($defaultTranslation!="") {
				$translation = $defaultTranslation;
			}
		}
		if ($this->exists($translateKey)) {
			$translation = $this->_translate[$translateKey];
		}
		return $this->replacePlaceholders($translation, $placeholders);
	}
283014
public function input($key = null, $default = null)
    {
        $input = $this->getInputSource();

        return $this->inputSift($input, $key, $default);
    }
852822
private function provideCurrency($currencyCode)
    {
        $currency = $this->currencyRepository->findOneBy(['code' => $currencyCode]);
        if (null === $currency) {
            /** @var CurrencyInterface $currency */
            $currency = $this->createCurrency($currencyCode);

            $this->currencyRepository->add($currency);
        }

        return $currency;
    }
1114435
def draw_uppercase_key(self, surface, key):
        
        key.value = u'\u21e7' 
        if key.is_activated():
            key.value = u'\u21ea'
        self.draw_character_key(surface, key, True)
1139798
public function showInput()
    {
        $attributes = $this->getInputAttributes();

        if (array_key_exists('name', $attributes)) {
            $inputName = $attributes['name'];
            unset($attributes['name']);
        } else {
            $inputName = static::DEFAULT_INPUT_NAME;
        }
        $input = Input::create(
            'text',
            $inputName,
            null,
            [
                'id' => static::DEFAULT_INPUT_ID,
                'class' => 'form-control ccm-input-captcha',
                'required' => 'required',
            ]
        );
        foreach ($attributes as $attributeName => $attributeValue) {
            if ($attributeValue === null) {
                $input->removeAttribute($attributeName);
            } else {
                switch ($attributeName) {
                    case 'class':
                        $input->addClass($attributeValue);
                        break;
                    default:
                        $input->setAttribute($attributeName, $attributeValue);
                        break;
                }
            }
        }
        echo '<div>', (string) $input, '</div><br />';
    }
427342
protected function _serializeOptionalAmount($nodeName, $amount, $currencyCode=null)
	{
		if( $currencyCode)
		{
			return (!is_null($amount) && !is_nan($amount)) ? "<$nodeName currencyCode=\"$currencyCode\">{$this->_helper->formatAmount($amount)}</$nodeName>" : '';
		} else {
			return (!is_null($amount) && !is_nan($amount)) ? "<$nodeName>{$this->_helper->formatAmount($amount)}</$nodeName>" : '';
		}
	}
745399
public function reverse($giftCard, $amount, $currency = 'usd')
    {
        $txnType = 'GiftCardReversal';

        HpsInputValidation::checkCurrency($currency);
        $amount = HpsInputValidation::checkAmount($amount);

        $xml = new DOMDocument();
        $hpsTransaction = $xml->createElement('hps:Transaction');
        $hpsGiftCard = $xml->createElement('hps:'. $txnType);
        $hpsBlock1 = $xml->createElement('hps:Block1');

        $hpsBlock1->appendChild($xml->createElement('hps:Amt', $amount));
        if ($giftCard instanceof HpsGiftCard) {
            $hpsBlock1->appendChild($this->_hydrateGiftCardData($giftCard, $xml));
        } else if ( $giftCard instanceof HpsTokenData ) {
            $cardData = new HpsGiftCard();
            $cardData->tokenValue = $giftCard->tokenValue;
        } else {
            $hpsBlock1->appendChild($xml->createElement('hps:GatewayTxnId', $giftCard));
        }

        $hpsGiftCard->appendChild($hpsBlock1);
        $hpsTransaction->appendChild($hpsGiftCard);

        return $this->_submitTransaction($hpsTransaction, $txnType);
    }
765040
public function renderPk(): string
    {
        $output = '';

        if ($this->primaryKey->isComposite()) {
            $output .= "\n" . $this->primaryKey->render($this);
        }

        return $output;
    }
948506
public function getValueOfCurrentLocaleForKey($key)
    {
        $translations = $this->getAttributeValue($key);
        $currentLocale = config('app.locale');
        $fallbackLocale = config('multilingual.fallback_locale');

        if ( ! $translations) return "";

        if ( ! @$translations[$currentLocale]) {
            return @$translations[$fallbackLocale] ?: '';
        };

        return @$translations[$currentLocale];
    }
1370889
public function formatPrice($price, $currency, $locale = null)
    {
        return $this->priceManager->getFormattedPrice($price, $currency, $locale);
    }
13106
public static function getGatewayAmountOfCurrency($amount, $currencyCode) {
        $currencyCode = strtoupper($currencyCode);

        if ( ! is_numeric($amount) ) {
            throw new InvalidArgumentException('The amount value is not numeric. The [' . $amount . '] value has been given.');
        }

        $amount = (float) $amount;

        if ($amount < 0) {
            throw new InvalidArgumentException('The amount value must be positive. The [' . $amount . '] value has been given.');
        }

        if( in_array($currencyCode, self::FULL_VALUE_CURRENCIES, true) ) {
            return (int) $amount;
        }

        if( in_array($currencyCode, self::DIV_1000_VALUE_CURRENCIES, true) ) {
            return (int) ($amount * self::DIV_1000);
        }

        return (int) ($amount * self::DIV_100);
    }