コード例 #1
0
function showSearches($option, $task, $showResults = null)
{
    global $database, $mainframe, $mosConfig_list_limit;
    global $_MAMBOTS;
    $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit);
    $limitstart = $mainframe->getUserStateFromRequest("view{$option}{$task}limitstart", 'limitstart', 0);
    // get the total number of records
    $query = "SELECT COUNT(*)" . "\n FROM #__core_log_searches";
    $database->setQuery($query);
    $total = $database->loadResult();
    require_once $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php';
    $pageNav = new mosPageNav($total, $limitstart, $limit);
    $query = "SELECT *" . "\n FROM #__core_log_searches" . "\n ORDER BY hits DESC";
    $database->setQuery($query, $pageNav->limitstart, $pageNav->limit);
    $rows = $database->loadObjectList();
    if ($database->getErrorNum()) {
        echo $database->stderr();
        return false;
    }
    $_MAMBOTS->loadBotGroup('search');
    $total = count($rows);
    for ($i = 0, $n = $total; $i < $n; $i++) {
        // determine if number of results for search item should be calculated
        // by default it is `off` as it is highly query intensive
        if ($showResults) {
            $results = $_MAMBOTS->trigger('onSearch', array($rows[$i]->search_term));
            $count = 0;
            $total = count($results);
            for ($j = 0, $n2 = $total; $j < $n2; $j++) {
                $count += count($results[$j]);
            }
            $rows[$i]->returns = $count;
        } else {
            $rows[$i]->returns = null;
        }
    }
    HTML_statistics::showSearches($rows, $pageNav, $option, $task, $showResults);
}
コード例 #2
0
ファイル: admin.statistics.php プロジェクト: cwcw/cms
function showSearches($option, $task)
{
    global $database, $mainframe, $mosConfig_list_limit;
    global $_MAMBOTS;
    $limit = $mainframe->getUserStateFromRequest("viewlistlimit", 'limit', $mosConfig_list_limit);
    $limitstart = $mainframe->getUserStateFromRequest("view{$option}{$task}limitstart", 'limitstart', 0);
    // get the total number of records
    $database->setQuery("SELECT count(*) FROM #__core_log_searches");
    $total = $database->loadResult();
    require_once $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php';
    $pageNav = new mosPageNav($total, $limitstart, $limit);
    $database->setQuery("SELECT *" . "\nFROM #__core_log_searches" . "\nORDER BY hits DESC" . "\nLIMIT {$pageNav->limitstart},{$pageNav->limit}");
    $rows = $database->loadObjectList();
    if ($database->getErrorNum()) {
        echo $database->stderr();
        return false;
    }
    $_MAMBOTS->loadBotGroup('search');
    for ($i = 0, $n = count($rows); $i < $n; $i++) {
        $results = $_MAMBOTS->trigger('onSearch', array($rows[$i]->search_term));
        $count = 0;
        for ($j = 0, $n2 = count($results); $j < $n2; $j++) {
            $count += count($results[$j]);
        }
        $rows[$i]->returns = $count;
    }
    HTML_statistics::showSearches($rows, $pageNav, $option, $task);
}