Inheritance: extends MX_Controller
Esempio n. 1
0
function process_json_file_timeline($filepath, $dbh)
{
    global $tweets_processed, $tweets_failed, $tweets_success, $valid_timeline, $empty_timeline, $invalid_timeline, $populated_timeline, $total_timeline, $all_tweet_ids, $all_users, $bin_name;
    $tweetQueue = new TweetQueue();
    $total_timeline++;
    ini_set('auto_detect_line_endings', true);
    $handle = @fopen($filepath, "r");
    if ($handle) {
        while (($buffer = fgets($handle, 40960)) !== false) {
            $tweet = json_decode($buffer, true);
            //var_export($tweet); print "\n\n";
            $buffer = "";
            $t = new Tweet();
            $t->fromJSON($tweet);
            if (!$t->isInBin($bin_name)) {
                $tweetQueue->push($t, $bin_name);
                if ($tweetQueue->length() > 100) {
                    $tweetQueue->insertDB();
                }
                $all_users[] = $t->from_user_id;
                $all_tweet_ids[] = $t->id;
                $tweets_processed++;
            }
            print ".";
        }
        if (!feof($handle)) {
            echo "Error: unexpected fgets() fail\n";
        }
        fclose($handle);
    }
    if ($tweetQueue->length() > 0) {
        $tweetQueue->insertDB();
    }
}
Esempio n. 2
0
 /**
  * Returns an array of Tweet objects that are populated from a Twitter JSON file.
  *
  * @param string $filename
  * @return array|false
  */
 public function getTweetsInJsonFile($filename)
 {
     $tweets = [];
     if (!file_exists($filename) || file_exists($filename) && !is_readable($filename)) {
         return false;
     }
     $jsonString = file_get_contents($filename);
     if ($jsonString === false) {
         return false;
     }
     // the twitter format includes extra JS code, but we just want the JSON array
     $pattern = '/\\[.*\\]/s';
     $matchError = preg_match($pattern, $jsonString, $matches);
     // $matchError can be zero or false if not found or there was a failure
     if (!$matchError) {
         return false;
     }
     $jsonArrayString = $matches[0];
     $jsonTweets = json_decode($jsonArrayString);
     foreach ($jsonTweets as $tweet) {
         $t = new Tweet();
         $t->loadFromJsonObject($tweet);
         $tweets[] = $t;
     }
     return $tweets;
 }
 private function process_data($data)
 {
     foreach ($data->results as $tweet) {
         $tweet = new Tweet($tweet->id_str);
         $tweet->save();
         $this->tids[] = $tweet->tid;
     }
 }
Esempio n. 4
0
 public function parseTimeline($timeline)
 {
     foreach ($timeline as $tweet) {
         $item = new Tweet();
         $item->setId($tweet->id)->setTitle($tweet->text)->setDescription($tweet->text)->setPubDate($tweet->created_at)->setPlace($tweet->place)->setUsername($tweet->user->screen_name)->setUserId($tweet->user->id);
         $this->addTweet($item);
     }
 }
