'', 'mode' => 'search', // or 'cache' or 'spell' 'startIndex' => 1, 'maxResults' => 10, // fixed to 10 for now by google 'formsize' => 30, // 'language' => `?? //'license_key' => false, ); } function run($dbi, $argstr, &$request, $basepage) { $args = $this->getArgs($argstr, $request); // if (empty($args['s'])) // return ''; $html = HTML(); extract($args); // prevent from dump if ($q and $request->isPost()) { require_once("lib/Google.php"); $google = new Google(); if (!$google) return ''; switch ($mode) { case 'search': $result = $google->doGoogleSearch($q); break; case 'cache': $result = $google->doGetCachedPage($q); break; case 'spell': $result = $google->doSpellingSuggestion($q); break; default: trigger_error("Invalid mode"); } if (isa($result,'HTML')) $html->pushContent($result); if (isa($result,'GoogleSearchResults')) { //TODO: result template if (!empty($result->resultElements)) { $list = HTML::ol(); foreach ($result->resultElements as $res) { $li = HTML::li(LinkURL($res['URL'],$res['directoryTitle']),HTML::br(), $res['directoryTitle'] ? HTML(HTML::raw('  '),HTML::em($res['summary']),' -- ',LinkURL($res['URL'])) : ''); $list->pushContent($li); } $html->pushContent($list); } else return _("Nothing found"); } if (is_string($result)) { // cache content also? $html->pushContent(HTML::blockquote(HTML::raw($result))); } } if ($formsize < 1) $formsize = 30; // todo: template $form = HTML::form(array('action' => $request->getPostURL(), 'method' => 'post', //'class' => 'class', //fixme 'accept-charset' => $GLOBALS['charset']), HiddenInputs(array('pagename' => $basepage, 'mode' => $mode))); $form->pushContent(HTML::input(array('type' => 'text', 'value' => $q, 'name' => 'q', 'size' => $formsize))); $form->pushContent(HTML::input(array('type' => 'submit', 'class' => 'button', 'value' => gettext($mode) ))); return HTML($html,$form); } }; // Local Variables: // mode: php // tab-width: 8 // c-basic-offset: 4 // c-hanging-comment-ender-p: nil // indent-tabs-mode: nil // End: ?>