root/branches/release-33/default_templates/search_results.mtml @ 1796

Revision 1796, 7.8 kB (checked in by fumiakiy, 20 months ago)

SetVarTemplate block is required to support Ajax-based background retrieval. BugId:78923

  • Property svn:keywords set to Id Revision
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
4<head>
5    <title><$MTBlogName encode_html="1"$>: <__trans phrase="Search Results"></title>
6    <$mt:include module="<__trans phrase="HTML Head">"$>
7    <MTIgnore>Below Javascript adds ajax search capability</MTIgnore>
8    <script type="text/javascript">
9    <!--
10    <MTIfMoreResults>
11    function getXmlHttp() {
12        if ( !window.XMLHttpRequest ) {
13            window.XMLHttpRequest = function() {
14                var types = [
15                    "Microsoft.XMLHTTP",
16                    "MSXML2.XMLHTTP.5.0",
17                    "MSXML2.XMLHTTP.4.0",
18                    "MSXML2.XMLHTTP.3.0",
19                    "MSXML2.XMLHTTP"
20                ];
21
22                for ( var i = 0; i < types.length; i++ ) {
23                    try {
24                        return new ActiveXObject( types[ i ] );
25                    } catch( e ) {}
26                }
27
28                return undefined;
29            };
30        }
31        if ( window.XMLHttpRequest )
32            return new XMLHttpRequest();
33    }
34
35    function getResults(page) {
36        page = parseInt(page);
37        if (timer) window.clearTimeout(timer);
38        var xh = getXmlHttp();
39        if (!xh) return false;
40        var res = results[page];
41        if (!res) return;
42        var url = res['next_url'];
43        if (!url) return;
44
45        xh.open('GET', url + '&format=js', true);
46        xh.onreadystatechange = function() {
47            if ( xh.readyState == 4 ) {
48                if ( xh.status && ( xh.status != 200 ) ) {
49                    // error - ignore
50                } else {
51                    try {
52                        var page_results = eval("(" + xh.responseText + ")");
53                        if ( page_results['error'] == null )
54                            results[page + 1] = page_results['result'];
55                    } catch (e) {
56                    }
57                }
58            }
59        };
60        xh.send(null);
61    }
62
63    function swapContent(direction) {
64        if ( direction == undefined ) direction = 1;
65        var page_span = document.getElementById('current-page');
66        if (!page_span) return true;
67        var next_page = direction + parseInt(page_span.innerHTML);
68        var res = results[next_page];
69        if (!res) return true;
70        var content = res['content'];
71        if (!content) return true;
72        var div = document.getElementById('search-results');
73        if (!div) return true;
74        div.innerHTML = content;
75        timer = window.setTimeout("getResults(" + next_page + ")", 1*1000);
76        window.scroll(0, 0);
77        return false;
78    }
79    <MTElse><MTIfPreviousResults>
80    function swapContent(direction) {
81        return true;
82    }</MTIfPreviousResults>
83    </MTIfMoreResults>
84    //-->
85    </script>
86</head>
87<body class="mt-search-results <$MTVar name="page_layout"$>">
88    <div id="container">
89        <div id="container-inner">
90
91
92            <$mt:include module="<__trans phrase="Banner Header">"$>
93
94
95            <div id="content">
96                <div id="content-inner">
97
98
99                    <div id="alpha">
100                        <div id="alpha-inner">
101
102<mt:ignore><!--
103    Below is the block to show search results.
104    This makes an independent block to support
105    Ajax-based background retrieval of the next search results.
106--></mt:ignore>
107<MTSetVarTemplate id="search_results" name="search_results"> 
108<MTSearchResults>
109    <MTBlogResultHeader>
110                            <div id="search-results">
111                                <span id="current-page" class="hidden"><MTCurrentPage></span>
112                                <h1 id="page-title" class="search-results-header">
113        <MTIfStraightSearch>
114                                    <__trans phrase="Results matching &ldquo;[_1]&rdquo; from [_2]" params="<$MTSearchString$>%%<$MTBlogName encode_html="1"$>">
115        </MTIfStraightSearch>
116        <MTIfTagSearch>
117                                    <__trans phrase="Results tagged &ldquo;[_1]&rdquo; from [_2]" params="<$MTSearchString$>%%<$MTBlogName encode_html="1"$>">
118        </MTIfTagSearch>
119                                </h1>
120                                <div class="search-results-container autopagerize_page_element">
121    </MTBlogResultHeader>
122                                    <$MTInclude module="<__trans phrase="Entry Summary">" hide_counts="1"$>
123    <MTBlogResultFooter>
124                                </div><div class="autopagerize_insert_before"></div>
125
126    <MTIgnore><!-- Used with the ajax search capability of the new search class --></MTIgnore>
127                                <div class="content-nav">
128                                    <MTIfPreviousResults><a href="<MTPreviousLink>" rel="prev" onclick="return swapContent(-1);">&lt; <__trans phrase="Previous"></a>&nbsp;&nbsp;</MTIfPreviousResults><MTPagerBlock><MTIfCurrentPage><MTVar name="__value__"><MTElse><a href="<MTPagerLink>"><MTVar name="__value__"></a></MTIfCurrentPage><mt:unless name="__last__">&nbsp;</mt:unless></MTPagerBlock><MTIfMoreResults>&nbsp;&nbsp;<a href="<MTNextLink>" rel="next" onclick="return swapContent();"><__trans phrase="Next"> &gt;</a></MTIfMoreResults>
129                                </div>
130                            </div>
131    </MTBlogResultFooter>
132</MTSearchResults>
133</MTSetVarTemplate>
134<mt:ignore><!-- Display search results constructed in the block above --></mt:ignore>
135<mt:var name="search_results">
136
137
138<mt:ignore><!-- Display no results message --></mt:ignore>
139<MTNoSearchResults>
140                            <h1 id="page-title" class="search-results-header">
141    <MTIfStraightSearch>
142                                <__trans phrase="Results matching &ldquo;[_1]&rdquo;" params="<$MTSearchString$>">
143    </MTIfStraightSearch>
144    <MTIfTagSearch>
145                                <__trans phrase="Results tagged &ldquo;[_1]&rdquo;" params="<$MTSearchString$>">
146    </MTIfTagSearch>
147                            </h1>
148                            <p><__trans phrase="No results found for &ldquo;[_1]&rdquo;." params="<$MTSearchString$>"></p>
149</MTNoSearchResults>
150
151
152<mt:ignore><!-- Display instructions for searching if search script was accessed without a query --></mt:ignore>
153<MTNoSearch>
154                            <h1 id="page-title" class="search-results-header"><__trans phrase="Instructions"></h1>
155                            <p><__trans phrase="By default, this search engine looks for all words in any order. To search for an exact phrase, enclose the phrase in quotes:"></p>
156                            <blockquote>
157                                <p><code>"<__trans phrase="movable type">"</code></p>
158                            </blockquote>
159                            <p><__trans phrase="The search engine also supports AND, OR, and NOT keywords to specify boolean expressions:"></p>
160                            <blockquote>
161                                <p><code><__trans phrase="personal OR publishing"></code></p>
162                                <p><code><__trans phrase="publishing NOT personal"></code></p>
163                            </blockquote>
164</MTNoSearch>
165
166<MTIgnore><!-- Used with the ajax search capability of the new search class --></MTIgnore>
167<MTIfMoreResults>
168<script type="text/javascript">
169<!--
170var div = document.getElementById('search-results');
171var results = {
172    '<MTCurrentPage>': {
173        'content': div.innerHTML,
174        'next_url': '<MTNextLink>'
175    }
176};
177var timer = window.setTimeout("getResults(" + <MTCurrentPage> + ")", 1*1000);
178//-->
179</script>
180</MTIfMoreResults>
181
182
183                        </div>
184                    </div>
185
186                    <$MTInclude module="<__trans phrase="Sidebar">"$>
187
188
189                </div>
190            </div>
191
192
193            <$mt:include module="<__trans phrase="Banner Footer">"$>
194
195
196        </div>
197    </div>
198</body>
199</html>
Note: See TracBrowser for help on using the browser.