Source of file GoogleSiteSearchDefaultFormExtension.php
Size: 1,575 Bytes - Last Modified: 2021-12-24T06:45:00+00:00
/var/www/docs.ssmods.com/process/src/src/Extensions/GoogleSiteSearchDefaultFormExtension.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 | <?php namespace DNADesign\GoogleSiteSearch\Extensions; use DNADesign\GoogleSiteSearch\Pages\GoogleSiteSearchPage; use SilverStripe\Control\Controller; use SilverStripe\Core\Config\Config; use SilverStripe\Core\Config\Configurable; use SilverStripe\Core\Extension; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; use SilverStripe\Forms\FormAction; use SilverStripe\Forms\TextField; /** * @package googlesitesearch */ class GoogleSiteSearchDefaultFormExtension extends Extension { use Configurable; /** * @var array */ private static $allowed_actions = [ 'GoogleSiteSearchForm', ]; /** * Return a form which sends the user to the first results page. If you want * to customize this form, use your own extension and apply that to the * page. * * @return Form */ public function GoogleSiteSearchForm() { if ($page = GoogleSiteSearchPage::get()->first()) { $label = $this->owner->config()->get('submit_button_label'); $formLabel = $this->owner->config()->get('input_label'); $form = new Form( Controller::curr(), 'GoogleSiteSearchForm', new FieldList(new TextField('Search', $formLabel)), new FieldList(new FormAction('doSearch', $label)) ); $form->setFormMethod('GET'); $form->setFormAction($page->Link()); $form->disableSecurityToken(); $form->loadDataFrom($_GET); return $form; } } } |