Skip to content

Commit

Permalink
2.11.36
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Sep 11, 2017
1 parent 14663bc commit 8b7afd5
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Config/lib/structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function df_config_e($path, $throw = true, $expectedClass = null) {
* проверил в отладчике.
* @used-by \Df\Config\Backend::fc()
* @used-by \Df\Config\Source::f()
* @used-by \Df\Payment\Comment\Description::getCommentText()
* @used-by \Df\Payment\Comment\Description::groupPath()
* @param string|null $path [optional]
* @return Field
*/
Expand Down Expand Up @@ -132,7 +132,7 @@ function df_config_field($path = null) {

/**
* 2016-08-02
* @used-by \Df\Payment\Comment\Description::getCommentText()
* @used-by \Df\Payment\Comment\Description::locations()
* @param string $path
* @param bool $throw [optional]
* @return Group|null
Expand Down
9 changes: 8 additions & 1 deletion Core/Format/Html/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@ private function openTagWithAttributesAsText() {return df_cc_s(
* Не использую @see df_e(), чтобы сохранить двойные кавычки (data-mage-init)
* и в то же время сконвертировать одинарные
* (потому что значения атрибутов мы ниже обрамляем именно одинарными).
*
* 2017-09-11
* Today I have notices that `'` does not work for me
* on the Magento 2 backend configuration pages:
* @see \Df\Payment\Comment\Description::a()
* So I switched to the `'` solution.
* «How do I escape a single quote?» https://stackoverflow.com/a/2428595
*/
$value = htmlspecialchars(
str_replace("'", ''', !is_array($value) ? $value : df_cc_s($value))
str_replace("'", ''', !is_array($value) ? $value : df_cc_s($value))
,ENT_NOQUOTES
,'UTF-8'
,false
Expand Down
2 changes: 1 addition & 1 deletion Core/lib/array.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ function df_first(array $a) {return !$a ? null : reset($a);}
* Похожая системная функция @see array_pop() возвращает отсечённый последний элемент.
* Противоположная системная функция @see df_tail() отсекает первый элемент массива.
* @used-by \Df\Config\Source::sibling()
* @used-by \Df\Payment\Comment\Description::getCommentText()
* @used-by \Df\Payment\Comment\Description::groupPath()
* @param mixed[] $a
* @return mixed[]|string[]
*/
Expand Down
3 changes: 2 additions & 1 deletion Core/lib/html.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ function df_tag_ab($text, ...$url) {return df_tag(
);}

/**
* 2016-10-24
* 2016-10-24
* @used-by \Df\Payment\Comment\Description::a()
* @param string $content
* @param bool $condition
* @param string $tag
Expand Down
4 changes: 2 additions & 2 deletions Core/lib/text.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function df_cc_n(...$args) {return df_ccc("\n", dfa_flatten($args));}
* @used-by \Df\API\Facade::p()
* @used-by \Df\Config\Source::sibling()
* @used-by \Df\Intl\Js::_toHtml()
* @used-by \Df\Payment\Comment\Description::getCommentText()
* @used-by \Df\Payment\Comment\Description::groupPath()
* @param string[] ...$args
* @return string
*/
Expand Down Expand Up @@ -332,7 +332,7 @@ function df_explode_n($s) {return explode("\n", df_normalize($s));}

/**
* 2016-09-03 Другой возможный алгоритм: df_explode_multiple(['/', DS], $path)
* @used-by \Df\Payment\Comment\Description::getCommentText()
* @used-by \Df\Payment\Comment\Description::groupPath()
* @param string $path
* @return string[]
*/
Expand Down
56 changes: 45 additions & 11 deletions Payment/Comment/Description.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,59 @@ class Description implements IComment {
* @return string
*/
function getCommentText($v) {
/** @var string $groupPath */
$groupPath = df_cc_path(df_head(df_explode_path(df_config_field()->getPath())));
$m = df_config_group($groupPath)->getData()['dfExtension']; /** @var string $m */
$rules = df_cfg("$groupPath/description_rules"); /** @var array(string => mixed)|null $rules */
$rules = df_cfg("{$this->groupPath()}/description_rules"); /** @var array(string => mixed)|null $rules */
$maxLength = dfa($rules, 'maxLength'); /** @var array(string => mixed)|null $maxLength */
$mTitle = dfpm_title($m); /** @var string $mTitle */
$title = $maxLength['title']; /** @var string $title */
$url = $maxLength['url']; /** @var string $url */
$v = dfa($maxLength, 'value'); /** @var int|null $v */
/** @var string $to */
$to = "to you in the $mTitle merchant interface alongside the payment";
if (dfa($rules, 'shownToTheCustomers')) {
$to = "to the customers on the $mTitle payment page, and $to";
}
return
"<p class='df-note'>It will be displayed $to.</p>
"<p class='df-note'>It will be displayed {$this->locations(dfa($rules, 'locations', []))}.</p>
<p class='df-note'>You can use <a href='https://mage2.pro/t/1834' target='_blank'>some variables</a> in the description.</p>" . ($v
? "<p class='df-note'>The full description length (after the variables substitution) should be not greater than <b><a href='$url' target='_blank' title='$title'>$v characters</a></b> (the description will be automatically chopped to $v characters if it is longer).</p>"
: "<p class='df-note'>The length <a href='$url' target='_blank' title='$title'>is not limited</a>.</p>"
);
}

/**
* 2017-09-11
* @used-by locations()
* @param string $text
* @param array(string => string|bool) $o
* @return string
*/
private function a($text, array $o) {return df_tag_if($text, dfa($o, 'url'), 'a', [
'target' => '_blank', 'title' => dfa($o, 'title'), 'href' => dfa($o, 'url')
]);}

/**
* 2017-09-11
* @return string
*/
private function groupPath() {return dfc($this, function() {return df_cc_path(df_head(df_explode_path(
df_config_field()->getPath()
)));});}

/**
* 2017-09-11
* @param array(string => mixed) $locations
* @return string
*/
private function locations(array $locations) {
$customer = dfa($locations, 'customer', []); /** @var array(string => mixed)|null $customer */
$merchant = dfa($locations, 'merchant', []); /** @var array(string => mixed)|null $merchant */
$payment = dfa($locations, 'payment', []); /** @var array(string => mixed)|null $payment */
/** @var string $mTitle */
$mTitle = dfpm_title(df_config_group($this->groupPath())->getData()['dfExtension']);
/** @var string $m */
$m = !df_bool(dfa($merchant, 'shown')) ? '' :
"to you {$this->a("in the $mTitle merchant interface", $merchant)} alongside the payment"
;
/** @var string $c */
$c = !df_bool(dfa($customer, 'shown')) ? '' : $this->a("in the $mTitle customer account", $customer);
/** @var string $p */
$p = !df_bool(dfa($payment, 'shown')) ? '' :$this->a("on the $mTitle payment page", $payment);
/** @var string $c */
$cc = !($c || $p) ? '' : 'to the customers' . ($c && $p ? ": $c and $p" : ' ' . ($c ?: $p));
return df_ccc(' and ', $m, $cc);
}
}
3 changes: 2 additions & 1 deletion Payment/lib/method.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ function dfpm_code_short($c) {return df_trim_text_left(dfpm_code($c), 'dfe_');}
* 2016-12-22
* @used-by dfp_report()
* @used-by dfp_sentry_tags()
* @used-by \Df\Payment\Comment\Description::locations()
* @used-by \Df\Payment\Settings::titleB()
* @used-by \Df\Payment\W\Action::notImplemented()
* @used-by \Df\Payment\W\Exception::mTitle()
* @used-by \Df\Payment\Settings::titleB()
* @used-by \Df\Payment\W\Handler::log()
* @param string|object $c
* @return string
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mage2pro/core"
,"version": "2.11.35"
,"version": "2.11.36"
,"description": "Mage2.PRO core package."
,"type": "magento2-module"
,"homepage": "https://mage2.pro"
Expand Down

0 comments on commit 8b7afd5

Please sign in to comment.