| 1 |
<?php
|
| 2 |
|
| 3 |
function pirate_help($section) {
|
| 4 |
switch ($section) {
|
| 5 |
case 'admin/modules#description':
|
| 6 |
return t("Avast ye scurvy dogs!");
|
| 7 |
}
|
| 8 |
}
|
| 9 |
|
| 10 |
function pirate_filter($op, $delta = 0, $format = -1, $text = '') {
|
| 11 |
switch ($op) {
|
| 12 |
case 'list':
|
| 13 |
return array(0 => t('Pirate filter'));
|
| 14 |
case 'description':
|
| 15 |
return t('Ah, Squiddy! I got nothing against ye. I just heard there was gold in yer belly. Ha ha har, ha ha ha har!');
|
| 16 |
case 'process':
|
| 17 |
if (date('md') != '0919') {
|
| 18 |
return $text;
|
| 19 |
}
|
| 20 |
$patterns = array(
|
| 21 |
'%\bmy\b%' => 'me',
|
| 22 |
'%\bboss\b%' => 'admiral',
|
| 23 |
'%\bmanager\b%' => 'admiral',
|
| 24 |
'%\b[Cc]aptain\b%' => "Cap'n",
|
| 25 |
'%\bmyself\b%' => 'meself',
|
| 26 |
'%\byour\b%' => 'yer',
|
| 27 |
'%\byou\b%' => 'ye',
|
| 28 |
'%\bfriend\b%' => 'matey',
|
| 29 |
'%\bfriends\b%' => 'maties',
|
| 30 |
'%\bco[-]?worker\b%' => 'shipmate',
|
| 31 |
'%\bco[-]?workers\b%' => 'shipmates',
|
| 32 |
'%\bpeople\b%' => 'scallywags',
|
| 33 |
'%\bearlier\b%' => 'afore',
|
| 34 |
'%\bold\b%' => 'auld',
|
| 35 |
'%\bthe\b%' => "th'",
|
| 36 |
'%\bof\b%' => "o'",
|
| 37 |
"%\bdon't\b%" => "dern't",
|
| 38 |
'%\bdo not\b%' => "dern't",
|
| 39 |
'%\bnever\b%' => "no nay ne'er",
|
| 40 |
'%\bever\b%' => "e'er",
|
| 41 |
'%\bover\b%' => "o'er",
|
| 42 |
'%\bYes\b%' => 'Aye',
|
| 43 |
'%\bNo\b%' => 'Nay',
|
| 44 |
'%\bYeah\b%' => 'Aye',
|
| 45 |
'%\byeah\b%' => 'aye',
|
| 46 |
'%\bare\b%' => 'be',
|
| 47 |
'%\bDrupalists\b%' => 'Bucaneers',
|
| 48 |
'%\bthere\b%' => 'thar',
|
| 49 |
'%b\bnot\b%' => 'nay',
|
| 50 |
'%\bdesign\b%' => 'bounty',
|
| 51 |
'%\bonline\b%' => 'on the plank',
|
| 52 |
'/and\b/' => "an'",
|
| 53 |
'/ious\b/' => "i'us",
|
| 54 |
"%\bdon't know\b%" => "dinna",
|
| 55 |
"%\bdidn't know\b%" => "did nay know",
|
| 56 |
"%\bhadn't\b%" => "ha'nae",
|
| 57 |
"%\bdidn't\b%"=> "di'nae",
|
| 58 |
"%\bwasn't\b%" => "weren't",
|
| 59 |
"%\bhaven't\b%" => "ha'nae",
|
| 60 |
'%\bfor\b%' => 'fer',
|
| 61 |
'%\bbetween\b%' => 'betwixt',
|
| 62 |
'%\baround\b%' => "aroun'",
|
| 63 |
'%\bto\b%' => "t'",
|
| 64 |
"%\bit's\b%" => "'tis",
|
| 65 |
'%\bwoman\b%' => 'wench',
|
| 66 |
'%\bwomen\b%' => 'wenches',
|
| 67 |
'%\blady\b%' => 'wench',
|
| 68 |
'%\bwife\b%' => 'lady',
|
| 69 |
'%\bgirl\b%' => 'lass',
|
| 70 |
'%\bgirls\b%' => 'lassies',
|
| 71 |
'%\bguy\b%' => 'lubber',
|
| 72 |
'%\bman\b%' => 'lubber',
|
| 73 |
'%\bfellow\b%' => 'lubber',
|
| 74 |
'%\bdude\b%' => 'lubber',
|
| 75 |
'%\bboy\b%' => 'lad',
|
| 76 |
'%\bboys\b%' => 'laddies',
|
| 77 |
'%\bchildren\b%' => 'little sandcrabs',
|
| 78 |
'%\bkids\b%' => 'minnows',
|
| 79 |
'%\bhim\b%' => 'that scurvey dog',
|
| 80 |
'%\bher\b%' => 'that comely wench',
|
| 81 |
'%\bhim\.\b%' => 'that drunken sailor',
|
| 82 |
'%\bHe\b%' => 'The ornery cuss',
|
| 83 |
'%\bShe\b%' => 'The winsome lass',
|
| 84 |
"%\bhe's\b%" => 'he be',
|
| 85 |
"%\bshe's\b%" => 'she be',
|
| 86 |
'%\bwas\b%' => "were bein'",
|
| 87 |
'%\bHey\b%' => 'Avast',
|
| 88 |
'%\bher\.\b%' => 'that lovely lass',
|
| 89 |
'%\bfood\b%' => 'chow',
|
| 90 |
'%\bmoney\b%' => 'dubloons',
|
| 91 |
'%\bdollars\b%' => 'pieces of eight',
|
| 92 |
'%\bcents\b%' => 'shillings',
|
| 93 |
'%\broad\b%' => 'sea',
|
| 94 |
'%\broads\b%' => 'seas',
|
| 95 |
'%\bstreet\b%' => 'river',
|
| 96 |
'%\bstreets\b%' => 'rivers',
|
| 97 |
'%\bhighway\b%' => 'ocean',
|
| 98 |
'%\bhighways\b%' => 'oceans',
|
| 99 |
'%\binterstate\b%' => 'high sea',
|
| 100 |
'%\bprobably\b%' => 'likely',
|
| 101 |
'%\bidea\b%' => 'notion',
|
| 102 |
'%\bcar\b%' => 'boat',
|
| 103 |
'%\bcars\b%' => 'boats',
|
| 104 |
'%\btruck\b%' => 'schooner',
|
| 105 |
'%\btrucks\b%' => 'schooners',
|
| 106 |
'%\bSUV\b%' => 'ship',
|
| 107 |
'%\bairplane\b%' => 'flying machine',
|
| 108 |
'%\bjet\b%' => 'flying machine',
|
| 109 |
'%\bmachine\b%' => 'contraption',
|
| 110 |
'%\bdriving\b%' => 'sailing',
|
| 111 |
'%\bunderstand\b%' => 'reckon',
|
| 112 |
'%\bdrive\b%' => 'sail',
|
| 113 |
'%\bdied\b%' => 'snuffed it',
|
| 114 |
'/ing\b/' => "in'",
|
| 115 |
'/ings\b/' => "in's",
|
| 116 |
// These next two do cool random substitutions
|
| 117 |
'/(\.\s)/e' => 'avast("$0",3)',
|
| 118 |
'/([!\?]\s)/e' => 'avast("$0",2)', // Greater chance after exclamation
|
| 119 |
);
|
| 120 |
foreach ($patterns as $pattern_search => $pattern_replace) {
|
| 121 |
$text = preg_replace($pattern_search, $pattern_replace, $text);
|
| 122 |
}
|
| 123 |
return $text;
|
| 124 |
default:
|
| 125 |
return $text;
|
| 126 |
}
|
| 127 |
}
|
| 128 |
|
| 129 |
function pirate_filter_tips($delta, $format, $long = FALSE) {
|
| 130 |
return "Avast! This website be taken over by pirates on September 19th. Yarr!";
|
| 131 |
}
|
| 132 |
|
| 133 |
// support function for pirate()
|
| 134 |
// this could probably be refactored to make it more generic, allowing
|
| 135 |
// different filters to pass their own patterns in.
|
| 136 |
function avast($stub = '',$chance = 5) {
|
| 137 |
$shouts = array(
|
| 138 |
", avast$stub",
|
| 139 |
"$stub Ahoy!",
|
| 140 |
", and a bottle of rum!",
|
| 141 |
", by Blackbeard's sword$stub",
|
| 142 |
", by Davy Jones' locker$stub",
|
| 143 |
"$stub Walk the plank!",
|
| 144 |
"$stub Aarrr!",
|
| 145 |
"$stub Yaaarrrrr!",
|
| 146 |
", pass the grog!",
|
| 147 |
", and dinna spare the whip!",
|
| 148 |
", with a chest full of booty$stub",
|
| 149 |
", and a bucket o' chum$stub",
|
| 150 |
", we'll keel-haul ye!",
|
| 151 |
"$stub Shiver me timbers!",
|
| 152 |
"$stub And hoist the mainsail!",
|
| 153 |
"$stub And swab the deck!",
|
| 154 |
", ye scurvey dog$stub",
|
| 155 |
"$stub Fire the cannons!",
|
| 156 |
", to be sure$stub",
|
| 157 |
", I'll warrant ye$stub",
|
| 158 |
", on a dead man's chest!",
|
| 159 |
"$stub Load the cannons!",
|
| 160 |
"$stub Prepare to be boarded!",
|
| 161 |
", I'll warrant ye$stub",
|
| 162 |
"$stub Ye'll be sleepin' with the fishes!",
|
| 163 |
"$stub The sharks will eat well tonight!",
|
| 164 |
"$stub Oho!",
|
| 165 |
"$stub Fetch me spyglass!",
|
| 166 |
", shiver me timbers",
|
| 167 |
", yo ho, ho",
|
| 168 |
", ya bilge rat!",
|
| 169 |
", Get out of me rum!",
|
| 170 |
", feed the fishes",
|
| 171 |
", me Jolly Roger",
|
| 172 |
", Ya horn swogglin' scurvy cur!",
|
| 173 |
", Ya swabbie!",
|
| 174 |
", All Hands Hoay!",
|
| 175 |
", Avast me hearties!",
|
| 176 |
", Dance the Hempen Jig",
|
| 177 |
", Hornswaggle",
|
| 178 |
", Ya lily livered swabbie!",
|
| 179 |
);
|
| 180 |
|
| 181 |
shuffle($shouts);
|
| 182 |
return (((1 == rand(1,$chance))?array_shift($shouts):$stub) . ' ');
|
| 183 |
}
|