예제 #1
0
    foreach ($sets as $s) {
        $argArray[] = 'sets[]=' . $s;
    }
    foreach ($colors as $c) {
        $argArray[] = 'colors[]=' . $c;
    }
    $argString = implode('&', $argArray);
    if (strlen($argString) !== 0) {
        $search_url .= '?' . $argString;
    }
    // Yay, finally done.
    $template->assign_vars(array('SEARCH_RESULT_COUNT' => $result_count, 'SEARCH_RESULT_START' => 1 + $start, 'SEARCH_RESULT_END' => min($start + $results_per_page, $result_count), 'PAGINATION' => generate_pagination($search_url, $result_count, $results_per_page, $start)));
    foreach ($cards as $row) {
        $manaCost = decodemana($row['mana_cost']);
        $isCreature = $row['power'] != NULL && $row['toughness'] != NULL ? true : false;
        $template->assign_block_vars('searchresults', array('CARD_NAME' => $row['name'], 'CARD_MANA' => $manaCost, 'CARD_CMC' => $row['cmc'], 'CARD_TYPES' => replaceManaSymbols($row['types']), 'S_IS_CREATURE' => $isCreature, 'CARD_POWER' => $row['power'], 'CARD_TOUGHNESS' => $row['toughness'], 'CARD_TEXT' => cleanRulesTextForDisplay($row['rules_text']), 'CARD_SET' => 'default', 'CARD_RARITY' => $RARITY_TRANSLATIONS[$row['rarity']], 'CARD_LOYALTY' => $row['loyalty'], 'URL' => './view_card.php?name=' . urlencode($row['name'])));
    }
    page_header('NGA Card Search Results');
    $template->set_filenames(array('body' => 'library/card_search_results_body.html'));
    page_footer();
} else {
    // No search is being performed yet. Show the search page.
    // Get a list of all sets
    // TODO: allow set owners to see their own sets
    $sql = 'SELECT * FROM nga_card_sets WHERE nga_card_sets.is_public = TRUE';
    $result = $db->sql_query($sql);
    $set_list = '';
    while ($row = $db->sql_fetchrow($result)) {
        $set_list .= '<option value="' . $row['short_name'] . '">' . $row['name'] . '</option>';
    }
    $db->sql_freeresult($result);
예제 #2
0
        FROM nga_cards AS c ';
//if ($set !== '') {
$sql .= 'INNER JOIN nga_card_printings AS p ON p.card_id = c.card_id
             INNER JOIN nga_card_sets AS s ON s.set_id = p.set_id ';
//}
$sql .= "WHERE (c.name = '{$name}' OR c.name = '~{$name}~')";
if ($set !== '') {
    $sql .= " AND s.short_name = '{$set}'";
}
$result = $db->sql_query($sql);
$allRows = $db->sql_fetchrowset($result);
$row = $allRows[0];
$manaHtml = decodemana($row['mana_cost']);
$cleanedRules = cleanRulesTextForDisplay($row['rules_text']);
$cleanedFlavor = cleanFlavorTextForDisplay($row['flavor_text']);
$cleanedTypes = cleanRulesTextForDisplay($row['types']);
$name = $row['name'];
if ($name[0] === '~' && substr($name, -1) === '~') {
    $name = '<i>' . substr($name, 1, -1) . '</i>';
}
if (isset($row['render_url'])) {
    $renderHTML = "<img class=\"card-render\" src=\"{$row['render_url']}\">";
} else {
    $renderHTML = renderCardHTML($name, $manaHtml, $row['colors'], $cleanedTypes, "[" . $row['short_name'] . "]", $cleanedRules, $cleanedFlavor, $row['power'], $row['toughness'], $row['loyalty']);
}
if ($view === 'render') {
    $template->assign_vars(array('S_RENDER_HTML' => $renderHTML));
    page_header('');
    $template->set_filenames(array('body' => 'library/card_render.html'));
    page_footer();
} else {