function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
function google_custom_search_menu() { // $config = variable_get( "google_custom_search" ,array()); $pagelink = "search/google-custom-search" ; $type = MENU_LOCAL_TASK; if ($config[ 'page' ]) { $pagelink = $config[ 'page' ]; $type = MENU_SUGGESTED_ITEM; } $items[$pagelink] = array( 'title' => ($config[ 'pagename' ]?$config[ 'pagename' ]: 'Google Custom Search' ), 'page callback' => 'google_custom_search_page' , 'page arguments' => array($config), 'access arguments' => array( 'use google custom search' ), 'type' => $type, ); return $items; } * This source code was highlighted with Source Code Highlighter .
* This source code was highlighted with Source Code Highlighter .
- function google_custom_search_main_form () {
- // Connect Pathauto
- _pathauto_include ();
- // Pathauto Settings
- $ all_settings = module_invoke_all ( 'pathauto' , 'settings' );
- // Types of materials
- $ types = node_get_types ( 'types' );
- // In the cycle we get all available types of materials, blogs and users
- foreach ($ all_settings as $ settings) {
- $ module = $ settings-> module;
- switch ($ module) {
- case 'user' :
- // ...
- break ;
- case 'node' :
- foreach ($ settings-> patternitems as $ itemname => $ itemlabel) {
- // ...
- }
- break ;
- case 'blog' :
- // ...
- break ;
- }
- }
- // Print everything on the form
- $ form = array ();
- $ form [ 'materials' ] = array (
- '#type' => 'fieldset' ,
- '#title' => 'Advanced Search' ,
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- );
- foreach ($ final as $ i => $ v) {
- $ form [ 'materials' ] [$ names [$ i]] = array (
- '#type' => 'checkbox' ,
- '#title' => $ v,
- '#default_value' => 0,
- '#name' => $ i,
- '#attributes' => array ( 'class' => 'google_custom_search_checkbox' ),
- );
- }
- return $ form;
- }
* This source code was highlighted with Source Code Highlighter .
- function google_custom_search_page ($ config) {
- if (! $ config) {
- drupal_set_message ( "Google Custom Search module is not configured. Please contact your administrator." , 'warning' );
- return FALSE;
- }
- $ output = drupal_get_form ( 'google_custom_search_main_form' );
- $ key = $ config [ 'key' ];
- $ host = $ _SERVER [ 'HTTP_HOST' ];
- if ($ config [ 'host' ]) {
- $ host = $ config [ 'host' ];
- }
- $ style = $ config [ 'style' ];
- $ string = isset ($ _ POST [ 'google_custom_search_string' ])? htmlspecialchars ($ _ POST [ 'google_custom_search_string' ]): "" ;
- $ output. = <<< THIS
- <script type = "text / javascript" src = "http://www.google.com/jsapi?key=$key" > </ script>
- <script type = "text / javascript" >
- google.load ( "search" , "1" , { "nocss" : true });
- function OnLoad () {
- // Download Google CSE
- searchHost = "$ host /" ;
- searchControl = new google.search.SearchControl ();
- // Set the output type
- searchControl.setResultSetSize (google.search.Search.LARGE_RESULTSET);
- var siteSearch = new google.search.WebSearch ();
- siteSearch.setUserDefinedClassSuffix ( "siteSearch" );
- siteSearch.setSiteRestriction (searchHost);
- // By default, we search the entire site
- siteSearch.setUserDefinedLabel ( "All Results" );
- searchControl.addSearcher (siteSearch);
- var drawOptions = new google.search.DrawOptions ();
- // Output style depending on the module settings (tabs or one after another)
- drawOptions.setDrawMode (google.search.SearchControl. $ style);
- searchControl.draw (document.getElementById ( "searchcontrol" ), drawOptions);
- searchControl.execute ( "$ string" );
- }
- // Update Google CSE when choosing the type of material (the same, but different tabs for different types of materials)
- $ ( '.google_custom_search_checkbox' ) .change (function () {
- delete searchControl;
- searchControl = new google.search.SearchControl ();
- searchControl.setResultSetSize (google.search.Search.LARGE_RESULTSET);
- var siteSearch = new google.search.WebSearch ();
- siteSearch.setUserDefinedClassSuffix ( 'siteSearch' );
- siteSearch.setSiteRestriction (searchHost);
- siteSearch.setUserDefinedLabel ( 'All Results' );
- searchControl.addSearcher (siteSearch);
- // Pass through all selected types
- $ ( '.google_custom_search_checkbox' ) .each (function () {
- if ($ ( this ) .attr ( 'checked' )) {
- var siteSearch = new google.search.WebSearch ();
- siteSearch.setUserDefinedClassSuffix ( 'siteSearch' );
- var newSearchName = $ ( this ) .parent (). text (). replace (/ / g, '' ) .replace (/ (^ \ s +) | (\ s + $) / g, '' );
- var newSearchHost = searchHost + $ ( this ) .attr ( 'name' ) .replace (/ / g, '' ) .replace (/ (^ \ s +) | (\ s + $) / g, '' );
- siteSearch.setSiteRestriction (newSearchHost);
- siteSearch.setUserDefinedLabel (newSearchName);
- searchControl.addSearcher (siteSearch);
- }
- });
- var drawOptions = new google.search.DrawOptions ();
- drawOptions.setDrawMode (google.search.SearchControl. $ style);
- searchControl.draw (document.getElementById ( 'searchcontrol' ), drawOptions);
- });
- google.setOnLoadCallback (OnLoad, true );
- </ script>
- THIS;
- return $ output;
- }
Source: https://habr.com/ru/post/79860/
All Articles