Ejemplo n.º 1
0
function exportMenu($id, $option)
{
    global $my, $mainframe, $dbprefix;
    global $lang, $offset, $db;
    $absolute_path = JPATH_ROOT;
    $database =& JFactory::getDBO();
    include $absolute_path . "/modules/mod_swmenupro/styles.php";
    $css = "";
    $database->setQuery("SELECT * FROM #__swmenu_config WHERE id='" . $id . "'");
    $result = $database->loadObjectList();
    $swmenupro = array();
    while (list($key, $val) = each($result[0])) {
        $swmenupro[$key] = $val;
    }
    $row =& JTable::getInstance('module');
    // load the row from the db table
    $row->load($id);
    $registry = new JRegistry();
    $registry->loadINI($row->params);
    $params = $registry->toObject();
    $menu = @$params->menutype ? $params->menutype : 'mainmenu';
    $menustyle = @$params->menustyle;
    $hybrid = @$params->hybrid ? $params->hybrid : 0;
    $css_load = @$params->cssload ? $params->cssload : 0;
    $use_table = @$params->tables ? $params->tables : 0;
    $levels = @$params->levels ? $params->levels : 25;
    $show_shadow = @$params->show_shadow ? $params->show_shadow : 0;
    $moduleID = @$params->moduleID;
    $parent_id = @$params->parentid ? $params->parentid : '0';
    $modulename = $row->title;
    $swmenupro_array = array();
    $swmenupro_array = swGetMenuLinks2($menu, $row->id, $hybrid, $use_table);
    if (count($swmenupro_array)) {
        $ordered = chain2('ID', 'PARENT', 'ORDER', $swmenupro_array, 0, 25);
    }
    switch ($menustyle) {
        case "popoutmenu":
            $css = TigraMenuStyle($swmenupro, $ordered);
            break;
        case "clickmenu":
            $css = ClickMenuStyle($swmenupro, $ordered);
            break;
        case "treemenu":
            $css = TreeMenuStyle($swmenupro, $ordered);
            break;
        case "gosumenu":
            $css = gosuMenuStyle($swmenupro, $ordered);
            break;
        case "transmenu":
            $css = transMenuStyle($swmenupro, $ordered, $show_shadow);
            break;
        case "clicktransmenu":
            $css = clickTransMenuStyle($swmenupro, $ordered);
            break;
        case "tabmenu":
            $css = cssTabMenuStyle($swmenupro, $ordered);
            break;
        case "slideclick":
            $css = SlideClickStyle($swmenupro, $ordered);
            break;
        case "dynamictabmenu":
            $css = dynamicTabMenuStyle($swmenupro, $ordered);
            break;
    }
    $file = $absolute_path . "/modules/mod_swmenupro/styles/menu" . $id . ".css";
    if (!file_exists($file)) {
        touch($file);
        $handle = fopen($file, 'w');
        // Let's open for read and write
    } else {
        $handle = fopen($file, 'w');
        // Let's open for read and write
    }
    rewind($handle);
    // Go back to the beginning
    if (fwrite($handle, $css)) {
        $msg = _SW_SAVE_MENU_CSS_MESSAGE;
    } else {
        $msg = _SW_NO_SAVE_MENU_CSS_MESSAGE;
    }
    // Don't forget to increment the counter
    fclose($handle);
    // Done
    return $msg;
    $limit = intval(JRequest::getVar('limit', 10));
    $limitstart = intval(JRequest::getVar('limitstart', 0));
    //  mosRedirect( "index2.php?task=showmodules&option=$option&limit=$limit&limitstart=$limitstart",$msg );
}
Ejemplo n.º 2
0
function saveconfig($id, $option)
{
    //echo "hello";
    global $my, $mainframe, $dbprefix;
    global $lang, $offset, $db;
    $absolute_path = JPATH_ROOT;
    $database =& JFactory::getDBO();
    $moduleid = JRequest::getVar('moduleID', array(0));
    $menutype = JRequest::getVar('menutype', "mainmenu");
    $menu = JRequest::getVar('menuid', array());
    $export = JRequest::getVar('export2', 0);
    $msg = _SW_SAVE_MENU_MESSAGE;
    $row =& JTable::getInstance('module');
    if (!$row->bind($_POST)) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    if (!$row->check()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->position = JRequest::getVar("position2", "left");
    if (!$row->store()) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->checkin();
    //$row->updateOrder( "position='$row->position'" );
    $row->module = "mod_swmenufree";
    $parent_id = JRequest::getVar('parentid', 0);
    $levels = JRequest::getVar('levels', 0);
    $moduleID = $row->id;
    $menustyle = JRequest::getVar('menustyle', 'popoutmenu');
    $css_load = JRequest::getVar('cssload', 0);
    $hybrid = JRequest::getVar('hybrid', 0);
    $active_menu = JRequest::getVar('active_menu', 0);
    $editor_hack = JRequest::getVar('editor_hack', 0);
    $parent_level = JRequest::getVar('parent_level', 0);
    $cache = JRequest::getVar('cache', 0);
    $cache_time = JRequest::getVar('cache_time', "1 hour");
    $moduleclass_sfx = JRequest::getVar('moduleclass_sfx', "");
    $tables = JRequest::getVar('tables', 0);
    $auto_position = JRequest::getVar('auto_position', 0);
    $padding_hack = JRequest::getVar('padding_hack', 0);
    $overlay_hack = JRequest::getVar('overlay_hack', 0);
    $sub_indicator = JRequest::getVar('sub_indicator', 0);
    $selectbox_hack = JRequest::getVar('selectbox_hack', 0);
    $show_shadow = JRequest::getVar('show_shadow', 0);
    $template = JRequest::getVar('template', "");
    $language = JRequest::getVar('language', "*");
    $component = JRequest::getVar('component', "");
    if ($row->module != "mod_mainmenu") {
        $params = "menutype=" . $menutype . "\n";
        $params .= "menustyle=" . $menustyle . "\n";
        $params .= "moduleID=" . $row->id . "\n";
        $params .= "levels=" . $levels . "\n";
        $params .= "parentid=" . $parent_id . "\n";
        $params .= "parent_level=" . $parent_level . "\n";
        $params .= "hybrid=" . $hybrid . "\n";
        $params .= "active_menu=" . $active_menu . "\n";
        $params .= "tables=" . $tables . "\n";
        $params .= "cssload=" . $css_load . "\n";
        $params .= "sub_indicator=" . $sub_indicator . "\n";
        $params .= "selectbox_hack=" . $selectbox_hack . "\n";
        $params .= "show_shadow=" . $show_shadow . "\n";
        $params .= "padding_hack=" . $padding_hack . "\n";
        $params .= "overlay_hack=" . $overlay_hack . "\n";
        $params .= "auto_position=" . $auto_position . "\n";
        $params .= "cache=" . $cache . "\n";
        $params .= "cache_time=" . $cache_time . "\n";
        $params .= "moduleclass_sfx=" . $moduleclass_sfx . "\n";
        $params .= "editor_hack=" . $editor_hack . "\n";
        $params .= "template=" . $template . "\n";
        $params .= "language=" . $language . "\n";
        $params .= "component=" . $component . "\n";
        $row->params = $params;
        if (!$row->store()) {
            echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
    }
    $menus = JRequest::getVar('selections', array());
    $database->setQuery("DELETE FROM #__modules_menu WHERE moduleid='{$row->id}'");
    $database->query();
    foreach ($menus as $menuid) {
        $database->setQuery("INSERT INTO #__modules_menu" . "\nSET moduleid='{$row->id}', menuid='{$menuid}'");
        $database->query();
    }
    $id2 = $row->id;
    $row = new swmenufreeMenu($database);
    if (!$row->bind($_POST)) {
        echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
        exit;
    }
    $row->id = 1;
    $database->setQuery("SELECT COUNT(*) FROM #__swmenufree_config");
    $database->query();
    $count = $database->loadResult();
    //echo "hello";
    if ($count) {
        if (!$row->store()) {
            echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
    } else {
        $row->id = 0;
        if (!$row->store()) {
            echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n";
            exit;
        }
        $database->setQuery("UPDATE #__swmenufree_config SET id = '1' WHERE id = '0'");
        $database->query();
    }
    if ($export) {
        $msg = exportMenu($id2, $option);
    }
    if ($cache) {
        $file = $absolute_path . "/modules/mod_swmenufree/cache/menu.cache";
        $data = "";
        if (!file_exists($file)) {
            touch($file);
            $handle = fopen($file, 'w');
            // Let's open for read and write
            // $filedate=$now;
            $swmenufree_array = swGetMenuLinks2($menutype, $row->id, $hybrid, $tables);
            $ordered = chain2('ID', 'PARENT', 'ORDER', $swmenufree_array, $parent_id, $levels);
            foreach ($ordered as $swarray) {
                $data .= implode("'..'", $swarray) . "\n";
            }
            fwrite($handle, $data);
            // Don't forget to increment the counter
            fclose($handle);
            // Done
        } else {
            $handle = fopen($file, 'w');
            // Let's open for read and write
            $swmenufree_array = swGetMenuLinks2($menutype, $row->id, $hybrid, $tables);
            $ordered = chain2('ID', 'PARENT', 'ORDER', $swmenufree_array, $parent_id, $levels);
            foreach ($ordered as $swarray) {
                $data .= implode("'..'", $swarray) . "\n";
            }
            fwrite($handle, $data);
            // Don't forget to increment the counter
            fclose($handle);
        }
    }
    sleep(3);
    echo "<dl id=\"system-message\"><dt class=\"message\">Message</dt>\r\r\n\t\t<dd class=\"message message fade\"><ul><li>" . $msg . "</li>\r\r\n\t   </ul></dd></dl>\n";
    //editCSS($id, $option);
    editDhtmlMenu($row->id, $option);
    //$mainframe->redirect( "index2.php?option=$option",$msg );
}