예제 #1
0
function showModuleSettings($module, $key)
{
    $table = getSettings($module);
    table_open();
    if ($table) {
        tr_open();
        td_open(1);
        echo getString("settings_description", "Beskrivelse");
        td_close();
        td_open(1);
        echo getString("settings_value", "Verdi");
        td_close();
        td_open(1);
        echo getString("settings_type", "Type");
        td_close();
        td_open(1);
        echo getString("settings_edit", "Endre");
        td_close();
        tr_close();
        while ($row = nextResultInTable($table)) {
            tr_open();
            td_open(1);
            echo $row['description'];
            td_close();
            form_start_post();
            if ($row['settingskey'] == $key) {
                showSetting($row, true);
                td_open(1);
                form_hidden("m_c", "showSettingsGUI");
                form_hidden("module", $module);
                form_hidden("key", $row['settingskey']);
                form_hidden("save", true);
                form_submit("submit", getString("settings_save_setting", "Lagre"));
                td_close();
            } else {
                showSetting($row, false);
                td_open(1);
                form_hidden("m_c", "showSettingsGUI");
                form_hidden("module", $module);
                form_hidden("key", $row['settingskey']);
                form_submit("submit", getString("settings_edit_setting", "Endre"));
                td_close();
            }
            form_end();
            tr_close();
        }
    } else {
        // ingen settings, gi beskjed:
        tr_open();
        td_open(1);
        echo getString("settings_could_not_find_settings_for_this_module", "Fant ingen innstillinger for denne modulen");
        td_close();
        tr_close();
    }
    table_close();
}
예제 #2
0
function textSearchResultGUI()
{
    if (isset($_REQUEST['nopartialmatch'])) {
        $partialmatch = 0;
    } else {
        $partialmatch = 1;
    }
    if (isset($_REQUEST['searchcomments'])) {
        $searchcomments = 1;
    } else {
        $searchcomments = 0;
    }
    $table = textSearchService($_REQUEST['text'], $partialmatch, $_REQUEST['author'], $searchcomments);
    if ($searchcomments) {
        h3("Søkte etter '" . $_REQUEST['text'] . "' i alle artikler og kommentarer, " . count($table) . " treff, nyeste først");
    } else {
        h3("Søkte etter '" . $_REQUEST['text'] . "' i alle artikler, " . count($table) . " treff, nyeste først");
    }
    if ($table == NULL) {
        //echo("no_articles_with_that_text");
        echo "Sorry Mac!";
    } else {
        table_open();
        foreach ($table as $row) {
            tr_open();
            echo '<td style="width:80px">';
            echo make_ddmmyy_date($row['date_posted']);
            td_close();
            td_open(1);
            if (isset($row['comment_to'])) {
                print_article_link($row['comment_to'], $row['title']);
                echo "(Kommentar til: ";
                print_parent_article_link($row['comment_to']);
                echo ")";
            } else {
                print_article_link($row['articleid'], $row['title']);
            }
            td_close();
            td_open(1);
            echo $row['author'];
            td_close();
            tr_close();
            tr_open();
            td_open(3);
            echo create_paragraph($row['body'], 200, 200);
            echo "...";
            br();
            br();
            td_close();
        }
        table_close();
    }
}
예제 #3
0
function previewArticle($article)
{
    if (!$article) {
        h3("Fant ikke artikkelen.");
    } else {
        table_open();
        tr_open();
        td_open(1);
        h1_link($article['title'], url_to_article($article['articleid']));
        articleMetaInfo($article['author'], $article['author_username'], make_date($article['date_posted']), make_time($article['time_posted']), $article['language']);
        div_open("textbody", "");
        $paragraph = makeReadyForPrint(nl2br($article['body']));
        echo $paragraph;
        div_close();
        td_close();
        tr_close();
        table_close();
    }
}
예제 #4
0
function module_categoryadmin()
{
    // adminpage, stop here if not logged in/right access-level
    if (!isValidAdmin()) {
        echo getString("not_valid_admin", "Administratorside, du må logge inn for å få tilgang her");
        return;
    }
    // Check whether user has sent category creation data
    if (isset($_REQUEST['action'])) {
        $action = $_REQUEST['action'];
    } else {
        $action = "";
    }
    if ($action == "createcategory") {
        if (isset($_REQUEST['categoryname'])) {
            $insertquery = "INSERT INTO category (name) VALUES ('" . $_REQUEST['categoryname'] . "')";
            $insertresult = DB_insert($insertquery);
            if ($insertresult) {
                echo "Category " . $_REQUEST['categoryname'] . " added.<br/>";
            } else {
                echo "Adding category failed.<br/>";
            }
        }
    } else {
        if ($action == "deletecategory") {
            if (isset($_REQUEST['categoryid'])) {
                if (isset($_REQUEST['confirmdeletecategory'])) {
                    $deletequery = "DELETE FROM category WHERE categoryid = " . $_REQUEST['categoryid'] . ";";
                    $deleteresult = DB_update($deletequery);
                    if ($deleteresult) {
                        echo "Category deleted.<br/>";
                    } else {
                        echo "Deletion failed. Maybe there are existing articles in this category?<br/>";
                    }
                } else {
                    echo "Please confirm that you wish to delete category " . $_REQUEST['categoryname'] . ". Click anywhere else to abort.<br/>";
                    form_start_post();
                    form_hidden("m_c", "module_categoryadmin");
                    form_hidden("action", "deletecategory");
                    form_hidden("categoryid", $_REQUEST['categoryid']);
                    form_hidden("confirmdeletecategory", "1");
                    form_submit("submit", "Confirm deletion");
                    form_end();
                    br();
                }
            }
        } else {
            if ($action == "editcategory") {
                if (isset($_REQUEST['categoryid'])) {
                    if (isset($_REQUEST['confirmeditcategory'])) {
                        $updatequery = "UPDATE category SET name = '" . $_REQUEST['categoryname'] . "' WHERE categoryid = " . $_REQUEST['categoryid'] . ";";
                        $updateresult = DB_insert($updatequery);
                        if ($updateresult) {
                            echo "Category " . $_REQUEST['categoryname'] . " updated.<br/><br/>";
                        } else {
                            echo "Updating category failed.<br/><br/>";
                        }
                    } else {
                        form_start_post();
                        echo "Category name:";
                        br();
                        form_textfield("categoryname", $_REQUEST['categoryname']);
                        form_hidden("m_c", "module_categoryadmin");
                        form_hidden("action", "editcategory");
                        form_hidden("categoryid", $_REQUEST['categoryid']);
                        form_hidden("confirmeditcategory", "1");
                        form_submit("submit", "Save edit");
                        form_end();
                        br();
                        br();
                    }
                }
            }
        }
    }
    // Query for existing categories
    $query = "SELECT categoryid, name FROM category;";
    $result = DB_get_table($query);
    $num_results = DB_rows_affected($result);
    if ($num_results == 0) {
        echo "No existing categories.";
    } else {
        echo "Existing categories:";
    }
    table_open();
    while ($row = DB_next_row($result)) {
        tr_open();
        td_open(1);
        echo $row['categoryid'];
        td_close();
        td_open(1);
        echo $row['name'];
        td_close();
        td_open(1);
        form_start_post();
        form_hidden("m_c", "module_categoryadmin");
        form_hidden("action", "editcategory");
        form_hidden("categoryname", $row['name']);
        form_hidden("categoryid", $row['categoryid']);
        form_submit("submit", "Edit");
        form_end();
        td_close();
        td_open(1);
        form_start_post();
        form_hidden("m_c", "module_categoryadmin");
        form_hidden("action", "deletecategory");
        form_hidden("categoryname", $row['name']);
        form_hidden("categoryid", $row['categoryid']);
        form_submit("submit", "Delete");
        form_end();
        td_close();
        tr_close();
    }
    table_close();
    echo "<br/>Create new category<br/>";
    form_start_post();
    echo "Name: ";
    form_textfield("categoryname", "");
    form_hidden("m_c", "module_categoryadmin");
    form_hidden("action", "createcategory");
    form_submit("submit", "Create");
    form_end();
}