Esempio n. 5
0
function search($idlist)
{
    global $twitter_keys, $current_key, $all_users, $all_tweet_ids, $bin_name, $dbh, $tweetQueue;
    $keyinfo = getRESTKey(0);
    $current_key = $keyinfo['key'];
    $ratefree = $keyinfo['remaining'];
    print "current key {$current_key} ratefree {$ratefree}\n";
    $tmhOAuth = new tmhOAuth(array('consumer_key' => $twitter_keys[$current_key]['twitter_consumer_key'], 'consumer_secret' => $twitter_keys[$current_key]['twitter_consumer_secret'], 'token' => $twitter_keys[$current_key]['twitter_user_token'], 'secret' => $twitter_keys[$current_key]['twitter_user_secret']));
    // by hundred
    for ($i = 0; $i < sizeof($idlist); $i += 100) {
        if ($ratefree <= 0 || $ratefree % 10 == 0) {
            $keyinfo = getRESTKey($current_key);
            $current_key = $keyinfo['key'];
            $ratefree = $keyinfo['remaining'];
            $tmhOAuth = new tmhOAuth(array('consumer_key' => $twitter_keys[$current_key]['twitter_consumer_key'], 'consumer_secret' => $twitter_keys[$current_key]['twitter_consumer_secret'], 'token' => $twitter_keys[$current_key]['twitter_user_token'], 'secret' => $twitter_keys[$current_key]['twitter_user_secret']));
        }
        $q = $idlist[$i];
        $n = $i + 1;
        while ($n < $i + 100) {
            if (!isset($idlist[$n])) {
                break;
            }
            $q .= "," . $idlist[$n];
            $n++;
        }
        $params = array('id' => $q);
        $code = $tmhOAuth->user_request(array('method' => 'GET', 'url' => $tmhOAuth->url('1.1/statuses/lookup'), 'params' => $params));
        $ratefree--;
        if ($tmhOAuth->response['code'] == 200) {
            $data = json_decode($tmhOAuth->response['response'], true);
            if (is_array($data) && empty($data)) {
                // all tweets in set are deleted
                continue;
            }
            $tweets = $data;
            $tweet_ids = array();
            foreach ($tweets as $tweet) {
                $t = new Tweet();
                $t->fromJSON($tweet);
                if (!$t->isInBin($bin_name)) {
                    $all_users[] = $t->from_user_id;
                    $all_tweet_ids[] = $t->id;
                    $tweet_ids[] = $t->id;
                    $tweetQueue->push($t, $bin_name);
                }
                print ".";
            }
            sleep(1);
        } else {
            echo "Failure with code " . $tmhOAuth->response['response']['code'] . "\n";
            var_dump($tmhOAuth->response['response']['info']);
            var_dump($tmhOAuth->response['response']['error']);
            var_dump($tmhOAuth->response['response']['errno']);
            die;
        }
        $tweetQueue->insertDB();
    }
}
Esempio n. 6
0
 /**
  * Get relevant properly sized data for using the Twitter API.
  *
  * @param Tweet $tweet
  *
  * @return array
  */
 protected function getPostData(Tweet $tweet)
 {
     $message = $tweet->getMessage();
     $message->rewind();
     $status = $message->getContents();
     if (0 === $tweet->getMediaId()) {
         return ['status' => substr($status, 0, 140)];
     }
     return ['status' => substr($status, 0, 110), 'media_ids' => $tweet->getMediaId()];
 }
