Example #1
0
 public static function &search($tags = null, $words = null, $order = null, $lang = null)
 {
     $results = array();
     if (!$tags && isset($_REQUEST['tags'])) {
         $tags = trim($_REQUEST['tags']);
     }
     if (!$words && isset($_REQUEST['words'])) {
         $words = trim($_REQUEST['words']);
     }
     if (!$tags && !$words) {
         return $results;
     }
     if ($tags && !is_array($tags)) {
         $tags = trim($tags) != '' ? preg_split("/\\s+/", trim($tags)) : array();
     }
     if ($words && !is_array($words)) {
         $words = trim($words) != '' ? preg_split("/\\s+/", trim($words)) : array();
     }
     $searcher = new I18nSearcher($tags, $words, $order, $lang);
     $results = $searcher->execute();
     return $results;
 }
Example #2
0
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);
}
Example #3
0
$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 {