示例#1
0
 function perform()
 {
     $journos = array();
     if ($this->q) {
         $journos = journo_FuzzyFind($this->q);
     }
     $total = sizeof($journos);
     $offset = $this->page * $this->per_page;
     $journos = array_slice($journos, $offset, $this->per_page);
     return new JournoSearchResults($journos, $total, $this->page_var, $this->per_page);
 }
示例#2
0
function view_lookup()
{
    $fullname = get_http_var('fullname', '');
    $fullname = trim($fullname);
    $fullname = preg_replace('/\\s+/', ' ', $fullname);
    // collapse spaces
    $matching_journos = array();
    if ($fullname) {
        $matching_journos = journo_FuzzyFind($fullname);
    }
    if (sizeof($matching_journos) > 0) {
        tmpl_lookup($fullname, $matching_journos);
    } else {
        // no matches - just go ahead and create it
        // TODO: show confirmation/fixup page
        view_create();
    }
}
示例#3
0
function spew_404($ref)
{
    header("HTTP/1.0 404 Not Found");
    $query = preg_replace('/[^a-z]+/', ' ', trim($ref));
    $title = "Couldn't find \"" . h(ucwords($query)) . "\"";
    page_header($title);
    $journos = journo_FuzzyFind($query);
    ?>
<h2><?php 
    echo $title;
    ?>
</h2>
<?php 
    if ($query) {
        ?>
<p>Did you perhaps mean one of these?</p>

<ul>
<?php 
        foreach ($journos as $j) {
            ?>
  <li><?php 
            echo journo_link($j);
            ?>
</li>
<?php 
        }
        ?>
</ul>
<?php 
    }
    ?>

<form method="get" action="/search">
 <input type="hidden" name="type" value="journo" />
 <input type="text" size="40" name="q" value="<?php 
    echo h($query);
    ?>
" />
 <input type="submit" name="action" value="Search for Journalist" />
</form>

<?php 
    page_footer();
}
<?php

require_once '../conf/general';
require_once '../../phplib/db.php';
require_once '../../phplib/utility.php';
require_once '../phplib/journo.php';
header("Cache-Control: no-cache");
$q = strtolower(get_http_var('q', ''));
$q = strtolower($q);
if ($q) {
    $matches = journo_FuzzyFind($q);
    foreach ($matches as $j) {
        print "{$j['prettyname']}|{$j['oneliner']}|{$j['ref']}\n";
    }
}