Skip to content

Commit

Permalink
Add title to search page (and whitespace)
Browse files Browse the repository at this point in the history
  • Loading branch information
daleharvey committed Jan 2, 2012
1 parent fe6e061 commit c345a1a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 48 deletions.
53 changes: 26 additions & 27 deletions application/controllers/threads.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function __construct()
$this->load->helper(array('date', 'url'));
$this->load->library('pagination');
$this->load->model('thread_dal');

// set all this so we dont have to continually call functions through session
$this->meta = array(
'user_id' => (int) $this->session->userdata('user_id'),
Expand All @@ -33,15 +33,15 @@ function index($pagination = 0, $filter = '', $ordering = '', $dir = 'desc', $wh
'dir' => strtolower($dir),
'whostarted' => strtolower($whostarted)
);

if ($args->filter == 'started' && $args->whostarted == '')
$args->whostarted = strtolower($this->meta['username']);

$this->load->model('threadsmodel');

$this->threadsmodel->meta = $this->meta;
$this->threadsmodel->args = $args;

// process thread information
$this->threadsmodel->get_threads();

Expand All @@ -60,7 +60,7 @@ function index($pagination = 0, $filter = '', $ordering = '', $dir = 'desc', $wh

// end of threads
$end = min(array($args->pagination + $this->meta['threads_shown'], $this->threadsmodel->thread_count));

$pages = $this->pagination->create_links() . '<span class="paging-text">' .
($args->pagination + 1) . ' - ' . $end . ' of ' . $this->threadsmodel->thread_count . ' Threads</span>';

Expand All @@ -78,19 +78,19 @@ function index($pagination = 0, $filter = '', $ordering = '', $dir = 'desc', $wh
'favorites' => explode(',', $this->thread_dal->get_favorites($this->meta['user_id'])),
'hidden_threads' => explode(',', $this->thread_dal->get_hidden($this->meta['user_id']))
));

$this->load->view('shared/footer');
}

