Permalink
Browse files

tabs --> spaces

  • Loading branch information...
1 parent 32aadee commit 3f158b7f95d5037411f9bdeb8107b3317f1fd002 @thegingerbloke committed Jul 21, 2011
Showing with 283 additions and 283 deletions.
  1. +14 −14 Translations.php
  2. +31 −31 TweetMunger.php
  3. +21 −21 index.php
  4. +217 −217 translations/pirate.php
View
@@ -28,24 +28,24 @@
public $translations = array();
/**
- * Translate!
- * Over-writable if necessary
+ * Translate!
+ * Over-writable if necessary
*
* @var string $text
* @return string
- */
- public function translate($text, $context) {
+ */
+ public function translate($text, $context) {
- foreach($this->translations as $search => $replace) {
- $text = preg_replace("/\b$search\b/i", $replace, $text);
- }
+ foreach($this->translations as $search => $replace) {
+ $text = preg_replace("/\b$search\b/i", $replace, $text);
+ }
- // condition : sometimes add in a funny end to a sentence
- if (count($this->shouts > 0)) {
- if (1 == rand(1,$this->shoutFrequency)) {
- shuffle($this->shouts);
- $text = preg_replace("/\. /", $this->shouts[0], $text);
- }
+ // condition : sometimes add in a funny end to a sentence
+ if (count($this->shouts > 0)) {
+ if (1 == rand(1,$this->shoutFrequency)) {
+ shuffle($this->shouts);
+ $text = preg_replace("/\. /", $this->shouts[0], $text);
+ }
}
$context->debug('<p>Munging: ' . $text . '</p>');
@@ -55,6 +55,6 @@ public function translate($text, $context) {
$text = $this->additionalMunging($text, $context);
}
- return $text;
+ return $text;
}
}
View
@@ -17,7 +17,7 @@
* Tweet Munger Class
*/
class TweetMunger {
-
+
/**
* The Twitter Search object
*
@@ -111,8 +111,8 @@ class TweetMunger {
* @var obj
*/
protected $translator;
-
-
+
+
/**
* Constructor.
* Save/overwrite any default settings passed through during instantiation.
@@ -133,13 +133,13 @@ public function __construct($options) {
// prep the selected translations
require_once('translations/'.$this->translations.'.php');
$translatorClass = ucFirst($this->translations)."Translations";
- $this->translator = new $translatorClass;
-
- // debug
- if ($this->debugMode) {
- $this->debug('<p><em>(Debug mode on, not posting to twitter)</em></p>');
- }
-
+ $this->translator = new $translatorClass;
+
+ // debug
+ if ($this->debugMode) {
+ $this->debug('<p><em>(Debug mode on, not posting to twitter)</em></p>');
+ }
+
// get the latest tweet from the munged account
$this->twitterSearch = new TwitterSearch();
$this->twitterSearch->user_agent = 'phptwittersearch:'.$this->userAgentAccount;
@@ -160,9 +160,9 @@ public function __construct($options) {
$this->tweet($text);
}
}
- }
-
-
+ }
+
+
/**
* Get the Twitter ID of the latest translated tweet
*
@@ -200,7 +200,7 @@ private function getLatestTweets($latestMungedTweetId) {
* @var int $id
* @return string
*/
- private function mungText($text, $id) {
+ private function mungText($text, $id) {
$this->debug('<p>Original Tweet (ID - '.$id.'): ' . $text . '</p>');
@@ -217,21 +217,21 @@ private function mungText($text, $id) {
$text = str_replace('#', '_', $text);
// use the translator class to translate
- $text = $this->translator->translate($text, $this);
-
- // ensure new text length is <= 140 characters
+ $text = $this->translator->translate($text, $this);
+
+ // ensure new text length is <= 140 characters
if (strlen($text) > 140) {
$text = substr($text, 0, 137) . "...";
$this->debug('<p>Text is too long, truncating...</p>');
}
- $this->debug('<p>Translation: ' . $text . '</p>');
+ $this->debug('<p>Translation: ' . $text . '</p>');
// return the newly translated text
return $text;
- }
-
-
+ }
+
+
/**
* Tweet the new text (if not in debug mode)
*
@@ -251,14 +251,14 @@ private function tweet($text) {
}
$this->debug('<hr />');
}
-
-
- /**
- *
- */
- public function debug($text) {
-// if ($this->debugMode) {
- echo $text;
-// }
- }
+
+
+ /**
+ *
+ */
+ public function debug($text) {
+// if ($this->debugMode) {
+ echo $text;
+// }
+ }
}
View
@@ -1,29 +1,29 @@
<?php
- require_once('TweetMunger.php');
+ require_once('TweetMunger.php');
?>
<!DOCTYPE html>
<html lang="en">
- <head>
- <meta charset="utf-8" />
- <title>Tweet Munger</title>
- </head>
- <body>
- <h1>Test</h1>
- <?php
-
- $tweetMunger = new TweetMunger(array(
- 'debugMode' => true,
- 'originalTwitterAccount' => 'xxx',
- 'mungedTwitterAccount' => 'yyy',
- 'userAgentAccount' => 'xxx@yyy.com',
+ <head>
+ <meta charset="utf-8" />
+ <title>Tweet Munger</title>
+ </head>
+ <body>
+ <h1>Test</h1>
+ <?php
+
+ $tweetMunger = new TweetMunger(array(
+ 'debugMode' => true,
+ 'originalTwitterAccount' => 'xxx',
+ 'mungedTwitterAccount' => 'yyy',
+ 'userAgentAccount' => 'xxx@yyy.com',
'newTweetCount' => 10,
'ignoreRetweets' => true,
'translations' => 'pirate',
- 'twitterConsumerKey' => 'x',
- 'twitterConsumerSecret' => 'x',
- 'twitterConsumerOauthToken' => 'x',
- 'twitterConsumerOauthSecret' => 'x'
- ));
- ?>
- </body>
+ 'twitterConsumerKey' => 'x',
+ 'twitterConsumerSecret' => 'x',
+ 'twitterConsumerOauthToken' => 'x',
+ 'twitterConsumerOauthSecret' => 'x'
+ ));
+ ?>
+ </body>
</html>
Oops, something went wrong.

0 comments on commit 3f158b7

Please sign in to comment.