当前位置: 首页>>代码示例>>PHP>>正文


PHP sort_results函数代码示例

本文整理汇总了PHP中sort_results函数的典型用法代码示例。如果您正苦于以下问题:PHP sort_results函数的具体用法?PHP sort_results怎么用?PHP sort_results使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sort_results函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mt_search

function mt_search($query)
{
    //stub
    $sid = mt_login();
    if (empty($sid)) {
        //phail
        return null;
    }
    if (empty($query) or empty($sid)) {
        return null;
    }
    $query = '	use "' . XML_BASE . 'yql_mp3tunes.search.xml" as mp3tunes.search; 
				select * from mp3tunes.search where sid="' . $sid . '" AND query="' . $query . '" AND token="' . MT_TOKEN . '";';
    //echo $query;
    $results = yql_get($query);
    $results = $results->results;
    //don't care that much about yql info
    var_dump($results);
    $results = sort_results($results, $query, array('artistname', 'tracktitle'));
    if (empty($results) || !is_array($results)) {
        return null;
    }
    $result = $results[0];
    $ret = new stdClass();
    $ret->title = $result->artistname . ' - ' . $result->tracktitle;
    $ret->url = $result->playurl;
    $ret->score = $result->score;
    //we care because we will run compare it against other service's scores
    return $ret;
}
开发者ID:hkenshin,项目名称:OnLocationMusic,代码行数:30,代码来源:lib_mt.php

示例2: search

function search($query)
{
    $results[] = sc_search($query);
    $results[] = mt_search($query);
    $results = sort_results($results, $query);
    $results = $results[0];
    if (empty($results)) {
        return null;
    }
    return $results;
}
开发者ID:hkenshin,项目名称:OnLocationMusic,代码行数:11,代码来源:libs.php

示例3: sc_search

function sc_search($query = '', $limit = 0)
{
    $results = get_results($query, 'soundcloud');
    $results = sort_results($results, $query, 'title');
    if (empty($results) || !is_array($results)) {
        return null;
    }
    $result = $results[0];
    $ret = new stdClass();
    $ret->title = $result->title;
    $ret->url = $result->stream_url . '?client_id=' . CLIENT_ID;
    $ret->score = $result->score;
    //we care because we will run compare it against other service's scores
    return $ret;
}
开发者ID:hkenshin,项目名称:OnLocationMusic,代码行数:15,代码来源:lib_sc.php

示例4: main

function main()
{
    if (strcmp('4.1.0', phpversion()) > 0) {
        die("Error: PHP version 4.1.0 or above required!");
    }
    if (!($file = fopen("search.idx", "rb"))) {
        die("Error: Search index file could NOT be opened!");
    }
    if (readHeader($file) != "DOXS") {
        die("Error: Header of index file is invalid!");
    }
    $query = "";
    if (array_key_exists("query", $_GET)) {
        $query = $_GET["query"];
    }
    echo "<input class=\"search\" type=\"text\" name=\"query\" value=\"{$query}\" size=\"20\" accesskey=\"s\"/>\n";
    echo "</span>\n";
    echo "</form>\n";
    echo "</div>\n";
    $results = array();
    $requiredWords = array();
    $forbiddenWords = array();
    $foundWords = array();
    $word = strtok($query, " ");
    while ($word) {
        if ($word[0] == '+') {
            $word = substr($word, 1);
            $requiredWords[] = $word;
        }
        if ($word[0] == '-') {
            $word = substr($word, 1);
            $forbiddenWords[] = $word;
        }
        if (!in_array($word, $foundWords)) {
            $foundWords[] = $word;
            search($file, $word, $results);
        }
        $word = strtok(" ");
    }
    $docs = array();
    combine_results($results, $docs);
    // filter out documents with forbidden word or that do not contain
    // required words
    $filteredDocs = filter_results($docs, $requiredWords, $forbiddenWords);
    // sort the results based on rank
    $sorted = array();
    sort_results($filteredDocs, $sorted);
    // report results to the user
    report_results($sorted);
    fclose($file);
}
开发者ID:ninghang,项目名称:bayesianPlay,代码行数:51,代码来源:search.php

示例5: run_the_queries

