Skip to content

Commit ca532d7

Browse files
committed
Use OptionsRenderer in s3-options-page
1 parent 5ec37f5 commit ca532d7

1 file changed

Lines changed: 57 additions & 253 deletions

File tree

views/s3/s3-options-page.php

Lines changed: 57 additions & 253 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,39 @@
55
/**
66
* @var mixed[] $view
77
*/
8+
9+
use WP2Static\OptionRenderer;
10+
use WP2Static\S3\S3Options;
11+
12+
/**
13+
* @var array<string, mixed> $options
14+
*/
15+
$options = $view['options'];
16+
17+
$row = function ( $slug ) use ( $options ) {
18+
$name = S3Options::getName( $slug );
19+
$opt = $options[ $name ];
20+
return '<tr><td style="width: 50%">' . OptionRenderer::optionLabel( $opt, true ) .
21+
'</td><td>' . OptionRenderer::optionInput( $opt ) . '</td></tr>';
22+
};
23+
24+
$object_acl_name = S3Options::getName( 'objectAcl' );
25+
826
?>
927

1028
<h2>S3 Deployment Options</h2>
1129

30+
<h3>AWS Credentials</h3>
31+
32+
<table class="widefat striped">
33+
<tbody>
34+
<?php echo $row( 'awsAccessKeyId' ); ?>
35+
<?php echo $row( 'awsSecretAccessKey' ); ?>
36+
<?php echo $row( 'awsRegion' ); ?>
37+
<?php echo $row( 'awsProfile' ); ?>
38+
</tbody>
39+
</table>
40+
1241
<h3>S3</h3>
1342

1443
<form
@@ -21,266 +50,41 @@
2150

2251
<table class="widefat striped">
2352
<tbody>
24-
25-
<tr>
26-
<td style="width:50%;">
27-
<label
28-
for="<?php echo $view['options']['s3Bucket']->name; ?>"
29-
><?php echo $view['options']['s3Bucket']->label; ?></label>
30-
</td>
31-
<td>
32-
<input
33-
id="<?php echo $view['options']['s3Bucket']->name; ?>"
34-
name="<?php echo $view['options']['s3Bucket']->name; ?>"
35-
type="text"
36-
value="<?php echo $view['options']['s3Bucket']->value !== '' ? $view['options']['s3Bucket']->value : ''; ?>"
37-
/>
38-
</td>
39-
</tr>
40-
41-
<tr>
42-
<td style="width:50%;">
43-
<label
44-
for="<?php echo $view['options']['s3Region']->name; ?>"
45-
><?php echo $view['options']['s3Region']->label; ?></label>
46-
</td>
47-
<td>
48-
<input
49-
id="<?php echo $view['options']['s3Region']->name; ?>"
50-
name="<?php echo $view['options']['s3Region']->name; ?>"
51-
type="text"
52-
value="<?php echo $view['options']['s3Region']->value !== '' ? $view['options']['s3Region']->value : ''; ?>"
53-
/>
54-
</td>
55-
</tr>
56-
57-
<tr>
58-
<td style="width:50%;">
59-
<label
60-
for="<?php echo $view['options']['s3AccessKeyID']->name; ?>"
61-
><?php echo $view['options']['s3AccessKeyID']->label; ?></label>
62-
</td>
63-
<td>
64-
<input
65-
id="<?php echo $view['options']['s3AccessKeyID']->name; ?>"
66-
name="<?php echo $view['options']['s3AccessKeyID']->name; ?>"
67-
value="<?php echo $view['options']['s3AccessKeyID']->value !== '' ? $view['options']['s3AccessKeyID']->value : ''; ?>"
68-
/>
69-
</td>
70-
</tr>
71-
72-
<tr>
73-
<td style="width:50%;">
74-
<label
75-
for="<?php echo $view['options']['s3SecretAccessKey']->name; ?>"
76-
><?php echo $view['options']['s3SecretAccessKey']->label; ?></label>
77-
</td>
78-
<td>
79-
<input
80-
id="<?php echo $view['options']['s3SecretAccessKey']->name; ?>"
81-
name="<?php echo $view['options']['s3SecretAccessKey']->name; ?>"
82-
type="password"
83-
value="<?php echo $view['options']['s3SecretAccessKey']->value !== '' ?
84-
\WP2Static\CoreOptions::encrypt_decrypt( 'decrypt', $view['options']['s3SecretAccessKey']->value ) :
85-
''; ?>"
86-
/>
87-
</td>
88-
</tr>
89-
90-
<tr>
91-
<td style="width:50%;">
92-
<label
93-
for="<?php echo $view['options']['s3Profile']->name; ?>"
94-
><?php echo $view['options']['s3Profile']->label; ?></label>
95-
</td>
96-
<td>
97-
<input
98-
id="<?php echo $view['options']['s3Profile']->name; ?>"
99-
name="<?php echo $view['options']['s3Profile']->name; ?>"
100-
type="text"
101-
value="<?php echo $view['options']['s3Profile']->value !== '' ? $view['options']['s3Profile']->value : ''; ?>"
102-
/>
103-
</td>
104-
</tr>
105-
106-
107-
<tr>
108-
<td style="width:50%;">
109-
<label
110-
for="<?php echo $view['options']['s3RemotePath']->name; ?>"
111-
><?php echo $view['options']['s3RemotePath']->label; ?></label>
112-
</td>
113-
<td>
114-
<input
115-
id="<?php echo $view['options']['s3RemotePath']->name; ?>"
116-
name="<?php echo $view['options']['s3RemotePath']->name; ?>"
117-
type="text"
118-
value="<?php echo $view['options']['s3RemotePath']->value !== '' ? $view['options']['s3RemotePath']->value : ''; ?>"
119-
/>
120-
</td>
121-
</tr>
122-
123-
<tr>
124-
<td style="width:50%;">
125-
<label
126-
for="<?php echo $view['options']['s3CacheControl']->name; ?>"
127-
><?php echo $view['options']['s3CacheControl']->label; ?></label>
128-
</td>
129-
<td>
130-
<input
131-
id="<?php echo $view['options']['s3CacheControl']->name; ?>"
132-
name="<?php echo $view['options']['s3CacheControl']->name; ?>"
133-
type="text"
134-
value="<?php echo $view['options']['s3CacheControl']->value !== '' ? $view['options']['s3CacheControl']->value : ''; ?>"
135-
/>
136-
</td>
137-
</tr>
138-
139-
<tr>
140-
<td style="width:50%;">
141-
<label
142-
for="<?php echo $view['options']['s3ObjectACL']->name; ?>"
143-
><?php echo $view['options']['s3ObjectACL']->label; ?></label>
144-
</td>
145-
<td>
146-
<select
147-
id="<?php echo $view['options']['s3ObjectACL']->name; ?>"
148-
name="<?php echo $view['options']['s3ObjectACL']->name; ?>"
149-
>
150-
<option
151-
<?php if ( $view['options']['s3ObjectACL']->value === 'public-read' ) {
152-
echo 'selected'; } ?>
153-
value="public-read">public-read</option>
154-
<option
155-
<?php if ( $view['options']['s3ObjectACL']->value === 'private' ) {
156-
echo 'selected'; } ?>
157-
value="private">private</option>
158-
</select>
159-
</td>
160-
</tr>
161-
162-
<tr>
163-
<td style="width:50%;">
164-
<label
165-
for="<?php echo $view['options']['s3Concurrency']->name; ?>"
166-
><?php echo $view['options']['s3Concurrency']->label; ?></label>
167-
</td>
168-
<td>
169-
<input
170-
id="<?php echo $view['options']['s3Concurrency']->name; ?>"
171-
name="<?php echo $view['options']['s3Concurrency']->name; ?>"
172-
type="text"
173-
value="<?php echo $view['options']['s3Concurrency']->value !== '' ? $view['options']['s3Concurrency']->value : ''; ?>"
174-
/>
175-
</td>
176-
</tr>
177-
53+
<?php echo $row( 'bucketName' ); ?>
54+
<?php echo $row( 'bucketPrefix' ); ?>
55+
<?php echo $row( 'headerCacheControl' ); ?>
56+
<tr>
57+
<td style="width:50%;">
58+
<label
59+
for="<?php echo $object_acl_name; ?>"
60+
><?php echo $view['options'][ $object_acl_name ]->option_spec->label; ?></label>
61+
</td>
62+
<td>
63+
<select
64+
id="<?php echo $object_acl_name; ?>"
65+
name="<?php echo $object_acl_name; ?>"
66+
>
67+
<option
68+
<?php if ( $view['options'][ $object_acl_name ]->value === 'public-read' ) {
69+
echo 'selected'; } ?>
70+
value="public-read">public-read</option>
71+
<option
72+
<?php if ( $view['options'][ $object_acl_name ]->value === 'private' ) {
73+
echo 'selected'; } ?>
74+
value="private">private</option>
75+
</select>
76+
</td>
77+
</tr>
78+
<?php echo $row( 'concurrency' ); ?>
17879
</tbody>
17980
</table>
18081

