class_STTREEHelpers.inc.php 16.2 KB
<?php
/**
 * @file	STTREEHelpers.inc.php
 * @category freeSN
 * @mailto	code [at] netz.coop
 * @version 0.4.200901
 * @link http://netz.coop
 * 
 *  @copyright Copyright by netz.coop e.G. 2015
 *  
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
class STTREEHelpers {

    public static $fullTreeArray = array();
    public static $ary_fullTreeGET = array();
    public static $varCountMax;
    public static $varDepthMax;
    public static $ary_treeCountPlanes = array();

    public static function getFullTree($param_start='Profile', $param_history=false) {
        if (!is_array($param_history)) {
            $param_history = array();
            $param_history[] = $param_start;
        } else {
            STTREEHelpers::push_element($param_start, $param_history, '$ary_fullTreeGET', 'getfullTree:30');
        }
        $array_MenuConf = STTree::$ary_testIn;
        $class_parents = class_parents($param_start);
        $class_noparents = class_parents('MultimediaText');
        $class_noparents['MultimediaText'] = 'MultimediaText';
        $class_parents = array_diff($class_parents, $class_noparents);
        foreach ($class_parents as $var_key => $var_value) {
            if ($array_MenuConf[0]['TestreeChild' . $var_value] != 'FALSE') {
                $param_history['1'] = $var_value;
                STTree::$ary_PrintTree[] = "<?php echo '<br><b>|=> '; echo $var_value; echo'</b>'; ?>";
                self::getMainMenu($var_value, $param_history, '1', '1');
            }
        }
    }

    public static function getMainMenu($param_current_class, $param_history, $param_count, $param_depth) {
        if (array_search($param_current_class, STTREE::$ary_notIncl) !== false) {
            STTREE::$ary_walkFncNotTested[$param_current_class . '_T' . $param_count] = 'Not in Testsystem right now STREEHELPER::getMainMenu';
            return;
        }
        $array_MTPreferences = CONFIG::getMultimediaTextPreferencs($param_current_class);
        if (!is_array($array_MTPreferences)) {
            $var_BCMT = CONFIG::getBC_MultimediaText($param_current_class);
            if ($param_count < self::$varCountMax && $var_BCMT && $var_BCMT != '*' && $var_BCMT != 'Profile') { //&& $var_BCMT != 'MultimediaText'
            }
        }
        if (is_array($array_MTPreferences)) {

            if (array_key_exists('BasisClipboards', $array_MTPreferences)) {
                $var_currrent_MTPreferenceBC = $array_MTPreferences['BasisClipboards'];
                unset($array_MTPreferences['BasisClipboards']);
                foreach ($var_currrent_MTPreferenceBC as $var_BC_delkey => $var_BC_delvalue) {
                    $ary_notTested = STTree::$ary_notIncl;
                    if (array_search($var_BC_delkey, $ary_notTested) !== false) {
                        self::$ary_treeCountPlanes[$param_depth + 1]++;
                        STTREE::$ary_walkFncNotTested[$var_BC_delkey . '_T' . $param_count] = 'Not in Testsystem right now STREEHELPER::getMainMenu';
                        unset($var_currrent_MTPreferenceBC[$var_BC_delkey]);
                    }
                }

                $var_num = count($param_history);
                foreach ($var_currrent_MTPreferenceBC as $var_BC_key => $var_BC_value) {
                    $varString = '';
                    $i = 0;
                    $varString .= '| ----- ----- ----- ';
                    for ($i = 1; $i < $param_depth; $i++) {
                        $varString .= '+ ----- ----- ----- ';
                    }
                    STTree::$ary_PrintTree[] = "<?php  echo '</b><br><i>'; echo '$varString'; echo '$var_BC_key'; echo '</i>'; ?>";
                    //$varString .= '			';
                    //                                        echo '</b><br><i> 98 ';
                    //                                        echo $varString;
                    //                                        echo $var_BC_key;
                    //                                        echo '</i>';
                    //                                          D::show($var_BC_value, $var_BC_key.' ::getMainMenu', 1, 1);
                    if (!key_exists($param_depth + 1, self::$ary_treeCountPlanes)) {
                        array_push(self::$ary_treeCountPlanes, $param_depth + 1);
                    }
                    self::$ary_treeCountPlanes[$param_depth + 1]++;
                    STTREEHelpers::push_element($var_BC_key, $param_history, '$ary_fullTreeGET', 'getMainMenu:104');
                    $param_history[$var_num] = $var_BC_key;
                    STTREEHelpers::menu_fromBC($var_BC_key, $param_history, '0', $param_depth);

                    STTREEHelpers::atachMenu_fromBC($var_BC_key, $param_history, $param_count, $param_depth);
                    self::getMainMenu($var_BC_key, $param_history, $param_count, $param_depth);
                    unset($param_history[$var_num]);
                }
            }
        }
    }

    private static function menu_fromBC($param_current_class, $param_history, $param_count, $param_depth) {
        $array_BCPreferencesMenu = CONFIG::getBasisClipboardPreferencs($param_current_class, 'Menu');

//		if($param_current_class === 'OutBox') {
//			$array_BCPreferencesMenu = array('Menu_newMessage'=> '');
//		}
        if (is_array($array_BCPreferencesMenu)) {
            $var_num = count($param_history);
            foreach ($array_BCPreferencesMenu as $var_BC_key => $var_BC_value) {
                $param_history[$var_num] = 'Menu';
                STTREEHelpers::push_element($var_BC_key, $param_history, '$ary_fullTreeGET', 'menu_fromBC:130');
                $param_history[$var_num] = $var_BC_key;
                unset($param_history[$var_num]);
            }
        }
    }

    private static function atachMenu_fromBC($param_current_class, $param_history, $param_count, $param_depth) {
        if ($param_current_class === 'SubProfileManagement' && $param_history[3] === 'SubProfileManagement') {
            return;
        }
        if (array_search($param_current_class, STTREE::$ary_notIncl) !== false) {
            STTREE::$ary_walkFncNotTested[$param_current_class . '_T' . $param_count] = 'Not in Testsystem right now STREEHELPER::atachMenu_fromBC';
            return;
        }
        if (is_string($param_current_class) && $param_depth < (self::$varDepthMax - 1)) {
            $param_depth++;
            $var_MT = CONFIG::getBC_MultimediaText($param_current_class);
        }
        if ($param_depth >= (self::$varDepthMax)) {
            return;
        }

        if (isset($var_MT) && $var_MT != '*') {
            $array_BCMenu = CONFIG::getMT_BasisClipboards($var_MT, 'BasisClipboards');
            if (is_array($array_BCMenu)) {
                $var_num = count($param_history);

                foreach ($array_BCMenu as $var_BC_key => $var_BC_value) {
                    if (array_search($var_BC_key, STTREE::$ary_notIncl) !== false) {
                        STTREE::$ary_walkFncNotTested[$var_BC_key . '_T' . $param_count] = 'Not in Testsystem right now STREEHELPER::atachMenu_fromBC';
                    } else {
                        if ($var_BC_key === 'SubProfileManagement') {
                            
                        } else {
                            self::$ary_treeCountPlanes[$param_depth + 1]++;
                            self::push_element($var_BC_key, $param_history, '$ary_fullTreeGET', 'atachMenu_fromBC:181');
                            self::menu_fromBC($var_BC_key, $param_history, $param_count, $param_depth);
                            $param_history_copy = $param_history;
                            $param_history[$var_num] = $var_BC_key;
                            $varString = '';
                            $i = 0;
                            $varString .= '| ----- ----- ----- ';
                            for ($i = 1; $i < $param_depth; $i++) {
                                $varString .= '+ ----- ----- ----- ';
                            }
                            STTree::$ary_PrintTree[] = "<?php   echo '</b><br><i>'; echo '$varString'; echo '$var_BC_key'; echo '</i>'; ?>";
                            self::atachMenu_fromBC($var_BC_key, $param_history, $param_count, $param_depth);
                            unset($param_history[$var_num]);
                        }
                    }
                }
            }
        }
    }

    private static function push_element($param_name, $_paramHistory, $param_ArrayName='$ary_fullTreeGET', $param_forDebug=null) {
        $number = count($_paramHistory) - 1;
        if ($number == '0') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$param_name] = array('1');
        } else if ($number == '1' && self::$varDepthMax > '0') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$param_name] = array('2');
        } else if ($number == '2' && self::$varDepthMax > '0') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$param_name] = array('3');
        } else if ($number == '3' && self::$varDepthMax > '0') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$_paramHistory['3']][$param_name] = array('4');
        } else if ($number == '4' && self::$varDepthMax > '1') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$_paramHistory['3']][$_paramHistory['4']][$param_name] = array('5');
        } else if ($number == '5' && self::$varDepthMax > '2') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$_paramHistory['3']][$_paramHistory['4']][$_paramHistory['5']][$param_name] = array('6');
        } else if ($number == '6' && self::$varDepthMax > '3') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$_paramHistory['3']][$_paramHistory['4']][$_paramHistory['5']][$_paramHistory['6']][$param_name] = array('7');
        } else if ($number == '7' && self::$varDepthMax > '4') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$_paramHistory['3']][$_paramHistory['4']][$_paramHistory['5']][$_paramHistory['6']][$_paramHistory['7']][$param_name] = array('8');
        } else if ($number == '8' && self::$varDepthMax > '5') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$_paramHistory['3']][$_paramHistory['4']][$_paramHistory['5']][$_paramHistory['6']][$_paramHistory['7']][$_paramHistory['8']][$param_name] = array('9');
        } else if ($number == '9' && self::$varDepthMax > '6') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$_paramHistory['3']][$_paramHistory['4']][$_paramHistory['5']][$_paramHistory['6']][$_paramHistory['7']][$_paramHistory['8']][$_paramHistory['9']][$param_name] = array('10');
        } else if ($number == '10' && self::$varDepthMax > '7') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$_paramHistory['3']][$_paramHistory['4']][$_paramHistory['5']][$_paramHistory['6']][$_paramHistory['7']][$_paramHistory['8']][$_paramHistory['9']][$_paramHistory['10']][$param_name] = array('11');
        } else if ($number == '11' && self::$varDepthMax > '8') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$_paramHistory['3']][$_paramHistory['4']][$_paramHistory['5']][$_paramHistory['6']][$_paramHistory['7']][$_paramHistory['8']][$_paramHistory['9']][$_paramHistory['10']][$_paramHistory['11']][$param_name] = array('12');
        } else if ($number == '12' && self::$varDepthMax > '9') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$_paramHistory['3']][$_paramHistory['4']][$_paramHistory['5']][$_paramHistory['6']][$_paramHistory['7']][$_paramHistory['8']][$_paramHistory['9']][$_paramHistory['10']][$_paramHistory['11']][$_paramHistory['12']][$param_name] = array('13');
        } else if ($number == '13' && self::$varDepthMax > '10') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$_paramHistory['3']][$_paramHistory['4']][$_paramHistory['5']][$_paramHistory['6']][$_paramHistory['7']][$_paramHistory['8']][$_paramHistory['9']][$_paramHistory['10']][$_paramHistory['11']][$_paramHistory['12']][$_paramHistory['13']][$param_name] = array('14');
        } else if ($number == '14' && self::$varDepthMax > '11') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$_paramHistory['3']][$_paramHistory['4']][$_paramHistory['5']][$_paramHistory['6']][$_paramHistory['7']][$_paramHistory['8']][$_paramHistory['9']][$_paramHistory['10']][$_paramHistory['11']][$_paramHistory['12']][$_paramHistory['13']][$_paramHistory['14']][$param_name] = array('15');
        } else if ($number == '15' && self::$varDepthMax > '12') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$_paramHistory['3']][$_paramHistory['4']][$_paramHistory['5']][$_paramHistory['6']][$_paramHistory['7']][$_paramHistory['8']][$_paramHistory['9']][$_paramHistory['10']][$_paramHistory['11']][$_paramHistory['12']][$_paramHistory['13']][$_paramHistory['14']][$_paramHistory['15']][$param_name] = array('16');
        } else if ($number == '16' && self::$varDepthMax > '13') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$_paramHistory['3']][$_paramHistory['4']][$_paramHistory['5']][$_paramHistory['6']][$_paramHistory['7']][$_paramHistory['8']][$_paramHistory['9']][$_paramHistory['10']][$_paramHistory['11']][$_paramHistory['12']][$_paramHistory['13']][$_paramHistory['14']][$_paramHistory['15']][$_paramHistory['16']][$param_name] = array('17');
        } else if ($number == '17' && self::$varDepthMax > '14') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$_paramHistory['3']][$_paramHistory['4']][$_paramHistory['5']][$_paramHistory['6']][$_paramHistory['7']][$_paramHistory['8']][$_paramHistory['9']][$_paramHistory['10']][$_paramHistory['11']][$_paramHistory['12']][$_paramHistory['13']][$_paramHistory['14']][$_paramHistory['15']][$_paramHistory['16']][$_paramHistory['17']][$param_name] = array('18');
        } else if ($number == '18' && self::$varDepthMax > '15') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$_paramHistory['3']][$_paramHistory['4']][$_paramHistory['5']][$_paramHistory['6']][$_paramHistory['7']][$_paramHistory['8']][$_paramHistory['9']][$_paramHistory['10']][$_paramHistory['11']][$_paramHistory['12']][$_paramHistory['13']][$_paramHistory['14']][$_paramHistory['15']][$_paramHistory['16']][$_paramHistory['17']][$_paramHistory['18']][$param_name] = array('19');
        } else if ($number == '19' && self::$varDepthMax > '16') {
            STTREEHelpers::$ary_fullTreeGET[$_paramHistory['0']][$_paramHistory['1']][$_paramHistory['2']][$_paramHistory['3']][$_paramHistory['4']][$_paramHistory['5']][$_paramHistory['6']][$_paramHistory['7']][$_paramHistory['8']][$_paramHistory['9']][$_paramHistory['10']][$_paramHistory['11']][$_paramHistory['12']][$_paramHistory['13']][$_paramHistory['14']][$_paramHistory['15']][$_paramHistory['16']][$_paramHistory['17']][$_paramHistory['18']][$_paramHistory['19']][$param_name] = array('20');
        } else {
            print_r('\n\n' . $param_ary['fullUrl'] . 'ERROR: to much Elements (max. 19): ' . $number . '; in SimpleTest: Method: ' . __METHOD__ . ' Line: ' . __LINE__ . '\n\n');
        }
    }

}
?>