function run_the_queries($gcmaz_wpdb, $wpdb, $sql_search_terms, $rows_to_return, $pages_to_ignore_gcmaz, $pages_to_ignore_local)
{
    /*******************************************************
     * 2 Queries (gcmaz domain & local site)
     * 
     *   I.  unfinished - pages to ignore
     *   II. Prep vars for the statement
     *   III.  To filter or not
     *   IV.  The Queries
     *   V.   Functions (merge, object to array, sort)
     * 
     *  Notes about the prepare statement:
     *  a.    escape the wildcards %=escape and %=wildcard
     *  b.    the C, D, E  ... denote placeholders in the wpdb->prepare statement in order where 
     *  c.     the sql statement has %s, %d denoting "string" or "integer"
     *  d.    blueprint of the prepared statement
     *         $rows = $gcmaz_wpdb->get_results($gcmaz_wpdb->prepare( "the sql query", C, D, E, F, G, H, I, J, K, L, M, N, O, P)
     *  e.    variables used in "local" end with _local to avoid collision
     ********************************************************/
    // I.  array of pages on gcmaz we don't want to return
    // need to set this up as options in custom gcmaz plugin instead of hardcoded (select pages to ignore in search results)
    $pages_to_ignore_gcmaz = $pages_to_ignore_gcmaz;
    $pages_to_ignore_local = $pages_to_ignore_local;
    // II.  INIT VARS FOR THE SQL PREPARE STATEMENT
    $var_for_publish = "publish";
    $var_for_page = "page";
    $var_for_post = "post";
    $var_for_whats = "whats-happening";
    $var_for_concert = "concert";
    $var_for_community = "community-info";
    $var_for_splash = "splash-post";
    $var_for_publish_local = "publish";
    $var_for_page_local = "page";
    $var_for_post_local = "post";
    $var_for_splash_local = "splash-post";
    // III.  FILTER OR NOT
    // the default search isn't filtered, but it can be refined in which case the following vars will be populated
    //check for search filter vars - to filter by domain, posts, pages
    if (isset($_POST['filter_the_search'])) {
        // not default search, filters in play
        //domain
        if (isset($_POST['showDomain'])) {
            $showDomain = sanitize_text_field($_POST['showDomain']);
        } else {
            $showDomain = 'gcmaz';
        }
        //pages
        if (isset($_POST['showPages'])) {
            $showPages = true;
        } else {
            $showPages = false;
        }
        //posts
        if (isset($_POST['showPosts'])) {
            $showPosts = true;
        } else {
            $showPosts = false;
        }
        //news
        if (isset($_POST['showNews'])) {
            $showNews = true;
        } else {
            $showNews = false;
        }
    } else {
        // default search
        $showDomain = 'gcmaz';
        $showPosts = true;
        $showPages = true;
        $showNews = true;
    }
    // IV.  THE QUERIES
    //-----------------------------------------------------
    //     FILTERED SEARCH TO SHOW KAFF NEWS
    //-----------------------------------------------------
    // don't bother with local search
    // search gcmaz.com for KAFF News "posts" only
    if ($showDomain == 'news' || $showDomain == 'gcmaz' && $showNews == true && $showPosts == false && $showPages == false) {
        $sql = "\n                    SELECT ID, post_date, post_title, guid, post_name, post_type\n                    FROM {$gcmaz_wpdb->posts}\n                    WHERE (" . implode(' OR ', $sql_search_terms) . ")\n                        AND post_status = '%s'\n                        AND (post_type = '%s')\n                        AND ID NOT IN (" . implode($pages_to_ignore_gcmaz, ", ") . ")\n                    ORDER BY post_date DESC\n                    LIMIT {$rows_to_return}\n                     ";
        //for debugging
        //echo "<div style='background:yellow;color:red'>NEWS</div>";
        //$prepared_statement = $gcmaz_wpdb->prepare($sql, $var_for_publish, $var_for_post);
        //print_r($prepared_statement);
        $rows_gcmaz = $gcmaz_wpdb->get_results($gcmaz_wpdb->prepare($sql, $var_for_publish, $var_for_post));
        // convert to array
        $results = convert_results_to_array($rows_gcmaz);
        // dont need to merge, just sort
        $results = sort_results($results);
        return $results;
    }
    //--------------------------------------------------------------------------------
    //     DEFAULT SEARCH  & FILTERED SEARCH THAT SHOWS POSTS & PAGES
    //--------------------------------------------------------------------------------
    if ($showPosts == true && $showPages == true || $showPosts == false && $showPages == false) {
        if ($showDomain == 'local') {
            //LOCAL ONLY
            //SKIPS NEWS
            $sql_local = "\n                            SELECT ID, post_date, post_title, guid, post_name, post_type\n                            FROM {$wpdb->posts}\n                            WHERE (" . implode(' OR ', $sql_search_terms) . ")\n                                AND post_status = '%s'\n                                AND (post_type = '%s' OR post_type = '%s' OR post_type = '%s')\n                                AND ID NOT IN (" . implode($pages_to_ignore_local, ", ") . ")\n                            ORDER BY post_date DESC\n                            LIMIT {$rows_to_return}\n                             ";
            //for debugging
            //echo "<div style='background:yellow;color:red'>LOCAL PAGES AND POSTS, SKIPS NEWS</div>";
//.........这里部分代码省略.........
开发者ID:smark73,项目名称:eagle,代码行数:101,代码来源:search.php

示例6: main

function main()
{
    if (strcmp('4.1.0', phpversion()) > 0) {
        die("Error: PHP version 4.1.0 or above required!");
    }
    if (!($file = fopen("search.idx", "rb"))) {
        die("Error: Search index file could NOT be opened!");
    }
    if (readHeader($file) != "DOXS") {
        die("Error: Header of index file is invalid!");
    }
    $query = "";
    if (array_key_exists("query", $_GET)) {
        $query = $_GET["query"];
    }
    end_form(ereg_replace("[^[:alnum:]:\\.\\t ]", " ", $query));
    echo "&nbsp;\n<div class=\"searchresults\">\n";
    $results = array();
    $requiredWords = array();
    $forbiddenWords = array();
    $foundWords = array();
    $word = strtok($query, " ");
    while ($word) {
        if ($word[0] == '+') {
            $word = substr($word, 1);
            $requiredWords[] = $word;
        }
        if ($word[0] == '-') {
            $word = substr($word, 1);
            $forbiddenWords[] = $word;
        }
        if (!in_array($word, $foundWords)) {
            $foundWords[] = $word;
            search($file, strtolower($word), $results);
        }
        $word = strtok(" ");
    }
    $docs = array();
    combine_results($results, $docs);
    // filter out documents with forbidden word or that do not contain
    // required words
    $filteredDocs = filter_results($docs, $requiredWords, $forbiddenWords);
    // sort the results based on rank
    $sorted = array();
    sort_results($filteredDocs, $sorted);
    // report results to the user
    report_results($sorted);
    echo "</div>\n";
    fclose($file);
}
开发者ID:kobkob,项目名称:ta,代码行数:50,代码来源:search.php

示例7: search

function search()
{
    if (strcmp('4.1.0', phpversion()) > 0) {
        die("Error: PHP version 4.1.0 or above required!");
    }
    $paths = paths();
    $files = array();
    $j = 0;
    for ($i = 0; $i < sizeof($paths); $i++) {
        if (!($f = @fopen($paths[$i] . "search.idx", "rb"))) {
            die("Error: Search index file could NOT be opened!");
            continue;
        }
        $files[$j++] = $f;
        if (readHeader($f) != "DOXS") {
            die("Error: Header of index file is invalid!");
        }
    }
    $query = "";
    if (array_key_exists("query", $_GET)) {
        $query = $_GET["query"];
    }
    //end_form($query);
    echo "&nbsp;\n<div class=\"searchresults\">\n";
    $results = array();
    $requiredWords = array();
    $forbiddenWords = array();
    $foundWords = array();
    $word = strtok($query, " ");
    while ($word) {
        if ($word[0] == '+') {
            $word = substr($word, 1);
            $requiredWords[] = $word;
        }
        if ($word[0] == '-') {
            $word = substr($word, 1);
            $forbiddenWords[] = $word;
        }
        if (!in_array($word, $foundWords)) {
            $foundWords[] = $word;
            for ($i = 0; $i < sizeof($files); $i++) {
                do_search($paths[$i], $files[$i], strtolower($word), $results);
            }
        }
        $word = strtok(" ");
    }
    $docs = array();
    combine_results($results, $docs);
    // filter out documents with forbidden word or that do not contain
    // required words
    $filteredDocs = filter_results($docs, $requiredWords, $forbiddenWords);
    // sort the results based on rank
    $sorted = array();
    sort_results($filteredDocs, $sorted);
    // report results to the user
    report_results($sorted);
    echo "</div>\n";
    foreach ($files as $file) {
        fclose($file);
    }
}
开发者ID:BackupTheBerlios,项目名称:senf-svn,代码行数:61,代码来源:search_functions.php

示例8: main

function main($idxfile)
{
    if (strcmp('4.1.0', phpversion()) > 0) {
        die("Error: PHP version 4.1.0 or above required!");
    }
    if (!($file = fopen($idxfile, "rb"))) {
        die("Error: Search index file could NOT be opened!");
    }
    if (readHeader($file) != "DOXS") {
        die("Error: Header of index file is invalid!");
    }
    $query = "";
    if (array_key_exists("query", $_GET)) {
        $query = $_GET["query"];
    }
    $results = array();
    $requiredWords = array();
    $forbiddenWords = array();
    $foundWords = array();
    $word = strtolower(strtok($query, " "));
    while ($word) {
        if ($word[0] == '+') {
            $word = substr($word, 1);
            $requiredWords[] = $word;
        }
        if ($word[0] == '-') {
            $word = substr($word, 1);
            $forbiddenWords[] = $word;
        }
        if (!in_array($word, $foundWords)) {
            $foundWords[] = $word;
            search($file, $word, $results);
        }
        $word = strtolower(strtok(" "));
    }
    $docs = array();
    combine_results($results, $docs);
    // filter out documents with forbidden word or that do not contain
    // required words
    $filteredDocs = filter_results($docs, $requiredWords, $forbiddenWords);
    // normalize rankings so they are in the range [0-100]
    normalize_ranking($filteredDocs);
    // sort the results based on rank
    $sorted = array();
    sort_results($filteredDocs, $sorted);
    // report results to the user
    report_results($sorted);
    fclose($file);
}
开发者ID:jimeiyang,项目名称:deepRotator,代码行数:49,代码来源:doxysearch.php


注:本文中的sort_results函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。