示例#1
0
文件: index.php 项目: horrabin/opendb
function build_table_page($language)
{
    global $PHP_SELF;
    global $ADMIN_TYPE;
    $block = "<p>[<a href=\"{$PHP_SELF}?type={$ADMIN_TYPE}\">Back to Main</a>]</p>";
    $block .= "<h3>Edit System Table {$language} Language Variables</h3>";
    $block .= "<div class=\"tabContainer\"><form name=\"config\" action=\"{$PHP_SELF}\" method=\"POST\">" . "<input type=\"hidden\" name=\"type\" value=\"" . $ADMIN_TYPE . "\">" . "<input type=\"hidden\" name=\"op\" value=\"update-tables\">" . "<input type=\"hidden\" name=\"language\" value=\"" . $language . "\">";
    $tabBlock = "";
    $paneBlock = "";
    $count = 1;
    $row = 0;
    $table_r = get_system_table_r();
    reset($table_r);
    while (list(, $table) = each($table_r)) {
        $tableconf_r = get_system_table_config($table);
        if (is_array($tableconf_r) && is_array($tableconf_r['columns'])) {
            reset($tableconf_r['columns']);
            while (list(, $column) = each($tableconf_r['columns'])) {
                $results = fetch_system_table_column_langvar_rs($language, $table, $column, !is_default_language($language) ? OPENDB_LANG_INCLUDE_DEFAULT : NULL);
                if ($results) {
                    $current_key1_value = NULL;
                    $table_lang_rs = NULL;
                    while ($table_lang_r = db_fetch_assoc($results)) {
                        if (count($tableconf_r['key']) > 1) {
                            if ($current_key1_value == NULL) {
                                $current_key1_value = $table_lang_r['key1'];
                            } else {
                                if ($current_key1_value != $table_lang_r['key1']) {
                                    $id = "{$table}&nbsp;/&nbsp;{$column}&nbsp;/&nbsp;" . $current_key1_value;
                                    $tabBlock .= "\n<li id=\"menu-pane{$count}\"" . ($count == 1 ? " class=\"first activetab\" " : "") . " onclick=\"return activateTab('pane{$count}')\">{$id}</li>";
                                    $paneBlock .= "<div id=\"pane{$count}\" class=\"" . ($count == 1 ? "tabContent" : "tabContentHidden") . "\">\n" . "<input type=\"submit\" class=\"submit\" value=\"Update\">" . build_div_table($language, $table, $column, $table_lang_rs, $row) . "</div>";
                                    $table_lang_rs = NULL;
                                    $current_key1_value = $table_lang_r['key1'];
                                    $count++;
                                }
                            }
                        }
                        $table_lang_rs[] = $table_lang_r;
                    }
                    db_free_result($results);
                }
                if (count($tableconf_r['key']) == 1) {
                    if (count($tableconf_r['columns']) > 1) {
                        $id = "{$table}&nbsp;/&nbsp;{$column}";
                    } else {
                        $id = "{$table}";
                    }
                    $tabBlock .= "\n<li id=\"menu-pane{$count}\"" . ($count == 1 ? " class=\"first activetab\" " : "") . " onclick=\"return activateTab('pane{$count}')\">{$id}</li>";
                    $paneBlock .= "<div id=\"pane{$count}\" class=\"" . ($count == 1 ? "tabContent" : "tabContentHidden") . "\">\n" . "<input type=\"submit\" class=\"submit\" value=\"Update\">" . build_div_table($language, $table, $column, $table_lang_rs, $row) . "\n</div>";
                    $table_lang_rs = NULL;
                    $count++;
                }
            }
        }
    }
    $block .= "<ul class=\"tabMenu\" id=\"tab-menu\">" . $tabBlock . "</ul>";
    $block .= '<div id="tab-content">' . $paneBlock . '</div>';
    $block .= '</form>';
    return $block;
}
示例#2
0
function fetch_opendb_table_lang_var($language, $table, $column, $key1, $key2 = NULL, $key3 = NULL)
{
    $tableconf_r = get_system_table_config($table);
    if (is_array($tableconf_r['key'])) {
        if (is_default_language($language)) {
            $query = "SELECT IFNULL(value, t.{$column}) AS value FROM {$table} t ";
            $query .= "LEFT OUTER JOIN s_table_language_var stlv ON \n\t\t\t\tstlv.language = '{$language}' AND stlv.tablename = '{$table}' AND stlv.columnname = '{$column}' ";
            for ($i = 1; $i <= count($tableconf_r['key']); $i++) {
                $query .= "AND stlv.key{$i} = t." . $tableconf_r['key'][$i - 1];
            }
            $query .= " WHERE ";
            for ($i = 1; $i <= count($tableconf_r['key']); $i++) {
                if ($i > 1) {
                    $query .= " AND ";
                }
                $query .= " t." . $tableconf_r['key'][$i - 1] . " = ";
                if ($i == 1) {
                    $query .= "'" . addslashes($key1) . "'";
                } else {
                    if ($i == 2) {
                        $query .= "'" . addslashes($key2) . "'";
                    } else {
                        if ($i == 3) {
                            $query .= "'" . addslashes($key3) . "'";
                        }
                    }
                }
            }
        } else {
            $query = "SELECT value FROM s_table_language_var \n\t\t\t\t\tWHERE language = '{$language}' AND tablename = '{$table}' AND columnname = '{$column}' ";
            for ($i = 1; $i <= count($tableconf_r['key']); $i++) {
                $query .= "AND " . $tableconf_r['key'][$i - 1] . " = ";
                if ($i == 1) {
                    $query .= "'" . addslashes($key1) . "'";
                } else {
                    if ($i == 2) {
                        $query .= "'" . addslashes($key2) . "'";
                    } else {
                        if ($i == 3) {
                            $query .= "'" . addslashes($key3) . "'";
                        }
                    }
                }
            }
        }
        $result = db_query($query);
        if ($result && db_num_rows($result) > 0) {
            $record_r = db_fetch_assoc($result);
            db_free_result($result);
            return $record_r['value'];
        }
    }
    //else
    return FALSE;
}