Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
file.php
1<?php
2
4
7
8Localization\Loc::loadMessages(__FILE__);
9
10require_once __DIR__.'/../../internals/input.php';
11
16class File extends Input\Base
17{
23 public static function getViewHtmlSingle(array $input, $value)
24 {
25 $result = '<span>';
26 if ($value)
27 {
28 $result .= Localization\Loc::getMessage('SALE_CASHBOX_INPUT_SECURITY_FILE_CONTROL_LOADED');
29 }
30 $result .= '</span>&nbsp;';
31
32 return $result;
33 }
34
41 public static function getEditHtmlSingle($name, array $input, $value)
42 {
43 $input['ONCHANGE'] =
44 "var anchor = this.previousElementSibling.previousElementSibling;".
45 "if (anchor.firstChild) anchor.removeChild(anchor.firstChild);".
46 "anchor.appendChild(document.createTextNode(this.value.split(/(\\\\|\\/)/g).pop()));".
47 ($input['ONCHANGE'] ?? '');
48
49 $fileAttributes = static::extractAttributes($input,
50 array('DISABLED'=>'', 'AUTOFOCUS'=>'', 'REQUIRED'=>''),
51 array('FORM'=>1, 'ACCEPT'=>1));
52
53 $otherAttributes = static::extractAttributes($input, array('DISABLED'=>''), array('FORM'=>1), false);
54
55 return static::getViewHtmlSingle($input, $value)
56 .'<input type="hidden" name="'.$name.'" value="'.htmlspecialcharsbx($value).'"'.$otherAttributes.'>'
57 .'<input type="file" name="'.$name.'" style="position:absolute; visibility:hidden"'.$fileAttributes.'>'
58 .'<input type="button" value="'.Localization\Loc::getMessage('SALE_CASHBOX_INPUT_SECURITY_FILE_CONTROL_BROWSE').'" onclick="this.previousSibling.click()">'
59 .(
60 $input['NO_DELETE']
61 ? ''
62 : '<label>'.Localization\Loc::getMessage('SALE_CASHBOX_INPUT_SECURITY_FILE_CONTROL_DELETE').' <input type="checkbox" name="'.$name.'[DELETE]" onclick="'
63 ."var button = this.parentNode.previousSibling, file = button.previousSibling;"
64 ."button.disabled = file.disabled = this.checked;"
65 .'"'.$otherAttributes.'></label>'
66 );
67 }
68
74 public static function getErrorSingle(array $input, $value)
75 {
76 $errors = [];
77 return $errors;
78 }
79}
80
85Input\Manager::register('SECURITY_FILE_CONTROL', array(
86 'CLASS' => __NAMESPACE__.'\\File',
87 'NAME' => Localization\Loc::getMessage('SALE_CASHBOX_INPUT_SECURITY_FILE_CONTROL')
88));
89
90Input\Manager::register('DATABASE_FILE', array(
91 'CLASS' => __NAMESPACE__.'\\File',
92 'NAME' => Localization\Loc::getMessage('SALE_CASHBOX_INPUT_SECURITY_FILE_CONTROL')
93));
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getViewHtmlSingle(array $input, $value)
Definition file.php:23
static getEditHtmlSingle($name, array $input, $value)
Definition file.php:41
static getErrorSingle(array $input, $value)
Definition file.php:74