Esempio n. 7
0
function search($keywords, $max_id = null)
{
    global $twitter_keys, $current_key, $ratefree, $bin_name, $dbh, $tweetQueue;
    $ratefree--;
    if ($ratefree < 1 || $ratefree % 10 == 0) {
        $keyinfo = getRESTKey($current_key, 'search', 'tweets');
        $current_key = $keyinfo['key'];
        $ratefree = $keyinfo['remaining'];
    }
    $tmhOAuth = new tmhOAuth(array('consumer_key' => $twitter_keys[$current_key]['twitter_consumer_key'], 'consumer_secret' => $twitter_keys[$current_key]['twitter_consumer_secret'], 'token' => $twitter_keys[$current_key]['twitter_user_token'], 'secret' => $twitter_keys[$current_key]['twitter_user_secret']));
    $params = array('q' => $keywords, 'count' => 100);
    if (isset($max_id)) {
        $params['max_id'] = $max_id;
    }
    $code = $tmhOAuth->user_request(array('method' => 'GET', 'url' => $tmhOAuth->url('1.1/search/tweets'), 'params' => $params));
    if ($tmhOAuth->response['code'] == 200) {
        $data = json_decode($tmhOAuth->response['response'], true);
        $tweets = $data['statuses'];
        $tweet_ids = array();
        foreach ($tweets as $tweet) {
            $t = new Tweet();
            $t->fromJSON($tweet);
            $tweet_ids[] = $t->id;
            if (!$t->isInBin($bin_name)) {
                $tweetQueue->push($t, $bin_name);
                if ($tweetQueue->length() > 100) {
                    $tweetQueue->insertDB();
                }
                print ".";
            }
        }
        if (!empty($tweet_ids)) {
            print "\n";
            if (count($tweet_ids) <= 1) {
                print "no more tweets found\n\n";
                return false;
            }
            $max_id = min($tweet_ids);
            print "max id: " . $max_id . "\n";
        } else {
            print "0 tweets found\n\n";
            return false;
        }
        sleep(1);
        search($keywords, $max_id);
    } else {
        echo $tmhOAuth->response['response'] . "\n";
        if ($tmhOAuth->response['response']['errors']['code'] == 130) {
            // over capacity
            sleep(1);
            search($keywords, $max_id);
        }
    }
}
Esempio n. 8
0
  public function load($id) {
    $result=HypertableConnection::query("SELECT * FROM tweet ".
                "WHERE ROW='$id'");
    if (!$result or !count($result->cells))
      return null;

    $tweet=new Tweet();
    $tweet->setId($id);
    $tweet->setTimestamp($result->cells[0]->key->timestamp);
    $tweet->setMessage($result->cells[0]->value);
    return $tweet;
  }
Esempio n. 9
0
 /**
  * Turn the array of results to an object array of Tweets.
  *
  * @param array $data Array of tweet results
  *
  * @return array An array of Tweets
  */
 protected function classify($data)
 {
     if (!isset($data) || empty($data)) {
         return;
     }
     $tweets = [];
     foreach ($data as $tweet) {
         $tweet_obj = new Tweet();
         $tweets[] = $tweet_obj->set_data($tweet);
     }
     return $tweets;
 }
Esempio n. 10
0
 public function store(Request $request)
 {
     $type = $request->get('type');
     $tweet = Tweet::find($id);
     if (!$tweet) {
         $tweet = new Tweet();
         $tweet[$type] = 1;
     }
     $tweet->id = $request->get('id');
     $tweet->text = $request->get('text');
     $tweet->increment($type);
     $tweet->save();
     return $request->all();
 }
 public function showTweet($tweet_id)
 {
     if (Request::ajax()) {
         $tweet = Tweet::where('tweet_id', '=', $tweet_id)->destroy();
         return Response::json(true);
     }
 }
 public static function data()
 {
     // Haetaan kaikki twiitit tietokannasta
     $tweets = Tweet::all();
     // Renderöidään views kansiossa sijaitseva tiedosto tietokannat.html muuttujan $tweets datalla
     View::make('data.html', array('tweets' => $tweets));
 }
Esempio n. 13
0
 public function get_posts()
 {
     $url = add_query_arg(array('screen_name' => self::$username, 'exclude_replies' => 'true'), self::$endpoint);
     $response = wp_remote_get($url, array('headers' => array('Authorization' => 'Bearer ' . self::$bearer_token)));
     $r = json_decode(wp_remote_retrieve_body($response));
     if ($r) {
         foreach ($r as $raw_tweet) {
             $tweet = new Tweet($raw_tweet);
             $social_post = $tweet->generate_socialpost();
             if (!$social_post->exists()) {
                 $social_post->save();
             } else {
             }
         }
     }
 }
