LEPTON CMS 7.2.0
feel free to keep it strictly simple...
Loading...
Searching...
No Matches
function.droplet_exists.php
Go to the documentation of this file.
1<?php
2
19// include secure.php to protect this file and the whole CMS!
20if(!defined("SEC_FILE")){define("SEC_FILE",'/framework/secure.php' );}
21if (defined('LEPTON_PATH')) {
22 include LEPTON_PATH.SEC_FILE;
23} else {
24 $oneback = "../";
25 $root = $oneback;
26 $level = 1;
27 while (($level < 10) && (!file_exists($root.SEC_FILE))) {
28 $root .= $oneback;
29 $level += 1;
30 }
31 if (file_exists($root.SEC_FILE)) {
32 include $root.SEC_FILE;
33 } else {
34 trigger_error(sprintf("[ <b>%s</b> ] Can't include secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
35 }
36}
37// end include secure file
38
39
49function droplet_exists($droplet_name, $page_id, &$option=array()) : bool
50{
52 $iPageId = 0;
53 $iSectionId = 0;
54
55 if (isset($option['POST_ID']) || defined('POST_ID'))
56 {
57 // Droplet may be placed at a NEWs article
58 $post_id = defined('POST_ID') ? POST_ID : $option['POST_ID'];
59 $iPageId = $database->get_one("SELECT page_id FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = ".$post_id." AND ((content_long LIKE '%[[".$droplet_name."?%') OR (content_long LIKE '%[[".$droplet_name."]]%')) ");
60 if ($iPageId > 0)
61 {
62 return true;
63 }
64 }
65
66 if (isset($option['TOPIC_ID']) || defined('TOPIC_ID'))
67 {
68 // Droplet may be placed at a TOPICs article
69 $topic_id = defined('TOPIC_ID') ? TOPIC_ID : $option['TOPIC_ID'];
70 $iPageId = $database->get_one("SELECT page_id FROM ".TABLE_PREFIX."mod_topics WHERE topic_id = ".$topic_id." AND ((content_long LIKE '%[[".$droplet_name."?%') OR (content_long LIKE '%[[".$droplet_name."]]%')) ");
71 if ($iPageId > 0)
72 {
73 return true;
74 }
75 }
76
77 $iSectionId = $database->get_one("SELECT section_id FROM ".TABLE_PREFIX."mod_wysiwyg WHERE page_id = ".$page_id." AND ((text LIKE '%[[".$droplet_name."?%') OR (text LIKE '%[[".$droplet_name."]]%')) ");
78 if ($iSectionId > 0)
79 {
80 return true;
81 }
82
83 return false;
84}
static getInstance(array &$settings=[])
$database
Definition constants.php:52
droplet_exists($droplet_name, $page_id, &$option=array())