| 3 |
/** |
/** |
| 4 |
* Implementation of hook_help(). |
* Implementation of hook_help(). |
| 5 |
*/ |
*/ |
| 6 |
function pirate_help($section) { |
function pirate_help($path, $arg) { |
| 7 |
switch ($section) { |
switch ($path) { |
| 8 |
case 'admin/modules#description': |
case 'admin/help#pirate': |
| 9 |
return t("Avast ye scurvy dogs!"); |
return t("Avast ye scurvy dogs!"); |
| 10 |
} |
} |
| 11 |
} |
} |
| 119 |
'%\bdied\b%' => 'snuffed it', |
'%\bdied\b%' => 'snuffed it', |
| 120 |
'/ing\b/' => "in'", |
'/ing\b/' => "in'", |
| 121 |
'/ings\b/' => "in's", |
'/ings\b/' => "in's", |
| 122 |
// These next two do cool random substitutions |
// These next two do cool random substitutions. |
| 123 |
'/(\.\s)/e' => 'avast("$0",3)', |
'/(\.\s)/e' => 'avast("$0",3)', |
| 124 |
'/([!\?]\s)/e' => 'avast("$0",2)', // Greater chance after exclamation |
'/([!\?]\s)/e' => 'avast("$0",2)', // Greater chance after exclamation. |
| 125 |
); |
); |
| 126 |
foreach ($patterns as $pattern_search => $pattern_replace) { |
foreach ($patterns as $pattern_search => $pattern_replace) { |
| 127 |
$text = preg_replace($pattern_search, $pattern_replace, $text); |
$text = preg_replace($pattern_search, $pattern_replace, $text); |
| 136 |
* Implementation of hook_filter_tips(). |
* Implementation of hook_filter_tips(). |
| 137 |
*/ |
*/ |
| 138 |
function pirate_filter_tips($delta, $format, $long = FALSE) { |
function pirate_filter_tips($delta, $format, $long = FALSE) { |
| 139 |
return "Avast! This website be taken over by pirates on September 19th. Yarr!"; |
return "Avast! This website be taken over by pirates on September 19th. Yarr!"; |
| 140 |
} |
} |
| 141 |
|
|
| 142 |
// Support function for pirate() |
// Support function for pirate(). |
| 143 |
// this could probably be refactored to make it more generic, allowing |
// this could probably be refactored to make it more generic, allowing |
| 144 |
// different filters to pass their own patterns in. |
// different filters to pass their own patterns in. |
| 145 |
function avast($stub = '',$chance = 5) { |
function avast($stub = '',$chance = 5) { |
| 185 |
", Dance the Hempen Jig", |
", Dance the Hempen Jig", |
| 186 |
", Hornswaggle", |
", Hornswaggle", |
| 187 |
", Ya lily livered swabbie!", |
", Ya lily livered swabbie!", |
| 188 |
); |
); |
| 189 |
|
|
| 190 |
shuffle($shouts); |
shuffle($shouts); |
| 191 |
return (((1 == rand(1,$chance))?array_shift($shouts):$stub) . ' '); |
return (((1 == rand(1,$chance))?array_shift($shouts):$stub) . ' '); |