DevHeads.net

com web/php: update cse code: include/prepend.inc

Link: <a href="http://git.php.net/?p=web/php.git;a=commitdiff;h=426758701bcfa182ef5214eacb775a5c2584c1fb" title="http://git.php.net/?p=web/php.git;a=commitdiff;h=426758701bcfa182ef5214eacb775a5c2584c1fb">http://git.php.net/?p=web/php.git;a=commitdiff;h=426758701bcfa182ef5214e...</a>

Log:
update cse code

The old CSE code stopped working Dec 4th, use the new
recommended way of embedding CSE.

Thanks Philip!

Changed paths:
M include/prepend.inc

Diff:
diff --git a/include/prepend.inc b/include/prepend.inc
index 23ded65..7969612 100644
--- a/include/prepend.inc
+++ b/include/prepend.inc
@@ -209,27 +209,18 @@ function google_cse($default = '', $lang = 'en') {
php.net's search functionality requires JavaScript to operate. Please enable
JavaScript and reload to continue.
</noscript>
-<div id="cse" style="width: 100%;"></div>
-<script src="//www.google.com/jsapi" type="text/javascript"></script>
-<script type="text/javascript">
- document.getElementById("cse").innerHTML = "Loading...";
- google.load('search', '1', {language : '<?php echo $lang; ?>', style : google.loader.themes.MINIMALIST});
- google.setOnLoadCallback(function() {
- var customSearchOptions = {};
- var customSearchControl = new google.search.CustomSearchControl(
- '011570197911755000456:fip9wopfz_u', customSearchOptions);
- customSearchControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);
- customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
- var options = new google.search.DrawOptions();
- options.setAutoComplete(true);
- customSearchControl.draw('cse', options);
-<?php
- if ($default) {
- echo " customSearchControl.execute(" . json_encode($default) . ");";
- }
-?>
- }, true);
+<script>
+ (function() {
+ var cx = '011570197911755000456:fip9wopfz_u';
+ var gcse = document.createElement('script');
+ gcse.type = 'text/javascript';
+ gcse.async = true;
+ gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
+ var s = document.getElementsByTagName('script')[0];
+ s.parentNode.insertBefore(gcse, s);
+ })();
</script>
+<gcse:search></gcse:search>
<?php
}