Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
google_cse
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
google_cse
Commits
9fc10d1a
Commit
9fc10d1a
authored
4 years ago
by
jeff cardwell
Committed by
Polo Reynaga
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3159988
by Jeff Cardwell, gravelpot: Remove references to "Google CSE Advanced"
parent
7b9ead94
Branches
Branches containing commit
Tags
8.x-3.2
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/Search/GoogleCSESearch.php
+6
-81
6 additions, 81 deletions
src/Plugin/Search/GoogleCSESearch.php
with
6 additions
and
81 deletions
src/Plugin/Search/GoogleCSESearch.php
+
6
−
81
View file @
9fc10d1a
...
...
@@ -135,7 +135,6 @@ class GoogleCSESearch extends ConfigurableSearchPluginBase implements Accessible
'safe'
=>
''
,
'custom_css'
=>
''
,
'custom_results_display'
=>
'results-only'
,
'use_adv'
=>
0
,
];
return
$configuration
;
}
...
...
@@ -168,64 +167,16 @@ class GoogleCSESearch extends ConfigurableSearchPluginBase implements Accessible
* {@inheritdoc}
*/
public
function
execute
()
{
$keys
=
$this
->
getKeywords
();
// @todo $condition is an unused variable verify and remove it.
$conditions
=
$this
->
searchParameters
[
'search_conditions'
];
if
(
$this
->
configuration
[
'use_adv'
])
{
$response
=
$this
->
googlecseservices
->
service
(
$keys
);
$results
=
$this
->
googlecseservices
->
responseResults
(
$response
[
0
],
$keys
,
$conditions
);
// Allow other modules to alter the keys.
$this
->
moduleHandler
->
alter
(
'google_cse_searched_keys'
,
$keys
);
// Allow other modules to alter the results.
$this
->
moduleHandler
->
alter
(
'google_cse_searched_results'
,
$results
);
return
$results
;
}
// This function must remain to satisfy the
// Drupal/search//Plugin/SearchInterface, but we have no use for it.
}
/**
* {@inheritdoc}
*/
public
function
buildResults
()
{
$results
=
$this
->
execute
();
// @see https://www.drupal.org/node/2195739
if
(
!
(
$this
->
configuration
[
'use_adv'
]))
{
$output
[]
=
[
'#theme'
=>
'google_cse_results'
];
return
$output
;
}
if
(
!
$results
)
{
// No results found.
$output
[]
=
[
'#theme'
=>
'google_cse_search_noresults'
];
}
if
(
$this
->
requestStack
->
getCurrentRequest
()
->
query
->
has
(
'page'
))
{
$current_page
=
$this
->
requestStack
->
getCurrentRequest
()
->
query
->
get
(
'page'
);
$number_results
=
t
(
'Results @from to @to of @total matches.'
,
[
'@from'
=>
$current_page
*
10
,
'@to'
=>
$current_page
*
10
+
10
,
'@total'
=>
$GLOBALS
[
'pager_total_items'
][
0
],
]);
$output
[
'prefix'
][
'#markup'
]
=
$number_results
.
'<ol class="search-results">'
;
}
foreach
(
$results
as
$entry
)
{
$output
[]
=
[
'#theme'
=>
'search_result'
,
'#result'
=>
$entry
,
'#plugin_id'
=>
$this
->
getPluginId
(),
];
}
if
(
$this
->
requestStack
->
getCurrentRequest
()
->
query
->
has
(
'page'
))
{
// Important, add the pager.
$pager
=
[
'#type'
=>
'pager'
];
$output
[
'suffix'
][
'#markup'
]
=
'</ol>'
.
$this
->
renderer
->
render
(
$pager
);
}
// Results are primarily generated by the Google API.
$output
[]
=
[
'#theme'
=>
'google_cse_results'
];
return
$output
;
}
...
...
@@ -244,21 +195,9 @@ class GoogleCSESearch extends ConfigurableSearchPluginBase implements Accessible
* {@inheritdoc}
*/
public
function
buildSearchUrlQuery
(
FormStateInterface
$form_state
)
{
// Read keyword and advanced search information from the form values,
// and put these into the GET parameters.
$keys
=
trim
(
$form_state
->
getValue
(
'keys'
));
if
(
!
$this
->
configuration
[
'use_adv'
])
{
return
[
'keys'
=>
$keys
];
}
// @TODO check usage of $here and $sitesearch
$sitesearch
=
NULL
;
$here
=
FALSE
;
return
[
'keys'
=>
$keys
,
'cx'
=>
$this
->
configuration
[
'cx'
],
'cof'
=>
$here
?
$this
->
configuration
[
'cof_here'
]
:
$this
->
configuration
[
'cof_google'
],
'sitesearch'
=>
isset
(
$sitesearch
)
?
$sitesearch
:
$this
->
googlecseservices
->
sitesearchDefault
(),
]
+
$this
->
googlecseservices
->
advancedSettings
();
return
[
'keys'
=>
$keys
];
}
/**
...
...
@@ -575,19 +514,6 @@ class GoogleCSESearch extends ConfigurableSearchPluginBase implements Accessible
]),
];
$form
[
'google_cse_adv'
]
=
[
'#title'
=>
$this
->
t
(
'Google CSE Advanced'
),
'#type'
=>
'details'
,
'#open'
=>
TRUE
,
];
$form
[
'google_cse_adv'
][
'use_adv'
]
=
[
'#title'
=>
t
(
'Use advanced, ad-free version, search engine (You will need a paid account with Google)'
),
'#type'
=>
'checkbox'
,
'#default_value'
=>
$this
->
configuration
[
'use_adv'
]
??
''
,
'#description'
=>
$this
->
t
(
'If enabled, search results will be fetch using Adv engine.'
),
];
return
$form
;
}
...
...
@@ -624,7 +550,6 @@ class GoogleCSESearch extends ConfigurableSearchPluginBase implements Accessible
$this
->
configuration
[
'safe'
]
=
$values
[
'safe'
];
$this
->
configuration
[
'custom_css'
]
=
$values
[
'custom_css'
];
$this
->
configuration
[
'custom_results_display'
]
=
$values
[
'custom_results_display'
];
$this
->
configuration
[
'use_adv'
]
=
$values
[
'use_adv'
];
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment