LEPTON CMS 7.0.0
feel free to keep it strictly simple...
Loading...
Searching...
No Matches
function.page_content.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
39function page_content(int $block = 1)
40{
41 // Get outside objects
42 global $TEXT, $MENU, $HEADING, $MESSAGE, $section_id;
44 $oLEPTON = LEPTON_frontend::getInstance();
45
46 if ( $oLEPTON->page_access_denied === true )
47 {
48 echo $MESSAGE['FRONTEND_SORRY_NO_VIEWING_PERMISSIONS'];
49 return;
50 }
51 if ( $oLEPTON->page_no_active_sections === true )
52 {
53 echo $MESSAGE[ 'FRONTEND_SORRY_NO_ACTIVE_SECTIONS' ];
54 return;
55 }
56
57 // [1] Include page content
58 if (!defined('PAGE_CONTENT') || $block != 1)
59 {
60 $page_id = intval( $oLEPTON->page_id );
61
62 // [1.0.1] Set session variable to save page_id only if PAGE_CONTENT is empty
63 $_SESSION[ 'PAGE_ID' ] = !isset( $_SESSION[ 'PAGE_ID' ] ) ? $page_id : $_SESSION[ 'PAGE_ID' ];
64 // [1.0.2] Set to new value if page_id changed and not 0
65 if ( ( $page_id != 0 ) && ( $_SESSION[ 'PAGE_ID' ] <> $page_id ) )
66 {
67 $_SESSION[ 'PAGE_ID' ] = $page_id;
68 }
69
70 // [1.2] First get all sections for this page
71 $aSections = [];
72 $database->execute_query(
73 "SELECT section_id, module, publ_start, publ_end from ".TABLE_PREFIX."sections WHERE page_id = ".$page_id." AND block = '".$block."' ORDER BY position",
74 true,
75 $aSections,
76 true
77 );
78
79 // [2] We have get valid sections! Loop through the sections and include their module files.
80 foreach ($aSections as $section)
81 {
82 // skip this section if it is out of publication-date
83 $now = time();
84 if ( !( ( $now <= $section[ 'publ_end' ] || $section[ 'publ_end' ] == 0 ) && ( $now >= $section[ 'publ_start' ] || $section[ 'publ_start' ] == 0 ) ) )
85 {
86 continue;
87 }
88 $section_id = $section[ 'section_id' ];
89 $module = $section[ 'module' ];
90 // make a anchor for every section.
91 if ( defined( 'SEC_ANCHOR' ) && SEC_ANCHOR != '' )
92 {
93 echo '<a class="section_anchor" id="' . SEC_ANCHOR . $section_id . '"></a>';
94 }
95 // check if module exists - feature: write in errorlog
96 if ( file_exists( LEPTON_PATH . '/modules/' . $module . '/view.php' ) )
97 {
98 // fetch content -- this is where to place possible output-filters (before highlighting)
99 ob_start(); // fetch original content
100 require LEPTON_PATH . '/modules/' . $module . '/view.php';
101 $content = ob_get_clean();
102 }
103 else
104 {
105 continue;
106 }
107
108 // [2] highlights search-results
109 LEPTON_handle::register("search_highlight");
110 $sSearchResult = (LEPTON_request::getRequest("searchresult") ?? NULL );
111 $sString = (LEPTON_request::getRequest("sstring") ?? "");
112 $sNoHighlight = (LEPTON_request::getRequest("nohighlight") ?? NULL );
113
114 //if ( isset( $_GET[ 'searchresult' ] ) && is_numeric( $_GET[ 'searchresult' ] ) && !isset( $_GET[ 'nohighlight' ] ) && isset( $_GET[ 'sstring' ] ) && !empty( $_GET[ 'sstring' ] ) )
115 if( ($sSearchResult != NULL) && ($sNoHighlight === NULL ) && ($sString != "") )
116 {
117 $arr_string = explode( " ", $sString );
118 if ( intval($sSearchResult) == 2 ) // exact match
119 {
120 $arr_string[ 0 ] = str_replace( "_", " ", $arr_string[ 0 ] );
121 }
122 echo search_highlight( $content, $arr_string );
123 }
124 else
125 {
126 echo $content;
127 }
128 }
129 }
130 else
131 {
132 require PAGE_CONTENT;
133 }
134}
static getInstance(array &$settings=[])
static getRequest(string $sField="")
$database
Definition constants.php:52
page_content(int $block=1)
search_highlight(string $sContent='', array $aTermsToMark=array())