MDL-24625 Dropped $CFG->block_search_text and $CFG->block_search_button
authorDavid Mudrak <david.mudrak@gmail.com>
Tue, 9 Nov 2010 12:40:56 +0000 (12:40 +0000)
committerDavid Mudrak <david.mudrak@gmail.com>
Tue, 9 Nov 2010 12:40:56 +0000 (12:40 +0000)
We should never store strings in the database, use get_string()
whenever possible. Also, I removed legacy config_global.html even though
I know Apu kept it intentionally for regressions test. The file can
always be searched in the repository history, no need to keep it.

blocks/search/block_search.php
blocks/search/config_global.html [deleted file]
blocks/search/db/upgrade.php
blocks/search/lang/en/block_search.php
blocks/search/settings.php
blocks/search/version.php
blocks/search_forums/block_search_forums.php

index ea8b782..436af7f 100644 (file)
@@ -41,17 +41,12 @@ class block_search extends block_base {
 
       $this->content = new stdClass;
 
-      //lazy check for the moment
-      //fetch values if defined in admin, otherwise use defaults
-      $label  = (!empty($CFG->block_search_text)) ? $CFG->block_search_text : get_string('searchmoodle', 'block_search');
-      $button = (!empty($CFG->block_search_button)) ? $CFG->block_search_button : get_string('go', 'block_search');
-
       //basic search form
       $this->content->text =
             '<form id="searchquery" method="get" action="'. $CFG->wwwroot .'/search/query.php"><div>'
-          . '<label for="block_search_q">'. $label .'</label>'
+          . '<label for="block_search_q">' . get_string('searchmoodle', 'block_search') . '</label>'
           . '<input id="block_search_q" type="text" name="query_string" />'
-          . '<input type="submit" value="'.$button.'" />'
+          . '<input type="submit" value="' . s(get_string('go', 'block_search')) . '" />'
           . '</div></form>';
 
       //no footer, thanks
diff --git a/blocks/search/config_global.html b/blocks/search/config_global.html
deleted file mode 100644 (file)
index f809533..0000000
+++ /dev/null
@@ -1,300 +0,0 @@
-<?php
-
-/**
-* Requires and includes
-*/
-include_once $CFG->dirroot."/search/lib.php";
-
-$defaultfiletypes = "PDF,TXT,HTML,PPT,XML,DOC,HTM";
-
-global $DB;
-?>
-<div style="text-align:center;">
-<table cellspacing="5" width="90%">
-    <tr>
-        <td valign="top" align="right">
-            <b><?php print_string('configsearchtext', 'block_search') ?>:</b>
-        </td>
-        <td valign="top" align="left">
-            <input id="block_search_text" type="text" name="block_search_text" value="<?php
-            if(isset($CFG->block_search_text)) {
-                p($CFG->block_search_text);
-            } else {
-                p(get_string('searchmoodle', 'block_search'));
-            } ?>"/><br/>
-        </td>
-    </tr>
-    <tr>
-        <td valign="top" align="right">
-            <b><?php print_string('configbuttonlabel', 'block_search') ?>:</b>
-        </td>
-        <td valign="top" align="left">
-          <input id="block_search_button" type="text" name="block_search_button" value="<?php
-            if(isset($CFG->block_search_button)) {
-                p($CFG->block_search_button);
-            } else {
-                p(get_string('go', 'block_search'));
-            } ?>"/><br/><br/>
-        </td>
-    </tr>
-    <tr>
-        <td valign="top" align="right">
-            <b><?php print_string('configenablefileindexing', 'block_search') ?>:</b>
-        </td>
-        <td valign="top" align="left">
-            <input id="block_enable_file_indexing" type="radio" name="block_search_enable_file_indexing" value="1" <?php
-            if(isset($CFG->block_search_enable_file_indexing) && $CFG->block_search_enable_file_indexing) {
-                echo " checked=\"checked\" ";
-            } ?> /> <?php print_string('yes') ?> -
-            <input id="block_search_enable_file_indexing" type="radio" name="block_search_enable_file_indexing" value="0" <?php
-            if(!isset($CFG->block_search_enable_file_indexing) || !$CFG->block_search_enable_file_indexing) {
-                echo " checked=\"checked\" ";
-            } ?> /> <?php print_string('no') ?>
-            <br/><br/>
-        </td>
-    </tr>
-    <tr>
-        <td valign="top" align="right">
-            <b><?php print_string('configfiletypes', 'block_search') ?>:</b>
-        </td>
-        <td valign="top" align="left">
-          <input id="block_search_filetypes" type="text" name="block_search_filetypes" value="<?php
-            if(!isset($CFG->block_search_filetypes)) {
-                $CFG->block_search_filetypes = $defaultfiletypes;
-            }
-            p($CFG->block_search_filetypes);
-            ?>" />
-            <br/><br/>
-        </td>
-    </tr>
-    <tr>
-        <td valign="top" align="right">
-            <b><?php print_string('usemoodleroot', 'block_search') ?>:</b>
-        </td>
-        <td valign="top" align="left">
-        <?php
-            $usemoodleroot = (isset($CFG->block_search_usemoodleroot)) ? 'checked="checked"' : '' ;
-            $notusemoodleroot = (!isset($CFG->block_search_usemoodleroot)) ? 'checked="checked"' : '' ;
-        ?>
-          <input id="block_search_usemoodleroot" type="radio" name="block_search_usemoodleroot" <?php echo $usemoodleroot ?> value="1"/> <?php print_string('yes') ?> -
-          <input id="block_search_notusemoodleroot" type="radio" name="block_search_usemoodleroot" <?php echo $notusemoodleroot ?> value="0"/> <?php print_string('no') ?>
-          <br/><br/>
-        </td>
-    </tr>
-    <tr>
-        <td valign="top" align="right">
-            <b><?php print_string('configlimitindexbody', 'block_search') ?>:</b>
-        </td>
-        <td valign="top" align="left">
-            <input id="block_search_limit_index_body" type="text" size="8" name="block_search_limit_index_body" value="<?php
-            if(isset($CFG->block_search_limit_index_body)) {
-                p($CFG->block_search_limit_index_body);
-            } else {
-                p('');
-            } ?>"/> <?php print_string('bytes', 'block_search') ?><br/><br/>
-        </td>
-    </tr>
-</table>
-
-<fieldset class="">
-<legend align="top"><?php print_string('pdfhandling', 'block_search') ?></legend>
-<table cellspacing="5" width="90%">
-    <tr>
-        <td valign="top" align="right">
-            <b><?php print_string('configpdftotextcmd', 'block_search') ?>:</b>
-        </td>
-        <td valign="top" align="left">
-            <input id="block_search_pdf_to_text_cmd" type="text" size="60" name="block_search_pdf_to_text_cmd" value="<?php
-            if(isset($CFG->block_search_pdf_to_text_cmd)) {
-                p($CFG->block_search_pdf_to_text_cmd);
-            } else {
-                if ($CFG->ostype == 'WINDOWS'){
-                    p("lib/xpdf/win32/pdftotext.exe -eol dos -enc UTF-8 -q");
-                }
-                else{
-                    p("lib/xpdf/linux/pdftotext -enc UTF-8 -eol unix -q");
-                }
-            } ?>"/><br/><br/>
-        </td>
-    </tr>
-</table>
-</fieldset>
-
-<fieldset class="">
-<legend align="top"><?php print_string('wordhandling', 'block_search') ?></legend>
-<table cellspacing="5" width="90%">
-    <tr>
-        <td valign="top" align="right">
-            <b><?php print_string('configwordtotextcmd', 'block_search') ?>:</b>
-        </td>
-        <td valign="top" align="left">
-            <input id="block_search_word_to_text_cmd" type="text" size="60" name="block_search_word_to_text_cmd" value="<?php
-            if(isset($CFG->block_search_word_to_text_cmd)) {
-                p($CFG->block_search_word_to_text_cmd);
-            } else {
-                if ($CFG->ostype == 'WINDOWS'){
-                    p("lib/antiword/win32/antiword/antiword.exe ");
-                }
-                else{
-                    p("lib/antiword/linux/usr/bin/antiword");
-                }
-            } ?>"/><br/><br/>
-        </td>
-    </tr>
-    <tr>
-        <td valign="top" align="right">
-            <b><?php print_string('configwordtotextenv', 'block_search') ?>:</b>
-        </td>
-        <td valign="top" align="left">
-            <input id="block_search_word_to_text_env" type="text" size="60" name="block_search_word_to_text_env" value="<?php
-            if(isset($CFG->block_search_word_to_text_env)) {
-                echo $CFG->block_search_word_to_text_env;
-            } else {
-                if ($CFG->ostype == 'WINDOWS'){
-                    p("HOME={$CFG->dirroot}\\lib\\antiword\\win32");
-                }
-                else{
-                    p("ANTIWORDHOME={$CFG->dirroot}/lib/antiword/linux/usr/share/antiword");
-                }
-            } ?>"/><br/><br/>
-        </td>
-    </tr>
-</table>
-</fieldset>
-
-<?php
-$types = explode(',', $CFG->block_search_filetypes);
-if (!empty($types)){
-    foreach($types as $type) {
-        $utype = strtoupper($type);
-        $type = strtolower($type);
-        $type = trim($type);
-        if (preg_match("/\\b$type\\b/i", $defaultfiletypes)) continue;
-?>
-<fieldset class="">
-<legend align="top"><?php echo get_string('handlingfor', 'block_search').' '.$utype ?></legend>
-<table cellspacing="5" width="90%">
-    <tr>
-        <td valign="top" align="right">
-            <b><?php print_string('configtypetotxtcmd', 'block_search') ?>:</b>
-        </td>
-        <td valign="top" align="left">
-            <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
-            $propname = "block_search_{$type}_to_text_cmd";
-            if(isset($CFG->$propname)) {
-                p($CFG->$propname);
-            }
-            ?>"/>
-            <br/><br/>
-        </td>
-    </tr>
-    <tr>
-        <td valign="top" align="right">
-            <b><?php print_string('configtypetotxtenv', 'block_search') ?>:</b>
-        </td>
-        <td valign="top" align="left">
-            <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
-            $propname = "block_search_{$type}_to_text_env";
-            if(isset($CFG->$propname)) {
-                echo $CFG->$propname;
-            } ?>"/><br/><br/>
-        </td>
-    </tr>
-</table>
-</fieldset>
-<?php
-    }
-}
-?>
-
-<fieldset class="">
-<legend align="top"><?php echo get_string('searchdiscovery', 'block_search') ?></legend>
-<table>
-    <tr>
-        <td>
-            <pre>
-            <?php
-            $searchnames = search_collect_searchables(true);
-            list($searchable_list, $params) = $DB->get_in_or_equal($searchnames);
-            ?>
-            </pre>
-        </td>
-    </tr>
-</table>
-</fieldset>
-
-<fieldset class="">
-<legend align="top"><?php echo get_string('modulessearchswitches', 'block_search') ?></legend>
-<table cellspacing="5" width="90%">
-    <tr valign="top">
-        <td align="left">
-<?php
-$i = 0;
-$found_searchable_modules = 0;
-if ($modules = $DB->get_records_select('modules', "name $searchable_list", $params, 'name', 'id,name')){
-    foreach($modules as $module){
-        $i++;
-        $keyname = "search_in_{$module->name}";
-        $checkedup = (!isset($CFG->$keyname) || $CFG->$keyname) ? 'checked="checked"' : '' ;
-        $checkeddown = !(!isset($CFG->$keyname) || $CFG->$keyname) ? 'checked="checked"' : '' ;
-        echo "<input type=\"radio\" name=\"search_in_{$module->name}\" value=\"0\" {$checkeddown} /> " . get_string('no');
-        echo " - <input type=\"radio\" name=\"search_in_{$module->name}\" value=\"1\" {$checkedup} /> " . get_string('yes');
-        echo " - ".get_string('modulename', $module->name).'<br/>';
-        if ($i % 20 == 0){
-            echo "</td><td align=\"left\">";
-        }
-        $found_searchable_modules = 1;
-    }
-}
-if (!$found_searchable_modules) {
-    print_string('nosearchablemodules', 'block_search');
-}
-?>
-
-        </td>
-    </tr>
-</table>
-</fieldset>
-
-<fieldset class="">
-<legend align="top"><?php echo get_string('blockssearchswitches', 'block_search') ?></legend>
-<table cellspacing="5" width="90%">
-    <tr valign="top">
-        <td align="left">
-<?php
-$i = 0;
-$found_searchable_blocks = 0;
-if ($blocks = $DB->get_records_select('block', "name $searchable_list", $params, 'name', 'id,name')){
-    foreach($blocks as $block){
-        $i++;
-        $keyname = "search_in_{$block->name}";
-        $checked = (!isset($CFG->$keyname) || $CFG->$keyname) ? 'checked="checked"' : '' ;
-        echo "<input type=\"checkbox\" name=\"search_in_{$block->name}\" value=\"1\" {$checked} />";
-
-        // multiple fallback strategy to get the name of the block
-        $blocklabel = get_string('pluginname', 'block_'.$block->name);
-        echo " - ".$blocklabel.'<br/>';
-        if ($i % 20 == 0){
-            echo "</td><td align=\"left\">";
-        }
-        $found_searchable_blocks = 1;
-    }
-}
-if (!$found_searchable_blocks) {
-    print_string('nosearchableblocks', 'block_search');
-}
-?>
-
-        </td>
-    </tr>
-</table>
-</fieldset>
-
-<table cellspacing="5" width="90%">
-    <tr>
-        <td valign="top" align="right" colspan="2">
-            <input type="submit" value="<?php print_string('savechanges'); ?>" />
-        </td>
-    </tr>
-</table>
-</div>
index 18af760..ee8b484 100644 (file)
@@ -77,6 +77,11 @@ function xmldb_block_search_upgrade($oldversion) {
         upgrade_block_savepoint(true, 2010101800, 'search');
     }
 
+    if ($oldversion < 2010110900) {
+        unset_config('block_search_text');
+        unset_config('block_search_button');
+        upgrade_block_savepoint(true, 2010110900, 'search');
+    }
 
     return $result;
-}
\ No newline at end of file
+}
index 262ff86..06df0ed 100644 (file)
 
 $string['blockssearchswitches'] = 'Indexer activation for blocks';
 $string['bytes'] = 'bytes (0 stands for no limits)';
