-
Notifications
You must be signed in to change notification settings - Fork 3
/
mkp_url_parameters.php
44 lines (26 loc) · 1.46 KB
/
mkp_url_parameters.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
// TXP 4.6 tag registration
if (class_exists('\Textpattern\Tag\Registry')) {
Txp::get('\Textpattern\Tag\Registry')
->register('mkp_url_parameters')
;
}
function mkp_url_parameters()
{
global $variable;
// preg_replace("|^https?://[^/]+|i", "", serverSet('REQUEST_URI')) was copied from the function preText in publish.php
$parts = explode('/', preg_replace("|^https?://[^/]+|i", "", serverSet('REQUEST_URI')), 5);
if (is_numeric($parts[1])) {
// y is numeric year, m is numeric month, monthtitle is name of month, d is numeric day
if (isset($parts[1])) { $variable['y'] = (is_numeric($parts[1])) ? $parts[1] : null; }
if (isset($parts[2])) { $variable['m'] = (is_numeric($parts[2]))? $parts[2] : null; }
if (isset($parts[2])) { $variable['monthtitle'] = (is_numeric($parts[2])) ? date('F', mktime(0, 0, 0, $parts[2])) : null; }
if (isset($parts[3])) { $variable['d'] = (is_numeric($parts[3]))? $parts[3] : null; }
} else {
// at this point we are going to assume that Textpattern is running in a subdirectory and shift to the right in our array
if (isset($parts[2])) { $variable['y'] = (is_numeric($parts[2])) ? $parts[2] : null; }
if (isset($parts[3])) { $variable['m'] = (is_numeric($parts[3]))? $parts[3] : null; }
if (isset($parts[3])) { $variable['monthtitle'] = (is_numeric($parts[3])) ? date('F', mktime(0, 0, 0, $parts[3])) : null; }
if (isset($parts[4])) { $variable['d'] = (is_numeric($parts[4]))? $parts[4] : null; }
}
return null;
}