private function replaceElements($elements, $res)
    {
        $replaces = [];

        // Some components may be disabled for current page
        $disabled_components = Structure::getDisabledComponents();
        $cached_components = Structure::getCachedComponents();

        $cacher = Cacher::getInstance()->getDefaultCacher();

        // May be another MVC class that implements required features
        $this->mvc_instance = new MVC();

        // Change elements to its' real data
        foreach($elements as $k=> $v){

            if (in_array($v['class'], $disabled_components)) {
                // Skip disabled
                $replaces[$res[0][$k]] = '';
            } elseif (in_array($v['class'], $cached_components)) {
                // Get from hard cache
                $cache_key = PAGE_ID . '_' . md5(PAGE_ID . '_' . $k . '_' . $v['class']);
                $cached_value = $cacher->get($cache_key);
                if ($cached_value) {
                    $replaces[$res[0][$k]] = $cached_value;
                } else {
                    // Replace if not found in cache
                    $replaces[$res[0][$k]] = $this->callReplace($v);
                    // Save in cache
                    $cacher->set($cache_key, $replaces[$res[0][$k]]);
                }
            } else {
                // Usual replace
                $replaces[$res[0][$k]] = $this->callReplace($v);
            }

        }
        // Replace data with its' component variables in template
        if ($replaces) {
            reset($replaces);
            foreach($replaces as $k=>$v){
                $this->html = str_replace($k, $v, $this->html);
            }
        }
    }
private function replaceElements($elements, $res)
    {
        $replaces = [];

        // Some components may be disabled for current page
        $disabled_components = Structure::getDisabledComponents();
        $cached_components = Structure::getCachedComponents();

        $cacher = Cacher::getInstance()->getDefaultCacher();

        // May be another MVC class that implements required features
        $this->mvc_instance = new MVC();

        // Change elements to its' real data
        foreach($elements as $k=> $v){

            if (in_array($v['class'], $disabled_components)) {
                // Skip disabled
                $replaces[$res[0][$k]] = '';
            } elseif (in_array($v['class'], $cached_components)) {
                // Get from hard cache
                $cache_key = PAGE_ID . '_' . md5(PAGE_ID . '_' . $k . '_' . $v['class']);
                $cached_value = $cacher->get($cache_key);
                if ($cached_value) {
                    $replaces[$res[0][$k]] = $cached_value;
                } else {
                    // Replace if not found in cache
                    $replaces[$res[0][$k]] = $this->callReplace($v);
                    // Save in cache
                    $cacher->set($cache_key, $replaces[$res[0][$k]]);
                }
            } else {
                // Usual replace
                $replaces[$res[0][$k]] = $this->callReplace($v);
            }

        }
        // Replace data with its' component variables in template
        if ($replaces) {
            reset($replaces);
            foreach($replaces as $k=>$v){
                $this->html = str_replace($k, $v, $this->html);
            }
        }
    }
private function replaceElements ( $ elements , $ res ) { $ replaces = [ ] ; // Some components may be disabled for current page $ disabled_components = Structure :: getDisabledComponents ( ) ; $ cached_components = Structure :: getCachedComponents ( ) ; $ cacher = Cacher :: getInstance ( ) -> getDefaultCacher ( ) ; // May be another MVC class that implements required features $ this -> mvc_instance = new MVC ( ) ; // Change elements to its' real data foreach ( $ elements as $ k => $ v ) { if ( in_array ( $ v [ 'class' ] , $ disabled_components ) ) { // Skip disabled $ replaces [ $ res [ 0 ] [ $ k ] ] = '' ; } elseif ( in_array ( $ v [ 'class' ] , $ cached_components ) ) { // Get from hard cache $ cache_key = PAGE_ID . '_' . md5 ( PAGE_ID . '_' . $ k . '_' . $ v [ 'class' ] ) ; $ cached_value = $ cacher -> get ( $ cache_key ) ; if ( $ cached_value ) { $ replaces [ $ res [ 0 ] [ $ k ] ] = $ cached_value ; } else { // Replace if not found in cache $ replaces [ $ res [ 0 ] [ $ k ] ] = $ this -> callReplace ( $ v ) ; // Save in cache $ cacher -> set ( $ cache_key , $ replaces [ $ res [ 0 ] [ $ k ] ] ) ; } } else { // Usual replace $ replaces [ $ res [ 0 ] [ $ k ] ] = $ this -> callReplace ( $ v ) ; } } // Replace data with its' component variables in template if ( $ replaces ) { reset ( $ replaces ) ; foreach ( $ replaces as $ k => $ v ) { $ this -> html = str_replace ( $ k , $ v , $ this -> html ) ; } } }
Replaces component parts with it's real data set in admin panel
@param array $elements
@param array $res
Replaces component parts with it s real data set in admin panel