This repository has been archived by the owner on Jul 21, 2019. It is now read-only.
/
functions.php
77 lines (60 loc) · 3.21 KB
/
functions.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
<?php
// ============================================================================================= //
// CONFIGURATIONS //
// ============================================================================================= //
// ------------------------------------------------------------------------- //
// Choose your working environment for loading CSS and JS files.
// - local => Files not compressed
// - prod => Compressed files
// ------------------------------------------------------------------------- //
define('ENVIRONMENT', 'local');
// ------------------------------------------------------------------------- //
// Define CSS assets
// ------------------------------------------------------------------------- //
define('ASSETS_CSS', 'assets/css');
// ------------------------------------------------------------------------- //
// Define JavaScript assets
// ------------------------------------------------------------------------- //
define('ASSETS_JAVASCRIPT', 'assets/js');
// ------------------------------------------------------------------------- //
// Define npm vendor
// ------------------------------------------------------------------------- //
define('NPM_VENDOR', 'node_modules');
// ------------------------------------------------------------------------- //
// Define error class
// ------------------------------------------------------------------------- //
define('ERROR_CLASS', 'has-error');
// ------------------------------------------------------------------------- //
// URL variables parameters
// - $layout => Get layout name
// - $page => Get page name
// - $error => Get error parameter
// ------------------------------------------------------------------------- //
$layout = filter_input(INPUT_GET, 'layout');
$page = filter_input(INPUT_GET, 'page');
$error = filter_input(INPUT_GET, 'error');
// ------------------------------------------------------------------------- //
// Load page modules
// ------------------------------------------------------------------------- //
if (isset($page)) {
include 'pages/' . $page . '.php';
}
// ============================================================================================= //
// FUNCTIONS //
// ============================================================================================= //
/**
* Generate Lorem Ipsum text.
*
* @param int $minLength (5 words minimum)
* @param int $maxLength
* @param string $type (para, words, bytes & lists)
* @param bool $lorem (Choose to start with the text "Lorem ipsum...")
*
* @return SimpleXMLElement[]
*/
function lipsum($minLength = 5, $maxLength = 50, $type = 'words', $lorem = true)
{
$length = mt_rand($minLength, $maxLength);
$url = "http://www.lipsum.com/feed/xml?amount=$length&what=$type&start=".($lorem ? '0' : '1');
return simplexml_load_file($url)->lipsum;
}