SearchQueryDetails

    內容表格
    沒有標頭
    /**
     * Search Query Details Table
     *
     * @param uri $uri - base uri (default: page.uri)
     * @param map $params - query params to preserve
     * @param str $query - query to query for information
     */
    var uri = $uri ?? page.uri;
    var params = $params ?? {};
    var searchQuery = $query ?? "";
    
    var dateSince = $dateSince; // nullable
    var dateBefore = $dateBefore ?? date.now;
    
    // fetch the results
    var queryDetails = searchanalytics.query{
        querystring: searchQuery,
        since: dateSince,
        before: dateBefore
    };
    
    // Begin output
    
    <h3 class="reports">
        wiki.localize("MindTouch.SearchAnalytics.detail.selected");
        &nbsp;;
        <span class="terms">queryDetails.sortedterms</span>
    </h3>
    
    <table class="table mt-report-results">
        Template('MindTouch/Controls/TableSortHeading', {
            uri: uri,
            params: params,
            columns: [
                {width: "", label: wiki.localize("MindTouch.SearchAnalytics.data.result")},
                {width: "25", label: wiki.localize("MindTouch.SearchAnalytics.data.hits")},
                {width: "165", label: wiki.localize("MindTouch.SearchAnalytics.data.date.search")},
                {width: "25", label: wiki.localize("MindTouch.SearchAnalytics.data.position.avg")},
                {width: "25", label: wiki.localize("MindTouch.SearchAnalytics.data.position.min")},
                {width: "25", label: wiki.localize("MindTouch.SearchAnalytics.data.position.max")}
            ]
            //enabled: (#queryDetails.selectedresults > 0)
        });
        if (#queryDetails.selectedresults < 1) {
        <tr>
            <td colspan="6" class="ui-state-empty">
                wiki.localize("MindTouch.SearchAnalytics.detail.selected.empty");
            </td>
        </tr>
        } else {
            foreach (var result in queryDetails.selectedresults) {
            <tr>
                Template('MindTouch/Reports/Controls/TableCellResult', result);
                <td class="data-type-numeric">
                    result.count;
                </td>
                <td class="data-type-numeric">
                    Template("MindTouch/Controls/DateTime", [result.dateselected, "datetime"]);
                </td>
                <td class="data-type-numeric">
                    result.position.min;
                </td>
                <td class="data-type-numeric">
                    result.position.max;
                </td>
                <td class="data-type-numeric">
                    result.position.avg;
                </td>
            </tr>
            }
        }
    </table>
    
    <h3 class="reports">
        wiki.localize("MindTouch.SearchAnalytics.detail.title");
        &nbsp;;
        <span class="terms">queryDetails.sortedterms</span>
    </h3>
    
    <dl class="mt-query">
        <dt>wiki.localize("MindTouch.SearchAnalytics.detail.searched");</dt>
        <dd>Template("MindTouch/Controls/DateTime", [queryDetails.datesearched, "datetime"]);</dd>
    
        if (#queryDetails.queries > 1) {
            <dt>wiki.localize("MindTouch.SearchAnalytics.detail.related");</dt>
            <dd class="description">
                wiki.localize("MindTouch.SearchAnalytics.detail.related.description");
            </dd>
            <dd>
                <ul>
                    var tip = wiki.localize("MindTouch.SearchAnalytics.detail.related.tip");
                    foreach (var rawQuery in queryDetails.queries) {
                        <li>
                            <a href=(site.homepage.uri & {search: rawQuery.raw}) target="_blank" title=(tip)>
                            rawQuery.raw;
                            &nbsp;;
                            <span class="count">"(" .. rawQuery.count .. ")"</span>
                            </a>
                       </li>
                    }
                </ul>
            </dd>
        }
        <dt>wiki.localize("MindTouch.SearchAnalytics.detail.previous");</dt>
        <dd class="description">
            wiki.localize("MindTouch.SearchAnalytics.detail.previous.description");
        </dd>
        <dd>
        if (#queryDetails.previous < 1) {
                wiki.localize("MindTouch.SearchAnalytics.detail.previous.empty");
            } else {
            <ul>
                foreach (var query in queryDetails.previous) {
                    <li>
                        <a href=(uri & params & {query: query.sortedterms})>
                            query.sortedterms;
                            &nbsp;;
                            <span class="count">"(" .. query.count .. ")"</span>
                        </a>
                    </li>
                }
            </ul>
        }
        </dd>
    </dl>
    
    // debugging
    //web.pre(json.format(queryDetails));
    標籤 (Edit tags)
    • No tags
    您必須 登入 才能發佈評論。
    Powered by MindTouch Core