public function find($search_terms = '', $pagination = 0, $filter = '', $ordering = '', $dir = 'desc', $whostarted = '')
{
redirect('/');
exit();
/* redirect('/'); */
/* exit(); */
// uncomment the following line you if broke something but you can't figure out what.
// $this->output->enable_profiler(TRUE);

$this->load->library('SphinxClient');

$args = (object)array(
'pagination' => (int) $pagination,
'filter' => '',
Expand All @@ -99,28 +99,24 @@ public function find($search_terms = '', $pagination = 0, $filter = '', $orderin
'whostarted' => '',
'search_terms' => $search_terms
);

$this->load->model('threadsmodel');

$this->threadsmodel->meta = $this->meta;
$this->threadsmodel->args = $args;

$s = new SphinxClient();

$s->SetServer("localhost", 3312);
$s->SetMatchMode(SPH_MATCH_EXTENDED2);
$s->SetMaxQueryTime(1);

$s->SetLimits($args->pagination, ($this->meta['threads_shown'] + 1));

$result = $s->query($search_terms);

//var_dump($result);

$final = $result['total_found'] > 0
? implode(',', array_keys($result['matches']))

$final = $result['total_found'] > 0
? implode(',', array_keys($result['matches']))
: '';

// process thread information
$this->threadsmodel->get_threads($final);

Expand All @@ -139,12 +135,15 @@ public function find($search_terms = '', $pagination = 0, $filter = '', $orderin

// end of threads
$end = min(array($args->pagination + $this->meta['threads_shown'], $result['total_found']));

$pages = $this->pagination->create_links() . '<span class="paging-text">' .
($args->pagination + 1) . ' - ' . $end . ' of ' . $result['total_found'] . ' Threads</span>';

$this->load->view('threads', array(
'title' => $this->thread_dal->get_front_title(),
'title' => (object)array(
'username' => 'Yayhooray',
'title_text' => "Searching for: \"$search_terms\""
),
'thread_result' => $this->threadsmodel->thread_results,
'pagination' => $pages,
'tab_links' => strlen($args->filter) > 0 ? '/f/'.$args->filter.'/' : '/o/',
Expand All @@ -157,7 +156,7 @@ public function find($search_terms = '', $pagination = 0, $filter = '', $orderin
'favorites' => explode(',', $this->thread_dal->get_favorites($this->meta['user_id'])),
'hidden_threads' => explode(',', $this->thread_dal->get_hidden($this->meta['user_id']))
));

$this->load->view('shared/footer');
}
}
Expand Down
42 changes: 21 additions & 21 deletions application/libraries/sphinxclient.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
function sphPackI64 ( $v )
{
assert ( is_numeric($v) );

// x64
if ( PHP_INT_SIZE>=8 )
{
Expand All @@ -138,7 +138,7 @@ function sphPackI64 ( $v )
if ( is_int($v) )
return pack ( "NN", $v < 0 ? -1 : 0, $v );

// x32, bcmath
// x32, bcmath
if ( function_exists("bcmul") )
{
if ( bccomp ( $v, 0 ) == -1 )
Expand Down Expand Up @@ -175,29 +175,29 @@ function sphPackI64 ( $v )
function sphPackU64 ( $v )
{
assert ( is_numeric($v) );

// x64
if ( PHP_INT_SIZE>=8 )
{
assert ( $v>=0 );

// x64, int
if ( is_int($v) )
return pack ( "NN", $v>>32, $v&0xFFFFFFFF );

// x64, bcmath
if ( function_exists("bcmul") )
{
$h = bcdiv ( $v, 4294967296, 0 );
$l = bcmod ( $v, 4294967296 );
return pack ( "NN", $h, $l );
}

// x64, no-bcmath
$p = max ( 0, strlen($v) - 13 );
$lo = (int)substr ( $v, $p );
$hi = (int)substr ( $v, 0, $p );

$m = $lo + $hi*1316134912;
$l = $m % 4294967296;
$h = $hi*2328 + (int)($m/4294967296);
Expand All @@ -208,7 +208,7 @@ function sphPackU64 ( $v )
// x32, int
if ( is_int($v) )
return pack ( "NN", 0, $v );

// x32, bcmath
if ( function_exists("bcmul") )
{
Expand All @@ -221,7 +221,7 @@ function sphPackU64 ( $v )
$p = max(0, strlen($v) - 13);
$lo = (float)substr($v, $p);
$hi = (float)substr($v, 0, $p);

$m = $lo + $hi*1316134912.0;
$q = floor($m / 4294967296.0);
$l = $m - ($q * 4294967296.0);
Expand Down Expand Up @@ -277,11 +277,11 @@ function sphUnpackU64 ( $v )
// x32, bcmath
if ( function_exists("bcmul") )
return bcadd ( $lo, bcmul ( $hi, "4294967296" ) );

// x32, no-bcmath
$hi = (float)$hi;
$lo = (float)$lo;

$q = floor($hi/10000000.0);
$r = $hi - $q*10000000.0;
$m = $lo + $r*4967296.0;
Expand Down Expand Up @@ -324,7 +324,7 @@ function sphUnpackI64 ( $v )
return $lo;
return sprintf ( "%.0f", $lo - 4294967296.0 );
}

$neg = "";
$c = 0;
if ( $hi<0 )
Expand All @@ -333,7 +333,7 @@ function sphUnpackI64 ( $v )
$lo = ~$lo;
$c = 1;
$neg = "-";
}
}

$hi = sprintf ( "%u", $hi );
$lo = sprintf ( "%u", $lo );
Expand All @@ -345,7 +345,7 @@ function sphUnpackI64 ( $v )
// x32, no-bcmath
$hi = (float)$hi;
$lo = (float)$lo;

$q = floor($hi/10000000.0);
$r = $hi - $q*10000000.0;
$m = $lo + $r*4967296.0;
Expand Down Expand Up @@ -510,7 +510,7 @@ function SetServer ( $host, $port = 0 )
$this->_path = $host;
return;
}

assert ( is_int($port) );
$this->_host = $host;
$this->_port = $port;
Expand Down Expand Up @@ -590,14 +590,14 @@ function _Connect ()
$fp = @fsockopen ( $host, $port, $errno, $errstr );
else
$fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout );

if ( !$fp )
{
if ( $this->_path )
$location = $this->_path;
else
$location = "{$this->_host}:{$this->_port}";

$errstr = trim ( $errstr );
$this->_error = "connection to $location failed (errno=$errno, msg=$errstr)";
$this->_connerror = true;
Expand Down Expand Up @@ -1236,7 +1236,7 @@ function _ParseSearchResponse ( $response, $nreqs )
if ( $type==SPH_ATTR_FLOAT )
{
list(,$uval) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
list(,$fval) = unpack ( "f*", pack ( "L", $uval ) );
list(,$fval) = unpack ( "f*", pack ( "L", $uval ) );
$attrvals[$attr] = $fval;
continue;
}
Expand Down Expand Up @@ -1264,7 +1264,7 @@ function _ParseSearchResponse ( $response, $nreqs )
} else if ( $type==SPH_ATTR_STRING )
{
$attrvals[$attr] = substr ( $response, $p, $val );
$p += $val;
$p += $val;
} else
{
$attrvals[$attr] = sphFixUint($val);
Expand Down Expand Up @@ -1345,7 +1345,7 @@ function BuildExcerpts ( $docs, $index, $words, $opts=array() )
if ( !isset($opts["passage_boundary"]) ) $opts["passage_boundary"] = "none";
if ( !isset($opts["emit_zones"]) ) $opts["emit_zones"] = false;
if ( !isset($opts["load_files_scattered"]) ) $opts["load_files_scattered"] = false;


/////////////////
// build request
Expand Down Expand Up @@ -1634,7 +1634,7 @@ function Close()

fclose ( $this->_socket );
$this->_socket = false;

return true;
}

Expand Down

0 comments on commit c345a1a

Please sign in to comment.