-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
208 lines (192 loc) · 4.93 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
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
<?php
/**
* FM Channel
*
* Set this to the FM channel of your FM broadcaster if in use, eg. 98.5;
* Leave at 0 if you do not utilize an FM broadcaster
*/
$fmChannel = 0;
/**
* Class table styling
*
* If set to True, the classes table on the index page will be ordered horizontally
* If set to False, the classes table on the index page will be ordered vertically
* Default is True
*/
$horizontalClasses = true;
/**
* Hide unused classes
*
* If set to true, the classes table on the index page will not show empty classes
* Default is false
*/
$hiddenClasses = false;
/**
* sectionInclude
*
* Function that takes a file's contents and inserts them in a new html div with a specified class.
* Does not show the html div if the file does not exist.
*
* @param string $file Relative path to contents of file to insert.
* @param string $cssClass Name to give inserted html div, used to stylize div. Add class name to stylesheet.css.
*
* @return null|string
*/
function sectionInclude($file, $cssClass)
{
if (file_exists($file))
{
return '<div class="w3-panel w3-center '.$cssClass.'">'.file_get_contents($file).'</div>';
}
else
{
return null;
}
}
/**
* eventTitleInclude
*
* @param string $file Relative path to contents of file to insert.
* @param string $cssClass Name to give inserted html div, used to stylize div. Add class name to stylesheet.css.
*
* @return null|string
*/
function eventTitleInclude($file, $cssClass)
{
if (file_exists($file))
{
$contents = file($file);
$html = '<div class="w3-panel w3-center '.$cssClass.'">';
foreach((array)$contents as $line)
{
$html .= $line;
$html .= "</div>";
}
$html .= '</div>';
return $html;
}
else
{
return null;
}
}
/**
* sectionLinkInclude
*
* Function that takes adds a link to a file in a new html div with a specified class.
* Does not show the html div and link if the file does not exist.
*
* @param string $file Relative path to file to link to.
* @param string $cssClass Name to give inserted html div, used to stylize div. Add class name to stylesheet.css.
* @param string $text Text to use as html link in html div.
*
* @return null|string
*/
function sectionLinkInclude($file, $cssClass, $text)
{
if (file_exists($file))
{
return '<div class="w3-panel w3-center '.$cssClass.'"><b><a href="'.$file.'">'.$text.'</a></b></div>';
}
else
{
return null;
}
}
/**
* classExists
*
* Function that creates a string with html links for autocross classes in the format of Mens / Womens.
* Function will show the class text regardless if the respective class file exists, but if it does, it will make the text a html link.
* Example: Input - CSP, Output - CSP / CSPL.
*
* @param string $class Text representation of a class, preferrably a shorthand version.
*
* @return string
*/
function classExists($class)
{
$strReturn = "";
$mens = false;
$womens = false;
// Check mens class
$mensClass = similar_file_exists("files/".$class.".php");
if ($mensClass)
{
$strReturn .= '<td><b><a href="'.$mensClass.'">'.$class.'</a></b>';
// $strReturn .= '<td><b><a href="showClass.php?class='.$class.'">'.$class.'</a></b>';
$mens = true;
}
else
{
$strReturn .= "<td>".$class;
}
$strReturn .= " / ";
// Check womens class
$womensClass = similar_file_exists("files/".$class."L.php");
if ($womensClass)
{
$strReturn .= '<b><a href="'.$womensClass.'">'.$class.'L</a></b></td>';
// $strReturn .= '<b><a href="showClass.php?class='.$class.'L">'.$class.'L</a></b></td>';
$womens = true;
}
else
{
$strReturn .= $class."L</td>";
}
if ($GLOBALS['hiddenClasses'])
{
if ($mens == true || $womens == true)
{
return $strReturn;
}
}
else
{
return $strReturn;
}
}
/**
* tableFileExists
*
* Function to create a string with a html link or just text.
*
* @param string $file Relative path to contents of file to insert.
* @param string $name Text to use as html link in html link.
*
* @return string
*/
function tableFileExists($file, $name)
{
if (file_exists("files/".$file))
{
return '<b><a href="files/'.$file.'">'.$name.'</a></b>';
}
else
{
return $name;
}
}
/**
* Alternative to file_exists() that will also return true if a file
* exists with the same name in a difference case.
*
* @param string $file Relative path to contents of file to insert.
*
* @return string
*/
function similar_file_exists($file)
{
if (file_exists($file))
{
return $file;
}
$lowerFile = strtolower($file);
foreach ((array)glob(dirname($file) . '/*') as $file)
{
if (strtolower($file) == $lowerFile)
{
return $file;
}
}
}