function after_property_import_cron($import_id) { if ($import_id == 1) { $search = new SaveSearch(); $search->notifyAll(); } }
} } $wpdb->insert('save_search_log', array('term' => trim(strtolower($search)))); self::updateIndex($search); } static function updateIndex($term, $single = false) { global $wpdb; $term = trim(strtolower($term)); $cur = $wpdb->get_var($wpdb->prepare("SELECT count FROM save_search_index WHERE single = %d AND term = %s", $single ? 1 : 0, $term)); if ($cur) { $wpdb->update('save_search_index', array('count' => $cur + 1, 'single' => $single), array('term' => $term)); } else { $wpdb->insert('save_search_index', array('term' => $term, 'single' => $single)); } } // retorna o número de vezes que o termo mais buscado foi buscado static function getTopCount() { global $wpdb; return $wpdb->get_var("SELECT count FROM save_search_index ORDER BY count DESC LIMIT 1"); } // retorna array com termos mais buscados, padrão 5 static function getTopTerms($count = 5) { global $wpdb; return $wpdb->get_col("SELECT term FROM save_search_index ORDER BY count DESC LIMIT {$count}"); } } SaveSearch::init();
</div> <?php if (is_search()) { ?> <div class="alert alert-info" role="alert"> <p> Estamos trabalhando para que você consiga achar tudo o que procura através de uma única busca. Para melhorar nosso entendimento do que as pessoas esperam do SNIIC, estamos coletando e analisando os termos mais buscados. <?php if (SaveSearch::getTopCount() > 50) { ?> Até agora são: <?php $termos = SaveSearch::getTopTerms(); foreach ($termos as $i => $termo) { if (empty($termo)) { continue; } ?> <em><?php echo trim($termo); ?> </em><?php echo $i < sizeof($termos) - 1 ? ', ' : '.'; } ?> <?php } ?>
} } else { $message = "<div class='error'>" . format_lang('errormsg', 63) . "</div>"; } } elseif ($_GET['action'] == 'search' && isset($_REQUEST['search_id'])) { $id = (int) $_REQUEST['search_id']; $found = SaveSearch::find_by_id($id); if ($found) { redirect_to(BASE_URL . "search/?" . urldecode(urldecode($found->reference))); die; } redirect_to(BASE_URL . "save_search/"); die; } elseif ($_GET['action'] == 'delete' && isset($_GET['search_id'])) { $id = (int) $_REQUEST['search_id']; $save_search = new SaveSearch(); $save_search->fk_employee_id = $employee_id; $save_search->id = $id; if ($save_search->delete_saveSearch()) { $message = "<div class='success'>" . format_lang('success', 'delete_success') . "</div>"; } else { $message = "<div class='error'>" . format_lang('errormsg', 64) . "</div>"; } } else { redirect_to(BASE_URL . "save_search/"); die; } $session->message($message); redirect_to(BASE_URL . "save_search/"); } $save_search_arr = SaveSearch::find_by_user_id($user_id);