Esempio n. 14
0
function process_json_file_timeline($filepath, $dbh)
{
    global $tweets_processed, $tweets_failed, $tweets_success, $valid_timeline, $empty_timeline, $invalid_timeline, $populated_timeline, $total_timeline, $all_tweet_ids, $all_users, $bin_name;
    $tweetQueue = new TweetQueue();
    $total_timeline++;
    $filestr = file_get_contents($filepath);
    // sylvester stores multiple json exports in the same file,
    // in order to decode it we will need to split it into its respective individual exports
    $jsons = explode("}][{", $filestr);
    print count($jsons) . " jsons found\n";
    foreach ($jsons as $json) {
        if (substr($json, 0, 2) != "[{") {
            $json = "[{" . $json;
        }
        if (substr($json, -2) != "}]") {
            $json = $json . "}]";
        }
        $timeline = json_decode($json);
        if (is_array($timeline)) {
            $valid_timeline++;
            if (!empty($timeline)) {
                $populated_timeline++;
            } else {
                $empty_timeline++;
            }
        } else {
            $invalid_timeline++;
        }
        foreach ($timeline as $tweet) {
            $t = new Tweet();
            $t->fromJSON($tweet);
            if (!$t->isInBin($bin_name)) {
                $tweetQueue->push($t, $bin_name);
                if ($tweetQueue->length() > 100) {
                    $tweetQueue->insertDB();
                }
                $all_users[] = $t->user->id;
                $all_tweet_ids[] = $t->id;
                $tweets_processed++;
            }
        }
    }
    if ($tweetQueue->length() > 0) {
        $tweetQueue->insertDB();
    }
}
 public static function addFavoris($req_twitter, $name_id)
 {
     foreach ($req_twitter as $key => $value) {
         Tweet::create(array('name_id' => $name_id->id, 'id_str' => $value->id, 'screen_name' => $value->user->screen_name, 'name' => $value->user->name, 'profile_image_url' => $value->user->profile_image_url, 'text' => $value->text, 'date_tweet' => $value->created_at));
         $max_id = $value->id;
     }
     return $max_id;
 }
Esempio n. 16
0
 public function loadTweets()
 {
     $conn = $this->connection;
     $sqlQuery = "SELECT user_id, tweets.id, text FROM tweets INNER JOIN users ON tweets.user_id = users.id ORDER BY tweets.created_at DESC";
     $result = $conn->query($sqlQuery);
     if ($result->num_rows > 0) {
         while (list($userId, $tweetId, $text) = $result->fetch_array(MYSQLI_NUM)) {
             $tweet = new Tweet($conn);
             $tweet->setUserId($userId);
             $tweet->setText($text);
             $tweet->setId($tweetId);
             $this->arrayWithTweets[] = $tweet;
         }
         return true;
     } else {
         return false;
     }
 }
Esempio n. 17
0
 public function reply($id)
 {
     try {
         $tweet = new Tweet($id);
         $comment = new TweetComment();
         $comment->setTweetId($tweet->getId());
         $comment->setProfileId(UserHelper::getProfileId());
         $comment->setContent(trim(fRequest::get('tweet-comment')));
         if (strlen($comment->getContent()) < 1) {
             throw new fValidationException('回复长度不能少于1个字符');
         }
         if (strlen($comment->getContent()) > 140) {
             throw new fValidationException('回复长度不能超过140个字符');
         }
         $comment->store();
     } catch (fException $e) {
         // TODO
     }
     fURL::redirect(SITE_BASE . '/profile/' . $tweet->getProfileId() . '#tweet/' . $tweet->getId());
 }
 public static function createFromJSON($json)
 {
     $tweets = json_decode($json, true);
     if (!is_array($tweets) || !isset($tweets['results'])) {
         throw new InvalidArgumentException('Unable to decode JSON response');
     }
     $tweetCollection = array();
     foreach ($tweets['results'] as $tweetArray) {
         $tweetCollection[] = Tweet::createFromArray($tweetArray);
     }
     return new self($tweetCollection);
 }
