TextboxSearch:
Datei: /pages/xml/textbox-search.php
<?php
class TextboxSearch extends Page {
public function InitializeComponent() {
$this->render = new AutoCompleteResult();
$_GET['term'] = trim(utf8decode(strip_tags($_GET['term'])));
$_GET['term'] = addslashes($_GET['term']);
$sql = new SqlDataView(new FavoritePageDbTable());
if (isset($_GET['filter']) &&
($_GET['filter']==1 || $_GET['filter']==0)) {
// When there is a filter param used
$_GET['filter'] = trim(utf8decode(strip_tags($_GET['filter'])));
$_GET['filter'] = addslashes($_GET['filter']);
if ($_GET['filter'] == 0) { $_GET['filter'] = " IS NULL"; }
else { $_GET['filter'] = " = 1"; }
$sql->setClause(FavoritePageDbTable::FIELD_NAME.
" LIKE '%".$_GET['term']."%' AND ".
FavoritePageDbTable::FIELD_ACTIF.
$_GET['filter']);
} else { // Without filter
$sql->setClause(FavoritePageDbTable::FIELD_NAME.
" LIKE '%".$_GET['term']."%'");
}
$ind = 0;
$it = $sql->retrieve();
while ($it->hasNext()) {
$row = $it->next();
$this->render->add(
$row->getValue(FavoritePageDbTable::FIELD_URL),
$row->getValue(FavoritePageDbTable::FIELD_NAME),
$row->getValue(FavoritePageDbTable::FIELD_NAME));
$ind++;
}
if ($ind == 0) {
$this->render->add("", utf8_encode("No result"), "");
}
}
}
?>