forked from oscarotero/Embed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
224 lines (205 loc) · 5.57 KB
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?php include('Embed/autoloader.php'); ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Embed tests</title>
<style type="text/css">
body {
font-family: sans-serif;
}
input[type="url"] {
width: 400px;
}
input[type="number"] {
width: 50px;
}
fieldset.main {
border: none;
background: #DDD;
font-weight: bold;
}
fieldset.options {
border: none;
background: #DDD;
font-size: 0.9em;
}
img {
border: solid 1px black;
}
table.embed {
width: 100%;
}
table.embed th,
table.embed td {
padding-top: 5px;
padding-bottom: 5px;
border-top: solid 1px #CCC;
vertical-align: top;
}
table.embed th {
text-align: right;
}
table.embed td {
padding-left: 20px;
}
</style>
</head>
<?php
function getOption ($name, $default = null) {
return isset($_GET['options'][$name]) ? $_GET['options'][$name] : $default;
}
?>
<body>
<form action="test.php">
<fieldset class="main">
<label>Url to test: <input type="url" name="url" autofocus placeholder="http://" value="<?php echo isset($_GET['url']) ? $_GET['url'] : ''; ?>"></label>
<button type="submit">Test</button>
</fieldset>
<fieldset class="options">
<label>Min image width: <input type="number" name="options[minImageWidth]" value="<?php echo getOption('minImageWidth', 0); ?>"></label>
<label>Min image height: <input type="number" name="options[minImageHeight]" value="<?php echo getOption('minImageHeight', 0); ?>"></label>
<label><input type="checkbox" name="options[getBiggerImage]" value="1" <?php echo getOption('getBiggerImage') ? 'checked' : ''; ?>> Get bigger image</label>
<label><input type="checkbox" name="options[getBiggerIcon]" value="1" <?php echo getOption('getBiggerIcon') ? 'checked' : ''; ?>> Get bigger icon</label>
<br>
<label>Facebook access token<input type="text" name="options[facebookAccessToken]" value="<?php echo getOption('facebookAccessToken'); ?>"></label>
</fieldset>
</form>
<?php if (!empty($_GET['url'])): ?>
<section>
<?php
$Url = new Embed\Url($_GET['url']);
$options = isset($_GET['options']) ? (array)$_GET['options'] : array();
$Service = Embed\Embed::create($Url, $options);
?>
<?php if (empty($Service)): ?>
<p>The url is not valid!</p>
<table class="embed">
<tr>
<th>Http request result</th>
<td>
<ul>
<?php
foreach ($Url->getResult() as $name => $value) {
if (is_array($value)) {
$value = print_r($value, true);
}
echo "<li><strong>$name:</strong> $value</li>";
}
?>
</ul>
</td>
</tr>
</table>
<?php else: ?>
<table class="embed">
<tr>
<th>Title</th>
<td><?php echo $Service->title; ?></td>
</tr>
<tr>
<th>Description</th>
<td><?php echo $Service->description; ?></td>
</tr>
<tr>
<th>Image</th>
<td><img src="<?php echo $Service->image; ?>"> <?php echo $Service->image; ?></td>
</tr>
<tr>
<th>Image size</th>
<td><?php echo $Service->imageWidth.' x '.$Service->imageHeight; ?></td>
</tr>
<tr>
<th>All images</th>
<td><pre><?php print_r($Service->images); ?></pre></td>
</tr>
<tr>
<th>Embed code</th>
<td><?php echo $Service->code; ?></td>
</tr>
<tr>
<th>Url</th>
<td><?php echo $Service->url; ?></td>
</tr>
<tr>
<th>Type</th>
<td><?php echo $Service->type; ?></td>
</tr>
<tr>
<th>Source</th>
<td><?php
if ($Service->source) {
echo $Service->source;
echo ' / <a href="test-sources.php?url='.urlencode($Service->source).'" target="_blank">Test</a>';
}
?>
</td>
</tr>
<tr>
<th>Author name</th>
<td><?php echo $Service->authorName; ?></td>
</tr>
<tr>
<th>Author url</th>
<td><?php echo $Service->authorUrl; ?></td>
</tr>
<tr>
<th>Provider icon</th>
<td><img src="<?php echo $Service->providerIcon; ?>"> <?php echo $Service->providerIcon; ?></td>
</tr>
<tr>
<th>All icons</th>
<td><pre><?php print_r($Service->providerIcons); ?></pre></td>
</tr>
<tr>
<th>Provider name</th>
<td><?php echo $Service->providerName; ?></td>
</tr>
<tr>
<th>Provider url</th>
<td><?php echo $Service->providerUrl; ?></td>
</tr>
<tr>
<th>Width</th>
<td><?php echo $Service->width; ?></td>
</tr>
<tr>
<th>Height</th>
<td><?php echo $Service->height; ?></td>
</tr>
<tr>
<th>Aspect ratio</th>
<td><?php echo $Service->aspectRatio; ?></td>
</tr>
<tr>
<th>Http request result</th>
<td>
<ul>
<?php
foreach ($Url->getResult() as $name => $value) {
if (is_array($value)) {
$value = print_r($value, true);
}
echo "<li><strong>$name:</strong> $value</li>";
}
?>
</ul>
</td>
</tr>
<?php foreach ($Service->providers as $name => $Provider) {
$content = htmlspecialchars(print_r($Provider, true), ENT_IGNORE);
echo '<tr><th>'.$name.'</th><td><pre>'.$content.'</pre></td></tr>';
}
?>
<tr>
<th>Content</th>
<td>
<pre><?php echo htmlspecialchars($Url->getContent(), ENT_IGNORE); ?></pre>
</td>
</tr>
</table>
<?php endif; ?>
</section>
<?php endif; ?>
</body>
</html>