LEPTON CMS 7.4.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!
19if(!defined("SEC_FILE")){define("SEC_FILE",'/framework/secure.php' );}
20if (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
47function root_parent( $page_id )
48{
49
50$info = '@TEMP_DEPRECATED 20250418: this function has to be reworked in L* 7.4.0")';
51echo(LEPTON_tools::display($info, 'pre','ui orange message'));
52echo (LEPTON_tools::display(debug_print_backtrace(), 'pre','ui message'));
53
54
56 LEPTON_handle::register("get_parent_ids");
57
58 // Get page details
59 $aDetails = [];
60 $database->execute_query(
61 "SELECT parent, level from ".TABLE_PREFIX."pages WHERE page_id = ".$page_id." ",
62 true,
63 $aDetails,
64 false
65 );
66
67 $parent = $aDetails[ 'parent' ];
68 $level = $aDetails[ 'level' ];
69
70 if ( $level == 1 )
71 {
72 return $parent;
73 }
74 elseif ( $parent == 0 )
75 {
76 return $page_id;
77 }
78 else
79 {
80 // Figure out what the root parents id is
81 $parent_ids = array_reverse( get_parent_ids($page_id));
82 return $parent_ids[ 0 ];
83 }
84}
static getInstance(array &$settings=[])
static display(mixed $something_to_display="", string $tag="pre", string|null $css_class=null, bool|null $useVarDump=null)
$database
Definition constants.php:52
get_parent_ids(int $iParentId)
root_parent( $page_id)