Last active
June 4, 2016 05:59
-
-
Save wluisi/e030726aab87a4de8544b7435b7e6066 to your computer and use it in GitHub Desktop.
uca_gcse_form.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Form builder for the searchbox forms. | |
*/ | |
function google_cse_searchbox_form_builder(&$form_state, $form_id, $self = FALSE) { | |
$form = array(); | |
// The default form. | |
if (variable_get('google_cse_results_display', 'here') == 'here') { | |
$form['#action'] = url($self ? $_GET['q'] : 'search/google'); | |
$cof = variable_get('google_cse_cof_here', 'FORID:11'); | |
} | |
else { | |
$form['#action'] = 'http://'. variable_get('google_cse_domain', 'www.google.com') .'/cse'; | |
$cof = variable_get('google_cse_cof_google', 'FORID:0'); | |
} | |
$form['#method'] = 'get'; | |
$form['cx'] = array( | |
'#type' => 'hidden', | |
'#value' => variable_get('google_cse_cx', ''), | |
); | |
$form['cof'] = array( | |
'#type' => 'hidden', | |
'#value' => $cof, | |
); | |
$form['query'] = array( | |
'#type' => 'textfield', | |
'#default_value' => isset($_GET['query']) ? $_GET['query'] : '', | |
); | |
$form['sa'] = array( | |
'#type' => 'submit', | |
'#value' => t('Search'), | |
); | |
foreach (google_cse_advanced_settings() as $parameter => $setting) { | |
$form[$parameter] = array( | |
'#type' => 'hidden', | |
'#value' => $setting, | |
); | |
} | |
// And the small differences between both. | |
switch ($form_id) { | |
case 'google_cse_searchbox_form': | |
$form['query']['#size'] = intval(variable_get('google_cse_searchbox_width', 15)); | |
$form['query']['#attributes']['title'] = t('Enter the terms you wish to search for.'); | |
break; | |
case 'google_cse_results_searchbox_form': | |
$form['query']['#size'] = intval(variable_get('google_cse_results_searchbox_width', 40)); | |
$form['query']['#title'] = t('Enter your keywords'); | |
if (variable_get('google_cse_results_gadget', 1)) { | |
$form['sa']['#suffix'] = theme('google_cse_results_gadget'); | |
} | |
break; | |
} | |
google_cse_sitesearch_form($form); | |
return $form; | |
} | |
?> | |
<form action="/search-gcse" accept-charset="UTF-8" method="get" id="google-cse-results-searchbox-form"> | |
<div> | |
<input type="hidden" name="cx" id="edit-cx" value="003353312815117394776:kpsngzbtr6w"> | |
<input type="hidden" name="cof" id="edit-cof" value="FORID:11"> | |
<div class="form-item" id="edit-query-wrapper"> | |
<label for="edit-query">Enter your keywords: </label> | |
<input type="text" maxlength="128" name="query" id="edit-query" size="40" value="" class="form-text" style="background: rgb(255, 255, 255);"> | |
</div> | |
<input type="submit" name="op" id="edit-sa" value="Search" class="form-submit"> | |
<input type="hidden" name="hl" id="edit-hl" value="en"> | |
<input type="hidden" name="lr" id="edit-lr" value="lang_en"> | |
<input type="hidden" name="form_build_id" id="form-L8NOcpTnmYPTFvRSwbG2aigKXB_zM4BCPdbVl55040U" value="form-L8NOcpTnmYPTFvRSwbG2aigKXB_zM4BCPdbVl55040U"> | |
<input type="hidden" name="form_id" id="edit-google-cse-results-searchbox-form" value="google_cse_results_searchbox_form"> | |
</div> | |
<input name="siteurl" type="hidden" value=""> | |
</form> | |
<div id="google-cse-results"></div> | |
<script type="text/javascript"> | |
//<![CDATA[ | |
var googleSearchIframeName = 'google-cse-results'; | |
var googleSearchFormName = 'google-cse-results-searchbox-form'; | |
var googleSearchFrameWidth = '714'; | |
var googleSearchFrameborder = 0; | |
var googleSearchDomain = 'www.google.com'; | |
var googleSearchPath = '/cse'; | |
//]]> | |
</script> | |
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment