Code Duplication    Length = 26-26 lines in 2 locations

class/utility.php 1 location

@@ 672-697 (lines=26) @@
669
     * @author        Hervé Thouzard (http://www.herve-thouzard.com)
670
     * @copyright (c) Hervé Thouzard
671
     */
672
    public static function updateCache()
673
    {
674
        global $xoopsModule;
675
        $folder  = $xoopsModule->getVar('dirname');
676
        $tpllist = [];
677
        require_once XOOPS_ROOT_PATH . '/class/xoopsblock.php';
678
        require_once XOOPS_ROOT_PATH . '/class/template.php';
679
        $tplfileHandler = xoops_getHandler('tplfile');
680
        $tpllist        = $tplfileHandler->find(null, null, null, $folder);
681
        $xoopsTpl       = new XoopsTpl();
682
        xoops_template_clear_module_cache($xoopsModule->getVar('mid')); // Clear module's blocks cache
683
684
        // Remove cache for each page.
685
        foreach ($tpllist as $onetemplate) {
686
            if ('module' === $onetemplate->getVar('tpl_type')) {
687
                // Note, I've been testing all the other methods (like the one of Smarty) and none of them run, that's why I have used this code
688
                $files_del = [];
689
                $files_del = glob(XOOPS_CACHE_PATH . '/*' . $onetemplate->getVar('tpl_file') . '*');
690
                if (count($files_del) > 0) {
691
                    foreach ($files_del as $one_file) {
692
                        unlink($one_file);
693
                    }
694
                }
695
            }
696
        }
697
    }
698
699
    /**
700
     * Verify that a mysql table exists

include/functions.php 1 location

@@ 550-575 (lines=26) @@
547
 * @author        Hervé Thouzard (http://www.herve-thouzard.com)
548
 * @copyright (c) Hervé Thouzard
549
 */
550
function news_updateCache()
551
{
552
    global $xoopsModule;
553
    $folder  = $xoopsModule->getVar('dirname');
554
    $tpllist = [];
555
    require_once XOOPS_ROOT_PATH . '/class/xoopsblock.php';
556
    require_once XOOPS_ROOT_PATH . '/class/template.php';
557
    $tplfileHandler = xoops_getHandler('tplfile');
558
    $tpllist        = $tplfileHandler->find(null, null, null, $folder);
559
    $xoopsTpl       = new XoopsTpl();
560
    xoops_template_clear_module_cache($xoopsModule->getVar('mid')); // Clear module's blocks cache
561
562
    // Remove cache for each page.
563
    foreach ($tpllist as $onetemplate) {
564
        if ('module' === $onetemplate->getVar('tpl_type')) {
565
            // Note, I've been testing all the other methods (like the one of Smarty) and none of them run, that's why I have used this code
566
            $files_del = [];
567
            $files_del = glob(XOOPS_CACHE_PATH . '/*' . $onetemplate->getVar('tpl_file') . '*');
568
            if (count($files_del) > 0) {
569
                foreach ($files_del as $one_file) {
570
                    unlink($one_file);
571
                }
572
            }
573
        }
574
    }
575
}
576
577
/**
578
 * Verify that a mysql table exists