Esempio n. 19
0
function do_update_if_needed($twitster)
{
    if (time_for_refresh()) {
        if (file_exists(UPDATE_PID_FILE)) {
            twitlog("Time for an update, but one is already in progress. Skipping.");
        } else {
            twitlog("It is time to refresh the cache, beginning now.");
            $tweets = Tweet::find();
            $since = is_array($tweets) && $tweets[0] ? $tweets[0]->id : false;
            $twitster->refresh($since);
        }
    }
}
 public function show($id = null)
 {
     $account = $this->load_account($id);
     $this->assign('account', $account);
     $page = 1;
     if ($this->GetData('page')) {
         $page = $this->GetData('page');
     }
     $id = mysql_real_escape_string($account->id);
     $tweets = Tweet::paginate("twitter_accounts.id = '{$id}'", "tweets.publish_at DESC, tweets.id DESC", $page, 20);
     $this->assign('tweets', $tweets);
     $this->title = "Twitter Account :: {$account->name}";
     $this->render('twitter_account/show.tpl');
 }
function soap_returned_msg($test_xml_string)
{
    $test_xml_string = cleanString($test_xml_string);
    if (!simplexml_load_string($test_xml_string)) {
        echo json_encode(array("error"));
    } else {
        file_put_contents("LOG/usage_" . $_SESSION['user_email'] . ".txt", date("F j, Y, g:i a") . " " . $_SERVER['REMOTE_ADDR'] . "\r\n", FILE_APPEND | LOCK_EX);
        $xml = simplexml_load_string($test_xml_string);
        $arrayTweets = array();
        foreach ($xml->children() as $tnum) {
            if ($tnum['tweetID'] != "") {
                $tweet = new Tweet();
                $tweet->initializeMembers($tnum);
                array_push($arrayTweets, $tweet);
            }
        }
        echo json_encode($arrayTweets);
        //free variable to avoid memory leak
        foreach ($arrayTweets as $t) {
            unset($t);
        }
        unset($arrayTweets);
    }
}
Esempio n. 22
0
 public function save()
 {
     \ORM::get_db()->beginTransaction();
     if ($this->is_new()) {
         Tweet::reset_in_reply_to_status_id();
     }
     TweetDate::register($this->date());
     parent::save();
     if (is_array($this->_medias)) {
         foreach ($this->_medias as $media) {
             $media->tweet_id = $this->id;
             $media->save();
         }
     }
     \ORM::get_db()->commit();
 }
Esempio n. 23
0
 /**
  * test grabbing a Favorite by profile id
  **/
 public function testGetValidFavoriteByProfileId()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("favorite");
     // create a new Favorite and insert to into mySQL
     $favorite = new Favorite($this->tweet->getTweetId(), $this->profile->getProfileId(), $this->VALID_FAVORITEDATE);
     $favorite->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $results = Favorite::getFavoriteByProfileId($this->getPDO(), $this->profile->getProfileId());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("favorite"));
     $this->assertCount(1, $results);
     $this->assertContainsOnlyInstancesOf("Favorite", $results);
     // grab the result from the array and validate it
     $pdoFavorite = $results[0];
     $this->assertEquals($pdoFavorite->getTweetId(), $this->tweet->getTweetId());
     $this->assertEquals($pdoFavorite->getProfileId(), $this->profile->getProfileId());
     $this->assertEquals($pdoFavorite->getFavoriteDate(), $this->VALID_FAVORITEDATE);
 }
 public function run($request)
 {
     // output
     echo "<br />\n<br />\nPurging...<br />\n<br />\n";
     flush();
     ob_flush();
     foreach (Tweet::get() as $page) {
         echo "Deleting " . $page->Title . "\n";
         $page->delete();
     }
     foreach (Versioned::get_by_stage('Tweet', 'Stage') as $page) {
         echo "Deleting From Stage: " . $page->Title . "\n";
         $page->deleteFromStage('Stage');
     }
     foreach (Versioned::get_by_stage('Tweet', 'Live') as $page) {
         echo "Deleting From Live: " . $page->Title . "\n";
         $page->deleteFromStage('Live');
     }
 }
 public function run($request)
 {
     // eol
     $eol = php_sapi_name() == 'cli' ? "\n" : "<br>\n";
     // output
     echo $eol . $eol . 'Purging...' . $eol . $eol;
     flush();
     @ob_flush();
     foreach (Tweet::get() as $page) {
         echo "Deleting " . $page->Title . $eol;
         $page->delete();
     }
     foreach (Versioned::get_by_stage('Tweet', 'Stage') as $page) {
         echo "Deleting From Stage: " . $page->Title . $eol;
         $page->deleteFromStage('Stage');
     }
     foreach (Versioned::get_by_stage('Tweet', 'Live') as $page) {
         echo "Deleting From Live: " . $page->Title . $eol;
         $page->deleteFromStage('Live');
     }
 }
 public function healthcheck()
 {
     // Check we have data from Mandrill
     $data = json_decode($this->PostData('mandrill_events'));
     if (!$data) {
         echo 'OK - No Data';
         die;
     }
     // We need to check if we've sent an alert in the past
     // 8 hours, if not, send another one.
     $content = "Exchange Alert: Delivery Delay";
     $cutoff = time() - 3600 * 8;
     $lastTweet = Tweet::find("tweets.message = '{$content}'", "publish_at DESC");
     if ($lastTweet && $lastTweet->publish_at > $cutoff) {
         echo 'OK - Alert Already Sent';
         die;
     }
     $account = TwitterAccount::find_by_code('site');
     $account->add_tweet($content);
     echo 'OK - Alert Sent';
     die;
 }
