<?php
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
$formname    = "form_site_list";
$inputname   = "input_id";
?>
<? if ($GLOBALS['admin_user']['right_website_admin'] == 1 || $GLOBALS['admin_user']['is_super_user'] == 1) { ?>
<ul class="toolbar_menu">
    <?= button("new", $translation->get("new"), $formname, "loadCard('new', true)"); ?>
</ul>
<?php } ?>

<div id="mainContent">

    <?php echo current_website_language($site, $language); ?>
    <h1><?php echo get_translation('top_websites'); ?></h1>

    <?php
if ($messages !== null) {
    if (count($messages)) {
            echo '<div id="overlayMessages">' . join("\r\n", $messages) . '</div>';
    } 
  }
    ?>

    <form id="<?= $formname ?>" name="<?= $formname ?>" method="post">
        <input type="hidden" class="selected_linklist_row" name="input_id" value="" />

        <div class="requestLoader"></div>
        <?
        $query  = "SELECT main_site.id AS 'id',  main_site.name AS '" . $translation->get("description") . "', main_site.code AS '" . $translation->get("textkey") . "', main_language.name AS '" . $translation->get("default_language") . "', (SELECT Count(id) FROM main_navigation WHERE main_site_id = main_site.id) AS '" . $translation->get("number_menu_items") . "' FROM main_site LEFT JOIN main_language ON main_site.std_main_language_id = main_language.id ORDER BY main_site.code ASC";
        $format = array('option', 'text', 'text', 'text', 'integer');
        if ($result = @mysqli_query($GLOBALS['mysql_con'], $query)) {
            if ($GLOBALS['admin_user']['right_website_admin'] == 1 || $GLOBALS['admin_user']['is_super_user'] == 1) {
                linklist($result, "form_site_list", $format, "input_id");
            }else{
                linklist($result, "form_site_list", $format, 'input_id', 'no_edit');
            }
           
        }
        ?>

    </form>
</div>