Skip to content

Commit

Permalink
Merge pull request #30 from nook-ru/cp1251_fix
Browse files Browse the repository at this point in the history
Исправления для корректной работы на windows-1251 установках
  • Loading branch information
niksamokhvalov authored Jun 10, 2016
2 parents e35c770 + 13027fa commit aa6e969
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 9 deletions.
4 changes: 4 additions & 0 deletions lang/ru/lib/EntityManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
$MESS['DIGITALWAND_AH_RELATION_SHOULD_BE_MULTIPLE_FIELD'] = "Связь должна быть множественным полем";
$MESS['DIGITALWAND_AH_ARGUMENT_CANT_CONTAIN_ID'] = "Аргумент %A% не может содержать идентификатор элемента";
$MESS['DIGITALWAND_AH_ARGUMENT_SHOULD_CONTAIN_ID'] = "Аргумент %A% должен содержать идентификатор элемента";
3 changes: 2 additions & 1 deletion lang/ru/lib/widget/OrmElementWidget.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php

$MESS['TITLE_FIELD_NAME'] = 'Элемент не найден';
$MESS['TITLE_FIELD_NAME'] = 'Элемент не найден';
$MESS['DIGITALWAND_AH_ORM_MISSING_ELEMENTS'] = 'Элементы не найдены';
6 changes: 3 additions & 3 deletions lib/EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ protected function collectReferencesData()
foreach ($references as $fieldName => $reference) {
if (array_key_exists($fieldName, $this->data)) {
if (!is_array($this->data[$fieldName])) {
$result->addError(new Entity\EntityError('Связь должна быть множественным полем'));
$result->addError(new Entity\EntityError(Loc::getMessage('DIGITALWAND_AH_RELATION_SHOULD_BE_MULTIPLE_FIELD')));

return $result;
}
Expand Down Expand Up @@ -460,7 +460,7 @@ protected function createReferenceData(Entity\ReferenceField $reference, array $
$fieldWidget = $this->getFieldWidget($referenceName);

if (!empty($referenceData[$fieldWidget->getMultipleField('ID')])) {
throw new ArgumentException('Аргумент data не может содержать идентификатор элемента', 'data');
throw new ArgumentException(Loc::getMessage('DIGITALWAND_AH_ARGUMENT_CANT_CONTAIN_ID', array('%A%' => 'referenceData')), 'referenceData');
}

$refClass = $reference->getRefEntity()->getDataClass();
Expand Down Expand Up @@ -496,7 +496,7 @@ protected function updateReferenceData(
$fieldWidget = $this->getFieldWidget($referenceName);

if (empty($referenceData[$fieldWidget->getMultipleField('ID')])) {
throw new ArgumentException('Аргумент data должен содержать идентификатор элемента', 'data');
throw new ArgumentException(Loc::getMessage('DIGITALWAND_AH_ARGUMENT_SHOULD_CONTAIN_ID', array('%A%' => 'referenceData')), 'referenceData');
}

// Сравнение старых данных и новых, обновляется только при различиях
Expand Down
7 changes: 7 additions & 0 deletions lib/helper/AdminEditHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ public function __construct(array $fields, array $tabs = array())
$this->tabControl = new \CAdminForm(str_replace("\\", "", get_called_class()), $this->tabs);

if (isset($_REQUEST['apply']) OR isset($_REQUEST['save'])) {
if (
isset($_SERVER["HTTP_BX_AJAX"])
||
isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && $_SERVER["HTTP_X_REQUESTED_WITH"] === "XMLHttpRequest"
) {
\CUtil::JSPostUnescape();
}
$this->data = $_REQUEST['FIELDS'];

if (isset($_REQUEST[$this->pk()])) {
Expand Down
2 changes: 1 addition & 1 deletion lib/widget/ComboBoxWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected function getMultipleValueReadonly()
$result = '';

if (empty($variants)) {
$result = 'Не удалось получить данные для выбора';
$result = Loc::getMessage('DIGITALWAND_AH_MISSING_VARIANTS');
} else {
foreach ($variants as $id => $data) {
$name = strlen($data["TITLE"]) > 0 ? $data["TITLE"] : "";
Expand Down
6 changes: 3 additions & 3 deletions lib/widget/HelperWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public static function prepareToOutput($string, $hideTags = true)
if ($hideTags) {
return preg_replace('/<.+>/mU', '', $string);
} else {
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
return htmlspecialchars($string, ENT_QUOTES, SITE_CHARSET);
}
}

Expand All @@ -370,7 +370,7 @@ public static function prepareToOutput($string, $hideTags = true)
public static function prepareToTagAttr($string)
{
// Не используйте addcslashes в этом методе, иначе в тегах будут дубли обратных слешей
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
return htmlspecialchars($string, ENT_QUOTES, SITE_CHARSET);
}

/**
Expand All @@ -382,7 +382,7 @@ public static function prepareToTagAttr($string)
*/
public static function prepareToJs($string)
{
$string = htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
$string = htmlspecialchars($string, ENT_QUOTES, SITE_CHARSET);
$string = addcslashes($string, "\r\n\"\\");

return $string;
Expand Down
2 changes: 1 addition & 1 deletion lib/widget/OrmElementWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function genEditHtmlInputs()
$return .= InputType("radio", $this->getEditInputName(), $element['ID'], $this->getValue(), false, $element['TITLE']);
}
} else {
$return = 'Элементы не найдены';
$return = Loc::getMessage('DIGITALWAND_AH_ORM_MISSING_ELEMENTS');
}

return $return;
Expand Down

0 comments on commit aa6e969

Please sign in to comment.