-$string['configbuttonlabel'] = 'Button label';
 $string['configenablefileindexing'] = 'Enable file indexing';
 $string['configfiletypes'] = 'File types handled';
 $string['configlimitindexbody'] = 'Indexed body size limitation';
 $string['configpdftotextcmd'] = 'Path to command pdftotext';
-$string['configsearchtext'] = 'Search text';
 $string['configtypetotxtcmd'] = 'Converter\'s command line';
 $string['configtypetotxtenv'] = 'Environment define for converter';
 $string['configwordtotextcmd'] = 'Path to command doctotext';
@@ -42,9 +40,7 @@ $string['enableindexinginblock'] = 'Allow indexing of the {$a} block';
 $string['envforcmdtotextfor'] = 'Environment for {$a} conversion command to text';
 $string['go'] = 'Go!';
 $string['handlingfor'] = 'Extra handling for';
-$string['headingofsearchblock'] = 'The title shown above the search box in the block';
 $string['indexbodylimit'] = 'The limit of indexing the body';
-$string['labelofsearchbutton'] = 'The text in the block search button itself';
 $string['listoffiletypes'] = 'The list of file types handled';
 $string['modulessearchswitches'] = 'Indexer activation for modules';
 $string['nosearchableblocks'] = 'No searchable blocks';
