$title = "Search";
include ('inc/header.php');
- function getSearch($query, $max_id_str){
- GLOBAL $output;
+ function getSearch($query, $sinceid, $maxid){
$t = getTwitter();
- $result = $t->search($query, $max_id_str);
- $statuses = $result->statuses;
- $max_id_str = end($statuses)->id_str;
- $resultCount = count($statuses);
+ $answer = $t->search($query,$sinceid,$maxid);
+
+ $resultCount = count($answer->statuses);
if ($resultCount <= 0) {
echo "<div id=\"empty\">No tweet to display.</div>";
} else {
include_once('lib/timeline_format.php');
$output = '<ol class="timeline" id="allTimeline">';
- foreach ($statuses as $status) {
- $output .= format_timeline($status, $t->username);
+ foreach ($answer->statuses as $status) {
+ if (isset($status->retweeted_status)) {
+ $output .= format_retweet($status);
+ } else {
+ $output .= format_timeline($status,$t->username);
+ }
}
- $output .= "</ol><div id=\"pagination\"><a id=\"more\" class=\"round more\" style=\"float: right;\" href=\"search.php?q=".urlencode($query)."&maxid=" . $max_id_str . "\">Next</a></div>";
+ $output .= "</ol><div id=\"pagination\">";
+
+ $next_results = isset($answer->search_metadata->next_results) ? $answer->search_metadata->next_results : false;
+ if ($next_results) $output .= "<a id=\"more\" class=\"btn btn-white\" style=\"float: right;\" href=\"search.php". $next_results ."\">Next</a>";
+ $output .= "</div>";
+ echo $output;
}
}
<div id="statuses" class="column round-left">
<form action="search.php" method="get" id="search_form">
- <input type="text" name="q" id="query" value="<?php echo $_GET['q'] ?>" />
- <input type="submit" class="more round" style="width: 103px; margin-left: 10px; display: block; float: left; height: 34px; font-family: tahoma; color: rgb(51, 51, 51);" value="Search">
+ <input type="text" name="q" id="query" value="<?php echo $_GET['q'] ?>" autocomplete="off" />
+ <span class="suggestion_loading fa fa-spinner fa-spin"></span>
+ <input type="submit" class="btn btn-white" value="Search">
+ <input type="button" class="btn btn-white" value="Save" id="btn_savesearch">
</form>
<?php
- $p = 1;
+ $sinceid = false;
+ $maxid = false;
+ if (isset($_GET['since_id'])) {
+ $sinceid = $_GET['since_id'];
+ }
if (isset($_GET['max_id'])) {
- $max_id = $_GET['max_id'];
- } else {
- $max_id = false;
+ $maxid = $_GET['max_id'];
}
- $output = '';
if (isset($_GET['q'])) {
$q = $_GET['q'];
- getSearch($q, $max_id);
+ getSearch($q, $sinceid, $maxid);
}
- echo $output;
?>
</div>