예제 #1
0
function upgrade()
{
    $database =& JFactory::getDBO();
    $absolute_path = JPATH_ROOT;
    $config =& JFactory::getConfig();
    $dbprefix = $config->get('dbprefix');
    $row = new stdClass();
    //echo $db;
    $row->message = "";
    $row->database_version = 1;
    if (TableExists($dbprefix . "swmenufree_config")) {
        $query = "SELECT * FROM #__swmenufree_config WHERE id = 1";
        $database->setQuery($query);
        $result = $database->loadObjectList();
        $swmenufree = array();
        $sql = "SELECT id FROM #__modules where module='mod_swmenufree' AND published > -1";
        $database->setQuery($sql);
        $id = $database->loadResult();
        $row =& JTable::getInstance('module');
        // load the row from the db table
        $row->load($id);
        $row->message = "";
        if ($result) {
            $style = $row->params;
            while (list($key, $val) = each($result[0])) {
                $swmenufree[$key] = $val;
                if ($key == 'id') {
                    $val = $row->id;
                    $style .= $key . "=" . $val . "\n";
                } else {
                    if ($key == 'corners') {
                        $style .= $val . "\n";
                    } else {
                        if ($key == 'sub_indicator') {
                            $style .= $val . "\n";
                        } else {
                            if ($key == 'sub_padding') {
                                $padding = explode("px", $val);
                                $style .= "sub_pad_top=" . $padding[0] . "\n";
                                $style .= "sub_pad_right=" . $padding[1] . "\n";
                                $style .= "sub_pad_bottom=" . $padding[2] . "\n";
                                $style .= "sub_pad_left=" . $padding[3] . "\n";
                            } else {
                                if ($key == 'main_padding') {
                                    $padding = explode("px", $val);
                                    $style .= "main_pad_top=" . $padding[0] . "\n";
                                    $style .= "main_pad_right=" . $padding[1] . "\n";
                                    $style .= "main_pad_bottom=" . $padding[2] . "\n";
                                    $style .= "main_pad_left=" . $padding[3] . "\n";
                                } else {
                                    if ($key == 'complete_padding') {
                                        $padding = explode("px", $val);
                                        $style .= "complete_margin_top=" . $padding[0] . "\n";
                                        $style .= "complete_margin_right=" . $padding[1] . "\n";
                                        $style .= "complete_margin_bottom=" . $padding[2] . "\n";
                                        $style .= "complete_margin_left=" . $padding[3] . "\n";
                                    } else {
                                        if ($key == 'top_margin') {
                                            $padding = explode("px", $val);
                                            $style .= "top_margin_top=" . $padding[0] . "\n";
                                            $style .= "top_margin_right=" . $padding[1] . "\n";
                                            $style .= "top_margin_bottom=" . $padding[2] . "\n";
                                            $style .= "top_margin_left=" . $padding[3] . "\n";
                                        } else {
                                            if ($key == 'main_border') {
                                                $border = explode(" ", $val);
                                                $style .= "main_border_width=" . rtrim(trim($border[0]), 'px') . "\n";
                                                $style .= "main_border_style=" . $border[1] . "\n";
                                                $style .= "main_border_color=" . $border[2] . "\n";
                                            } else {
                                                if ($key == 'main_border_over') {
                                                    $border = explode(" ", $val);
                                                    $style .= "main_border_over_width=" . rtrim(trim($border[0]), 'px') . "\n";
                                                    $style .= "main_border_over_style=" . $border[1] . "\n";
                                                    $style .= "main_border_color_over=" . $border[2] . "\n";
                                                } else {
                                                    if ($key == 'sub_border') {
                                                        $border = explode(" ", $val);
                                                        $style .= "sub_border_width=" . rtrim(trim($border[0]), 'px') . "\n";
                                                        $style .= "sub_border_style=" . $border[1] . "\n";
                                                        $style .= "sub_border_color=" . $border[2] . "\n";
                                                    } else {
                                                        if ($key == 'sub_border_over') {
                                                            $border = explode(" ", $val);
                                                            $style .= "sub_border_over_width=" . rtrim(trim($border[0]), 'px') . "\n";
                                                            $style .= "sub_border_over_style=" . $border[1] . "\n";
                                                            $style .= "sub_border_color_over=" . $border[2] . "\n";
                                                        } else {
                                                            $style .= $key . "=" . $val . "\n";
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            $style .= "top_sub_indicator_top=0\n";
            $style .= "top_sub_indicator_left=0\n";
            $style .= "top_sub_indicator_align=right\n";
            $style .= "sub_sub_indicator_top=0\n";
            $style .= "sub_sub_indicator_left=0\n";
            $style .= "sub_sub_indicator_align=right\n";
            $style .= "tablet_hack=0\n";
            $style .= "complete_background_position=top left\n";
            $style .= "active_background_position=top left\n";
            $style .= "top_background_position=top left\n";
            $style .= "sub_background_position=top left\n";
            $style .= "top_hover_background_position=top left\n";
            $style .= "sub_hover_background_position=top left\n";
            $style .= "complete_background_repeat=repeat\n";
            $style .= "active_background_repeat=repeat\n";
            $style .= "top_background_repeat=repeat\n";
            $style .= "sub_background_repeat=repeat\n";
            $style .= "top_hover_background_repeat=repeat\n";
            $style .= "sub_hover_background_repeat=repeat\n";
            if (TableExists($dbprefix . "swmenufree_styles")) {
                $query = "SELECT * FROM #__swmenufree_styles WHERE id = 1";
                $database->setQuery($query);
                $styles = $database->loadObjectList();
                if (!count($styles)) {
                    $row->message .= "Copying swmenufree_config table to swmenufree_styles<br />";
                    $database->setQuery("INSERT INTO #__swmenufree_styles SET id='1', params='{$style}'");
                    $database->query();
                }
            } else {
                $database->setQuery(" CREATE TABLE IF NOT EXISTS #__swmenufree_styles (\n                      `id` int(11) NOT NULL,\n                      `params` text,\n                       PRIMARY KEY (`id`)\n                     ) ENGINE=MyISAM DEFAULT CHARSET=utf8;\n                    ");
                $row->message .= "Creating swmenufree_styles table and copying swmenufree_config table to swmenufree_styles<br />";
                $database->query();
                $database->setQuery("INSERT INTO #__swmenufree_styles SET id='1', params='{$style}'");
                $database->query();
            }
        }
        //echo count($swmenufree);
    } else {
        if (TableExists($dbprefix . "swmenufree_styles")) {
            $query = "SELECT * FROM #__swmenufree_styles WHERE id = 1";
            $database->setQuery($query);
            $styles = $database->loadObjectList();
            if (!count($styles)) {
                $row->message .= "Creating default style<br />";
                $database->setQuery("INSERT INTO `#__swmenufree_styles` (`id`, `params`) VALUES\n(1, 'position=left\norientation=vertical/right\nmain_width=0\nmain_height=0\nsub_width=0\nsub_height=0\nmain_top=0\nmain_left=0\nlevel1_sub_top=0\nlevel1_sub_left=0\nlevel2_sub_top=0\nlevel2_sub_left=0\ncomplete_margin_top=8\ncomplete_margin_right=16\ncomplete_margin_bottom=16\ncomplete_margin_left=16\ntop_margin_top=12\ntop_margin_right=0\ntop_margin_bottom=0\ntop_margin_left=0\nmain_pad_top=11\nmain_pad_right=28\nmain_pad_bottom=11\nmain_pad_left=20\nsub_pad_top=9\nsub_pad_right=29\nsub_pad_bottom=10\nsub_pad_left=15\ncomplete_background_image=\ncomplete_background_repeat=repeat\ncomplete_background_position=left top\nactive_background_image=\nactive_background_repeat=repeat\nactive_background_position=left top\nmain_back_image=\ntop_background_repeat=repeat\ntop_background_position=left top\nmain_back_image_over=\ntop_hover_background_repeat=repeat\ntop_hover_background_position=left top\nsub_back_image=\nsub_background_repeat=repeat\nsub_background_position=left top\nsub_back_image_over=\nsub_hover_background_repeat=repeat\nsub_hover_background_position=left top\ncomplete_background=#4E84CC\nactive_background=#942E8D\nmain_back=#0F3322\nmain_over=#163961\nsub_back=#168C9E\nsub_over=#D1FF54\ntop_sub_indicator=images/swmenufree/arrows/whiteleft-on.gif\ntop_sub_indicator_align=right\ntop_sub_indicator_top=0\ntop_sub_indicator_left=13\nsub_sub_indicator=images/swmenufree/arrows/blackleft-on.gif\nsub_sub_indicator_align=right\nsub_sub_indicator_top=0\nsub_sub_indicator_left=13\nfont_family=Times New Roman, Times, serif\nsub_font_family=Times New Roman, Times, serif\ntop_ttf=\nsub_ttf=\nmain_font_color=#EBEFF5\nmain_font_color_over=#E1EBE4\nsub_font_color=#FEFFF5\nsub_font_color_over=#0A1F14\nactive_font=#F0F09E\nmain_font_size=15\nsub_font_size=15\nfont_weight=normal\nfont_weight_over=normal\nmain_align=left\nsub_align=left\ntop_wrap=nowrap\nsub_wrap=nowrap\ntop_font_extra=\nsub_font_extra=\nmain_border_width=3\nmain_border_over_width=0\nsub_border_width=0\nsub_border_over_width=0\nmain_border_style=solid\nmain_border_over_style=none\nsub_border_style=none\nsub_border_over_style=none\nmain_border_color=#17050E\nmain_border_color_over=#F34AFF\nsub_border_color=#061C1B\nsub_border_color_over=#94FFB4\nc_corner_style=curvycorner\nc_corner_size=23\nctl_corner=1\ncbr_corner=1\nt_corner_style=none\nt_corner_size=12\nttl_corner=1\ntbr_corner=1\ns_corner_style=none\ns_corner_size=12\nstl_corner=1\nstr_corner=1\nsbl_corner=1\nsbr_corner=1\nmenustyle=mygosumenu\nmenutype=mainmenu\nparentid=0\nlevels=0\nactive_menu=1\ncssload=0\nhybrid=0\ntables=0\noverlay_hack=1\npadding_hack=0\nauto_position=1\nflash_hack=0\ndisable_jquery=0\ntablet_hack=0\nextra=fade\nspecialB=321\nspecialA=80\npreview_background=#FFFFFF\ntitle=swMenuFree\nborder_hack=0\noption=com_swmenufree\ntmpl=index\ntask=saveedit\nid=108\ntop_font_face=\nsub_font_face=\npreview=dynamic\nexport2=\ndefaultfolder=swmenufree\n');\n");
                $database->query();
            }
        } else {
            $database->setQuery(" CREATE TABLE IF NOT EXISTS #__swmenufree_styles (\n                      `id` int(11) NOT NULL,\n                      `params` text,\n                       PRIMARY KEY (`id`)\n                     ) ENGINE=MyISAM DEFAULT CHARSET=utf8;\n                    ");
            $row->message .= "Creating swmenufree_styles table and default style<br />";
            $database->query();
            $database->setQuery("INSERT INTO `#__swmenufree_styles` (`id`, `params`) VALUES\n(1, 'position=left\norientation=vertical/right\nmain_width=0\nmain_height=0\nsub_width=0\nsub_height=0\nmain_top=0\nmain_left=0\nlevel1_sub_top=0\nlevel1_sub_left=0\nlevel2_sub_top=0\nlevel2_sub_left=0\ncomplete_margin_top=8\ncomplete_margin_right=16\ncomplete_margin_bottom=16\ncomplete_margin_left=16\ntop_margin_top=12\ntop_margin_right=0\ntop_margin_bottom=0\ntop_margin_left=0\nmain_pad_top=11\nmain_pad_right=28\nmain_pad_bottom=11\nmain_pad_left=20\nsub_pad_top=9\nsub_pad_right=29\nsub_pad_bottom=10\nsub_pad_left=15\ncomplete_background_image=\ncomplete_background_repeat=repeat\ncomplete_background_position=left top\nactive_background_image=\nactive_background_repeat=repeat\nactive_background_position=left top\nmain_back_image=\ntop_background_repeat=repeat\ntop_background_position=left top\nmain_back_image_over=\ntop_hover_background_repeat=repeat\ntop_hover_background_position=left top\nsub_back_image=\nsub_background_repeat=repeat\nsub_background_position=left top\nsub_back_image_over=\nsub_hover_background_repeat=repeat\nsub_hover_background_position=left top\ncomplete_background=#4E84CC\nactive_background=#942E8D\nmain_back=#0F3322\nmain_over=#163961\nsub_back=#168C9E\nsub_over=#D1FF54\ntop_sub_indicator=images/swmenufree/arrows/whiteleft-on.gif\ntop_sub_indicator_align=right\ntop_sub_indicator_top=0\ntop_sub_indicator_left=13\nsub_sub_indicator=images/swmenufree/arrows/blackleft-on.gif\nsub_sub_indicator_align=right\nsub_sub_indicator_top=0\nsub_sub_indicator_left=13\nfont_family=Times New Roman, Times, serif\nsub_font_family=Times New Roman, Times, serif\ntop_ttf=\nsub_ttf=\nmain_font_color=#EBEFF5\nmain_font_color_over=#E1EBE4\nsub_font_color=#FEFFF5\nsub_font_color_over=#0A1F14\nactive_font=#F0F09E\nmain_font_size=15\nsub_font_size=15\nfont_weight=normal\nfont_weight_over=normal\nmain_align=left\nsub_align=left\ntop_wrap=nowrap\nsub_wrap=nowrap\ntop_font_extra=\nsub_font_extra=\nmain_border_width=3\nmain_border_over_width=0\nsub_border_width=0\nsub_border_over_width=0\nmain_border_style=solid\nmain_border_over_style=none\nsub_border_style=none\nsub_border_over_style=none\nmain_border_color=#17050E\nmain_border_color_over=#F34AFF\nsub_border_color=#061C1B\nsub_border_color_over=#94FFB4\nc_corner_style=curvycorner\nc_corner_size=23\nctl_corner=1\ncbr_corner=1\nt_corner_style=none\nt_corner_size=12\nttl_corner=1\ntbr_corner=1\ns_corner_style=none\ns_corner_size=12\nstl_corner=1\nstr_corner=1\nsbl_corner=1\nsbr_corner=1\nmenustyle=mygosumenu\nmenutype=mainmenu\nparentid=0\nlevels=0\nactive_menu=1\ncssload=0\nhybrid=0\ntables=0\noverlay_hack=1\npadding_hack=0\nauto_position=1\nflash_hack=0\ndisable_jquery=0\ntablet_hack=0\nextra=fade\nspecialB=321\nspecialA=80\npreview_background=#FFFFFF\ntitle=swMenuFree\nborder_hack=0\noption=com_swmenufree\ntmpl=index\ntask=saveedit\nid=108\ntop_font_face=\nsub_font_face=\npreview=dynamic\nexport2=\ndefaultfolder=swmenufree\n');\n");
            $database->query();
        }
    }
    $database->setQuery("SELECT COUNT(*) FROM `#__extensions` WHERE element LIKE '%com_swmenufree%'");
    $com_entries = $database->loadResult();
    if ($com_entries != 1) {
        $row->message .= _SW_UPDATE_LINKS . "<br />";
        //$database->setQuery("DELETE FROM `#__components` WHERE admin_menu_link like '%com_swmenufree%'");
        //$database->query();
        $database->setQuery("INSERT INTO `#__extensions` VALUES ( '', 'swMenuFree', 'component', 'com_swmenufree', '', 0, 1, 0, 0, '{\"legacy\":true,\"name\":\"swMenuFree\",\"type\":\"component\",\"creationDate\":\"06\\/09\\/2010\",\"author\":\"Sean White\",\"copyright\":\"This Component is Proprietry Software\",\"authorEmail\":\"sean@swmenupro.com\",\"authorUrl\":\"http:\\/\\/www.swmenupro.com\",\"version\":\"7.0\",\"description\":\"Joomla 1.5 DHTML Menu Component\",\"group\":\"\"}', '{}', '', '', 0, '0000-00-00 00:00:00', 0, 0)");
        $database->query();
        $database->setQuery("DELETE FROM `#__menu` WHERE link='index.php?option=com_swmenufree'");
        $database->query();
    }
    $database->setQuery("SELECT COUNT(*) FROM `#__extensions` WHERE element LIKE '%mod_swmenufree%'");
    $com_entries = $database->loadResult();
    if ($com_entries != 1) {
        $row->message .= _SW_UPDATE_LINKS . "<br />";
        //$database->setQuery("DELETE FROM `#__components` WHERE admin_menu_link like '%com_swmenufree%'");
        //$database->query();
        $database->setQuery("INSERT INTO `#__extensions` VALUES('', 'swMenuFree', 'module', 'mod_swmenufree', '', 0, 1, 0, 0, '{\"legacy\":false,\"name\":\"swMenuFree\",\"type\":\"module\",\"creationDate\":\"26\\/01\\/2012\",\"author\":\"Sean White\",\"copyright\":\"This component is copyright www.swmenupro.com\",\"authorEmail\":\"sean@swmenupro.com\",\"authorUrl\":\"http:\\/\\/www.swmenupro.com\",\"version\":\"7.0\",\"description\":\"Joomla\\/Mambo DHTML Menu Component\",\"group\":\"\"}', '{}', '', '', 0, '0000-00-00 00:00:00', 0, 0)");
        $database->query();
    }
    $database->setQuery("SELECT COUNT(*) FROM `#__menu` WHERE title LIKE '%swMenuFree%' AND client_id='1'");
    $com_entries = $database->loadResult();
    if ($com_entries != 1) {
        $row->message .= _SW_UPDATE_LINKS . "<br />";
        //$database->setQuery("DELETE FROM `#__components` WHERE admin_menu_link like '%com_swmenufree%'");
        //$database->query();
        $database->setQuery("SELECT extension_id FROM `#__extensions` WHERE element LIKE '%com_swmenufree%'");
        $com_id = $database->loadResult();
        $database->setQuery("INSERT INTO `#__menu` VALUES('', 'main', 'swMenuFree', 'swMenuFree', '', 'swMenuFree', 'index.php?option=com_swmenufree', 'component', 0, 1, 1, " . $com_id . ", 0, 0, '0000-00-00 00:00:00', 0, 1, 'components/com_swmenufree/images/swmenupro_icon.png', 0, '', 283, 284, 0, '', 1);");
        $database->query();
    }
    $row->component_version = get_Version($absolute_path . '/administrator/components/com_swmenufree/swmenufree.xml');
    $row->upgrade_version = $row->component_version;
    $xml = @simplexml_load_file('http://swmenupro.com/swmenufree_updates.xml');
    if ($xml) {
        foreach ($xml->update as $update) {
            switch ((string) $update->targetplatform['version']) {
                // Get attributes as element indices
                case substr(JVERSION, 0, 3):
                    if (floatval($update->version) > floatval($row->component_version)) {
                        $row->message .= "swMenuFree " . $update->version . " is available.  Please visit <a href='http://www.swmenupro.com'>swmenupro.com</a> and download the latest swMenuFree " . $update->version . " file.  Then use the upload feature on this page to upload the file and upgrade this copy of swMenuFree.<br />";
                    }
                    break;
            }
        }
    }
    if (file_exists($absolute_path . '/modules/mod_swmenufree/mod_swmenufree.xml')) {
        $row->module_version = get_Version($absolute_path . '/modules/mod_swmenufree/mod_swmenufree.xml');
        $row->new_module_version = get_Version($absolute_path . '/administrator/components/com_swmenufree/module/mod_swmenufree.xml');
        if ($row->module_version < $row->new_module_version) {
            if (copydirr($absolute_path . "/administrator/components/com_swmenufree/module", $absolute_path . "/modules/mod_swmenufree", false)) {
                //  unlink($absolute_path . '/modules/mod_swmenufree/mod_swmenufree.xml');
                //  rename($absolute_path . "/modules/mod_swmenufree/mod_swmenufree.sw", $absolute_path . "/modules/mod_swmenufree/mod_swmenufree.xml");
                $row->message .= _SW_MODULE_SUCCESS . "<br />";
            } else {
                $row->message .= _SW_MODULE_FAIL . "<br />";
            }
        }
    } else {
        mkdir($absolute_path . "/modules/mod_swmenufree");
        if (copydirr($absolute_path . "/administrator/components/com_swmenufree/module", $absolute_path . "/modules/mod_swmenufree", false)) {
            //rename($absolute_path . "/modules/mod_swmenufree/mod_swmenufree.sw", $absolute_path . "/modules/mod_swmenufree/mod_swmenufree.xml");
            $row->message .= _SW_MODULE_SUCCESS . "<br />";
        } else {
            $row->message .= _SW_MODULE_FAIL . "<br />";
        }
    }
    if (file_exists($absolute_path . '/administrator/components/com_swmenufree/admin.swmenufree.php')) {
        unlink($absolute_path . '/administrator/components/com_swmenufree/admin.swmenufree.php');
    }
    if (!is_dir(JPATH_ROOT . '/images/swmenufree')) {
        if (@mkdir(JPATH_ROOT . '/images/swmenufree')) {
            //echo 'Directory created: '.JPATH_ROOT .DS. 'images'.DS.'swmenufree';
        } else {
            $row->message .= '<b>ERROR:</b>cannot create directory ' . JPATH_ROOT . '/images/swmenufree<br />';
        }
        if (copydirr(JPATH_ROOT . '/modules/mod_swmenufree/images', JPATH_ROOT . '/images/swmenufree', false)) {
            //rename($absolute_path."/modules/mod_swmenufree/mod_swmenufree.sw",$absolute_path."/modules/mod_swmenufree/mod_swmenufree.xml");
            $row->message .= "Successfully Installed swmenufree images<br />";
        } else {
            $row->message .= "Could Not Install swMenuFree Images.<br />\n";
        }
    }
    $row->component_version = get_Version($absolute_path . '/administrator/components/com_swmenufree/swmenufree.xml');
    $row->module_version = get_Version($absolute_path . '/modules/mod_swmenufree/mod_swmenufree.xml');
    $langfile = "english.php";
    if (file_exists($absolute_path . '/administrator/components/com_swmenufree/language/default.ini')) {
        $filename = $absolute_path . '/administrator/components/com_swmenufree/language/default.ini';
        $handle = fopen($filename, "r");
        $langfile = fread($handle, filesize($filename));
        fclose($handle);
    }
    $basedir = $absolute_path . "/administrator/components/com_swmenufree/language/";
    $handle = opendir($basedir);
    $lang = array();
    $lists = array();
    while ($file = readdir($handle)) {
        if ($file == "." || $file == ".." || $file == "default.ini") {
        } else {
            $lang[] = JHTML::_('select.option', $file, $file);
        }
        $lists['langfiles'] = JHTML::_('select.genericlist', $lang, 'language', 'id="language" class="inputbox" size="1" style="width:200px"', 'value', 'text', $langfile);
    }
    closedir($handle);
    HTML_swmenufree::upgradeForm($row, $lists);
    HTML_swmenufree::footer();
}
예제 #2
0
function upgrade($option, $installdir = "")
{
    global $mainframe;
    //require_once( $absolute_path . '/includes/domit/xml_domit_lite_include.php' );
    //$componentBaseDir	= mosPathName( $absolute_path . '/administrator/components/' );
    //$componentDirs 		= mosReadDirectory( $componentBaseDir );
    $database =& JFactory::getDBO();
    $absolute_path = JPATH_ROOT;
    $config =& JFactory::getConfig();
    $dbprefix = $config->getValue('config.dbprefix');
    $db = $config->getValue('config.db');
    //echo $db;
    $row->message = "";
    $row->database_version = 1;
    $columncount = 0;
    if (TableExists($dbprefix . "swmenufree_config", $db)) {
        $query = "SELECT * FROM #__swmenufree_config WHERE id = 1";
        $database->setQuery($query);
        $result = $database->loadObjectList();
        $swmenufree = array();
        if ($result) {
            while (list($key, $val) = each($result[0])) {
                //echo "1";
                $columncount++;
                $swmenufree[$key] = $val;
            }
        }
        //echo count($swmenufree);
        if ($columncount < 42 && $columncount > 1) {
            $row->message .= sprintf(_SW_TABLE_UPGRADE, '#__swmenufree_config') . "<br />";
            $database->setQuery("ALTER TABLE `#__swmenufree_config` \r\r\n  \t\t\tADD `extra` mediumtext,\r\r\n  \t\t\tMODIFY orientation varchar(20)\r\r\n \t\t\t ");
            $database->query();
            $row->database_version = 0;
        }
    } else {
        $row->message .= sprintf(_SW_TABLE_CREATE, '#__swmenufree_config') . "<br />";
        $database->setQuery("CREATE TABLE `#__swmenufree_config` (\r\r\n  `id` int(11) NOT NULL default '0',\r\r\n  `main_top` smallint(8) default '0',\r\r\n  `main_left` smallint(8) default '0',\r\r\n  `main_height` smallint(8) default '20',\r\r\n  `sub_border_over` varchar(30) default '0',\r\r\n  `main_width` smallint(8) default '100',\r\r\n  `sub_width` smallint(8) default '100',\r\r\n  `main_back` varchar(7) default '#4682B4',\r\r\n  `main_over` varchar(7) default '#5AA7E5',\r\r\n  `sub_back` varchar(7) default '#4682B4',\r\r\n  `sub_over` varchar(7) default '#5AA7E5',\r\r\n  `sub_border` varchar(30) default '#FFFFFF',\r\r\n  `main_font_size` smallint(8) default '0',\r\r\n  `sub_font_size` smallint(8) default '0',\r\r\n  `main_border_over` varchar(30) default '0',\r\r\n  `sub_font_color` varchar(7) default '#000000',\r\r\n  `main_border` varchar(30) default '#FFFFFF',\r\r\n  `main_font_color` varchar(7) default '#000000',\r\r\n  `sub_font_color_over` varchar(7) default '#FFFFFF',\r\r\n  `main_font_color_over` varchar(7) default '#FFFFFF',\r\r\n  `main_align` varchar(8) default 'left',\r\r\n  `sub_align` varchar(8) default 'left',\r\r\n  `sub_height` smallint(7) default '20',\r\r\n  `position` varchar(10) default 'absolute',\r\r\n  `orientation` varchar(20) default NULL,\r\r\n  `font_family` varchar(50) default 'Arial',\r\r\n  `font_weight` varchar(10) default 'normal',\r\r\n  `font_weight_over` varchar(10) default 'normal',\r\r\n  `level2_sub_top` int(11) default '0',\r\r\n  `level2_sub_left` int(11) default '0',\r\r\n  `level1_sub_top` int(11) NOT NULL default '0',\r\r\n  `level1_sub_left` int(11) NOT NULL default '0',\r\r\n  `main_back_image` varchar(100) default NULL,\r\r\n  `main_back_image_over` varchar(100) default NULL,\r\r\n  `sub_back_image` varchar(100) default NULL,\r\r\n  `sub_back_image_over` varchar(100) default NULL,\r\r\n  `specialA` varchar(50) default '80',\r\r\n  `main_padding` varchar(40) default '0px 0px 0px 0px',\r\r\n  `sub_padding` varchar(40) default '0px 0px 0px 0px',\r\r\n  `specialB` varchar(100) default '50',\r\r\n  `sub_font_family` varchar(50) default 'Arial',\r\r\n  `extra` mediumtext,\r\r\n  PRIMARY KEY  (`id`)\r\r\n)");
        $database->query();
    }
    $database->setQuery("SELECT COUNT(*) FROM `#__extensions` WHERE element LIKE '%com_swmenufree%'");
    $com_entries = $database->loadResult();
    if ($com_entries != 1) {
        $row->message .= _SW_UPDATE_LINKS . "<br />";
        //$database->setQuery("DELETE FROM `#__components` WHERE admin_menu_link like '%com_swmenufree%'");
        //$database->query();
        $database->setQuery("INSERT INTO `#__extensions` VALUES ( '', 'swmenufree', 'component', 'com_swmenufree', '', 0, 1, 0, 0, '{\"legacy\":true,\"name\":\"swMenuFree\",\"type\":\"component\",\"creationDate\":\"06\\/09\\/2010\",\"author\":\"Sean White\",\"copyright\":\"This Component is Proprietry Software\",\"authorEmail\":\"sean@swmenupro.com\",\"authorUrl\":\"http:\\/\\/www.swmenupro.com\",\"version\":\"6.1\",\"description\":\"Joomla 1.5 DHTML Menu Component\",\"group\":\"\"}', '{}', '', '', 0, '0000-00-00 00:00:00', 0, 0','1')");
        $database->query();
    }
    $database->setQuery("SELECT COUNT(*) FROM `#__menu` WHERE title LIKE '%swMenuFree%' AND client_id='1'");
    $com_entries = $database->loadResult();
    if ($com_entries != 1) {
        $row->message .= _SW_UPDATE_LINKS . "<br />";
        //$database->setQuery("DELETE FROM `#__components` WHERE admin_menu_link like '%com_swmenufree%'");
        //$database->query();
        $database->setQuery("SELECT extension_id FROM `#__extensions` WHERE element LIKE '%com_swmenufree%'");
        $com_id = $database->loadResult();
        $database->setQuery("INSERT INTO `#__menu` VALUES ( '', 'main', 'swMenuFree', 'swmenufree', '', 'swmenufree', 'index.php?option=com_swmenufree', 'component', 0, 1, 1, " . $com_id . ", 0, 0, '0000-00-00 00:00:00', 0, 1, 'class:component', 0, '', 277, 278, 0, '', 1)");
        $database->query();
    }
    if (file_exists($absolute_path . '/modules/mod_swmenufree/mod_swmenufree.xml')) {
        $row->module_version = get_Version($absolute_path . '/modules/mod_swmenufree/mod_swmenufree.xml');
        $row->new_module_version = get_Version($absolute_path . '/administrator/components/com_swmenufree/modules/mod_swmenufree/mod_swmenufree.sw');
        if ($row->module_version < $row->new_module_version) {
            if (copydirr($absolute_path . "/administrator/components/com_swmenufree/modules", $absolute_path . "/modules", 0757, false)) {
                unlink($absolute_path . '/modules/mod_swmenufree/mod_swmenufree.xml');
                rename($absolute_path . "/modules/mod_swmenufree/mod_swmenufree.sw", $absolute_path . "/modules/mod_swmenufree/mod_swmenufree.xml");
                $row->message .= _SW_MODULE_SUCCESS . "<br />";
            } else {
                $row->message .= _SW_MODULE_FAIL . "<br />";
            }
        }
    } else {
        if (copydirr($absolute_path . "/administrator/components/com_swmenufree/modules", $absolute_path . "/modules", 0757, false)) {
            rename($absolute_path . "/modules/mod_swmenufree/mod_swmenufree.sw", $absolute_path . "/modules/mod_swmenufree/mod_swmenufree.xml");
            $row->message .= _SW_MODULE_SUCCESS . "<br />";
        } else {
            $row->message .= _SW_MODULE_FAIL . "<br />";
        }
    }
    $row->component_version = get_Version($absolute_path . '/administrator/components/com_swmenufree/swmenufree.xml');
    $row->module_version = get_Version($absolute_path . '/modules/mod_swmenufree/mod_swmenufree.xml');
    $langfile = "english.php";
    if (file_exists($absolute_path . '/administrator/components/com_swmenufree/language/default.ini')) {
        $filename = $absolute_path . '/administrator/components/com_swmenufree/language/default.ini';
        $handle = fopen($filename, "r");
        $langfile = fread($handle, filesize($filename));
        fclose($handle);
    }
    $basedir = $absolute_path . "/administrator/components/com_swmenufree/language/";
    $handle = opendir($basedir);
    $lang = array();
    $lists = array();
    while ($file = readdir($handle)) {
        if ($file == "." || $file == ".." || $file == "default.ini") {
        } else {
            $lang[] = JHTML::_('select.option', $file, $file);
        }
        $lists['langfiles'] = JHTML::_('select.genericlist', $lang, 'language', 'id="language" class="inputbox" size="1" style="width:200px"', 'value', 'text', $langfile);
    }
    closedir($handle);
    HTML_swmenufree::upgradeForm($row, $lists);
    HTML_swmenufree::footer();
}