Esempio n. 1
0
function generateSQL($t, $formid, $cntr)
{
    global $_TABLES;
    if ($t == 'formDefinitions') {
        $table = $_TABLES['nxform_definitions'];
        $query = DB_query("SELECT * from {$table} WHERE id='{$formid}'");
    } else {
        $table = $_TABLES['nxform_fields'];
        $query = DB_query("SELECT * from {$table} WHERE formid='{$formid}'");
    }
    while ($A = DB_fetchArray($query)) {
        $numfields = DB_numFields($query);
        $myvars = array();
        $sqlstmt .= '$_SQL[' . $cntr . '][] = "INSERT INTO ' . $table;
        $sqlstmtVars = '';
        $sqlstmtValues = '';
        // Need to skip the first field - which is an auto-increment primary key
        for ($i = 1; $i < $numfields; $i++) {
            $fieldname = DB_fieldName($query, $i);
            //echo "<br>$i:$fieldname and value:{$A[$fieldname]}";
            $myvars[$fieldname] = $A[$fieldname];
            if ($t == 'formFields' and $fieldname == 'formid') {
                $value = $cntr;
            } else {
                $value = addslashes($A[$fieldname]);
                //$value = str_replace('"','\"',$A[$fieldname]);
                //$value = str_replace('\'','\\\'',$A[$fieldname]);
            }
            if ($i > 1) {
                $sqlstmtVars .= ",{$fieldname}";
                if (is_null($A[$fieldname])) {
                    $sqlstmtValues .= ",NULL";
                } else {
                    $sqlstmtValues .= ",'{$value}'";
                }
            } else {
                $sqlstmtVars .= "{$fieldname}";
                $sqlstmtValues .= "'{$value}'";
            }
        }
        $sqlstmt = $sqlstmt . ' (' . $sqlstmtVars . ') VALUES (' . $sqlstmtValues . ')";' . LB;
    }
    return $sqlstmt;
}
Esempio n. 2
0
function menuConfig()
{
    global $_CONF, $_TABLES, $_USER, $LANG_NEXMENU01, $id, $inactive, $showdisabled;
    global $menulocation, $CONF_NEXMENU, $LANG_NEXMENU04, $LANG_NEXMENU05;
    $statusmsg = $_GET['statusmsg'];
    include $_CONF['path_system'] . 'classes/navbar.class.php';
    $tpl = new Template($_CONF['path_layout'] . 'nexmenu/admin');
    if ($CONF_NEXMENU['debug']) {
        $tpl->set_file('page', 'menuconfig-debug.thtml');
    } else {
        $tpl->set_file('page', 'menuconfig.thtml');
    }
    $tpl->set_var('site_url', $_CONF['site_url']);
    $tpl->set_var('layout_url', $_CONF['layout_url']);
    $tpl->set_var('imgset', $_CONF['layout_url'] . '/nexmenu/images/admin');
    $tpl->set_var('LANG_usecolorpicker', $LANG_NEXMENU05[32]);
    $theme = COM_applyFilter($_POST['theme']);
    if (empty($theme)) {
        $theme = COM_applyFilter($_GET['theme']);
    }
    if (empty($theme)) {
        $theme = $_USER['theme'];
    }
    if (!empty($theme)) {
        // Check if a record already exists for theme - if not create one from the default record
        if (DB_count($_TABLES['nexmenu_config'], 'theme', $theme) == 1) {
            $query = DB_query("SELECT * FROM {$_TABLES['nexmenu_config']} WHERE theme='{$theme}'");
            $A = DB_fetchArray($query);
        } else {
            $query = DB_query("SELECT * FROM {$_TABLES['nexmenu_config']} WHERE theme='default'");
            if (DB_numRows($query) == 1) {
                DB_query("INSERT INTO {$_TABLES['nexmenu_config']} (theme,header_style,block_style) VALUES ('{$theme}','CSS','CSS')");
                $D = DB_fetchArray($query);
                $numfields = DB_numFields($query);
                // Need to skip the first field - which is an auto-increment primary key
                for ($i = 1; $i < $numfields; $i++) {
                    $fieldname = DB_fieldName($query, $i);
                    DB_query("UPDATE {$_TABLES['nexmenu_config']} SET {$fieldname}='{$D[$fieldname]}' WHERE theme='{$theme}'");
                }
                $query = DB_query("SELECT * FROM {$_TABLES['nexmenu_config']} WHERE theme='{$theme}'");
                $A = DB_fetchArray($query);
            } else {
                COM_errorLog("glMenu - tried to create new config record for theme: {$theme}, and default config record not found");
                echo "<p>Unexpected plugin Error - check error.log</p>";
                die;
            }
        }
    } else {
        $theme = 'default';
        $query = DB_query("SELECT * FROM {$_TABLES['nexmenu_config']} WHERE theme='{$theme}'");
        $A = DB_fetchArray($query);
    }
    $scripturl = $_CONF['site_admin_url'] . '/plugins/nexmenu/index.php';
    $navbar = new navbar();
    $navbar->add_menuitem($LANG_NEXMENU04['1'], $scripturl . "?menulocation=header&showdisabled={$showdisabled}");
    $navbar->add_menuitem($LANG_NEXMENU04['2'], $scripturl . "?menulocation=block&showdisabled={$showdisabled}");
    $navbar->add_menuitem($LANG_NEXMENU04['3'], $scripturl . "?op=addaction&id={$idCurrent}&menulocation={$menulocation}&showdisabled={$showdisabled}");
    $navbar->add_menuitem($LANG_NEXMENU04['6'], $scripturl . "?op=config&menulocation=block&showdisabled={$showdisabled}");
    $navbar->set_selected($LANG_NEXMENU04['6']);
    $tpl->set_var('navbar', $navbar->generate());
    if ($statusmsg != '') {
        $tpl->set_var('showalert', '');
    } else {
        $tpl->set_var('showalert', 'none');
    }
    $tpl->set_var('statusmsg', $statusmsg);
    $tpl->set_var('LANG_title', $LANG_NEXMENU05[6]);
    $menustyles = array_keys($CONF_NEXMENU['menutypes']);
    $headerMenuType_options = '';
    $blockMenuType_options = '';
    foreach ($menustyles as $option) {
        if ($A['header_style'] == $option) {
            $headerMenuType_options .= '<option value="' . $option . '" SELECTED=selected>' . $option . '</option>';
        } else {
            $headerMenuType_options .= '<option value="' . $option . '">' . $option . '</option>';
        }
    }
    foreach ($menustyles as $option) {
        if ($A['block_style'] == $option) {
            $blockMenuType_options .= '<option value="' . $option . '" SELECTED=selected>' . $option . '</option>';
        } else {
            $blockMenuType_options .= '<option value="' . $option . '">' . $option . '</option>';
        }
    }
    if ($A['header_style'] == 'Milonic') {
        $tpl->set_var('show_headerCssMenuSettings', 'none');
        $tpl->set_var('show_headerMilonicMenuSettings', '');
    } else {
        $tpl->set_var('show_headerCssMenuSettings', '');
        $tpl->set_var('show_headerMilonicMenuSettings', 'none');
    }
    if ($A['block_style'] == 'Milonic') {
        $tpl->set_var('show_blockCssMenuSettings', 'none');
        $tpl->set_var('show_blockMilonicMenuSettings', '');
    } else {
        $tpl->set_var('show_blockCssMenuSettings', '');
        $tpl->set_var('show_blockMilonicMenuSettings', 'none');
    }
    $themes = COM_getThemes();
    $themes[0] = 'default';
    ksort($themes);
    foreach ($themes as $option) {
        if ($A['theme'] == $option) {
            $theme_options .= '<option value="' . $option . '" SELECTED=selected>' . $option . '</option>';
        } else {
            $theme_options .= '<option value="' . $option . '">' . $option . '</option>';
        }
    }
    $tpl->set_var('headerMenuType_options', $headerMenuType_options);
    $tpl->set_var('blockMenuType_options', $blockMenuType_options);
    $tpl->set_var('theme_options', $theme_options);
    $tpl->set_var('headerbg', $A['headerbg']);
    $tpl->set_var('headerfg', $A['headerfg']);
    $tpl->set_var('blockbg', $A['blockbg']);
    $tpl->set_var('blockfg', $A['blockfg']);
    $tpl->set_var('headersubmenubg', $A['headersubmenubg']);
    $tpl->set_var('headersubmenufg', $A['headersubmenufg']);
    $tpl->set_var('blocksubmenubg', $A['blocksubmenubg']);
    $tpl->set_var('blocksubmenufg', $A['blocksubmenufg']);
    $tpl->set_var('onhover_headerbg', $A['onhover_headerbg']);
    $tpl->set_var('onhover_headerfg', $A['onhover_headerfg']);
    $tpl->set_var('onhover_blockbg', $A['onhover_blockbg']);
    $tpl->set_var('onhover_blockfg', $A['onhover_blockfg']);
    $tpl->set_var('onhover_headersubmenubg', $A['onhover_headersubmenubg']);
    $tpl->set_var('onhover_headersubmenufg', $A['onhover_headersubmenufg']);
    $tpl->set_var('onhover_blocksubmenubg', $A['onhover_blocksubmenubg']);
    $tpl->set_var('onhover_blocksubmenufg', $A['onhover_blocksubmenufg']);
    $tpl->set_var('header_properties', $A['headermenu_properties']);
    $tpl->set_var('block_properties', $A['blockmenu_properties']);
    $tpl->set_var('LANG_menumode', $LANG_NEXMENU05[0]);
    $tpl->set_var('LANG_langlabels', $LANG_NEXMENU05[1]);
    $tpl->set_var('LANG_newwindow', $LANG_NEXMENU05[2]);
    $tpl->set_var('LANG_reference', $LANG_NEXMENU05[3]);
    $tpl->set_var('LANG_enabled', $LANG_NEXMENU05[4]);
    $tpl->set_var('LANG_disabled', $LANG_NEXMENU05[5]);
    $tpl->set_var('LANG_miloniclabel1', $LANG_NEXMENU05[7]);
    $tpl->set_var('LANG_miloniclabel2', $LANG_NEXMENU05[8]);
    $tpl->set_var('LANG_miloniclabel3', $LANG_NEXMENU05[9]);
    $tpl->set_var('LANG_miloniclabel4', $LANG_NEXMENU05[10]);
    $tpl->set_var('LANG_miloniclabel5', $LANG_NEXMENU05[12]);
    $tpl->set_var('LANG_miloniclabel6', $LANG_NEXMENU05[13]);
    $tpl->set_var('LANG_miloniclabel7', $LANG_NEXMENU05[14]);
    $tpl->set_var('LANG_milonichelp1', $LANG_NEXMENU05[11]);
    $tpl->set_var('LANG_csslabel1', $LANG_NEXMENU05[15]);
    $tpl->set_var('LANG_csslabel2', $LANG_NEXMENU05[16]);
    $tpl->set_var('LANG_csslabel3', $LANG_NEXMENU05[17]);
    $tpl->set_var('LANG_csslabel4', $LANG_NEXMENU05[18]);
    $tpl->set_var('LANG_csslabel5', $LANG_NEXMENU05[19]);
    $tpl->set_var('LANG_csslabel6', $LANG_NEXMENU05[20]);
    $tpl->set_var('LANG_csslabel7', $LANG_NEXMENU05[21]);
    $tpl->set_var('LANG_csslabel8', $LANG_NEXMENU05[22]);
    $tpl->set_var('LANG_csslabel9', $LANG_NEXMENU05[23]);
    $tpl->set_var('LANG_csslabel26', $LANG_NEXMENU05[26]);
    $tpl->set_var('LANG_csslabel27', $LANG_NEXMENU05[27]);
    $tpl->set_var('LANG_csslabel28', $LANG_NEXMENU05[28]);
    $tpl->set_var('LANG_csslabel29', $LANG_NEXMENU05[29]);
    $tpl->set_var('LANG_csslabel30', $LANG_NEXMENU05[30]);
    $tpl->set_var('LANG_csslabel31', $LANG_NEXMENU05[31]);
    $tpl->set_var('LANG_yes', $LANG_NEXMENU05[24]);
    $tpl->set_var('LANG_no', $LANG_NEXMENU05[25]);
    if ($A['multilanguage'] == 1) {
        $tpl->set_var('chk_langon', "CHECKED=checked");
    } else {
        $tpl->set_var('chk_langoff', "CHECKED=checked");
    }
    if ($A['targetfeatures'] == '') {
        $tpl->set_var('targetfeatures', 'width=800,height=600,left=50,top=50,scrollbars=yes;');
    } else {
        $A['targetfeatures'] = str_replace('targetfeatures=', '', $A['targetfeatures']);
        $tpl->set_var('targetfeatures', $A['targetfeatures']);
    }
    if ($_GET['writecss'] == 1) {
        $tpl->set_var('chk_writecss_yes', 'CHECKED=checked');
    } else {
        $tpl->set_var('chk_writecss_no', 'CHECKED=checked');
    }
    $menustyles = '';
    foreach ($CONF_NEXMENU['milonicstyles'] as $menustyle) {
        if ($A['blockmenu_style'] == $menustyle) {
            $menustyles .= '<option value="' . $menustyle . '" SELECTED=selected>' . $menustyle . '</option>';
        } else {
            $menustyles .= '<option value="' . $menustyle . '">' . $menustyle . '</option>';
        }
    }
    $tpl->set_var('style1_options', $menustyles);
    if ($A['header_style'] == 'Milonic') {
        $tpl->set_var('show_milonicstyles', '');
        $tpl->set_var('show_cssmenucolors', 'none');
    } else {
        $tpl->set_var('show_milonicstyles', 'none');
        $tpl->set_var('show_cssmenucolors', '');
    }
    $menustyles = '';
    foreach ($CONF_NEXMENU['milonicstyles'] as $menustyle) {
        if ($A['blocksubmenu_style'] == $menustyle) {
            $menustyles .= '<option value="' . $menustyle . '" SELECTED=selected>' . $menustyle . '</option>';
        } else {
            $menustyles .= '<option value="' . $menustyle . '">' . $menustyle . '</option>';
        }
    }
    $tpl->set_var('style2_options', $menustyles);
    $menustyles = '';
    foreach ($CONF_NEXMENU['milonicstyles'] as $menustyle) {
        if ($A['headermenu_style'] == $menustyle) {
            $menustyles .= '<option value="' . $menustyle . '" SELECTED=selected>' . $menustyle . '</option>';
        } else {
            $menustyles .= '<option value="' . $menustyle . '">' . $menustyle . '</option>';
        }
    }
    $tpl->set_var('style3_options', $menustyles);
    $menustyles = '';
    foreach ($CONF_NEXMENU['milonicstyles'] as $menustyle) {
        if ($A['headersubmenu_style'] == $menustyle) {
            $menustyles .= '<option value="' . $menustyle . '" SELECTED=selected>' . $menustyle . '</option>';
        } else {
            $menustyles .= '<option value="' . $menustyle . '">' . $menustyle . '</option>';
        }
    }
    $tpl->set_var('style4_options', $menustyles);
    $tpl->set_var('LANG_CANCEL', $LANG_NEXMENU01['LANG_CANCEL']);
    $tpl->set_var('cancel_url', $_CONF['site_admin_url'] . '/plugins/nexmenu/index.php?op=display&id=' . $id . '&showdisabled=' . $inactive . '&menulocation=' . $menulocation);
    $tpl->set_var('LANG_SUBMIT', $LANG_NEXMENU01['LANG_UPDATE']);
    $tpl->parse('output', 'page');
    return $tpl->finish($tpl->get_var('output'));
}