65 {
66 $wopi_discovery_url = $this->
settings->get(
"wopi_discovery_url");
67 $saving_interval_value = (
int) $this->
settings->get(
"saving_interval",
'0');
68 $saving_interval_value = $saving_interval_value === 0 ? null : $saving_interval_value;
69
70 $wopi_url = $this->ui_factory
71 ->input()
72 ->field()
73 ->text(
74 $this->
lng->txt(
"wopi_url"),
75 $this->
lng->txt(
"wopi_url_byline")
76 )
77 ->withDisabled(!$this->write_access)
78 ->withAdditionalTransformation(
79 $this->
refinery->custom()->transformation(fn($v) => $v ===
'' ?
null : $v)
81 $this->
refinery->custom()->constraint(
function ($v):
bool {
82 if ($v === null) {
83 return false;
84 }
86 }, $this->
lng->txt(
'msg_error_wopi_invalid_discorvery_url'))
88 $this->
refinery->custom()->transformation(
function ($v):
true {
89 $this->
settings->set(
"wopi_discovery_url", $v);
90
91 return true;
92 })
93 )->withValue(
94 $wopi_discovery_url ?? ''
95 );
96
97 $saving_interval = $this->ui_factory->input()->field()->optionalGroup(
98 [
99 $this->ui_factory
100 ->input()
101 ->field()
102 ->numeric(
103 $this->
lng->txt(
"saving_interval"),
104 $this->lng->txt("saving_interval_byline")
105 )
106 ->withDisabled(!$this->write_access)
107 ->withAdditionalTransformation(
108 $this->
refinery->custom()->transformation(fn($v) => $v ===
'' ?
null : $v)
109 )->withAdditionalTransformation(
110 $this->
refinery->custom()->transformation(function ($v):
true {
111 if ($v === null || $v === 0) {
112 $this->
settings->delete(
"saving_interval");
113 return true;
114 }
115
116 $this->
settings->set(
"saving_interval", (
string) $v);
117
118 return true;
119 })
120 )->withValue(
121 $saving_interval_value
122 )
123 ],
124 $this->
lng->txt(
"activate_saving_interval")
126 $saving_interval_value === null ? null : [$saving_interval_value]
127 )->withAdditionalTransformation(
128 $this->
refinery->custom()->transformation(
function ($v) {
129 if ($v === null || $v === [null]) {
130 $this->
settings->delete(
"saving_interval");
131 }
132 return $v;
133 })
134 );
135
136 return $this->ui_factory
137 ->input()
138 ->field()
139 ->section(
140 [
141 $this->ui_factory
142 ->input()
143 ->field()
144 ->optionalGroup(
145 [$wopi_url, $saving_interval],
146 $this->
lng->txt(
"activate_wopi")
147 )
148 ->withDisabled(!$this->write_access)
149 ->withValue(
150 $wopi_discovery_url === null ? null : [
151 $wopi_discovery_url,
152 $saving_interval_value === null ? null : [$saving_interval_value]
153 ]
154 )->withAdditionalTransformation(
155 $this->
refinery->custom()->transformation(function ($v) {
156 if ($v === null || $v === [null]) {
157 $this->
settings->set(
"wopi_activated",
'0');
158 $this->
settings->delete(
"wopi_discovery_url");
159 } else {
160 $this->
settings->set(
"wopi_activated",
"1");
161 }
162 return $v;
163 })
164 )
165 ],
166 $this->
lng->txt(
"wopi_settings"),
167 );
168 }
The scope of this class is split ilias-conform URI's into components.