function showMedia()
{
    #----------------------------------------------------------------------
    global $chosenYears, $chosenRegionId, $chosenOrder;
    #--- Prepare conditions.
    $yearCondition = yearCondition();
    $regionCondition = regionCondition('competition');
    $orderCondition = $chosenOrder == 'date' ? "ORDER BY competition.year DESC,\n                                                         competition.month DESC,\n                                                         competition.day DESC" : "ORDER BY timestampDecided DESC";
    #--- Get data of the (matching) media items.
    $media = dbQuery("\n    SELECT media.*, competition.*, cellName, country.name AS countryName\n\n    FROM CompetitionsMedia media, Competitions competition, Countries country\n    WHERE 1\n      AND competition.id = competitionId\n      AND country.id = countryId\n      {$yearCondition}\n      {$regionCondition}\n      AND status = 'accepted'\n    {$orderCondition}, cellName\n  ");
    #--- Print the data.
    tableBegin('results', 6);
    #  tableCaption( false, spaced(array( eventName($chosenEventId), chosenRegionName(), $chosenYears )));
    tableHeader(explode('|', 'Insertion Date|Competition Date|Competition|Country, City|Type|Link'), array(5 => 'class="f"'));
    foreach ($media as $data) {
        extract($data);
        #--- Print the empty row.
        if ($chosenOrder == 'submission') {
            $year = preg_replace('/-.*/', '', $timestampDecided);
        }
        if (isset($previousYear) && $year != $previousYear) {
            tableRowEmpty();
        }
        $previousYear = $year;
        tableRow(array(preg_replace('/ .*/', '', $timestampDecided), competitionDate($data), competitionLink($competitionId, $cellName), "<b>{$countryName}</b>, {$cityName}", $type, externalLink($uri, $text)));
    }
    tableEnd();
}
function processLink($text, $link)
{
    $text = preg_replace('/\\\\([\'\\"])/', '$1', $text);
    $link = preg_replace('/\\\\([\'\\"])/', '$1', $link);
    if (preg_match('/^mailto:(.*)$/', $link, $match)) {
        return emailLink($match[1], $text);
    }
    if (preg_match('/^https?:(.*)$/', $link, $match)) {
        return externalLink($link, $text);
    }
    return emptyLink('[{' . $text . '}{' . $link . '}]');
}
function infoMedium()
{
    #----------------------------------------------------------------------
    global $mediumId;
    $infos = dbQuery("\n    SELECT media.*, competition.cellName\n    FROM CompetitionsMedia media, Competitions competition\n    WHERE media.id = '{$mediumId}'\n      AND competition.id = media.competitionId\n  ");
    extract($infos[0]);
    echo "<table border='0' cellspacing='0' cellpadding='2' width='100%'>\n";
    $tableList = array(array('Type', $type), array('Competition', competitionLink($competitionId, $cellName)), array('Link', externalLink(htmlEscape($uri), htmlEscape($text))), array('Submitter', emailLink(htmlEscape($submitterEmail), htmlEscape($submitterName))), array('Comment', htmlEscape($submitterComment)), array('Submitted on:', $timestampSubmitted), array('Decided on', $timestampDecided), array('Status', $status));
    foreach ($tableList as $table) {
        list($name, $value) = $table;
        echo "<tr><td>{$name}</td><td>{$value}</td></tr>";
    }
    echo "</table>";
    displayChoices(array(array(choiceButton(false, "refuse{$mediumId}", 'Erase'), choiceButton(false, "accept{$mediumId}", 'Accept'))));
}
function showCompetitionInfos()
{
    #----------------------------------------------------------------------
    global $chosenCompetitionId;
    #--- Get the competition infos from the database.
    $competition = getFullCompetitionInfos($chosenCompetitionId);
    extract($competition);
    $delegates = getCompetitionDelegates($chosenCompetitionId);
    $wcaDelegate = joinUsers($delegates, true);
    $organizers = getCompetitionOrganizers($chosenCompetitionId);
    // Only show organizer emails if there is no contact info given.
    $organizer = joinUsers($organizers, !$contact);
    $website = externalLink($website, "{$name} website");
    #--- Show the infos.
    echo "<h1>{$name}</h1>\n";
    #--- Start the table.
    echo "<div class='table-responsive'>\n";
    echo "<table width='100%' id='competitionDetails'><tr valign='top'>\n";
    #--- Left part.
    echo "<td style='width:70%'><table>";
    $country = getCountry($countryId);
    showItem('key', "Date", array(competitionDate($competition), $year));
    showItem('key', "City", array($cityName, $country['name']));
    showItem('key', "Venue", array($venue));
    showItem('sub', "Address", array($venueAddress));
    showItem('sub', "Details", array($venueDetails));
    showItem('key', "Website", array($website), false);
    showItem('key', "Organizer", array($organizer));
    showItem('key', "WCA Delegate", array($wcaDelegate));
    showItem('key', "Contact", array($contact));
    echo "</table></td>";
    #--- Right part.
    echo "<td style='width:30%'><table>";
    showItem('key', "Information", array($information));
    showListItemNew('View results for', computeCompetitionEvents($eventSpecs));
    showListItemNew('Reports', computeMedia('report'));
    showListItemNew('Articles', computeMedia('article'));
    showListItemNew('Multimedia', computeMedia('multimedia'));
    echo "</table></td>";
    #--- End table.
    echo "</tr></table></div>";
}
function showMedia()
{
    #----------------------------------------------------------------------
    global $chosenType, $chosenStatus, $chosenRegionId, $chosenOrder;
    #--- Prepare conditions.
    $typeCondition = $chosenType ? "AND type='{$chosenType}'" : '';
    $accepted = $chosenStatus == 'accepted';
    $order = $accepted ? "ORDER BY timestampDecided    DESC" : "ORDER BY timestampSubmitted  DESC";
    $orderCondition = $chosenOrder == 'date' ? "ORDER BY competition.year DESC,\n                                                         competition.month DESC,\n                                                         competition.day DESC" : $order;
    $headerDate = $accepted ? "Insertion" : "Submission";
    #--- Get data of the (matching) media items.
    $media = dbQuery("\n    SELECT media.*,\n           competition.year, competition.month, competition.day,\n           competition.endMonth, competition.endDay,\n           competition.countryId, competition.cityName,\n           cellName,\n           country.name AS countryName\n    FROM CompetitionsMedia media, Competitions competition, Countries country\n    WHERE 1\n      AND competition.id = competitionId\n      AND country.id = countryId\n      {$typeCondition}\n      " . regionCondition('competition') . "\n      AND status='{$chosenStatus}'\n    {$orderCondition}, cellName\n  ");
    #--- Begin form and table.
    echo "<form action='validate_media_ACTION.php' method='POST'>\n";
    tableBegin('results', 7);
    tableHeader(explode('|', $headerDate . ' Date|Competition Date|Competition|Country, City|Type|Link|'), array(5 => 'class="f"'));
    #--- Print results.
    foreach ($media as $data) {
        extract($data);
        $timestamp = $accepted ? $timestampDecided : $timestampSubmitted;
        if ($chosenOrder == 'submission') {
            $year = preg_replace('/-.*/', '', $timestamp);
        }
        if (isset($previousYear) && $year != $previousYear) {
            tableRowEmpty();
        }
        $previousYear = $year;
        $button = "<input type='submit' class='butt' value='Info' name='info{$id}' /> ";
        $button .= "<input type='submit' class='butt' value='Edit' name='edit{$id}' /> ";
        $button .= $accepted ? "<input type='submit' class='butt' value='Erase' name='refuse{$id}' />" : "<input type='submit' class='butt' value='Accept' name='accept{$id}' />\n                            <input type='submit' class='butt' value='Refuse' name='refuse{$id}' />";
        tableRow(array(preg_replace('/ .*/', '', $timestamp), competitionDate($data), competitionLink($competitionId, $cellName), "<b>{$countryName}</b>, {$cityName}", $type, externalLink(htmlEscape($uri), htmlEscape($text)), $button));
    }
    #--- End form and table.
    tableEnd();
    echo "</form>";
}
    <dt><a href="media.php">Multimedia</a></dt>
    <dd>Articles, Videos, Pictures and Reports about competitions.</dd>

    <dt><a href="statistics.php">Statistics</a></dt>
    <dd>Some additional statistics for fun.</dd>

  </dl>
</div>

<p>
  The WCA result pages are designed and built by
    <?php 
print externalLink('http://www.stefan-pochmann.info/', 'Stefan Pochmann');
?>
,
    <?php 
print externalLink('https://www.worldcubeassociation.org/results/p.php?i=2004GALL02', 'Clément Gallet');
?>
, and
    <?php 
print externalLink('http://www.rubikscube.info/', 'Josef Jelinek');
?>
.<br />
  We would like to thank them for their great work for the cubing community.<br />
  <br />
  If you have questions about the rankings or if you want to correct something, then please <a href="/contact">contact the appropriate party</a>.
</p>

<?php 
require_once 'includes/_footer.php';