Esempio n. 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);
Esempio n. 2
0
function cleanRulesTextForDisplay($text)
{
    // Clean up card text by:
    //  - replacing newlines with <br/>s
    //  - replacing {foo} with the appropriate mana symbols
    //  - making parenthetical things italic
    //  - replacing ~foo~ with italicized text
    //  - making //foo// purple
    $cleanedText = '<p>' . $text . '</p>';
    $cleanedText = str_replace("\n", '</p><p>', $cleanedText);
    $cleanedText = preg_replace('/(\\(.*?\\))/', '<i>\\1</i>', $cleanedText);
    $cleanedText = replaceManaSymbols($cleanedText);
    $cleanedText = preg_replace('/~(.*?)~/', '<i>\\1</i>', $cleanedText);
    $cleanedText = preg_replace('# //(.*?)//#', ' <span style="color:purple;">\\1</span>', $cleanedText);
    return $cleanedText;
}