class OldSearchAd in Google AdSense integration 8
Provides an AdSense old search engine form.
Plugin annotation
@AdsenseAd(
id = "oldsearch",
name = @Translation("Old search"),
isSearch = TRUE,
needsSlot = FALSE
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\adsense\AdsenseAdBase implements AdsenseAdInterface, ContainerFactoryPluginInterface uses StringTranslationTrait
- class \Drupal\adsense\SearchAdBase
- class \Drupal\adsense_oldcode\Plugin\AdsenseAd\OldSearchAd
- class \Drupal\adsense\SearchAdBase
- class \Drupal\adsense\AdsenseAdBase implements AdsenseAdInterface, ContainerFactoryPluginInterface uses StringTranslationTrait
Expanded class hierarchy of OldSearchAd
1 file declares its use of OldSearchAd
- AdsenseOldSearchSettings.php in oldcode/
src/ Form/ AdsenseOldSearchSettings.php
File
- oldcode/
src/ Plugin/ AdsenseAd/ OldSearchAd.php, line 18
Namespace
Drupal\adsense_oldcode\Plugin\AdsenseAdView source
class OldSearchAd extends SearchAdBase {
/**
* Ad Channel.
*
* @var string
*/
private $channel;
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id = '', $plugin_definition = NULL, $config_factory = NULL, $module_handler = NULL, $current_user = NULL) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $config_factory, $module_handler, $current_user);
$this->channel = !empty($configuration['channel']) ? $configuration['channel'] : '';
}
/**
* {@inheritdoc}
*/
public function getAdPlaceholder() {
$client = PublisherId::get();
$content = "Old Search\nclient = {$client}";
return [
'#content' => [
'#markup' => nl2br($content),
],
'#format' => 'Search Box',
];
}
/**
* {@inheritdoc}
*/
public function getAdContent() {
$client = PublisherId::get();
$this->moduleHandler
->alter('adsense', $client);
$config = $this->configFactory
->get('adsense_oldcode.settings');
$logo = $config
->get('adsense_search_logo');
$box_background_color = $config
->get('adsense_search_color_box_background');
$domain_0 = $config
->get('adsense_search_domain_0');
$domain_1 = $config
->get('adsense_search_domain_1');
$domain_2 = $config
->get('adsense_search_domain_2');
$domain = $domain_1 ? "{$domain_0};{$domain_1}" : $domain_0;
$domain = $domain_2 ? "{$domain};{$domain_2}" : $domain;
// @todo this is necessary for unclean URLs.
/* global $base_url;
$results_path = $base_url;*/
return [
'#theme' => 'adsense_oldsearch_form',
'#country' => $config
->get('adsense_search_country'),
'#bg_color' => $box_background_color,
'#logo' => $logo,
'#logo_color' => $box_background_color == '#000000' ? 'blk' : ($box_background_color == '#CCCCCC' ? 'gry' : 'wht'),
'#hidden_q' => FALSE,
'#domain' => $domain,
'#qsize' => $config
->get('adsense_search_textbox_length'),
'#search_button' => $config
->get('adsense_search_button'),
'#btn' => $logo == 'adsense_search_logo_on_button' ? $this
->t('Google Search') : $this
->t('Search'),
'#box_text_color' => $config
->get('adsense_search_color_box_text'),
'#domain_0' => $domain_0,
'#domain_1' => $domain_1,
'#domain_2' => $domain_2,
'#client' => $client,
'#channel' => $config
->get('adsense_ad_channel_' . $this->channel),
'#encoding' => $config
->get('adsense_search_encoding'),
'#safe_mode' => $config
->get('adsense_search_safe_mode'),
'#url' => $config
->get('adsense_search_color_url'),
'#border' => $config
->get('adsense_search_color_border'),
'#visited' => $config
->get('adsense_search_color_visited_url'),
'#bg' => $config
->get('adsense_search_color_bg'),
'#logobg' => $config
->get('adsense_search_color_logo_bg'),
'#title' => $config
->get('adsense_search_color_title'),
'#text' => $config
->get('adsense_search_color_text'),
'#light' => $config
->get('adsense_search_color_light_url'),
'#language' => $config
->get('adsense_search_language'),
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AdsenseAdBase:: |
protected | property | Config factory. | |
AdsenseAdBase:: |
protected | property | Current user. | |
AdsenseAdBase:: |
protected | property | Module handler. | |
AdsenseAdBase:: |
public static | function |
List of available languages. Overrides AdsenseAdInterface:: |
|
AdsenseAdBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
AdsenseAdBase:: |
public static | function |
Creates the ad object, as specified by the definitions in the parameter. Overrides AdsenseAdInterface:: |
|
AdsenseAdBase:: |
public | function | Display ad HTML. | |
AdsenseAdBase:: |
public static | function | Check if ads display is disabled. | |
OldSearchAd:: |
private | property | Ad Channel. | |
OldSearchAd:: |
public | function |
Return the ad content. Overrides AdsenseAdInterface:: |
|
OldSearchAd:: |
public | function |
Return the ad placeholder. Overrides AdsenseAdInterface:: |
|
OldSearchAd:: |
public | function |
Creates a new AdsenseAdBase instance. Overrides AdsenseAdBase:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
SearchAdBase:: |
public static | function |
This is the array that holds all ad formats. Overrides AdsenseAdInterface:: |
|
SearchAdBase:: |
public static | function | Supply available countries for the search configuration forms. | |
SearchAdBase:: |
public static | function | Supply available encodings for the search configuration forms. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |