Project

General

Profile

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
//    require (dirname(__DIR__).'/SimpleRegister.php');
34

    
35
    // detect if system running backend or frontend is already set by SimpleRegister
36
//    $oApp = (isset($GLOBALS['admin']) ? $GLOBALS['admin'] : $GLOBALS['wb']);
37
    $bIsBackend = ($oApp instanceof admin);
38
    // set addon depending path / url
39
    $sAddonPath = $oReg->AppPath.'modules/'.$sAddonName;
40
    $sAddonUrl  = $oReg->AppUrl.'modules/'.$sAddonName;
41
    $sAddonRel = '/modules/'.basename(__DIR__);
42
    $sAddonThemeRel ='/themes/default';
43
    // define the theme to use -----------------------------------------------------------
44
    if (is_readable($sAddonPath.'/themes/default')) {
45
    // first set fallback to system default theme
46
        $sAddonThemePath = $sAddonPath.'/themes/default';
47
        $sAddonThemeUrl  = $sAddonUrl.'/themes/default';
48
    }
49
    if (is_readable($sAddonPath.'/themes/'.$oReg->DefaultTheme)) {
50
    // overload with the selected theme if accessible
51
        $sAddonThemePath = $sAddonPath.'/themes/'.$oReg->DefaultTheme;
52
        $sAddonThemeUrl  = $sAddonUrl.'/themes/'.$oReg->DefaultTheme;
53
    }
54
    // define the template to use --------------------------------------------------------
55
    if (is_readable($sAddonPath.'/templates/default')) {
56
        // first set fallback to system default template
57
        $sAddonTemplatePath = $sAddonPath.'/templates/default';
58
        $sAddonTemplateUrl  = $sAddonUrl.'/templates/default';
59
    }
60
    if (is_readable($sAddonPath.'/templates/'.$oReg->DefaultTemplate)) {
61
        // try setting to the template of global settings
62
        $sAddonTemplatePath = $sAddonPath.'/templates/'.$oReg->DefaultTemplate;
63
        $sAddonTemplateUrl  = $sAddonUrl.'/templates/'.$oReg->DefaultTemplate;
64
    }
65
    if (!$bIsBackend && is_readable($sAddonPath.'/templates/'.$oReg->Template)) {
66
        // try setting to the template of page depending settings
67
        $sAddonTemplatePath = $sAddonPath.'/templates/'.$oReg->Template;
68
        $sAddonTemplateUrl  = $sAddonUrl.'/templates/'.$oReg->Template;
69
    }
70
        // load core depending language file ------------------------------------------------
71
        if(is_readable($oReg->AppPath.'/languages/EN.php') ){
72
            include($oReg->AppPath.'languages/EN.php');
73
        }
74
        if(is_readable($oReg->AppPath.'/languages/'.$oReg->Language.'.php') ){
75
            include($oReg->AppPath.'/languages/'.$oReg->Language.'.php');
76
        }
77
    // load addon depending language file ------------------------------------------------
78
    if (is_readable($sAddonPath.'/languages/EN.php')) {
79
        // first load fallback to system default language (EN)
80
        include $sAddonPath.'/languages/EN.php';
81
    }
82
    if (is_readable($sAddonPath.'/languages/'.$oReg->DefaultLanguage.'.php')) {
83
        // try loading language of global settings
84
        include $sAddonPath.'/languages/'.$oReg->DefaultLanguage.'.php';
85
    }
86
    if (is_readable($sAddonPath.'/languages/'.$oReg->Language.'.php')) {
87
        // try loading language of user (backend) or page (frontend) defined settings
88
        include $sAddonPath.'/languages/'.$oReg->Language.'.php';
89
    }
90
    // load addon Theme/Template depending language file ---------------------------------
91
    $sTmp = ($bIsBackend ? $sAddonThemePath : $sAddonTemplatePath).'/languages/';
92
    if (is_readable($sTmp.'EN.php')) {
93
        // first load fallback to system default language (EN)
94
        include $sTmp.'EN.php';
95
    }
96
    if (is_readable($sTmp.$oReg->DefaultLanguage.'.php')) {
97
        // try loading language of global settings
98
        include $sTmp.$oReg->DefaultLanguage.'.php';
99
    }
100
    if (is_readable($sTmp.$oReg->Language.'.php')) {
101
        // try loading language of user (backend) or page (frontend) defined settings
102
        include $sTmp.$oReg->Language.'.php';
103
    }
104

    
105
    if( !function_exists( 'make_dir' ) ) { require($oReg->AppPath.'/framework/functions.php');  }
106
    // Simple Command Dispatcher ---------------------------------------------------------
107
     // Include the ordering class
108
    if (!class_exists('order')) {
109
    include $oReg->AppPath.'framework/class.order.php';
110
    }
111
    if (!class_exists('admin')) {
112
        include $oReg->AppPath.'framework/class.admin.php';
113
    }
114
    if (!class_exists('Translate')) {
115
        include $oReg->AppPath.'framework/Translate.php';
116
    }
117
    Translate::getInstance ()->enableAddon ('modules\\'.$sAddonName);
118

    
119
    // sanitize command from compatibility file
120
    $sCommand = (isset($sCommand) ? strtolower($sCommand) : 'overview');
121
    // sanitize/validate request var 'cmd'
122
    $sCmd = preg_replace(
123
        '/[^a-z\/0-1]/siu',
124
        '',
125
        (isset($_REQUEST['cmd']) ? strtolower($_REQUEST['cmd']) : '')
126
    );
127
    // build valid sCommand string
128
    if (($sCommand && $sCmd)) {
129
        if (!preg_match('/^'.$sCommand.'/si', $sCmd)) {
130
            // concate both arguments if needed
131
            $sCommand .= '/'.$sCmd;
132
        } else {
133
            $sCommand = $sCmd;
134
        }
135
$sCmd = '';
136
    }
137

    
138
/*
139
print '<pre  class="mod-pre rounded">function <span>'.__FUNCTION__.'( '.''.' );</span>  filename: <span>'.basename(__FILE__).'</span>  line: '.__LINE__.' -> <br />';
140
print_r( $sCommand ); print '</pre>'; flush (); //  ob_flush();;sleep(10); die();
141
    $sCommand = 'cmd'.str_replace( // remove spaces and add prefix 'cmd'
142
        ' ', '',
143
        ucfirst( // make first char of every word to uppercase
144
            str_replace( // change '/' to space
145
                '/', ' ',
146
                preg_replace( // change leading 'add/' to 'modify/'
147
                    '/^add\//s',
148
                    'modify/',
149
                    trim(($sCommand ?: $sCmd), '/') // remove leading and trailing slashes
150
                )
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
*/
162

    
163
// end of file
(3-3/15)