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
|
* SimpleCommandDispatcher.inc
|
19
|
*
|
20
|
* @category Addons
|
21
|
* @package Addons_Dispatcher
|
22
|
* @copyright Manuela v.d.Decken <manuela@isteam.de>
|
23
|
* @author Manuela v.d.Decken <manuela@isteam.de>
|
24
|
* @license http://www.gnu.org/licenses/gpl.html GPL License
|
25
|
* @version 3.0.1
|
26
|
* @lastmodified $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
|
27
|
* @since File available since 17.12.2015
|
28
|
* @description xyz
|
29
|
*/
|
30
|
|
31
|
class Helpers
|
32
|
{
|
33
|
|
34
|
protected $oDb = null;
|
35
|
protected $oReg = null;
|
36
|
protected $oApp = null;
|
37
|
protected $bSqlStatement = false;
|
38
|
protected $sFilterPath = '';
|
39
|
protected $aFilters = array();
|
40
|
protected $aInsertSql = array();
|
41
|
|
42
|
|
43
|
public function __construct( ){
|
44
|
$this->initialize();
|
45
|
}
|
46
|
|
47
|
public function __set($name, $value){
|
48
|
throw new InvalidArgumentException('tried to set readonly or nonexisting property [ '.$name.' }!! ');
|
49
|
}
|
50
|
|
51
|
public function __get($name){
|
52
|
throw new InvalidArgumentException('tried to get nonexisting property [ '.$name.' }!! ');
|
53
|
}
|
54
|
|
55
|
public function set($name, $value){
|
56
|
$this->$name = $value;
|
57
|
}
|
58
|
|
59
|
public function get($name){
|
60
|
if(is_array($this->$name)){
|
61
|
return implode("\n", $this->$name);
|
62
|
} else { return $this->$name; }
|
63
|
}
|
64
|
|
65
|
protected function initialize()
|
66
|
{
|
67
|
$this->sFilterPath = dirname(__DIR__).'/filters/';
|
68
|
$this->aFilters = $this->buildFilterArray();
|
69
|
$this->aInsertSql = $this->buildFilterArray(true);
|
70
|
}
|
71
|
|
72
|
protected function getFilterInFolder( )
|
73
|
{
|
74
|
return glob($this->sFilterPath.'*');
|
75
|
}
|
76
|
|
77
|
protected function buildFilterArray( $isSql = false ) {
|
78
|
$i=1;
|
79
|
$aFiles = $this->getFilterInFolder();
|
80
|
$aFilters = array();
|
81
|
$aInstallData = array();
|
82
|
$aInstallData[] = 'INSERT INTO `{TABLE_PREFIX}mod_output_filter` (`name`, `value`) VALUES'."\n";
|
83
|
foreach ( $aFiles as $Filter) {
|
84
|
$sFileName = basename($Filter);
|
85
|
$key = preg_replace("/\.[^.]+$/", "", $sFileName);
|
86
|
$aFilters[$key] = true;
|
87
|
$sFilter = '(\''.$key.'\', \'1\')';
|
88
|
if( $i < sizeof($aFiles) ) { $sFilter .= ', '."\n"; }else{ $sFilter .= ';'; }
|
89
|
$i++;
|
90
|
$aInstallData[] = $sFilter;
|
91
|
|
92
|
}
|
93
|
return ( $isSql ? $aInstallData : $aFilters );
|
94
|
}
|
95
|
|
96
|
} // end class Helpers
|
97
|
|
98
|
if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }
|
99
|
|
100
|
|
101
|
$oHelpers = new Helpers();
|
102
|
echo $oHelpers->get( 'sFilterPath' ).'<br />';
|
103
|
echo $oHelpers->get( 'aInsertSql' ).'<br />';
|
104
|
/**
|
105
|
echo $oHelpers;
|
106
|
*
|
107
|
print '<pre class="mod-pre rounded">function <span>'.__FUNCTION__.'( '.''.' );</span> filename: <span>'.basename(__FILE__).'</span> line: '.__LINE__.' -> <br />';
|
108
|
print_r( $oHelpers ); print '</pre>'; flush (); // ob_flush();;sleep(10); die();
|
109
|
*/
|