<?php
$translation     = \DynCom\mysyde\common\classes\Registry::get("translation");
$formname        = "form_world_list";
$inputname       = "input_id";
$siteparts       = \DynCom\mysyde\common\classes\Siteparts::get();
?>

<div id="overlaycrumb">
    <?php if ($input_world["id"] == "") {
        echo $translation->get("collection_world");
    } else {
        echo $translation->get("collection_world");
    }
    ?>
</div>

<ul class="toolbar_menu">
    <?= button("save", $translation->get("save"), $formname, ""); ?>
    <?= button("save", $translation->get("save_and_close"), $formname, "backButton()"); ?>
</ul>
    
<form id="<?= $formname ?>" name="<?= $formname ?>" method="post">
    <input name="input_id" type="hidden" value="<?= $input_id ?>">
    <input type="hidden" class="selected_linklist_row" name="input_world_id" value="" />
    <input type="hidden" name="fieldtype" value="" />
    <input type="hidden" name="type_id" value="" />
    <ul class="toolbar_menu collection_world">
        <?= button("new", $translation->get("new"), $formname, "loadCard('new_collection_setup_world', true)", "", FALSE); ?>
        <?= button("edit", $translation->get("edit"), $formname, "loadCard('edit_collection_setup_world')", "", FALSE); ?>
        <?= button("delete", $translation->get("delete"), $formname, "loadCard('delete_collection_setup_world', false, '{$translation->get('delete_collection_setup_world_confirm')}')", "", FALSE); ?>
        <?= button("up", $translation->get("go_up"), $formname, "loadCard('moveup_collection_setup_world')", "", FALSE); ?>
        <?= button("down", $translation->get("go_down"), $formname, "loadCard('movedown_collection_setup_world')", "", FALSE); ?>
    </ul>
    <?php
    $query = "SELECT * FROM main_collection_setup_world ORDER BY sorting ASC";
    if ($result = @mysqli_query($GLOBALS['mysql_con'], $query)) {
        $num_rows = @mysqli_num_rows($result);
        if ($num_rows >= 1) {
            echo "  <table data-sortableupdateaction=\"update_sortorder_collection_setup_world\" cellpadding=0 cellspacing=0 border=0 class=\"linklist sortableTable\">\n";
            echo "<tr>";
            echo format_key($translation->get("description"), "");
            echo format_key("", "");
            echo "</tr>";
            echo "<tr>";
            echo format_seperator("");
            echo format_seperator("");
            echo "</tr>";
            while ($row = @mysqli_fetch_array($result, 1)) {
                echo "    <tr id=\"linklistid_{$row['id']}\" class=\"linklist_content\" data-checked=\"{$checkedRow}\" data-inputname=\"input_id\" data-action=\"edit_collection_setup_world\" data-inputid=\"{$row['id']}\">\n";
                echo format_value($row['description'], "input_id");
                echo format_value("", "sorticon", "sort");
                echo "    </tr>\n";
            }
            echo "  </table>\n";
        } else {
            echo "<div class=\"infobox\">" . $translation->get("no_rows_found") . "</div>";
        }
    }
    ?>
</form>