MDL-22061 removing unnecessary [[ tests
[moodle.git] / blocks / search / config_global.html
CommitLineData
f28f2d90 1<?php
2
3/**
4* Requires and includes
5*/
6include_once $CFG->dirroot."/search/lib.php";
7
8$defaultfiletypes = "PDF,TXT,HTML,PPT,XML,DOC,HTM";
9
ac3620f6 10global $DB;
f28f2d90 11?>
682d4032 12<div style="text-align:center;">
f28f2d90 13<table cellspacing="5" width="90%">
918fb61f 14 <tr>
15 <td valign="top" align="right">
16 <b><?php print_string('configsearchtext', 'block_search') ?>:</b>
17 </td>
18 <td valign="top" align="left">
4ca6cfbf 19 <input id="block_search_text" type="text" name="block_search_text" value="<?php
918fb61f 20 if(isset($CFG->block_search_text)) {
21 p($CFG->block_search_text);
22 } else {
23 p(get_string('searchmoodle', 'block_search'));
24 } ?>"/><br/>
25 </td>
26 </tr>
27 <tr>
28 <td valign="top" align="right">
29 <b><?php print_string('configbuttonlabel', 'block_search') ?>:</b>
30 </td>
31 <td valign="top" align="left">
4ca6cfbf 32 <input id="block_search_button" type="text" name="block_search_button" value="<?php
918fb61f 33 if(isset($CFG->block_search_button)) {
34 p($CFG->block_search_button);
35 } else {
36 p(get_string('go', 'block_search'));
37 } ?>"/><br/><br/>
38 </td>
39 </tr>
40 <tr>
41 <td valign="top" align="right">
42 <b><?php print_string('configenablefileindexing', 'block_search') ?>:</b>
43 </td>
44 <td valign="top" align="left">
4ca6cfbf 45 <input id="block_enable_file_indexing" type="radio" name="block_search_enable_file_indexing" value="1" <?php
918fb61f 46 if(isset($CFG->block_search_enable_file_indexing) && $CFG->block_search_enable_file_indexing) {
47 echo " checked=\"checked\" ";
4ca6cfbf
PS
48 } ?> /> <?php print_string('yes') ?> -
49 <input id="block_search_enable_file_indexing" type="radio" name="block_search_enable_file_indexing" value="0" <?php
918fb61f 50 if(!isset($CFG->block_search_enable_file_indexing) || !$CFG->block_search_enable_file_indexing) {
51 echo " checked=\"checked\" ";
52 } ?> /> <?php print_string('no') ?>
53 <br/><br/>
54 </td>
55 </tr>
56 <tr>
57 <td valign="top" align="right">
58 <b><?php print_string('configfiletypes', 'block_search') ?>:</b>
59 </td>
60 <td valign="top" align="left">
4ca6cfbf 61 <input id="block_search_filetypes" type="text" name="block_search_filetypes" value="<?php
f28f2d90 62 if(!isset($CFG->block_search_filetypes)) {
63 $CFG->block_search_filetypes = $defaultfiletypes;
4ca6cfbf 64 }
f28f2d90 65 p($CFG->block_search_filetypes);
66 ?>" />
67 <br/><br/>
918fb61f 68 </td>
69 </tr>
f8d8b7be 70 <tr>
71 <td valign="top" align="right">
72 <b><?php print_string('usemoodleroot', 'block_search') ?>:</b>
73 </td>
74 <td valign="top" align="left">
4ca6cfbf
PS
75 <?php
76 $usemoodleroot = (isset($CFG->block_search_usemoodleroot)) ? 'checked="checked"' : '' ;
77 $notusemoodleroot = (!isset($CFG->block_search_usemoodleroot)) ? 'checked="checked"' : '' ;
f8d8b7be 78 ?>
4ca6cfbf
PS
79 <input id="block_search_usemoodleroot" type="radio" name="block_search_usemoodleroot" <?php echo $usemoodleroot ?> value="1"/> <?php print_string('yes') ?> -
80 <input id="block_search_usemoodleroot" type="radio" name="block_search_usemoodleroot" <?php echo $notusemoodleroot ?> value="0"/> <?php print_string('no') ?>
f8d8b7be 81 <br/><br/>
82 </td>
83 </tr>
f28f2d90 84 <tr>
85 <td valign="top" align="right">
86 <b><?php print_string('configlimitindexbody', 'block_search') ?>:</b>
87 </td>
88 <td valign="top" align="left">
4ca6cfbf 89 <input id="block_search_limit_index_body" type="text" size="8" name="block_search_limit_index_body" value="<?php
f28f2d90 90 if(isset($CFG->block_search_limit_index_body)) {
91 p($CFG->block_search_limit_index_body);
92 } else {
93 p('');
94 } ?>"/> <?php print_string('bytes', 'block_search') ?><br/><br/>
95 </td>
96 </tr>
97</table>
98
049f43f7
VF
99<fieldset class="">
100<legend align="top"><?php print_string('pdfhandling', 'block_search') ?></legend>
f28f2d90 101<table cellspacing="5" width="90%">
918fb61f 102 <tr>
103 <td valign="top" align="right">
104 <b><?php print_string('configpdftotextcmd', 'block_search') ?>:</b>
105 </td>
106 <td valign="top" align="left">
4ca6cfbf 107 <input id="block_search_pdf_to_text_cmd" type="text" size="60" name="block_search_pdf_to_text_cmd" value="<?php
918fb61f 108 if(isset($CFG->block_search_pdf_to_text_cmd)) {
109 p($CFG->block_search_pdf_to_text_cmd);
110 } else {
918fb61f 111 if ($CFG->ostype == 'WINDOWS'){
775f811a 112 p("lib/xpdf/win32/pdftotext.exe -eol dos -enc UTF-8 -q");
918fb61f 113 }
114 else{
775f811a 115 p("lib/xpdf/linux/pdftotext -enc UTF-8 -eol unix -q");
918fb61f 116 }
117 } ?>"/><br/><br/>
118 </td>
119 </tr>
f28f2d90 120</table>
121</fieldset>
122
049f43f7
VF
123<fieldset class="">
124<legend align="top"><?php print_string('wordhandling', 'block_search') ?></legend>
f28f2d90 125<table cellspacing="5" width="90%">
918fb61f 126 <tr>
127 <td valign="top" align="right">
128 <b><?php print_string('configwordtotextcmd', 'block_search') ?>:</b>
129 </td>
130 <td valign="top" align="left">
4ca6cfbf 131 <input id="block_search_word_to_text_cmd" type="text" size="60" name="block_search_word_to_text_cmd" value="<?php
918fb61f 132 if(isset($CFG->block_search_word_to_text_cmd)) {
133 p($CFG->block_search_word_to_text_cmd);
134 } else {
135 if ($CFG->ostype == 'WINDOWS'){
136 p("lib/antiword/win32/antiword/antiword.exe ");
137 }
138 else{
139 p("lib/antiword/linux/usr/bin/antiword");
140 }
141 } ?>"/><br/><br/>
142 </td>
143 </tr>
144 <tr>
145 <td valign="top" align="right">
146 <b><?php print_string('configwordtotextenv', 'block_search') ?>:</b>
147 </td>
148 <td valign="top" align="left">
4ca6cfbf 149 <input id="block_search_word_to_text_env" type="text" size="60" name="block_search_word_to_text_env" value="<?php
918fb61f 150 if(isset($CFG->block_search_word_to_text_env)) {
294ce987 151 echo $CFG->block_search_word_to_text_env;
918fb61f 152 } else {
153 if ($CFG->ostype == 'WINDOWS'){
154 p("HOME={$CFG->dirroot}\\lib\\antiword\\win32");
155 }
156 else{
157 p("ANTIWORDHOME={$CFG->dirroot}/lib/antiword/linux/usr/share/antiword");
158 }
159 } ?>"/><br/><br/>
160 </td>
161 </tr>
f28f2d90 162</table>
163</fieldset>
164
4ca6cfbf 165<?php
f28f2d90 166$types = split(',', $CFG->block_search_filetypes);
167if (!empty($types)){
168 foreach($types as $type) {
169 $utype = strtoupper($type);
170 $type = strtolower($type);
171 $type = trim($type);
172 if (preg_match("/\\b$type\\b/i", $defaultfiletypes)) continue;
173?>
049f43f7
VF
174<fieldset class="">
175<legend align="top"><?php echo get_string('handlingfor', 'block_search').' '.$utype ?></legend>
f28f2d90 176<table cellspacing="5" width="90%">
918fb61f 177 <tr>
178 <td valign="top" align="right">
f28f2d90 179 <b><?php print_string('configtypetotxtcmd', 'block_search') ?>:</b>
918fb61f 180 </td>
181 <td valign="top" align="left">
4ca6cfbf 182 <input id="block_search_<?php p($type) ?>_to_text_cmd" type="text" size="60" name="block_search_<?php p($type) ?>_to_text_cmd" value="<?php
f28f2d90 183 $propname = "block_search_{$type}_to_text_cmd";
184 if(isset($CFG->$propname)) {
185 p($CFG->$propname);
4ca6cfbf 186 }
f28f2d90 187 ?>"/>
188 <br/><br/>
189 </td>
190 </tr>
191 <tr>
192 <td valign="top" align="right">
193 <b><?php print_string('configtypetotxtenv', 'block_search') ?>:</b>
194 </td>
195 <td valign="top" align="left">
4ca6cfbf 196 <input id="block_search_<?php p($type) ?>_to_text_env" type="text" size="60" name="block_search_<?php p($type) ?>_to_text_env" value="<?php
f28f2d90 197 $propname = "block_search_{$type}_to_text_env";
198 if(isset($CFG->$propname)) {
294ce987 199 echo $CFG->$propname;
f28f2d90 200 } ?>"/><br/><br/>
918fb61f 201 </td>
202 </tr>
f28f2d90 203</table>
204</fieldset>
205<?php
206 }
207}
208?>
209
049f43f7
VF
210<fieldset class="">
211<legend align="top"><?php echo get_string('searchdiscovery', 'block_search') ?></legend>
f28f2d90 212<table>
213 <tr>
214 <td>
215 <pre>
216 <?php
217 $searchnames = search_collect_searchables(true);
218 list($searchable_list, $params) = $DB->get_in_or_equal($searchnames);
219 ?>
220 </pre>
221 </td>
222 </tr>
223</table>
224</fieldset>
225
049f43f7
VF
226<fieldset class="">
227<legend align="top"><?php echo get_string('modulessearchswitches', 'block_search') ?></legend>
f28f2d90 228<table cellspacing="5" width="90%">
229 <tr valign="top">
230 <td align="left">
231<?php
232$i = 0;
233$found_searchable_modules = 0;
234if ($modules = $DB->get_records_select('modules', "name $searchable_list", $params, 'name', 'id,name')){
235 foreach($modules as $module){
236 $i++;
237 $keyname = "search_in_{$module->name}";
238 $checkedup = (!isset($CFG->$keyname) || $CFG->$keyname) ? 'checked="checked"' : '' ;
239 $checkeddown = !(!isset($CFG->$keyname) || $CFG->$keyname) ? 'checked="checked"' : '' ;
240 echo "<input type=\"radio\" name=\"search_in_{$module->name}\" value=\"0\" {$checkeddown} /> " . get_string('no');
241 echo " - <input type=\"radio\" name=\"search_in_{$module->name}\" value=\"1\" {$checkedup} /> " . get_string('yes');
242 echo " - ".get_string('modulename', $module->name).'<br/>';
243 if ($i % 20 == 0){
244 echo "</td><td align=\"left\">";
245 }
246 $found_searchable_modules = 1;
247 }
4ca6cfbf 248}
f28f2d90 249if (!$found_searchable_modules) {
250 print_string('nosearchablemodules', 'block_search');
4ca6cfbf 251}
f28f2d90 252?>
253
254 </td>
255 </tr>
256</table>
257</fieldset>
258
049f43f7
VF
259<fieldset class="">
260<legend align="top"><?php echo get_string('blockssearchswitches', 'block_search') ?></legend>
f28f2d90 261<table cellspacing="5" width="90%">
262 <tr valign="top">
263 <td align="left">
264<?php
265$i = 0;
266$found_searchable_blocks = 0;
267if ($blocks = $DB->get_records_select('block', "name $searchable_list", $params, 'name', 'id,name')){
268 foreach($blocks as $block){
269 $i++;
270 $keyname = "search_in_{$block->name}";
271 $checked = (!isset($CFG->$keyname) || $CFG->$keyname) ? 'checked="checked"' : '' ;
272 echo "<input type=\"checkbox\" name=\"search_in_{$block->name}\" value=\"1\" {$checked} />";
4ca6cfbf 273
f28f2d90 274 // multiple fallback strategy to get the name of the block
150135ab 275 $blocklabel = get_string('pluginname', 'block_'.$block->name);
f28f2d90 276 echo " - ".$blocklabel.'<br/>';
277 if ($i % 20 == 0){
278 echo "</td><td align=\"left\">";
279 }
280 $found_searchable_blocks = 1;
281 }
4ca6cfbf 282}
f28f2d90 283if (!$found_searchable_blocks) {
284 print_string('nosearchableblocks', 'block_search');
4ca6cfbf 285}
f28f2d90 286?>
287
288 </td>
289 </tr>
290</table>
291</fieldset>
292
293<table cellspacing="5" width="90%">
918fb61f 294 <tr>
295 <td valign="top" align="right" colspan="2">
296 <input type="submit" value="<?php print_string('savechanges'); ?>" />
297 </td>
298 </tr>
299</table>
77a297d2 300</div>