| 1 |
<?php |
<?php |
| 2 |
|
|
| 3 |
function pirate_help($section) { |
function pirate_help($section) { |
| 4 |
|
/** |
| 5 |
|
* Implement hook_help(). |
| 6 |
|
*/ |
| 7 |
switch ($section) { |
switch ($section) { |
| 8 |
case 'admin/modules#description': |
case 'admin/modules#description': |
| 9 |
return t("Avast ye scurvy dogs!"); |
return t("Avast ye scurvy dogs!"); |
| 10 |
} |
} |
| 11 |
} |
} |
| 12 |
|
|
| 13 |
function pirate_filter($op, $delta = 0, $format = -1, $text = '') { |
function pirate_filter_info() { |
| 14 |
switch ($op) { |
/** |
| 15 |
case 'list': |
* Implement hook_filter_info(). |
| 16 |
return array(0 => t('Pirate filter')); |
*/ |
| 17 |
case 'description': |
$filters = array(); |
| 18 |
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!'); |
$filters['pirate'] = array( |
| 19 |
case 'process': |
'title' => t('Pirate filter'), |
| 20 |
if (date('md') != '0919') { |
'description' => t('Ah, Squiddy! I got nothing against ye. I just heard there was gold in yer belly. Ha ha har, ha ha ha har!'), |
| 21 |
return $text; |
'process callback' => '_pirate_eval', |
| 22 |
} |
'tips callback' => '_pirate_tips', |
| 23 |
$patterns = array( |
); |
| 24 |
'%\bmy\b%' => 'me', |
return $filters; |
| 25 |
'%\bboss\b%' => 'admiral', |
} |
| 26 |
'%\bmanager\b%' => 'admiral', |
|
| 27 |
'%\b[Cc]aptain\b%' => "Cap'n", |
function _pirate_eval($text) { |
| 28 |
'%\bmyself\b%' => 'meself', |
if (date('md') != '0919') { |
| 29 |
'%\byour\b%' => 'yer', |
return $text; |
| 30 |
'%\byou\b%' => 'ye', |
} |
| 31 |
'%\bfriend\b%' => 'matey', |
$patterns = array( |
| 32 |
'%\bfriends\b%' => 'maties', |
'%\bmy\b%' => 'me', |
| 33 |
'%\bco[-]?worker\b%' => 'shipmate', |
'%\bboss\b%' => 'admiral', |
| 34 |
'%\bco[-]?workers\b%' => 'shipmates', |
'%\bmanager\b%' => 'admiral', |
| 35 |
'%\bpeople\b%' => 'scallywags', |
'%\b[Cc]aptain\b%' => "Cap'n", |
| 36 |
'%\bearlier\b%' => 'afore', |
'%\bmyself\b%' => 'meself', |
| 37 |
'%\bold\b%' => 'auld', |
'%\byour\b%' => 'yer', |
| 38 |
'%\bthe\b%' => "th'", |
'%\byou\b%' => 'ye', |
| 39 |
'%\bof\b%' => "o'", |
'%\bfriend\b%' => 'matey', |
| 40 |
"%\bdon't\b%" => "dern't", |
'%\bfriends\b%' => 'maties', |
| 41 |
'%\bdo not\b%' => "dern't", |
'%\bco[-]?worker\b%' => 'shipmate', |
| 42 |
'%\bnever\b%' => "no nay ne'er", |
'%\bco[-]?workers\b%' => 'shipmates', |
| 43 |
'%\bever\b%' => "e'er", |
'%\bpeople\b%' => 'scallywags', |
| 44 |
'%\bover\b%' => "o'er", |
'%\bearlier\b%' => 'afore', |
| 45 |
'%\bYes\b%' => 'Aye', |
'%\bold\b%' => 'auld', |
| 46 |
'%\bNo\b%' => 'Nay', |
'%\bthe\b%' => "th'", |
| 47 |
'%\bYeah\b%' => 'Aye', |
'%\bof\b%' => "o'", |
| 48 |
'%\byeah\b%' => 'aye', |
"%\bdon't\b%" => "dern't", |
| 49 |
'%\bare\b%' => 'be', |
'%\bdo not\b%' => "dern't", |
| 50 |
'%\bDrupalists\b%' => 'Bucaneers', |
'%\bnever\b%' => "no nay ne'er", |
| 51 |
'%\bthere\b%' => 'thar', |
'%\bever\b%' => "e'er", |
| 52 |
'%b\bnot\b%' => 'nay', |
'%\bover\b%' => "o'er", |
| 53 |
'%\bdesign\b%' => 'bounty', |
'%\bYes\b%' => 'Aye', |
| 54 |
'%\bonline\b%' => 'on the plank', |
'%\bNo\b%' => 'Nay', |
| 55 |
'/and\b/' => "an'", |
'%\bYeah\b%' => 'Aye', |
| 56 |
'/ious\b/' => "i'us", |
'%\byeah\b%' => 'aye', |
| 57 |
"%\bdon't know\b%" => "dinna", |
'%\bare\b%' => 'be', |
| 58 |
"%\bdidn't know\b%" => "did nay know", |
'%\bDrupalists\b%' => 'Bucaneers', |
| 59 |
"%\bhadn't\b%" => "ha'nae", |
'%\bthere\b%' => 'thar', |
| 60 |
"%\bdidn't\b%"=> "di'nae", |
'%b\bnot\b%' => 'nay', |
| 61 |
"%\bwasn't\b%" => "weren't", |
'%\bdesign\b%' => 'bounty', |
| 62 |
"%\bhaven't\b%" => "ha'nae", |
'%\bonline\b%' => 'on the plank', |
| 63 |
'%\bfor\b%' => 'fer', |
'/and\b/' => "an'", |
| 64 |
'%\bbetween\b%' => 'betwixt', |
'/ious\b/' => "i'us", |
| 65 |
'%\baround\b%' => "aroun'", |
"%\bdon't know\b%" => "dinna", |
| 66 |
'%\bto\b%' => "t'", |
"%\bdidn't know\b%" => "did nay know", |
| 67 |
"%\bit's\b%" => "'tis", |
"%\bhadn't\b%" => "ha'nae", |
| 68 |
'%\bwoman\b%' => 'wench', |
"%\bdidn't\b%"=> "di'nae", |
| 69 |
'%\bwomen\b%' => 'wenches', |
"%\bwasn't\b%" => "weren't", |
| 70 |
'%\blady\b%' => 'wench', |
"%\bhaven't\b%" => "ha'nae", |
| 71 |
'%\bwife\b%' => 'lady', |
'%\bfor\b%' => 'fer', |
| 72 |
'%\bgirl\b%' => 'lass', |
'%\bbetween\b%' => 'betwixt', |
| 73 |
'%\bgirls\b%' => 'lassies', |
'%\baround\b%' => "aroun'", |
| 74 |
'%\bguy\b%' => 'lubber', |
'%\bto\b%' => "t'", |
| 75 |
'%\bman\b%' => 'lubber', |
"%\bit's\b%" => "'tis", |
| 76 |
'%\bfellow\b%' => 'lubber', |
'%\bwoman\b%' => 'wench', |
| 77 |
'%\bdude\b%' => 'lubber', |
'%\bwomen\b%' => 'wenches', |
| 78 |
'%\bboy\b%' => 'lad', |
'%\blady\b%' => 'wench', |
| 79 |
'%\bboys\b%' => 'laddies', |
'%\bwife\b%' => 'lady', |
| 80 |
'%\bchildren\b%' => 'little sandcrabs', |
'%\bgirl\b%' => 'lass', |
| 81 |
'%\bkids\b%' => 'minnows', |
'%\bgirls\b%' => 'lassies', |
| 82 |
'%\bhim\b%' => 'that scurvey dog', |
'%\bguy\b%' => 'lubber', |
| 83 |
'%\bher\b%' => 'that comely wench', |
'%\bman\b%' => 'lubber', |
| 84 |
'%\bhim\.\b%' => 'that drunken sailor', |
'%\bfellow\b%' => 'lubber', |
| 85 |
'%\bHe\b%' => 'The ornery cuss', |
'%\bdude\b%' => 'lubber', |
| 86 |
'%\bShe\b%' => 'The winsome lass', |
'%\bboy\b%' => 'lad', |
| 87 |
"%\bhe's\b%" => 'he be', |
'%\bboys\b%' => 'laddies', |
| 88 |
"%\bshe's\b%" => 'she be', |
'%\bchildren\b%' => 'little sandcrabs', |
| 89 |
'%\bwas\b%' => "were bein'", |
'%\bkids\b%' => 'minnows', |
| 90 |
'%\bHey\b%' => 'Avast', |
'%\bhim\b%' => 'that scurvey dog', |
| 91 |
'%\bher\.\b%' => 'that lovely lass', |
'%\bher\b%' => 'that comely wench', |
| 92 |
'%\bfood\b%' => 'chow', |
'%\bhim\.\b%' => 'that drunken sailor', |
| 93 |
'%\bmoney\b%' => 'dubloons', |
'%\bHe\b%' => 'The ornery cuss', |
| 94 |
'%\bdollars\b%' => 'pieces of eight', |
'%\bShe\b%' => 'The winsome lass', |
| 95 |
'%\bcents\b%' => 'shillings', |
"%\bhe's\b%" => 'he be', |
| 96 |
'%\broad\b%' => 'sea', |
"%\bshe's\b%" => 'she be', |
| 97 |
'%\broads\b%' => 'seas', |
'%\bwas\b%' => "were bein'", |
| 98 |
'%\bstreet\b%' => 'river', |
'%\bHey\b%' => 'Avast', |
| 99 |
'%\bstreets\b%' => 'rivers', |
'%\bher\.\b%' => 'that lovely lass', |
| 100 |
'%\bhighway\b%' => 'ocean', |
'%\bfood\b%' => 'chow', |
| 101 |
'%\bhighways\b%' => 'oceans', |
'%\bmoney\b%' => 'dubloons', |
| 102 |
'%\binterstate\b%' => 'high sea', |
'%\bdollars\b%' => 'pieces of eight', |
| 103 |
'%\bprobably\b%' => 'likely', |
'%\bcents\b%' => 'shillings', |
| 104 |
'%\bidea\b%' => 'notion', |
'%\broad\b%' => 'sea', |
| 105 |
'%\bcar\b%' => 'boat', |
'%\broads\b%' => 'seas', |
| 106 |
'%\bcars\b%' => 'boats', |
'%\bstreet\b%' => 'river', |
| 107 |
'%\btruck\b%' => 'schooner', |
'%\bstreets\b%' => 'rivers', |
| 108 |
'%\btrucks\b%' => 'schooners', |
'%\bhighway\b%' => 'ocean', |
| 109 |
'%\bSUV\b%' => 'ship', |
'%\bhighways\b%' => 'oceans', |
| 110 |
'%\bairplane\b%' => 'flying machine', |
'%\binterstate\b%' => 'high sea', |
| 111 |
'%\bjet\b%' => 'flying machine', |
'%\bprobably\b%' => 'likely', |
| 112 |
'%\bmachine\b%' => 'contraption', |
'%\bidea\b%' => 'notion', |
| 113 |
'%\bdriving\b%' => 'sailing', |
'%\bcar\b%' => 'boat', |
| 114 |
'%\bunderstand\b%' => 'reckon', |
'%\bcars\b%' => 'boats', |
| 115 |
'%\bdrive\b%' => 'sail', |
'%\btruck\b%' => 'schooner', |
| 116 |
'%\bdied\b%' => 'snuffed it', |
'%\btrucks\b%' => 'schooners', |
| 117 |
'/ing\b/' => "in'", |
'%\bSUV\b%' => 'ship', |
| 118 |
'/ings\b/' => "in's", |
'%\bairplane\b%' => 'flying machine', |
| 119 |
// These next two do cool random substitutions |
'%\bjet\b%' => 'flying machine', |
| 120 |
'/(\.\s)/e' => 'avast("$0",3)', |
'%\bmachine\b%' => 'contraption', |
| 121 |
'/([!\?]\s)/e' => 'avast("$0",2)', // Greater chance after exclamation |
'%\bdriving\b%' => 'sailing', |
| 122 |
); |
'%\bunderstand\b%' => 'reckon', |
| 123 |
foreach ($patterns as $pattern_search => $pattern_replace) { |
'%\bdrive\b%' => 'sail', |
| 124 |
$text = preg_replace($pattern_search, $pattern_replace, $text); |
'%\bdied\b%' => 'snuffed it', |
| 125 |
} |
'/ing\b/' => "in'", |
| 126 |
return $text; |
'/ings\b/' => "in's", |
| 127 |
default: |
|
| 128 |
return $text; |
// These next two do cool random substitutions |
| 129 |
|
'/(\.\s)/e' => 'avast("$0",3)', |
| 130 |
|
'/([!\?]\s)/e' => 'avast("$0",2)', // Greater chance after exclamation |
| 131 |
|
); |
| 132 |
|
foreach ($patterns as $pattern_search => $pattern_replace) { |
| 133 |
|
$text = preg_replace($pattern_search, $pattern_replace, $text); |
| 134 |
} |
} |
| 135 |
|
return $text; |
| 136 |
} |
} |
| 137 |
|
|
| 138 |
function pirate_filter_tips($delta, $format, $long = FALSE) { |
function _pirate_tips($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 |
|
|