function saveconfig($id, $option) { global $my, $mainframe, $dbprefix; global $lang, $offset, $db; $absolute_path = JPATH_ROOT; $database =& JFactory::getDBO(); if (!$id) { $id = intval(JRequest::getVar('id', 0)); } $swmenupro_array = array(); $now = date("Y-m-d H:i:s", time() + $offset * 60 * 60); $row =& JTable::getInstance('module'); // load the row from the db table $row->load($id); $moduleid = JRequest::getVar('moduleID', array(0)); $menutype = JRequest::getVar('menutype', "mainmenu"); $menu = JRequest::getVar('menuid', array()); $export = JRequest::getVar('export2', 0); $rowid = JRequest::getVar('rowid', array()); $showname = JRequest::getVar('showname', array()); $imagealign = JRequest::getVar('imagealign', array()); $targetlevel = JRequest::getVar('targetlevel', array()); $returntask = JRequest::getVar('returntask', "showmodules"); $msg = _SW_SAVE_MENU_MESSAGE; $row->params = "xvx"; //$row = new JModule( $database ); 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_swmenupro"; $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); $sub_indicator = JRequest::getVar('sub_indicator', 0); $selectbox_hack = JRequest::getVar('selectbox_hack', 0); $show_shadow = JRequest::getVar('show_shadow', 0); $padding_hack = JRequest::getVar('padding_hack', 0); $auto_position = JRequest::getVar('auto_position', 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 .= "cache=" . $cache . "\n"; $params .= "cache_time=" . $cache_time . "\n"; $params .= "moduleclass_sfx=" . $moduleclass_sfx . "\n"; $params .= "editor_hack=" . $editor_hack . "\n"; $params .= "padding_hack=" . $padding_hack . "\n"; $params .= "auto_position=" . $auto_position . "\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(); } $row = new swmenuproMenu($database); if (!$row->bind($_POST)) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-1); </script>\n"; exit; } $row->id = $row->id ? $row->id : $moduleID; $database->setQuery("SELECT count(*) FROM #__swmenu_config WHERE id='" . $row->id . "'"); $database->query(); $count = $database->loadResult(); if ($count >= 1) { $ret = $row->_db->updateObject($row->_tbl, $row, $row->_tbl_key); } else { $ret = $row->_db->insertObject($row->_tbl, $row, $row->_tbl_key); } $name = strval(JRequest::getVar('name', "")); $data2 = strval(JRequest::getVar('php_out', "")); $menuid = $row->id; $limit = intval(JRequest::getVar('limit', 10)); $limitstart = intval(JRequest::getVar('limitstart', 0)); $data3 = explode("}}", $data2); for ($i = 0; $i < count($data3) - 1; $i++) { $data4 = explode(";;", $data3[$i]); /* $val=trim($data4[0]."-id"); $item= trim( mosGetParam( $_REQUEST, $val, 0 ) ); $val=trim($data4[0]."_normal_css"); $normal_css= trim( mosGetParam( $_REQUEST, $val, "" ) ); $val=trim($data4[0]."_over_css"); $over_css= trim( mosGetParam( $_REQUEST, $val, "" ) ); $val=trim($data4[0]."_showitem"); $showitem= trim( mosGetParam( $_REQUEST, $val, 1 ) ); $val=trim($data4[0]."_target"); $targetlevel= trim( mosGetParam( $_REQUEST, $val, 1 ) ); */ $item = $data4[23]; $normal_css = $data4[20]; $over_css = $data4[21]; $showitem = $data4[22]; $targetlevel = $data4[6]; //echo $data4[8]."<br>".$item; //$image= ( mosGetParam( $_REQUEST, trim($data4[0]."-image"), "" ) ); if ($data4[8]) { $image = substr($data4[8], 3) . "," . $data4[10] . "," . $data4[11] . "," . $data4[12] . "," . $data4[13]; } else { $image = ""; } $showname = $data4[18]; $imagealign = $data4[19]; if ($data4[9]) { $imageover = substr($data4[9], 3) . "," . $data4[14] . "," . $data4[15] . "," . $data4[16] . "," . $data4[17]; } else { $imageover = ""; } //$targetlevel=1; $database->setQuery("SELECT COUNT(*) FROM #__swmenu_extended WHERE menu_id='" . $item . "' AND moduleID='" . $menuid . "'"); $database->query(); $exists = $database->loadResult(); if ($exists && $item) { $database->setQuery("UPDATE #__swmenu_extended SET image ='" . $image . "', image_over='" . $imageover . "', show_name='" . $showname . "', image_align='" . $imagealign . "', target_level='" . $targetlevel . "', normal_css='" . $normal_css . "', over_css='" . $over_css . "', show_item='" . $showitem . "' WHERE menu_id='" . $item . "' AND moduleID='" . $menuid . "'"); $database->query(); } elseif ($item) { $database->setQuery("INSERT INTO #__swmenu_extended VALUES ('','" . $item . "','" . $image . "','" . $imageover . "','" . $menuid . "','" . $showname . "','" . $imagealign . "','" . $targetlevel . "','" . $normal_css . "','" . $over_css . "','" . $showitem . "','')"); $database->query(); } } if ($export) { $msg = exportMenu($row->id, $option); } if ($cache) { $file = $absolute_path . "/modules/mod_swmenupro/cache/menu" . $row->id . ".cache"; $data = ""; if (!file_exists($file)) { touch($file); $handle = fopen($file, 'w'); // Let's open for read and write // $filedate=$now; $swmenupro_array = swGetMenuLinks2($menutype, $row->id, $hybrid, $tables); $ordered = chain2('ID', 'PARENT', 'ORDER', $swmenupro_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 $swmenupro_array = swGetMenuLinks2($menutype, $row->id, $hybrid, $tables); $ordered = chain2('ID', 'PARENT', 'ORDER', $swmenupro_array, $parent_id, $levels); foreach ($ordered as $swarray) { $data .= implode("'..'", $swarray) . "\n"; } fwrite($handle, $data); // Don't forget to increment the counter fclose($handle); } } $limit = intval(JRequest::getVar('limit', 10)); $limit = $limit ? $limit : 'all'; $limitstart = intval(JRequest::getVar('limitstart', 0)); if ($returntask == "editDhtmlMenu") { echo "<span class='message'>" . $msg . "</span>\n"; //editDhtmlMenu($row->id, $option); $mainframe->redirect("index.php?task={$returntask}&option={$option}&limit={$limit}&limitstart={$limitstart}&id={$row->id}", $msg); } else { $mainframe->redirect("index.php?task={$returntask}&option={$option}&limit={$limit}&limitstart={$limitstart}", $msg); //mosRedirect( "index2.php?task=$returntask&option=$option&limit=$limit&limitstart=$limitstart",$msg ); } }
function saveconfig() { $database =& JFactory::getDBO(); $export = JRequest::getVar('export2', 0); $msg = _SW_SAVE_MENU_MESSAGE; $style = ""; reset($_POST); while (list($key, $val) = each($_POST)) { $style .= $key . "=" . $val . "\n"; } $database->setQuery("SELECT COUNT(*) FROM #__swmenufree_styles"); $database->query(); $count = $database->loadResult(); if ($count) { $database->setQuery("UPDATE #__swmenufree_styles SET params='" . $style . "' WHERE id = '1'"); $database->query(); } else { $database->setQuery("INSERT INTO #__swmenufree_styles" . "\nSET id='1', params='{$style}'"); $database->query(); } if ($export) { $msg = exportMenu(); } sleep(3); echo "<div id=\"system-message-container\"><div class=\"system-message\">\n\t\t{$msg}</div></div>\n"; editDhtmlMenu(); }
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 ); }