<commit_before><?php

require_once "lib/session.php";

define('sites_form',
       '<div class="form">
<p>These decisions have been remembered for this session:</p>
<form method="post" action="%s">
<table>
<tbody>
%s
</tbody>
</table>
<input type="submit" name="remove" value="Remove Selected" />
<input type="submit" name="refresh" value="Refresh List" />
<input type="submit" name="forget" value="Forget All" />
</form>
<p>All decisions will be forgotten when this session ends.</p>
</div>
');

define('sites_empty_message',
       '<p>
  No sites are remembered for this session. When you authenticate with a site,
  you can choose to add it to this list by choosing <q>Remember this
  decision</q>.
</p>
<p>%s</p>
');

define('sites_row',
       '<tr>
<td><input type="checkbox" name=%s value="%s" id=%s /></td>
<td><label for=%s>%s %s</label></td>
</tr>');

function siteListRow_render($i, $site, $trusted)
{
    $esc_site = htmlspecialchars($site, ENT_QUOTES);
    if ($trusted) {
        $trust = 'Trust';
    } else {
        $trust = 'Do not trust';
    }
    $id = sprintf('"site%s"', $i);
    return sprintf(sites_row, $id, $esc_site, $id, $id, $trust, $esc_site);
}

function siteList_render($sites)
{
    $rows = '';
    $i = 0;
    foreach ($sites as $site => $trusted) {
        $rows .= siteListRow_render($i, $site, $trusted);
        $i += 1;
    }
    return $rows;
}

function sites_render($sites)
{
    if ($sites) {
        $rows = siteList_render($sites);
        $form = sprintf(sites_form, buildURL('sites'), $rows);
        $body = $pre . $form;
    } else {
        $body = sprintf(sites_empty_message, link_render(buildURL(''), 'Return home'));
    }
    return page_render($body, getLoggedInUser(), 'Remembered Sites');<commit_msg>[project @ Improve remembered decisions page]<commit_after><?php

require_once "lib/session.php";

define('sites_form',
       '<p>These decisions have been remembered for this session. All decisions
will be forgotten when the session ends.</p>
<div class="form">
<form method="post" action="%s">
<table>
<tbody>
%s
</tbody>
</table>
<input type="submit" name="remove" value="Remove Selected" />
<input type="submit" name="refresh" value="Refresh List" />
<input type="submit" name="forget" value="Forget All" />
</form>
</div>
');

define('sites_empty_message',
       '<p>
  No sites are remembered for this session. When you authenticate with a site,
  you can choose to add it to this list by choosing <q>Remember this
  decision</q>.
</p>
<p>%s</p>
');

define('sites_row',
       '<tr>
<td><input type="checkbox" name=%s value="%s" id=%s /></td>
<td><label for=%s><code>%s</code></label></td>
</tr>');

function siteListRow_render($i, $site)
{
    $esc_site = htmlspecialchars($site, ENT_QUOTES);
    $id = sprintf('"site%s"', $i);
    return sprintf(sites_row, $id, $esc_site, $id, $id, $esc_site);
}

function siteList_render($sites)
{
    $trusted_sites = array();
    $untrusted_sites = array();
    foreach ($sites as $site => $trusted) {
        if ($trusted) {
            $trusted_sites[] = $site;
        } else {
            $untrusted_sites[] = $site;
        }
    }
    $rows = '';
    $i = 0;
    foreach (array('Trusted Sites' => $trusted_sites,
                   'Untrusted Sites' => $untrusted_sites) as
             $name => $sites) {
        if ($sites) {
            $rows .= '<tr><th colspan="2">'. $name . '</th></tr>';
            foreach ($sites as $site) {
                $rows .= siteListRow_render($i, $site);
                $i += 1;
            }
        }
    }
    return $rows;
}

function sites_render($sites)
{
    if ($sites) {
        $rows = siteList_render($sites);
        $form = sprintf(sites_form, buildURL('sites'), $rows);
        $body = $pre . $form;
    } else {
        $body = sprintf(sites_empty_message, link_render(buildURL(''), 'Return home'));
    }
    return page_render($body, getLoggedInUser(), 'Remembered Sites');
{'fraction_non_alphanumeric': 0.1832022329358031, 'fraction_numerical': 0.001268713524486171, 'mean_word_length': 3.2296137339055795, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 72, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6942863', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1338, 'n_words': 342}