This repository was archived by the owner on Mar 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsearch.php
More file actions
executable file
·205 lines (194 loc) · 5.97 KB
/
Copy pathsearch.php
File metadata and controls
executable file
·205 lines (194 loc) · 5.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php get_header(); ?>
<?php $options = get_option(THEME_OPTIONS_NAME);?>
<?php if ($options['enable_google'] == 1) { ?>
<?php
$domain = $options['search_domain'];
$limit = (int)$options['search_per_page'];
$start = (is_numeric($_GET['start'])) ? (int)$_GET['start'] : 0;
$results = get_search_results($_GET['s'], $start, $limit, $domain);
?>
<div class="row page-content" id="search-results">
<div class="span12" id="page-top">
<h1>Search Results for "<?=htmlentities($_GET['s'])?>"</h1>
</div>
<div class="span12">
<article>
<?php if(count($results['items'])):?>
<ul class="result-list">
<?php foreach($results['items'] as $result):?>
<li class="item">
<h3>
<a class="<?=mimetype_to_application(($result['mime']) ? $result['mime'] : 'text/html')?>" href="<?=$result['url']?>">
<?php if($result['title']):?>
<?=$result['title']?>
<?php else:?>
<?=substr($result['url'], 0, 45)?>...
<?php endif;?>
</a>
</h3>
<a href="<?=$result['url']?>" class="ignore-external url sans"><?=$result['url']?></a>
<div class="snippet">
<?=str_replace('<br>', '', $result['snippet'])?>
</div>
</li>
<?php endforeach;?>
</ul>
<?php if($start + $limit < $results['number']):?>
<a class="button more" href="./?s=<?=$_GET['s']?>&start=<?=$start + $limit?>">More Results</a>
<?php endif;?>
<?php else:?>
<p>No results found for "<?=htmlentities($_GET['s'])?>".</p>
<?php endif;?>
</article>
</div>
</div>
<?php
}
// Determine if Relevanssi is installed. If it is,
// use the standard loop so Relevanssi can modify it,
// otherwise we want to use a custom query
elseif ($options['enable_google'] == 0 || !$options['enable_google']) {
if (is_plugin_active('relevanssi/relevanssi.php') == true) { ?>
<?php the_post(); ?>
<div class="row page-content" id="search-results">
<div class="span12" id="page-top">
<h1>Search Results for "<?=htmlentities($_GET['s'])?>"</h1>
</div>
<div class="span12">
<article>
<?php if(have_posts()):?>
<ul class="result-list">
<?php while(have_posts()): the_post();?>
<li class="item">
<h3>
<a
<?php if ($post->post_type == 'resourcelink') { ?>
class="<?=ResourceLink::get_document_application($post)?>" href="<?=ResourceLink::get_url($post)?>">
<?php
} else {
?>
href="<?=the_permalink()?>">
<?php } ?>
<?=the_title()?>
</a>
</h3>
<?php
$ancestors = get_post_ancestors($post->ID);
if ($ancestors) { ?>
<p class="result-breadcrumbs"><small>under
<?php
krsort($ancestors);
foreach ($ancestors as $ancestor) {
print '<a href="'.get_permalink($ancestor).'">'.get_post($ancestor)->post_title.'</a>';
if ($ancestor !== end($ancestors)) {
print ' » ';
}
}
?>
</small></p>
<?php
}
?>
<div class="snippet">
<?php if ($post->post_content !== '') { the_excerpt(); } ?>
</div>
</li>
<?php endwhile;?>
</ul>
<?php else:?>
<p>No results found for "<?=htmlentities($_GET['s'])?>".</p>
<?php endif;?>
</article>
</div>
</div>
<?php } else { ?>
<?php
$args = array(
'post_type' => array('resourcelink','post','page'),
's' => htmlentities($_GET['s']),
'numberposts' => '-1',
);
$posts = get_posts($args);
?>
<div class="row page-content" id="search-results">
<div class="span12" id="page-top">
<h1>Search Results for “<?=htmlentities($_GET['s'])?>”</h1>
</div>
<div class="span12">
<article>
<?php if($posts):?>
<ul class="result-list">
<?php
foreach ($posts as $post) {
// Determine if the post is a resource link that links
// to a page/page anchor (is a duplicate of an already-
// retrieved post.)
$not_duplicate = false;
if ($post->post_type !== 'resourcelink') {
$not_duplicate = true;
}
else {
if ($post->post_type == 'resourcelink' && get_post_meta($post->ID, 'resourcelink_is_doc', TRUE) == 'on') {
$not_duplicate = true;
}
}
if ($not_duplicate == true) {
?>
<li class="item">
<h3>
<a
<?php if ($post->post_type == 'resourcelink') { ?>
class="<?=ResourceLink::get_document_application($post)?>" href="<?=ResourceLink::get_url($post)?>">
<?php
} else {
?>
href="<?=the_permalink()?>">
<?php } ?>
<?=the_title()?>
</a>
</h3>
<?php
$ancestors = get_post_ancestors($post->ID);
if ($ancestors) { ?>
<p class="result-breadcrumbs"><small>under
<?php
krsort($ancestors);
foreach ($ancestors as $ancestor) {
print '<a href="'.get_permalink($ancestor).'">'.get_post($ancestor)->post_title.'</a>';
if ($ancestor !== end($ancestors)) {
print ' » ';
}
}
?>
</small></p>
<?php
}
?>
<div class="snippet">
<?php if ($post->post_content !== '') {
// Strip out shortcode and html content
$filtered_content = strip_tags(strip_shortcodes(($post->post_content)));
// Cut the post content length down to excerpt length and print it
$excerpt_length = 500;
$excerpt = substr($filtered_content, 0, $excerpt_length);
if ($excerpt) {
print $excerpt.'...';
}
}
?>
</div>
</li>
<?php } ?>
<?php } ?>
</ul>
<?php else:?>
<p>No results found for "<?=htmlentities($_GET['s'])?>".</p>
<?php endif;?>
</article>
</div>
</div>
<?php
}
}
?>
<?php get_footer();?>