index 9e070c2..f3d8ca2 100644 (file)
@@ -4,14 +4,6 @@ defined('MOODLE_INTERNAL') || die;
 
 if ($ADMIN->fulltree) {
 
-    //Search text
-    $settings->add(new admin_setting_configtext('block_search_text', get_string('configsearchtext', 'block_search'),
-                       get_string('headingofsearchblock', 'block_search'), get_string('searchmoodle', 'block_search'), PARAM_TEXT ));
-
-    //Button Label
-    $settings->add(new admin_setting_configtext('block_search_button', get_string('configbuttonlabel', 'block_search'),
-                       get_string('labelofsearchbutton', 'block_search'), get_string('go', 'block_search'), PARAM_TEXT));
-
     //Enable file indexing (y/n)
     $settings->add(new admin_setting_configcheckbox('block_search_enable_file_indexing', get_string('configenablefileindexing', 'block_search'),
                        get_string('enablefileindexing', 'block_search'), 0, 1, 0));
index 84d4c91..77f6050 100644 (file)
@@ -15,5 +15,5 @@
 // You should have received a copy of the GNU General Public License
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
-$plugin->version = 2010101800;
+$plugin->version = 2010110900;
 $plugin->cron = 1;
index 02eef48..cf22705 100644 (file)
@@ -22,18 +22,15 @@ class block_search_forums extends block_base {
 
         $advancedsearch = get_string('advancedsearch', 'block_search_forums');
 
-        $search = get_string('search');
-
-        //Accessibility: replaced <input value=" />" type="submit"> with configurable text/'silent' character.
-        // Theme config, $CFG->block_search_button = get_arrow_right() .'<span class="accesshide">'.get_string('search').'</span>';
-        $button = (isset($CFG->block_search_button)) ? $CFG->block_search_button : get_string('go');
+        $strsearch  = get_string('search');
+        $strgo      = get_string('go');
 
         $this->content->text  = '<div class="searchform">';
         $this->content->text .= '<form action="'.$CFG->wwwroot.'/mod/forum/search.php" style="display:inline"><fieldset class="invisiblefieldset">';
         $this->content->text .= '<input name="id" type="hidden" value="'.$this->page->course->id.'" />';  // course
-        $this->content->text .= '<label class="accesshide" for="searchform_search">'.$search.'</label>'.
+        $this->content->text .= '<label class="accesshide" for="searchform_search">'.$strsearch.'</label>'.
                                 '<input id="searchform_search" name="search" type="text" size="16" />';
-        $this->content->text .= '<button id="searchform_button" type="submit" title="'.$search.'">'.$button.'</button><br />';
+        $this->content->text .= '<button id="searchform_button" type="submit" title="'.$strsearch.'">'.$strgo.'</button><br />';
         $this->content->text .= '<a href="'.$CFG->wwwroot.'/mod/forum/search.php?id='.$this->page->course->id.'">'.$advancedsearch.'</a>';
         $this->content->text .= $OUTPUT->help_icon('search');
         $this->content->text .= '</fieldset></form></div>';