function return_i18n_search_results($tags = null, $words = null, $first = 0, $max = 10, $order = null, $lang = null) { require_once GSPLUGINPATH . 'i18n_search/searcher.class.php'; $results = I18nSearcher::search($tags, $words, $order, $lang); $count = count($results); if ($max > 0) { $results = array_slice($results, $first, $max); } else { if ($first > 0) { $results = array_slice($results, $first); } } return array('totalCount' => $count, 'first' => $first, 'results' => $results); }
$showLanguage = $is_i18n && array_key_exists('showLanguage', $params) ? $params['showLanguage'] : $is_i18n; $showDate = array_key_exists('showDate', $params) ? $params['showDate'] : true; $dateLocale = @$i18n['DATE_LOCALE']; $dateFormat = @$i18n['DATE_FORMAT']; $numWords = array_key_exists('numWords', $params) ? $params['numWords'] : I18N_NUM_WORDS; $max = array_key_exists('max', $params) ? (int) $params['max'] : I18N_MAX_RESULTS; $showPaging = array_key_exists('showPaging', $params) ? $params['showPaging'] : true; $componentName = array_key_exists('component', $params) ? $params['component'] : null; $idPrefix = array_key_exists('idPrefix', $params) ? $params['idPrefix'] : null; $tagClassPrefix = array_key_exists('tagClassPrefix', $params) ? $params['tagClassPrefix'] : null; $pageNum = $showPaging && isset($_REQUEST['page']) ? @(int) $_REQUEST['page'] - 1 : 0; $first = $pageNum * $max; $processFunction = array_key_exists('process', $params) ? $params['process'] : null; $processParameter = $processFunction && array_key_exists('parameter', $params) ? $params['parameter'] : null; # get all results $allresults = I18nSearcher::search($alltags, $allwords, $order, $lang); if ($processFunction) { if (!function_exists($processFunction) && function_exists('i18n_search_' . $processFunction)) { $processFunction = 'i18n_search_' . $processFunction; } # process results, e.g. $allresults = call_user_func($processFunction, $allresults, $processParameter); } # get requested result page $totalCount = count($allresults); if ($max > 0) { $results = array_slice($allresults, $first, $max); } else { if ($first > 0) { $results = array_slice($results, $first); } else {