LEPTON CMS 7.0.0
feel free to keep it strictly simple...
Loading...
Searching...
No Matches
function.load_template.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
51 function load_template( $directory )
52 {
53 global $MESSAGE;
55
56 if (is_dir(LEPTON_PATH.'/templates/'.$directory) && file_exists(LEPTON_PATH.'/templates/'.$directory.'/info.php'))
57 {
58 global $template_license, $template_directory, $template_author, $template_version, $template_function, $template_description, $template_platform, $template_name, $template_guid;
59 require LEPTON_PATH.'/templates/'.$directory.'/info.php';
60
61 if(!isset($template_delete))
62 {
63 $template_delete = true;
64 }
65
66 // Check that it doesn't already exist
67 $sqlwhere = "`type` = 'template' AND `directory` = '" . $template_directory . "'";
68 $sql = "SELECT COUNT(*) FROM `" . TABLE_PREFIX . "addons` WHERE " . $sqlwhere;
69 if ( $database->get_one( $sql ) )
70 {
71 $sql_job = "update";
72 }
73 else
74 {
75 $sql_job = "insert";
76 $sqlwhere = "";
77 }
78
79 $fields = array(
80 'directory' => $template_directory,
81 'name' => $template_name,
82 'description' => $template_description,
83 'type' => 'template',
84 'function' => strtolower( $template_function ),
85 'to_delete' => intval( $template_delete ),
86 'version' => $template_version,
87 'platform' => $template_platform,
88 'author' => $template_author,
89 'license' => $template_license
90 );
91
92 if (isset($template_guid))
93 {
94 $fields['guid'] = $template_guid;
95 }
96
97 $database->build_and_execute(
98 $sql_job,
99 TABLE_PREFIX . "addons",
100 $fields,
101 $sqlwhere
102 );
103 }
104 }
static getInstance(array &$settings=[])
$database
Definition constants.php:52
load_template( $directory)