MyBB Community Forums

Full Version: Cardsearch Plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello

I have modified a plugin which makes a google search. Now it uses a [card]*****[/card] Tag to link the words on the cardseach http://www.magic-cards.info . I use this tag for my Magic the Gathering (Trading Card Game) Forum: http://www.mtgbattle.de

The Problem is, that i want to add some features to the plugin, but i dont know how to do this. So my first wish is to create a button on the Post Editor which creats the tag automatic like the "Underline-Button".

The secound Problem is, that i want to create a new tag calles [deck]*****[/deck] which links lot of cards indivdual to the cardseach. Most Decklists (is a Card) in MtG are looking this way.

4x Pithing Needle
3x Fledgling Dragon
4x Disenchant
4x Flametongue Kavu

the tag i am looking for makes if its arround this listing a link to every card: "Pithing Needle", "Fledgling Dragon", "Disenchant" and "Flametongue Kavu" on magic-cards.info.

Can someone help me please?

btw: sry for my bad english! Wink

PS: Here you see the modificated plugin form DennisTT

<?php
// Google BBCode Plugin
// By DennisTT
// Version 1.0.0

// Tell MyBB when to run the hooks
// $plugins->add_hook("hook name", "function name");
$plugins->add_hook("parse_message", "googlebbcode_run");

// The information that shows up on the plugin manager
// Note that the name of the function before _info, _activate, _deactivate must be the same as the filename before the extension.
function googlebbcode_info()
{
return array(
"name" => "Karten verlinken",
"description" => "Erlaubt einfache Links zur magic-cards.info ([card]Suchbegriff[/card]).",
"website" => "http://www.mtgbattle.de",
"author" => "Patrick Jung",
"authorsite" => "http://www.mtgbattle.de",
"version" => "1.0.0",
);
}

// This function runs when the plugin is activated.
function googlebbcode_activate()
{
}

// This function runs when the plugin is deactivated.
function googlebbcode_deactivate()
{
}

// This is the function that is run when the hook is called.
// It must match the function name you placed when you called add_hook.
// You are not just limited to 1 hook per page. You can add as many as you want.
function googlebbcode_run($message)
{
return preg_replace("#\[card\](.*?)\[/card\]#sie", "'<a href=\"http://www.magiccards.info/autocard/'.urlencode(stripslashes('$1')).'\" target=\"_blank\" title=\"'.stripslashes(htmlspecialchars('$1')).'\">'.stripslashes(htmlspecialchars('$1')).'</a>'", $message);
}

// End of plugin.