Пример #1
0
function swGetMenu($menu, $id, $hybrid, $cache, $cache_time, $use_table, $parent_id, $levels)
{
    global $my, $mainframe;
    $absolute_path = JPATH_ROOT;
    // $live_site=$mainframe->getSiteURL();
    $swmenupro_array = array();
    $ordered = array();
    $file = $absolute_path . "/modules/mod_swmenupro/cache/menu" . $id . ".cache";
    $final_menu = array();
    if ($cache) {
        $data = "";
        if (!file_exists($file)) {
            touch($file);
            $handle = fopen($file, 'w');
            $swmenupro_array = swGetMenuLinks($menu, $id, $hybrid, $use_table);
            $ordered = chain('ID', 'PARENT', 'ORDER', $swmenupro_array, $parent_id, $levels);
            for ($i = 0; $i < count($ordered); $i++) {
                $data .= implode("'..'", $ordered[$i]) . "\n";
            }
            fwrite($handle, $data);
            fclose($handle);
            $final_menu = get_Final_Menu($swmenupro_array, $parent_id, $levels);
        } else {
            if (strtotime($cache_time, filemtime($file)) < strtotime("now") && is_writable($file)) {
                $handle = fopen($file, 'w');
                $swmenupro_array = swGetMenuLinks($menu, $id, $hybrid, $use_table);
                $ordered = chain('ID', 'PARENT', 'ORDER', $swmenupro_array, $parent_id, $levels);
                for ($i = 0; $i < count($ordered); $i++) {
                    $data .= implode("'..'", $ordered[$i]) . "\n";
                }
                fwrite($handle, $data);
                fclose($handle);
                $final_menu = get_Final_Menu($swmenupro_array, $parent_id, $levels);
            } else {
                if (file_exists($file)) {
                    $swmenu = file($file);
                    for ($i = 0; $i < count($swmenu); $i++) {
                        $swmenupro[] = explode("'..'", $swmenu[$i]);
                        $final_menu[] = array("TITLE" => $swmenupro[$i][0], "URL" => $swmenupro[$i][1], "ID" => $swmenupro[$i][2], "PARENT" => $swmenupro[$i][3], "ORDER" => $swmenupro[$i][4], "IMAGE" => $swmenupro[$i][5], "IMAGEOVER" => $swmenupro[$i][6], "SHOWNAME" => $swmenupro[$i][7], "IMAGEALIGN" => $swmenupro[$i][8], "TARGETLEVEL" => $swmenupro[$i][9], "TARGET" => $swmenupro[$i][10], "ACCESS" => $swmenupro[$i][11], "NCSS" => $swmenupro[$i][12], "OCSS" => $swmenupro[$i][13], "SHOWITEM" => $swmenupro[$i][14], "TYPE" => $swmenupro[$i][15], "indent" => trim(substr($swmenu[$i], strlen($swmenu[$i]) - 2)));
                    }
                    $final_menu = get_Final_Menu($final_menu, $parent_id, $levels);
                }
            }
        }
    } else {
        $swmenupro_array = swGetMenuLinks($menu, $id, $hybrid, $use_table);
        $final_menu = get_Final_Menu($swmenupro_array, $parent_id, $levels);
    }
    return $final_menu;
}
Пример #2
0
function swGetMenu($menu, $id, $hybrid, $cache, $cache_time, $use_table, $parent_id, $levels)
{
    global $my, $mainframe;
    $start = time();
    $absolute_path = JPATH_ROOT;
    $config =& JFactory::getConfig();
    $langsw = $config->get('language');
    $swmenupro_array = array();
    $ordered = array();
    $final_menu = array();
    $file = $absolute_path . "/modules/mod_swmenufree/cache/{$menu},{$id},{$hybrid},{$cache},{$cache_time},{$use_table},{$parent_id},{$levels},{$langsw}.cache";
    if ($cache) {
        if (!file_exists($file)) {
            $swmenupro_array = swGetMenuLinks($menu, $id, $hybrid, $use_table);
            $final_menu = get_Final_Menu($swmenupro_array, $parent_id, $levels);
            $handle = fopen($file, 'w');
            fwrite($handle, var_export($final_menu, 1));
            fclose($handle);
        } else {
            if (strtotime($cache_time, filemtime($file)) < strtotime("now") && is_writable($file)) {
                $swmenupro_array = swGetMenuLinks($menu, $id, $hybrid, $use_table);
                $final_menu = get_Final_Menu($swmenupro_array, $parent_id, $levels);
                $handle = fopen($file, 'w');
                fwrite($handle, var_export($final_menu, 1));
                fclose($handle);
            } else {
                if (file_exists($file)) {
                    $handle = fopen($file, 'r');
                    $import = fread($handle, 1000000);
                    fclose($handle);
                    eval('$final_menu = ' . $import . ';');
                }
            }
        }
    } else {
        $swmenupro_array = swGetMenuLinks($menu, $id, $hybrid, $use_table);
        $final_menu = get_Final_Menu($swmenupro_array, $parent_id, $levels);
    }
    return $final_menu;
}