LEPTON CMS 7.0.0
feel free to keep it strictly simple...
Loading...
Searching...
No Matches
function.page_tree.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
52function page_tree(int $root_id = 0, array &$page_storage = [], array $fields = ['page_id', 'page_title', 'menu_title', 'parent','position','visibility'] ): void
53{
54 global $LEPTON_CORE_all_pages;
56
57 // [1.1] make sure that field "page_id" is in list
58 if (!in_array('page_id', $fields))
59 {
60 $fields[] ="page_id";
61 }
62 // [1.2] make sure that field "parent" is in list
63 if (!in_array('parent', $fields))
64 {
65 $fields[] = "parent";
66 }
67 // [1.3] make sure that field "visibility" is in list
68 if (!in_array('visibility', $fields))
69 {
70 $fields[] = "visibility";
71 }
72
73 $select_fields = "`".implode("`,`", $fields)."`";
74
75 $LEPTON_CORE_all_pages = [];
76 $database->execute_query(
77 "SELECT ".$select_fields." FROM `".TABLE_PREFIX."pages` ORDER BY `parent`,`position`",
78 true,
79 $LEPTON_CORE_all_pages
80 );
81
82 LEPTON_CORE_make_list( $root_id, $page_storage );
83 }
84
92function LEPTON_CORE_make_list(int $aNum, array &$aRefArray ): void
93{
94 global $LEPTON_CORE_all_pages, $TEXT;
95
96 foreach($LEPTON_CORE_all_pages as &$ref) {
97
98 if ($ref['parent'] > $aNum)
99 {
100 break;
101 }
102
103 if ($ref['parent'] == $aNum) {
104
105 switch( $ref['visibility'] ) {
106
107 case 'public':
108 $ref['status_icon'] = "visible_16.png";
109 $ref['status_text'] = $TEXT['PUBLIC'];
110 $ref['status_uiicon'] = 'unhide';
111 break;
112
113 case 'private':
114 $ref['status_icon'] = "private_16.png";
115 $ref['status_text'] = $TEXT['PRIVATE'];
116 $ref['status_uiicon'] = 'user';
117 break;
118
119 case 'registered':
120 $ref['status_icon'] = "keys_16.png";
121 $ref['status_text'] = $TEXT['REGISTERED'];
122 $ref['status_uiicon'] = 'sign in';
123 break;
124
125 case 'hidden':
126 $ref['status_icon'] = "hidden_16.png";
127 $ref['status_text'] = $TEXT['HIDDEN'];
128 $ref['status_uiicon'] = 'hide';
129 break;
130
131 case 'none':
132 $ref['status_icon'] = "none_16.png";
133 $ref['status_text'] = $TEXT['NONE'];
134 $ref['status_uiicon'] = 'lock';
135 break;
136
137 case 'deleted':
138 $ref['status_icon'] = "deleted_16.png";
139 $ref['status_text'] = $TEXT['DELETED'];
140 $ref['status_uiicon'] = 'recycle red';
141 break;
142
143 default:
144 die( LEPTON_tools::display("Error: [20012] ".$ref['visibility']. " unknown!", "pre", "ui message red"));
145 break;
146
147 }
148
149 $ref['subpages'] = [];
150 LEPTON_CORE_make_list( $ref['page_id'], $ref['subpages'] );
151
152 if (isset($ref['link'])) {
153 $ref['link'] = PAGES_DIRECTORY.$ref['link'].PAGE_EXTENSION; // show link also in overview, therefore no additional LEPTON_URL
154 }
155
156 $aRefArray[] = &$ref;
157 }
158 }
159}
static getInstance(array &$settings=[])
static display(mixed $something_to_display="", string $tag="pre", string|null $css_class=null)
$database
Definition constants.php:52
page_tree(int $root_id=0, array &$page_storage=[], array $fields=['page_id', 'page_title', 'menu_title', 'parent', 'position', 'visibility'])
LEPTON_CORE_make_list(int $aNum, array &$aRefArray)