[dev] Google search applet

Joe Wilson joe.wilson at mindcandy.org
Sat Aug 9 10:52:51 PDT 2003


Attached is a patch that adds a Google search applet for the Horde block summary
page.  There are two new files needed: horde/lib/Block/google.php and
horde/templates/javascript/open_google_win.js.  Also, a minor patch to
horde/config/registry.php.dist to add the google entry.

One known issue is that the javascript gets cached and so changing languages
does not get reflected in the google window until the page is either manually
cleared from the cache or expires.  Since most people don't change languages
frequently, this shouldn't be an issue, but any shared machines where multiple
languages are used, but not individual logins (individual browser caches),
might have some problems.

Regards,

Joe

Index: registry.php.dist
===================================================================
RCS file: /usr/local/cvs/horde/horde/config/registry.php.dist,v
retrieving revision 1.170
diff -u -r1.170 registry.php.dist
--- registry.php.dist   7 Aug 2003 19:35:27 -0000       1.170
+++ registry.php.dist   9 Aug 2003 17:45:52 -0000
@@ -567,3 +567,9 @@
     'name' => _("Current Time"),
     'type' => 'time'
 );
+
+$this->applets['google'] = array(
+            'name' => 'Google',
+            'type' => 'google'
+        );
+

*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#
 *#
  *#   Joe Wilson             (917) 690-0507 (c)
   *#   884 Palmer Ave.        (914) 777-3250 (h)
    *#   Mamaroneck, NY 10543
     *#
      *#    He to whom [the mysterious] is a stranger,
       *#    who can no longer pause to wonder and stand
        *#    rapt in awe, is as good as dead: his eyes are closed.
         *#                           - Albert Einstein
          *#
           *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*



-------------- next part --------------
<?php
/**
 * $Horde: horde/lib/Block/google.php,v 1.0 2003/04/26 11:18:50 jan Exp $
 *
 * @package Horde
 */
class Horde_Block_google extends Horde_Block {

    /**
     * Constructor.
     */
    function Horde_Block_google($params = array())
    {
        $this->_params = $params;
        $this->_app = 'horde';
        $this->_type = 'google';
    }

    /**
     * Does this block have any user editable parameters?
     *
     * @return boolean  True is there are editable parameters.
     *                  False if there are not.
     */
    function isEditable()
    {
        return false;
    }

    /**
     * The title to go in this block.
     *
     * @return string   The title text.
     */
    function _title()
    {
        return _("Google");
    }

    /**
     * The content to go in this block.
     *
     * @return string   The content
     */
    function _content()
    {
        $html = '<table width="100%" height="100%">';
	$html .= '<form name="google" onsubmit="return false;">';
	$html .= '<tr><script language="JavaScript" type="text/javascript" src="' . $GLOBALS['registry']->getParam('webroot', 'horde') . '/javascript.php?file=open_google_win.js&amp;app=horde"></script>';
        $html .= '<td><img src="' . $GLOBALS['registry']->getParam('graphics', 'horde') . '/google.gif" alt="' ._("Google") . '" /></td></tr>';
	$html .= '<tr><td><input maxLength="256" size="40" name="q" width="100%" /></td></tr>';
	$html .= '<tr><td><table width="100%"><tr><td><input type="radio" name="area" value="web" width="20%" checked="checked">' . _("Web") . '</input></td>';
        $html .= '<td><input type="radio" name="area" value="images" width="20%">' . _("Images") . '</input></td>';
        $html .= '<td><input type="radio" name="area" value="groups" width="20%">' . _("Groups") . '</input></td>';
        $html .= '<td><input type="radio" name="area" value="directory" width="20%">' . _("Directory") . '</input></td>';
        $html .= '<td><input type="radio" name="area" value="news" width="20%">' . _("News") . '</input></td></tr></table></td></tr>';
	$html .= '<tr><td><input type=submit value="' . _("Google Search") . '" onclick="javascript:open_google_win();" /></td></tr>';
        $html .= '</form>';
        $html .= '</table>';
	return $html;
    }

}


More information about the dev mailing list