-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkp_if_en.php
37 lines (22 loc) · 951 Bytes
/
mkp_if_en.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
// TXP 4.6 tag registration
if (class_exists('\Textpattern\Tag\Registry')) {
Txp::get('\Textpattern\Tag\Registry')
->register('mkp_if_en')
;
}
function mkp_if_en($atts, $thing='')
{
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 the url begins with 'en' this will return true; otherwise false
if ($parts[1] == 'en') {
// the variable target_section will return the section specified in the url
if (isset($parts[2])) { $variable['target_section'] = $parts[2]; }
// the variable target_article will return the article id specified in the url
if (isset($parts[3])) { $variable['target_article'] = (is_numeric($parts[3])) ? $parts[3] : null; }
return parse(EvalElse($thing, true));
} else {
return parse(EvalElse($thing, false));
}
}