Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Created October 29, 2011 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterdavis/1324961 to your computer and use it in GitHub Desktop.
Save walterdavis/1324961 to your computer and use it in GitHub Desktop.
<?php
case 'index':
default:
$list = array();
if(isset($_SESSION['flash'])){
$flash = $_SESSION['flash'];
unset($_SESSION['flash']);
}
if(isset($_POST['q']) && !empty($_POST['q'])){
$list = ActiveRecord::PublicSearch('mar',$_POST['q']);
$page_title = 'Search Results';
$page_header = 'search results';
$out .= '<p class="global_search"><a href="' . BASE_URL . 'mar/index">Back to List</a></p>';
$count = count($list);
$out .= '<div class="search_results"><span class="number">' . number_format($count) . '</span> ' . pluralize('result',$count) . ' for the search string "' . h($_POST['q']) . '"</div>';
if($count == 0) $out .= '<p class="search_error">Oops, please search again with a different term.</p>';
}else{
$list = ActiveRecord::FindAll('mar','1=1','added_at DESC');
$page_title = 'Connections';
// $page_header = '';
}
$total = ActiveRecord::Count('mar');
foreach($list as $person) {
$out .= '<div class="' . alternate() . ' entry"><span class="name">' . $person->full_name() . '</span> ' .
$person->link_for('edit','first',array('text'=>'Edit')) . ' ' . $person->link_for('view','first',array('text'=>'View')) . ' <br/> ' . $person->added_at . '</div>';
}
$search_term = (isset($_POST['q'])) ? trim(strip_tags($_POST['q'])) : '';
include(APP_ROOT . '/views/index.php');
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment