MDL-22054 the last blockname removed
[moodle.git] / blocks / search / config_global.html
1 <?php
3 /**
4 * Requires and includes
5 */
6 include_once $CFG->dirroot."/search/lib.php";
8 $defaultfiletypes = "PDF,TXT,HTML,PPT,XML,DOC,HTM";
10 global $DB;
11 ?>
12 <div style="text-align:center;">
13 <table cellspacing="5" width="90%">
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">
19             <input id="block_search_text" type="text" name="block_search_text" value="<?php
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">
32           <input id="block_search_button" type="text" name="block_search_button" value="<?php
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">
45             <input id="block_enable_file_indexing" type="radio" name="block_search_enable_file_indexing" value="1" <?php
46             if(isset($CFG->block_search_enable_file_indexing) && $CFG->block_search_enable_file_indexing) {
47                 echo " checked=\"checked\" ";
48             } ?> /> <?php print_string('yes') ?> -
49             <input id="block_search_enable_file_indexing" type="radio" name="block_search_enable_file_indexing" value="0" <?php
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">
61           <input id="block_search_filetypes" type="text" name="block_search_filetypes" value="<?php
62             if(!isset($CFG->block_search_filetypes)) {
63                 $CFG->block_search_filetypes = $defaultfiletypes;
64             }
65             p($CFG->block_search_filetypes);
66             ?>" />
67             <br/><br/>
68         </td>
69     </tr>
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">
75         <?php
76             $usemoodleroot = (isset($CFG->block_search_usemoodleroot)) ? 'checked="checked"' : '' ;
77             $notusemoodleroot = (!isset($CFG->block_search_usemoodleroot)) ? 'checked="checked"' : '' ;
78         ?>
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') ?>
81           <br/><br/>
82         </td>
83     </tr>
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">
89             <input id="block_search_limit_index_body" type="text" size="8" name="block_search_limit_index_body" value="<?php
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>
99 <fieldset class="">
100 <legend align="top"><?php print_string('pdfhandling', 'block_search') ?></legend> 
101 <table cellspacing="5" width="90%">
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">
107             <input id="block_search_pdf_to_text_cmd" type="text" size="60" name="block_search_pdf_to_text_cmd" value="<?php
108             if(isset($CFG->block_search_pdf_to_text_cmd)) {
109                 p($CFG->block_search_pdf_to_text_cmd);
110             } else {
111                 if ($CFG->ostype == 'WINDOWS'){
112                     p("lib/xpdf/win32/pdftotext.exe -eol dos -enc UTF-8 -q");
113                 }
114                 else{
115                     p("lib/xpdf/linux/pdftotext -enc UTF-8 -eol unix -q");
116                 }
117             } ?>"/><br/><br/>
118         </td>
119     </tr>
120 </table>
121 </fieldset>
123 <fieldset class="">
124 <legend align="top"><?php print_string('wordhandling', 'block_search') ?></legend> 
125 <table cellspacing="5" width="90%">
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">
131             <input id="block_search_word_to_text_cmd" type="text" size="60" name="block_search_word_to_text_cmd" value="<?php
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">
149             <input id="block_search_word_to_text_env" type="text" size="60" name="block_search_word_to_text_env" value="<?php
150             if(isset($CFG->block_search_word_to_text_env)) {
151                 echo $CFG->block_search_word_to_text_env;
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>
162 </table>
163 </fieldset>
165 <?php
166 $types = split(',', $CFG->block_search_filetypes);
167 if (!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 ?>
174 <fieldset class="">
175 <legend align="top"><?php echo get_string('handlingfor', 'block_search').' '.$utype ?></legend> 
176 <table cellspacing="5" width="90%">
177     <tr>
178         <td valign="top" align="right">
179             <b><?php print_string('configtypetotxtcmd', 'block_search') ?>:</b>
180         </td>
181         <td valign="top" align="left">
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
183             $propname = "block_search_{$type}_to_text_cmd";
184             if(isset($CFG->$propname)) {
185                 p($CFG->$propname);
186             }
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">
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
197             $propname = "block_search_{$type}_to_text_env";
198             if(isset($CFG->$propname)) {
199                 echo $CFG->$propname;
200             } ?>"/><br/><br/>
201         </td>
202     </tr>
203 </table>
204 </fieldset>
205 <?php
206     }
208 ?>
210 <fieldset class="">
211 <legend align="top"><?php echo get_string('searchdiscovery', 'block_search') ?></legend> 
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>
226 <fieldset class="">
227 <legend align="top"><?php echo get_string('modulessearchswitches', 'block_search') ?></legend> 
228 <table cellspacing="5" width="90%">
229     <tr valign="top">
230         <td align="left">
231 <?php
232 $i = 0;
233 $found_searchable_modules = 0;
234 if ($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     }
249 if (!$found_searchable_modules) {
250     print_string('nosearchablemodules', 'block_search');
252 ?>
254         </td>
255     </tr>
256 </table>
257 </fieldset>
259 <fieldset class="">
260 <legend align="top"><?php echo get_string('blockssearchswitches', 'block_search') ?></legend> 
261 <table cellspacing="5" width="90%">
262     <tr valign="top">
263         <td align="left">
264 <?php
265 $i = 0;
266 $found_searchable_blocks = 0;
267 if ($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} />";
274         // multiple fallback strategy to get the name of the block
275         $blocklabel = get_string('pluginname', 'block_'.$block->name);
276         if ($blocklabel == '[[blockname]]') $blocklabel = get_string($block->name, 'block_'.$block->name);
277         if ($blocklabel == "[[{$block->name}]]") $blocklabel = "<span class=\"dimmed_text\">$block->name</span>";
278         echo " - ".$blocklabel.'<br/>';
279         if ($i % 20 == 0){
280             echo "</td><td align=\"left\">";
281         }
282         $found_searchable_blocks = 1;
283     }
285 if (!$found_searchable_blocks) {
286     print_string('nosearchableblocks', 'block_search');
288 ?>
290         </td>
291     </tr>
292 </table>
293 </fieldset>
295 <table cellspacing="5" width="90%">
296     <tr>
297         <td valign="top" align="right" colspan="2">
298             <input type="submit" value="<?php print_string('savechanges'); ?>" />
299         </td>
300     </tr>
301 </table>
302 </div>