181-
18282
<h3>CloudFront</h3>
18383

18484
<table class="widefat striped">
18585
<tbody>
186-
187-
<tr>
188-
<td style="width:50%;">
189-
<label
190-
for="<?php echo $view['options']['cfRegion']->name; ?>"
191-
><?php echo $view['options']['cfRegion']->label; ?></label>
192-
</td>
193-
<td>
194-
<input
195-
id="<?php echo $view['options']['cfRegion']->name; ?>"
196-
name="<?php echo $view['options']['cfRegion']->name; ?>"
197-
type="text"
198-
value="<?php echo $view['options']['cfRegion']->value !== '' ? $view['options']['cfRegion']->value : ''; ?>"
199-
/>
200-
</td>
201-
</tr>
202-
203-
<tr>
204-
<td style="width:50%;">
205-
<label
206-
for="<?php echo $view['options']['cfAccessKeyID']->name; ?>"
207-
><?php echo $view['options']['cfAccessKeyID']->label; ?></label>
208-
</td>
209-
<td>
210-
<input
211-
id="<?php echo $view['options']['cfAccessKeyID']->name; ?>"
212-
name="<?php echo $view['options']['cfAccessKeyID']->name; ?>"
213-
value="<?php echo $view['options']['cfAccessKeyID']->value !== '' ? $view['options']['cfAccessKeyID']->value : ''; ?>"
214-
/>
215-
</td>
216-
</tr>
217-
218-
<tr>
219-
<td style="width:50%;">
220-
<label
221-
for="<?php echo $view['options']['cfSecretAccessKey']->name; ?>"
222-
><?php echo $view['options']['cfSecretAccessKey']->label; ?></label>
223-
</td>
224-
<td>
225-
<input
226-
id="<?php echo $view['options']['cfSecretAccessKey']->name; ?>"
227-
name="<?php echo $view['options']['cfSecretAccessKey']->name; ?>"
228-
type="password"
229-
value="<?php echo $view['options']['cfSecretAccessKey']->value !== '' ?
230-
\WP2Static\CoreOptions::encrypt_decrypt( 'decrypt', $view['options']['cfSecretAccessKey']->value ) :
231-
''; ?>"
232-
/>
233-
</td>
234-
</tr>
235-
236-
<tr>
237-
<td style="width:50%;">
238-
<label
239-
for="<?php echo $view['options']['cfProfile']->name; ?>"
240-
><?php echo $view['options']['cfProfile']->label; ?></label>
241-
</td>
242-
<td>
243-
<input
244-
id="<?php echo $view['options']['cfProfile']->name; ?>"
245-
name="<?php echo $view['options']['cfProfile']->name; ?>"
246-
type="text"
247-
value="<?php echo $view['options']['cfProfile']->value !== '' ? $view['options']['cfProfile']->value : ''; ?>"
248-
/>
249-
</td>
250-
</tr>
251-
252-
<tr>
253-
<td style="width:50%;">
254-
<label
255-
for="<?php echo $view['options']['cfDistributionID']->name; ?>"
256-
><?php echo $view['options']['cfDistributionID']->label; ?></label>
257-
</td>
258-
<td>
259-
<input
260-
id="<?php echo $view['options']['cfDistributionID']->name; ?>"
261-
name="<?php echo $view['options']['cfDistributionID']->name; ?>"
262-
type="text"
263-
value="<?php echo $view['options']['cfDistributionID']->value !== '' ? $view['options']['cfDistributionID']->value : ''; ?>"
264-
/>
265-
</td>
266-
</tr>
267-
268-
<tr>
269-
<td style="width:50%;">
270-
<label
271-
for="<?php echo $view['options']['cfMaxPathsToInvalidate']->name; ?>"
272-
><?php echo $view['options']['cfMaxPathsToInvalidate']->label; ?></label>
273-
</td>
274-
<td>
275-
<input
276-
id="<?php echo $view['options']['cfMaxPathsToInvalidate']->name; ?>"
277-
name="<?php echo $view['options']['cfMaxPathsToInvalidate']->name; ?>"
278-
type="text"
279-
value="<?php echo $view['options']['cfMaxPathsToInvalidate']->value !== '' ? $view['options']['cfMaxPathsToInvalidate']->value : ''; ?>"
280-
/>
281-
</td>
282-
</tr>
283-
86+
<?php echo $row( 'distributionId' ); ?>
87+
<?php echo $row( 'maxPathsToInvalidate' ); ?>
28488
</tbody>
28589
</table>
28690

0 commit comments

Comments
 (0)