forked from oscarotero/Embed
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.php
179 lines (160 loc) · 3.83 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
<?php
function autoload ($className) {
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strripos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
if (is_file($fileName)) {
require $fileName;
}
}
spl_autoload_register('autoload');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Embed tests</title>
<style type="text/css">
body {
font-family: sans-serif;
}
input {
width: 400px;
}
fieldset {
border: none;
background: #DDD;
font-weight: bold;
}
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>
<body>
<form action="test.php">
<fieldset>
<label>Url to test: <input type="url" name="url" autofocus placeholder="http://"></label>
<button type="submit">Test</button>
</fieldset>
</form>
<?php if (!empty($_GET['url'])): ?>
<section>
<?php
$Url = new Embed\Url($_GET['url']);
$Service = Embed\Embed::create($Url);
?>
<?php if (empty($Service)): ?>
<p>The url is not valid!</p>
<?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>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>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>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>