LEPTON CMS
7.2.0
feel free to keep it strictly simple...
Loading...
Searching...
No Matches
function.root_parent.php
Go to the documentation of this file.
1
<?php
2
18
// include secure.php to protect this file and the whole CMS!
19
if
(!defined(
"SEC_FILE"
)){define(
"SEC_FILE"
,
'/framework/secure.php'
);}
20
if
(defined(
'LEPTON_PATH'
)) {
21
include LEPTON_PATH.SEC_FILE;
22
}
else
{
23
$oneback =
"../"
;
24
$root
= $oneback;
25
$level
= 1;
26
while
((
$level
< 10) && (!file_exists(
$root
.SEC_FILE))) {
27
$root
.= $oneback;
28
$level
+= 1;
29
}
30
if
(file_exists(
$root
.SEC_FILE)) {
31
include
$root
.SEC_FILE;
32
}
else
{
33
trigger_error(sprintf(
"[ <b>%s</b> ] Can't include secure.php!"
, $_SERVER[
'SCRIPT_NAME'
]), E_USER_ERROR);
34
}
35
}
36
// end include secure file
37
38
47
function
root_parent
( $page_id )
48
{
49
$database
=
LEPTON_database::getInstance
();
50
LEPTON_handle::register
(
"get_parent_ids"
);
51
52
// Get page details
53
$aDetails = array();
54
$database
->execute_query(
55
"SELECT parent, level from "
.TABLE_PREFIX.
"pages WHERE page_id = "
.$page_id.
" "
,
56
true
,
57
$aDetails,
58
false
59
);
60
61
$parent = $aDetails[
'parent'
];
62
$level
= $aDetails[
'level'
];
63
64
if
(
$level
== 1 )
65
{
66
return
$parent;
67
}
68
elseif ( $parent == 0 )
69
{
70
return
$page_id;
71
}
72
else
73
{
74
// Figure out what the root parents id is
75
$parent_ids = array_reverse(
get_parent_ids
($page_id));
76
return
$parent_ids[ 0 ];
77
}
78
}
LEPTON_database\getInstance
static getInstance(array &$settings=[])
Definition
lepton_database.php:75
LEPTON_handle\register
static register()
Definition
lepton_handle.php:729
$database
$database
Definition
constants.php:52
get_parent_ids
get_parent_ids(int $iParentId)
Definition
function.get_parent_ids.php:49
$root
$root
Definition
function.root_parent.php:24
$level
$level
Definition
function.root_parent.php:25
root_parent
root_parent( $page_id)
Definition
function.root_parent.php:47
SVN
upload
framework
functions
function.root_parent.php
Generated by
1.10.0