Esempio n. 27
0
function process_json_file_timeline($filepath, $dbh)
{
    print $filepath . "\n";
    global $tweets_processed, $tweets_failed, $tweets_success, $all_tweet_ids, $all_users, $bin_name;
    $tweetQueue = new TweetQueue();
    ini_set('auto_detect_line_endings', true);
    $handle = @fopen($filepath, "r");
    if ($handle) {
        while (($buffer = fgets($handle, 40960)) !== false) {
            $buffer = trim($buffer);
            if (empty($buffer)) {
                continue;
            }
            $tweet = json_decode($buffer);
            $buffer = "";
            $t = Tweet::fromGnip($tweet);
            if ($t === false) {
                continue;
            }
            if (!$t->isInBin($bin_name)) {
                $all_users[] = $t->from_user_id;
                $all_tweet_ids[] = $t->id;
                $tweetQueue->push($t, $bin_name);
                if ($tweetQueue->length() > 100) {
                    $tweetQueue->insertDB();
                }
                $tweets_processed++;
            }
            print ".";
        }
        if (!feof($handle)) {
            echo "Error: unexpected fgets() fail\n";
        }
        fclose($handle);
    }
    if ($tweetQueue->length() > 0) {
        $tweetQueue->insertDB();
    }
}
 public function update()
 {
     $pseudos = Name::all();
     $name = Input::get('pseudo');
     $db_name = Name::where('screen_name', '=', $name)->first();
     if (isset($db_name->screen_name) && strtolower($name) == strtolower($db_name->screen_name)) {
         // Le pseudo existe déjà dans la BDD, on affiche directement
         $twitter = Tweet::where('name_id', '=', $db_name->id)->paginate(20);
         return View::make('twitter', compact('twitter', 'pseudos'))->with(['name' => $name]);
     } else {
         $author = Twitter::getUserTimeline(array('screen_name' => $name, 'count' => 1));
         if (isset($author->errors)) {
             $erreur = 'Il n\'existe pas d\'utilisateur au nom de ' . $name;
             return View::make('twitter')->with(['name' => $name, 'erreur' => $erreur]);
         } else {
             // Le pseudo n'existe pas dans la base de donnée, on créé une entrée et on récupère ses tweets favoris
             TwitterFav::createUser($author);
             $name_id = Name::where('screen_name', '=', $author[0]->user->screen_name)->first();
             $req_twitter = Twitter::getFavorites(array('screen_name' => $name, 'count' => 200, 'format' => 'object'));
             if (isset($req_twitter->errors)) {
                 echo 'Trop de requetes, veuillez patienter.';
                 exit;
             }
             while ($req_twitter != 0) {
                 // On ajoute les tweets favoris en BDD
                 $max_id = TwitterFav::addFavoris($req_twitter, $name_id);
                 $req_twitter = Twitter::getFavorites(array('max_id' => $max_id, 'screen_name' => $name, 'count' => 200, 'format' => 'object'));
                 if (isset($req_twitter->errors)) {
                     echo 'Trop de requetes, veuillez patienter.';
                     exit;
                 }
                 sleep(10);
             }
             $twitter = Tweet::where('name_id', '=', $name_id->id)->paginate(25);
             $pseudos = Name::all();
             return View::make('twitter', compact('twitter', 'pseudos'))->with(['name' => $name]);
         }
     }
 }
