1
|
<?php
|
2
|
/*
|
3
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
4
|
*
|
5
|
* This program is free software: you can redistribute it and/or modify
|
6
|
* it under the terms of the GNU General Public License as published by
|
7
|
* the Free Software Foundation, either version 3 of the License, or
|
8
|
* (at your option) any later version.
|
9
|
*
|
10
|
* This program is distributed in the hope that it will be useful,
|
11
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
* GNU General Public License for more details.
|
14
|
*
|
15
|
* You should have received a copy of the GNU General Public License
|
16
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
*/
|
18
|
|
19
|
/**
|
20
|
* SimpleCommandDispatcher.inc
|
21
|
*
|
22
|
* @category Addons
|
23
|
* @package Addons_Dispatcher
|
24
|
* @copyright Manuela v.d.Decken <manuela@isteam.de>
|
25
|
* @author Manuela v.d.Decken <manuela@isteam.de>
|
26
|
* @license http://www.gnu.org/licenses/gpl.html GPL License
|
27
|
* @version 3.0.1
|
28
|
* @lastmodified $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
|
29
|
* @since File available since 17.12.2015
|
30
|
* @description xyz
|
31
|
*/
|
32
|
|
33
|
if (is_readable(dirname(dirname(__DIR__)).'/modules/SimpleRegister.php')){
|
34
|
require dirname(dirname(__DIR__)).'/modules/SimpleRegister.php';
|
35
|
} else {
|
36
|
throw new Exception('Call of an invalid WebsiteBaker Version ['.WB_VERSION.' '.WB_SP.'] failed!');
|
37
|
}
|
38
|
|
39
|
// detect if system running backend or frontend is already set by SimpleRegister
|
40
|
// $oApp = (isset($GLOBALS['admin']) ? $GLOBALS['admin'] : $GLOBALS['wb']);.$sAddonName
|
41
|
$bIsBackend = ($oReg->App instanceof admin);
|
42
|
// set addon depending path / url
|
43
|
$sAddonPath = $oReg->AppPath.'';
|
44
|
$sAddonUrl = $oReg->AppUrl.'';
|
45
|
$sAddonRel = '/';
|
46
|
// define the theme to use -----------------------------------------------------------
|
47
|
if (is_readable($sAddonPath.'themes/default')) {
|
48
|
// first set fallback to system default theme
|
49
|
$sAddonThemePath = $sAddonPath.'themes/default';
|
50
|
$sAddonThemeUrl = $sAddonUrl.'themes/default';
|
51
|
}
|
52
|
if (is_readable($sAddonPath.'themes/'.$oReg->DefaultTheme)) {
|
53
|
// overload with the selected theme if accessible
|
54
|
$sAddonThemePath = $sAddonPath.'themes/'.$oReg->DefaultTheme;
|
55
|
$sAddonThemeUrl = $sAddonUrl.'themes/'.$oReg->DefaultTheme;
|
56
|
}
|
57
|
// define the template to use --------------------------------------------------------
|
58
|
if (is_readable($sAddonPath.'templates/default')) {
|
59
|
// first set fallback to system default template
|
60
|
$sAddonTemplatePath = $sAddonPath.'templates/default';
|
61
|
$sAddonTemplateUrl = $sAddonUrl.'templates/default';
|
62
|
}
|
63
|
if (is_readable($sAddonPath.'templates/'.$oReg->DefaultTemplate)) {
|
64
|
// try setting to the template of global settings
|
65
|
$sAddonTemplatePath = $sAddonPath.'templates/'.$oReg->DefaultTemplate;
|
66
|
$sAddonTemplateUrl = $sAddonUrl.'templates/'.$oReg->DefaultTemplate;
|
67
|
}
|
68
|
if (!$bIsBackend && is_readable($sAddonPath.'/templates/'.$oReg->Template)) {
|
69
|
// try setting to the template of page depending settings
|
70
|
$sAddonTemplatePath = $sAddonPath.'templates/'.$oReg->Template;
|
71
|
$sAddonTemplateUrl = $sAddonUrl.'templates/'.$oReg->Template;
|
72
|
}
|
73
|
// load addon depending language file ------------------------------------------------
|
74
|
if (is_readable($sAddonPath.'/languages/EN.php')) {
|
75
|
// first load fallback to system default language (EN)
|
76
|
include $sAddonPath.'/languages/EN.php';
|
77
|
}
|
78
|
if (is_readable($sAddonPath.'templates/languages/'.$oReg->DefaultLanguage.'.php')) {
|
79
|
// try loading language of global settings
|
80
|
include $sAddonPath.'templates/languages/'.$oReg->DefaultLanguage.'.php';
|
81
|
}
|
82
|
if (is_readable($sAddonPath.'templates/languages/'.$oReg->Language.'.php')) {
|
83
|
// try loading language of user (backend) or page (frontend) defined settings
|
84
|
include $sAddonPath.'templates/languages/'.$oReg->Language.'.php';
|
85
|
}
|
86
|
// load addon Theme/Template depending language file ---------------------------------
|
87
|
$sTmp = ($bIsBackend ? $sAddonThemePath : $sAddonTemplatePath).'/languages/';
|
88
|
if (is_readable($sTmp.'EN.php')) {
|
89
|
// first load fallback to system default language (EN)
|
90
|
include $sTmp.'EN.php';
|
91
|
}
|
92
|
if (is_readable($sTmp.$oReg->DefaultLanguage.'.php')) {
|
93
|
// try loading language of global settings
|
94
|
include $sTmp.$oReg->DefaultLanguage.'.php';
|
95
|
}
|
96
|
if (is_readable($sTmp.$oReg->Language.'.php')) {
|
97
|
// try loading language of user (backend) or page (frontend) defined settings
|
98
|
include $sTmp.$oReg->Language.'.php';
|
99
|
}
|
100
|
// Simple Command Dispatcher ---------------------------------------------------------
|
101
|
// Include the ordering class
|
102
|
if (!class_exists('order')) {
|
103
|
include $oReg->AppPath.'framework/class.order.php';
|
104
|
}
|
105
|
if (!class_exists('admin')) {
|
106
|
include $oReg->AppPath.'framework/class.admin.php';
|
107
|
}
|
108
|
if (!class_exists('Translate')) {
|
109
|
include $oReg->AppPath.'framework/Translate.php';
|
110
|
}
|
111
|
|
112
|
// Translate::getInstance ()->enableAddon ('modules\\'.$sAddonName);
|
113
|
// sanitize command from compatibility file
|
114
|
|
115
|
$sClassDatabaseFile = dirname(__DIR__).'/framework/SP7Database.php';
|
116
|
if (!class_exists('database', false) && is_readable($sClassDatabaseFile)){require $sClassDatabaseFile;}
|
117
|
$sCommand = (isset($sCommand) ? strtolower($sCommand) : '');
|
118
|
// sanitize/validate request var 'cmd'
|
119
|
$sCmd = preg_replace(
|
120
|
'/[^a-z\/0-1]/siu',
|
121
|
'',
|
122
|
(isset($_REQUEST['cmd']) ? strtolower($_REQUEST['cmd']) : '')
|
123
|
);
|
124
|
// build valid sCommand string
|
125
|
if (($sCommand && $sCmd)) {
|
126
|
if (!preg_match('/^'.$sCommand.'/si', $sCmd)) {
|
127
|
// concate both arguments if needed
|
128
|
$sCommand .= '/'.$sCmd;
|
129
|
} else {
|
130
|
$sCommand = $sCmd;
|
131
|
}
|
132
|
$sCmd = '';
|
133
|
}
|
134
|
$sCommand = str_replace( // remove spaces and add prefix 'cmd'
|
135
|
' ', '',
|
136
|
ucfirst( // make first char of every word to uppercase
|
137
|
str_replace( // change '/' to space
|
138
|
'/', ' ',
|
139
|
preg_replace( // change leading 'add/' to 'modify/'
|
140
|
'/^add\//s',
|
141
|
'modify/',
|
142
|
trim(($sCommand ?: $sCmd), '/') // remove leading and trailing slashes
|
143
|
)
|
144
|
)
|
145
|
)
|
146
|
);
|
147
|
|
148
|
/*--------------------------------------------------------------------------------------------------------*/
|
149
|
$unixPath = (function ($string){
|
150
|
return str_replace('\\', '/', $string);
|
151
|
});
|
152
|
/*--------------------------------------------------------------------------------------------------------*/
|
153
|
|
154
|
/*
|
155
|
// execute command -------------------------------------------------------------------
|
156
|
if (is_readable($sAddonPath.'/cmd/'.$sCommand.'.inc') ) {
|
157
|
include($sAddonPath.'/cmd/'.$sCommand.'.inc');
|
158
|
} else {
|
159
|
throw new Exception('call of invalid command ['.$sCommand.'] for [modules/'.$sAddonName.'] failed!');
|
160
|
}
|
161
|
//Template
|
162
|
$oTpl = new Template($sAddonPath, 'remove');
|
163
|
$oTpl->set_file('head', 'backend.css');
|
164
|
$oTpl->set_var('TEMPLATE_URL', ($bIsBackend?$sAddonThemeUrl:$sAddonTemplateUrl).'/css/default.css');
|
165
|
include $oTpl->parse('output', 'head');
|
166
|
*/
|
167
|
|
168
|
|
169
|
/*
|
170
|
echo $sUploadTemplateFile.'<br />';
|
171
|
ob_start();
|
172
|
include(is_readable($sUploadTemplateFile)?$sUploadTemplateFile:'');
|
173
|
$sUploadTemplate = ob_get_clean();
|
174
|
|
175
|
$sUploadTemplateFile = $sAddonThemePath.'/FineUpload/templates/gallery.html';
|
176
|
$sUploadTemplate = '';
|
177
|
if (is_readable($sUploadTemplateFile)){
|
178
|
$sUploadTemplate = file_get_contents($sUploadTemplateFile);
|
179
|
}
|
180
|
*/
|
181
|
|
182
|
// end of file
|