function index() { //$this->autoRender=false; App::import('vendor', 'friendfeed'); $friendfeed = new Friendfeed(); //search($query, $service=null, $start=0, $num=30) $keyword = $this->params['keyword']; if (isset($this->params['page'])) { $page = $this->params['page']; } else { $page = 1; } $results = $friendfeed->search($keyword, null, $page); $_nextpage = $page + 1; $_prevpage = $page - 1; $totalpages = 7; $pagenotice = 'Page ' . $page . ' of ' . $totalpages . ' '; $numList = $page + 5; $_numList = ''; for ($i = 1; $i < 6; $i++) { $pnum = $page + $i; $_numList .= '<a href="' . Router::url('/friendfeed/' . urlencode($keyword) . '/' . $pnum) . '">' . $pnum . '</a> '; } //fixme: url routes $firstpage = '<a href="' . Router::url('/friendfeed/' . urlencode($keyword) . '/1') . '">Start </a> '; $nextpage = '<a href="' . Router::url('/friendfeed/' . urlencode($keyword) . '/' . $_nextpage) . '">Next </a> '; $prevpage = '<a href="' . Router::url('/friendfeed/' . urlencode($keyword) . '/' . $_prevpage) . '">Prev </a> '; $lastpage = '<a href="' . Router::url('/friendfeed/' . urlencode($keyword) . '/' . $totalpages) . '">Last </a> '; if ($page == 1) { $this->set('FriendfeedPagination', $pagenotice . $nextpage); } else { if ($page == $totalpages) { $this->set('FriendfeedPagination', $firstpage . $prevpage . $pagenotice); } else { $this->set('FriendfeedPagination', $pagenotice . $firstpage . $prevpage . $_numList . $nextpage . $lastpage); } } //echo '<pre>'; //print_r($results); $this->set('FriendFeed', $results); $this->set('keyword', $keyword); }
/** * Get FF Comments Function * * This function retrieves FF comments from FF API and * saves them to database if they aren't in blog's database * * @param integer * * @return array * */ function get_ff_comments_from_ff($ff_id) { global $wpdb, $post, $ff_username, $ff_remote_key; $ff = new Friendfeed($ff_username, $ff_remote_key); if (!$ff) { return false; } /** * FF API üzerinden ögeye ait olan yorumları alıyoruz */ $ff_comments_q = $ff->fetch('/api/feed/entry/' . $ff_id); $ff_comments = $ff_comments_q->entries[0]->comments; if ($ff_comments) { $insert_sql = "INSERT INTO " . COMMENTS_TABLE_NAME . " (comment_ID,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t comment_post_ID,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t comment_author,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t comment_author_url,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t comment_date,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t comment_content,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t is_ff_comment) VALUES "; $insert_sql_values = ''; foreach ($ff_comments as $comment) { $q = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . COMMENTS_TABLE_NAME . " WHERE comment_ID = %s", $comment->id)); /** * Eğer yorum veritabanı tablosunda kayıtlı değilse * Ve daha önce eklenip silinmemiş ise kayıt ediyoruz */ if (empty($q)) { if (!wp_ff_is_comment_in_blacklist($comment->id)) { $insert_sql_values .= "('" . $wpdb->escape($comment->id) . "',\r\n\t\t\t\t\t\t\t\t\t\t '" . $wpdb->escape($post->ID) . "',\r\n\t\t\t\t\t\t\t\t\t\t '" . $wpdb->escape($comment->user->name) . "',\r\n\t\t\t\t\t\t\t\t\t\t '" . $wpdb->escape($comment->user->profileUrl) . "',\r\n\t\t\t\t\t\t\t\t\t\t '" . $wpdb->escape($comment->date) . "',\r\n\t\t\t\t\t\t\t\t\t\t '" . $wpdb->escape($comment->body) . "',\r\n\t\t\t\t\t\t\t\t\t\t 1),"; } } } // Eğer insert stringi boş değil ise eklenecek yorum var demektir // Ee eklenecek yorum varsa ekliyelim değil mi? :) if (!empty($insert_sql_values)) { $wpdb->query($insert_sql . substr($insert_sql_values, 0, strlen($insert_sql_values) - 1)); } } return $ff_comments; }