forked from NicolasGraph/oui_section_page
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoui_section_page.php
More file actions
86 lines (67 loc) · 1.85 KB
/
oui_section_page.php
File metadata and controls
86 lines (67 loc) · 1.85 KB
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
<?php
Txp::get('\Textpattern\Tag\Registry')
->register('oui_section_page')
->register('oui_if_section_page');
/**
* Gets a section's page.
*
* @param string $section The section
* @return string|bool The page or FALSE on error
*/
function oui_fetch_section_page($section)
{
static $secpages = array();
global $thissection;
// Try cache.
if (isset($secpages[$section])) {
return $secpages[$section];
}
// Try global set by section_list().
if (!empty($thissection['page']) && $thissection['name'] == $section) {
$secpages[$section] = $thissection['page'];
return $thissection['page'];
}
if (empty($section)) {
return '';
}
$f = safe_field("page", 'txp_section', "name = '".doSlash($section)."'");
$secpages[$section] = $f;
return $f;
}
// -------------------------------------------------------------
function oui_section_page($atts, $thing = null)
{
global $thisarticle, $s, $thissection;
extract(lAtts(array(
'class' => '',
'section' => '',
'wraptag' => '',
), $atts));
if ($section) {
$sec = $section;
} elseif (!empty($thissection['name'])) {
$sec = $thissection['name'];
} elseif (!empty($thisarticle['section'])) {
$sec = $thisarticle['section'];
} else {
$sec = $s;
}
if ($sec) {
$out = oui_fetch_section_page($sec);
return doTag($out, $wraptag, $class);
}
}
// -------------------------------------------------------------
function oui_if_section_page($atts, $thing)
{
global $pretext;
extract($pretext);
extract(lAtts(array(
'name' => false,
'section' => '',
), $atts));
if ($section) {
$page = oui_page(array('section' => $section));
}
return parse($thing, $name === false or in_list($page, $name));
}