Esempio n. 29
0
 protected function tweet_register($all_regist = false)
 {
     if (!$this->is_twitter_connect()) {
         return false;
     }
     try {
         $params = array();
         if ($all_regist) {
             $tweets = array();
             for ($i = 0; $i < 15; $i++) {
                 // 3000件までしか担保されてないため、200 * 15 = 3000 で無限ループ防止
                 $tweets_buf = $this->get_tweets($params);
                 if (empty($tweets_buf)) {
                     break;
                 }
                 $params['max_id'] = end($tweets_buf)->id;
                 reset($tweets_buf);
                 $tweets = array_merge($tweets, Tweet::build_tweets($tweets_buf));
             }
         } else {
             $since_id = Tweet::registered_max_tweet_id();
             if (isset($since_id) && $since_id > 0) {
                 $params['since_id'] = $since_id;
             }
             $tweets = Tweet::build_tweets($this->get_tweets($params));
         }
         return array_map(function ($tweet) {
             if ($tweet->is_reply()) {
                 return null;
             }
             // リプライツイートは無視する
             return $tweet->save();
         }, $tweets);
     } catch (Exception $e) {
         // HACK: エラー処理
         trigger_error('Tweet 取得ミスった');
     }
 }
Esempio n. 30
0
<?php

// Define path constant
$path = str_replace('\\', '/', __DIR__);
$path_fragments = explode('/', $path);
$dir_name = $path_fragments[count($path_fragments) - 1];
define('ABC_SOCIAL_DIR', $dir_name);
// attach the social extensions to the config and page classes
SiteConfig::add_extension('SocialMediaConfig');
Page::add_extension('SocialMediaPageExtension');
// attach common behaviours to the social updates
FBUpdate::add_extension('SocialUpdatePageExtension');
Tweet::add_extension('SocialUpdatePageExtension');
InstagramUpdate::add_extension('SocialUpdatePageExtension');
// add the embed functionality
if (!Config::inst()->get('SocialGlobalConf', 'disable_wysiwyg_embed')) {
    ShortcodeParser::get('default')->register('social_embed', array('SocialMediaPageExtension', 'SocialEmbedParser'));
    HtmlEditorConfig::get('cms')->enablePlugins(array('social_embed' => '../../../' . ABC_SOCIAL_DIR . '/js/editor-plugin.js'));
    HtmlEditorConfig::get('cms')->addButtonsToLine(2, 'social_embed');
}
// allow script tags
// maybe we could try using requirements and stripping the script tags
// HtmlEditorConfig::get('cms')
//     ->setOption(
//         'extended_valid_elements',
//         'img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|usemap|data*],' .
//         'iframe[src|name|width|height|align|frameborder|marginwidth|marginheight|scrolling],' .
//         'object[width|height|data|type],' .
//         'param[name|value],' .
//         'map[class|name|id],' .
//         'area[shape|coords|href|target|alt],ol[class|start],' .