-
Notifications
You must be signed in to change notification settings - Fork 5
/
FunctionalTemplatingHTML5.php
375 lines (291 loc) · 6.26 KB
/
FunctionalTemplatingHTML5.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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<?php
/*
Author: Joy Harvel
Name: Functional Templating - All HTML 5 Elements
Description:Creates functions for creating HTML elements via function calls
Note: Incomplete and unoptimized
ToDo:
[ ] Add All HTML 5 Elements with required attributes
[ ] Convert params to array of key value pairs and check for required params
[x] Add setting for error reporting (X required param was missing from Y element with the ID of NNNN)
[ ] Add error reporting to all functions
[ ] Add Global Attributes & Event Attributes as params
Example:
<?php
// Area Map Example
$area_arr = array(AREA('area-1', 'CSSClass', '0,0,10,10'), AREA('area-2', 'CSSClass', '0,10,10,20'));
$page = MAP('my-map', 'my-map', 'CSSClass' 0, $area_arr);
$page .= '<img src="image.png" usemap="#my-map">';
echo $page;
?>
*/
define('INDENT', ' '); // 4 spaces
define('RPTERR', false); // true/false - Error Report Toggle
/*
<a></a>
A('home-btn', 'btn btn-primary', 'Visit My Site', 0, 'JoyHarvel.com');
*/
function A($id, $class, $html, $indent = 0, $href = '#', $hreflang = 'en', $target='_self', $download = false){
$output = str_repeat(INDENT, $indent);
$output .= "<a id='$id' class='$class' href='$href' hreflang='$hreflang' target='$target'";
if($download == true){ $output .= ' download';}
$output .= ">$html</a>" . PHP_EOL;
return $output;
}
/*
<abbr></abbr>
ABBR('elem-1234', 'CSSClass', 'ASAP', 'As Soon As Possible');
*/
function ABBR($id, $class, $html, $title, $indent = 0){
$output = str_repeat(INDENT, $indent);
$output .= "<abbr id='$id' class='$class' title='$title'>$html</abbr>" . PHP_EOL;
return $output;
}
/*
<area></area>
$area_arr = array(AREA('area-1', 'CSSClass', '0,0,10,10'), AREA('area-2', 'CSSClass', '0,10,10,20'));
echo MAP('my-map', 'my-map', 'CSSClass' 0, $area_arr);
echo '<img src="image.png" usemap="#my-map">';
*/
function AREA($id, $class, $coords, $shape = 'rect', $href = '#', $alt = "Link", $target = '_self'){
$output = "<area id='$id' class='$class' shape='$shape' coords='$coords' href='$href' alt='$alt' target='$target'>" . PHP_EOL;
return $output;
}
/*
<article></article>
ARTICLE( 'ID', 'CSSClass', 'ASAP', 'As Soon As Possible');
*/
function ARTICLE($id, $class, $html, $title, $indent = 0){
$output = str_repeat(INDENT, $indent);
$output .= "<article id='$id' class='$class' title='$title'>$html</article>" . PHP_EOL;
return $output;
}
/*
<aside></aside>
ASIDE('ID', 'CSSClass', 'Aside from the content around this');
*/
function ASIDE($id, $class, $html, $indent = 0){
$output = str_repeat(INDENT, $indent);
$output .= "<aside id='$id' class='$class'>$html</aside>" . PHP_EOL;
return $output;
}
/*
<audio></audio>
AUDIO('ID', 'CSSClass', array());
*/
function AUDIO($id, $class, $sources, $indent = 0, $controls = true){
$output = str_repeat(INDENT, $indent);
$output .= "<audio id='$id' class='$class'";
if($controls == true){ $output .= ' controls';}
$output .= ">" . PHP_EOL;
foreach($sources as $source){
$output .= str_repeat(INDENT, $indent + 1) . $source . PHP_EOL;
}
$output .= "Your browser does not support the audio tag.</audio>" . PHP_EOL;
return $output;
}
/*
<b></b>
*/
function B($id, $class, $html, $indent = 0){
$output = str_repeat(INDENT, $indent);
$output .= "<b id='$id' class='$class'>$html</b>" . PHP_EOL;
return $output;
}
/*
<base>
BASE('home-btn', 0, 'JoyHarvel.com');
*/
function BASE($id, $indent = 0, $href = '#', $target = '_self'){
$output = str_repeat(INDENT, $indent);
$output .= "<base id='$id' href='$href' target='$target'>" . PHP_EOL;
return $output;
}
/*
<bdi><bdi>
*/
function BDI($id, $class, $html, $indent = 0){
$output = str_repeat(INDENT, $indent);
$output .= "<bdi id='$id' class='$class'>$html</bdi>" . PHP_EOL;
return $output;
}
/*
<bdo></bdo>
*/
function BDO($id, $class, $html, $indent = 0, $dir = 'rtl'){
$output = str_repeat(INDENT, $indent);
$output .= "<bdo id='$id' class='$class' dir='$dir'>$html</bdo>" . PHP_EOL;
return $output;
}
/*
<blockquote></blockquote>
*/
function BLOCKQUOTE($id, $class, $html, $cite = '', $indent = 0 ){
$output = str_repeat(INDENT, $indent);
$output .= "<blockquote id='$id' class='$class' cite='$dir'>$html</blockquote>" . PHP_EOL;
return $output;
}
/*
<body></body>
*/
function BODY($html){
return "<body>" . PHP_EOL . $html . PHP_EOL . '</body>';
}
/*
<br>
*/
function BR($indent = 0 ){
$output = str_repeat(INDENT, $indent);
$output .= "<br>" . PHP_EOL;
return $output;
}
/*
<button>
<canvas>
<caption>
<center>
<cite>
<code>
<col>
<colgroup>
*/
/*
COMMENT
COMMENT('Your comment here');
*/
function COMMENT($comment = '...'){
return "<!--$comment-->" . PHP_EOL;
}
/*
<datalist>
<dd>
<del>
<details>
<dfn>
<dialog>
<dir>
<div>
<dl>
<dt>
*/
/*
DOCTYPE
DOCTYPE();
*/
function DOCTYPE($type = 'html'){
return "<DOCTYPE $type>" . PHP_EOL;
}
/*
<em>
<embed>
<fieldset>
<figcaption>
<figure>
<font>
<footer>
<form>
<frame>
<frameset>
<h1> - <h6>
<head>
<header>
<hr>
*/
/*
HTML
HTML('HTML Markup');
*/
function HTML($html, $lang = 'en-US'){
return "<html lang='$lang'>" . PHP_EOL . $html . PHP_EOL . '</html>';
}
/*
<i></i>
*/
function I($id, $class, $html, $indent = 0){
$output = str_repeat(INDENT, $indent);
$output .= "<i id='$id' class='$class'>$html</i>" . PHP_EOL;
return $output;
}
/*
<iframe>
<img>
<input>
<ins>
<kbd>
<keygen>
<label>
<legend>
<li>
<link>
<main>
*/
/*
Area / Image Map
$area_arr = array(AREA('area-1', 'CSSClass', '0,0,10,10'), AREA('area-2', 'CSSClass', '0,10,10,20'));
echo MAP('my-map', 'my-map', 'CSSClass' 0, $area_arr);
echo '<img src="image.png" usemap="#my-map">';
*/
function MAP($name, $id, $class, $indent = 0, $areas = array()){
$output = str_repeat(INDENT, $indent);
$output .= "<map name='$name' id='$id' class='$class'>" . PHP_EOL;
foreach($areas as $area){
$output .= str_repeat(INDENT, $indent + 1) . $area;
}
$output .= str_repeat(INDENT, $indent) . "</map>" . PHP_EOL;
return $output;
}
/*
<mark>
<menu>
<menuitem>
<meta>
<meter>
<nav>
<noframes>
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<pre>
<progress>
<q>
<rp>
<rt>
<ruby>
<s>
<samp>
<script>
<section>
<select>
<small>
<source>
<span>
<strike>
<strong>
<style>
<sub>
<summary>
<sup>
<table>
<tbody>
<td>
<textarea>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<track>
<tt>
<u>
<ul>
<var>
<video>
<wbr>
*/
?>