static function parse_entry_json($item)
 {
     $entry = array();
     if (preg_match('/href="([^"]*)"/', html_entity_decode($item->source, ENT_COMPAT, LANG_CHARSET), $matches)) {
         $source_link = $matches[1][0];
     }
     //$link = str_replace('<a href="','',str_replace('"/a>','',html_entity_decode($item['source'])));
     $user = $item->user;
     $entry[TWITTER_SEARCHRESULT_LOGIN] = $user->screen_name;
     $entry[TWITTER_SEARCHRESULT_REALNAME] = $user->name;
     if (!function_exists('htmlspecialchars_decode')) {
         $entry[TWITTER_SEARCHRESULT_TWEET] = $item->text;
         // PHP4 Version w/o html_specialcar decoding.
     } else {
         $entry[TWITTER_SEARCHRESULT_TWEET] = htmlspecialchars_decode($item->text);
     }
     $uniq = isset($item->id_str) ? $item->id_str : sprintf('%0.0f', $item->id);
     $entry[TWITTER_SEARCHRESULT_ID] = $uniq;
     $entry[TWITTER_SEARCHRESULT_URL_AUTOR] = TwitterOAuthApi::get_base_url() . $entry[TWITTER_SEARCHRESULT_LOGIN];
     $entry[TWITTER_SEARCHRESULT_URL_IMG] = $user->profile_image_url;
     $entry[TWITTER_SEARCHRESULT_URL_TWEET] = TwitterOAuthApi::get_base_url() . $entry[TWITTER_SEARCHRESULT_LOGIN] . '/status/' . $entry[TWITTER_SEARCHRESULT_ID];
     if (!empty($source_link)) {
         $entry[TWITTER_SEARCHRESULT_URL_SRC] = $source_link;
     }
     $entry[TWITTER_SEARCHRESULT_PUBDATE] = $item->created_at;
     $entry[TWITTER_SEARCHRESULT_RETWEET] = preg_match('/^(rt|retweet|retweeting)[ :].*/i', $item->text);
     // get expanded urls
     if (!empty($item->entities)) {
         if (!empty($item->entities->urls)) {
             $urls = array();
             $urlsExpanded = array();
             $redirCheck = new RedirectCheck();
             foreach ($item->entities->urls as $url) {
                 if (!empty($url->expanded_url)) {
                     $urls[] = $url->expanded_url;
                 }
             }
             $entry[TWITTER_SEARCHRESULT_URL_ARRAY] = $urls;
         }
     }
     return $entry;
 }
 function display_twitter_client($tweeter_in_sidbar = false)
 {
     $identities = $this->load_identities();
     $status_timeline = $this->load_timeline();
     $tweeter_has_timeline = $this->get_config('tweeter_history', false) === true;
     if ($_POST['tweeter_timeline']) {
         $pstatus_timeline = $_POST['tweeter_timeline'];
     } else {
         $pstatus_timeline = $this->get_config('tweeter_timeline');
     }
     // Always remember last set identity
     $val_identitiy = $_POST['tweeter_account'];
     $acc_number = '';
     if (empty($val_identitiy) || $val_identitiy == 0) {
         $account_name = $this->get_config('twittername', '');
         $account_pwd = $this->get_config('twitterpwd', '');
         $account_type = $this->get_config('id_service', 'twitter');
     } else {
         $acc_number = (int) $val_identitiy + 1;
         $account_name = $this->get_config('twittername' . $acc_number, '');
         $account_pwd = $this->get_config('twitterpwd' . $acc_number, '');
         $account_type = $this->get_config('id_service' . $acc_number, 'twitter');
     }
     // Display client
     if ($this->get_config('tweeter_show', 'disable') != 'disable') {
         if (isset($_POST['tweeter_submit'])) {
             if (isset($_POST['tweet'], $_POST['shorturl'])) {
                 if ($_POST['shorturl'] !== 'http://' && !empty($_POST['shorturl'])) {
                     $val_short = $this->default_shorturl($_POST['shorturl']);
                     if ($val_short == $_POST['shorturl']) {
                         $val_short = 'ERROR';
                     }
                     $val_tweet = $_POST['tweet'] . $val_short;
                     $val_short = '';
                 } elseif (!empty($_POST['tweet'])) {
                     $update = $_POST['tweet'];
                     // Change encoding of update to UTF-8
                     if (LANG_CHARSET != 'UTF-8' && function_exists("mb_convert_encoding")) {
                         $update = mb_convert_encoding($update, 'UTF-8', LANG_CHARSET);
                     }
                     if ($account_type == "identica") {
                         $api = new Twitter($account_type == 'identica');
                         $twit = $api->update($account_name, $account_pwd, $update);
                     } else {
                         $connection = $this->twitteroa_connect($acc_number);
                         $api = new TwitterOAuthApi($connection);
                         $status = $api->update($update);
                         $twit = true;
                     }
                     if ($twit === true) {
                         $notice = PLUGIN_EVENT_TWITTER_TWEETER_STORED;
                     } else {
                         $val_tweet = $_POST['tweet'];
                         $notice = PLUGIN_EVENT_TWITTER_TWEETER_STOREFAIL . $twit;
                     }
                 }
             }
         } elseif (isset($_POST['tweeter_change_identity'])) {
             $val_tweet = $_POST['tweet'];
             $val_short = $_POST['shorturl'];
         }
         // Create strings of twitter URL length:
         $this->twitter_check_config();
         $http_length_str = str_repeat("=", (int) $this->get_config('twitter_config_http_len'));
         $https_length_str = str_repeat("=", (int) $this->get_config('twitter_config_https_len'));
         // Hide shorten url input, if no url shorter is used!
         if ('raw' == $this->get_config('anounce_url_service', '7ax.de')) {
             echo "<style type=\"text/css\">div#serendipity_admin_tweeter_shorturl {display: none;}</style>";
             @define('PLUGIN_EVENT_TWITTER_TWEETER_SHORTEN_OR_UPDATE', PLUGIN_EVENT_TWITTER_TWEETER_UPDATE);
         } else {
             @define('PLUGIN_EVENT_TWITTER_TWEETER_SHORTEN_OR_UPDATE', PLUGIN_EVENT_TWITTER_TWEETER_SHORTEN . ' / ' . PLUGIN_EVENT_TWITTER_TWEETER_UPDATE);
         }
         // Display the form
         include dirname(__FILE__) . '/tweeter/tweeter_client.inc.php';
     } else {
         return true;
         // if disabled, don't display anything else!
     }
     // Display history
     if ($tweeter_has_timeline) {
         if ($account_type == "identica") {
             $count = $this->get_config('tweeter_history_count', 10);
             $api = new Twitter($account_type == 'identica');
             $statuses = $api->timeline($account_name, $account_pwd, $count);
         } else {
             require_once dirname(__FILE__) . '/twitteroauth/twitteroauth.php';
             if ($_POST['tweeter_timeline']) {
                 $get_connection = "statuses/" . $_POST['tweeter_timeline'];
             } else {
                 $get_connection = "statuses/" . $this->get_config('tweeter_timeline');
             }
             $connection = $this->twitteroa_connect($acc_number);
             $statuses = $connection->get($get_connection);
             $http_code = $connection->http_code;
             $api = new Twitter($account_type == 'identica');
         }
         $buffer = '';
         if (!is_array($statuses)) {
             if (empty($statuses)) {
                 $buffer = '<li><strong>Result from Twitter was empty.</strong><br/>Perhaps down for maintenance?</li>';
             } elseif (is_object($statuses)) {
                 if (!empty($statuses->error)) {
                     $buffer = '<li><strong>' . $statuses->error . '</strong></li>';
                 } else {
                     $buffer = '<li><strong>Reported an unknown error</strong></li>';
                 }
             } else {
                 print_r($statuses);
                 $buffer = '<li><strong>Twitter reported http error ' . $statuses . '</strong></li>';
             }
         } else {
             if ($account_type == "twitter") {
                 if ($_POST['tweeter_timeline']) {
                     $buffer_header = PLUGIN_EVENT_TWITTER_TIMELINE . ": " . $_POST['tweeter_timeline'];
                 } else {
                     $buffer_header = PLUGIN_EVENT_TWITTER_TIMELINE . ": " . $this->get_config('tweeter_timeline');
                 }
             }
             foreach ($statuses as $status) {
                 // Setup links inside of the text
                 $status->text = $api->replace_links_in_status($status->text);
                 // Change encoding to blog encoding
                 if (LANG_CHARSET != 'UTF-8' && function_exists("mb_convert_encoding")) {
                     $status->text = mb_convert_encoding($status->text, LANG_CHARSET, 'UTF-8');
                 }
                 if (strtoupper($account_name) != strtoupper($status->user->screen_name)) {
                     $reply_link = '<a href="javascript:tweeter_reply(\'' . $status->user->screen_name . '\');" title="' . PLUGIN_EVENT_TWITTER_TWEETER_REPLY . '">@</a>';
                     $direct_link = '<a href="javascript:tweeter_dm(\'' . $status->user->screen_name . '\');" title="' . PLUGIN_EVENT_TWITTER_TWEETER_DM . '">DM</a>';
                     $retweet_link = '<a href="javascript:tweeter_retweet(\'' . $status->user->screen_name . '\', \'' . str_replace('"', '#quot2;', str_replace("'", '#quot1;', strip_tags($status->text))) . '\');" title="' . PLUGIN_EVENT_TWITTER_TWEETER_RETWEET . '">RT</a>';
                 } else {
                     $reply_link = '';
                     $direct_link = '';
                     $retweet_link = '';
                 }
                 // Twitter delivers the complete status ID in an extra field!
                 $status_id = $account_type == 'identica' ? $status->id : $status->id_str;
                 // Add each status formatted to a html buffer
                 $buffer .= '<li class="tweeter_line">
                                 <div class="tweeter_profile_img">
                                     <img src="' . $status->user->profile_image_url . '" width="48" height="48" alt="" title="' . $status->user->screen_name . '"/>
                                 </div>
                                 <div  class="tweeter_profile_text">
                                     <a href="' . $api->get_base_url() . $status->user->screen_name . '">' . $status->user->screen_name . '</a> ' . $status->text . '
                                 </div>
                                 <div  class="tweeter_profile_links">
                                     <a href="' . $api->get_status_url($status->user->screen_name, $status_id) . '">' . Twitter::create_status_ago_string($status->created_at) . '</a> from ' . $status->source . ' ' . $reply_link . ' ' . $direct_link . ' ' . $retweet_link . '
                                 </div>
                             </li>';
             }
         }
         // Display the history
         include dirname(__FILE__) . '/tweeter/tweeter_history.inc.php';
         $return = true;
     }
 }