class DrupalMaskIconMetaTag in Metatag 7
Mask icon meta tag controller.
Hierarchy
- class \DrupalDefaultMetaTag implements DrupalMetaTagInterface
- class \DrupalTextMetaTag
- class \DrupalMaskIconMetaTag
- class \DrupalTextMetaTag
Expanded class hierarchy of DrupalMaskIconMetaTag
1 string reference to 'DrupalMaskIconMetaTag'
- metatag_favicons_metatag_info in metatag_favicons/
metatag_favicons.metatag.inc - Implements hook_metatag_info().
File
- metatag_favicons/
metatag_favicons.mask-icon.class.inc, line 11 - Custom class for the mask-icon meta tag's custom data.
View source
class DrupalMaskIconMetaTag extends DrupalTextMetaTag {
/**
* {@inheritdoc}
*/
public function getForm(array $options = array()) {
$form['value'] = array(
'#type' => 'textfield',
'#title' => $this->info['label'],
'#default_value' => isset($this->data['value']) ? $this->data['value'] : '',
'#description' => isset($this->info['description']) ? $this->info['description'] : '',
'#maxlength' => 1024,
'#weight' => $this
->getWeight(),
);
$form['color'] = array(
'#type' => 'textfield',
'#title' => t('Icon: SVG color'),
'#default_value' => isset($this->data['color']) ? $this->data['color'] : '',
'#description' => t('Provides a color for the SVG icon. Per <a href="@specs_url">Apple\'s specifications</a>, it may be a hexadecimal value (e.g. "#990000"), an RGB value (e.g. "rgb(153, 0, 0)"), or a recognized color-keyword (e.g. "red", "lime", "navy", etc). Will only be output if the SVG icon meta tag has a value.', array(
'@specs_url' => 'https://developer.apple.com/library/mac/releasenotes/General/WhatsNewInSafari/Articles/Safari_9_0.html#//apple_ref/doc/uid/TP40014305-CH9-SW20',
)),
'#maxlength' => 10,
'#weight' => $form['value']['#weight'] + 0.01,
);
return $form;
}
/**
* {@inheritdoc}
*/
public function getValue(array $options = array()) {
$value = array(
'value' => '',
'color' => NULL,
);
// The 'color' attribute will only be output if the 'value' is present.
if (!empty($this->data['value'])) {
// Pass the 'value' through the parent logic.
$value['value'] = parent::getValue($options);
// Get the optional 'color' attribute.
if (!empty($this->data['color'])) {
$value['color'] = check_plain($this
->tidyValue($this->data['color']));
}
}
return $value;
}
/**
* {@inheritdoc}
*/
public function getElement(array $options = array()) {
$value = $this
->getValue($options);
// This meta tag has two separate values.
$color = $value['color'];
$value = $value['value'];
// Don't bother proceeding if the 'value' is empty.
if (strlen($value) === 0) {
return array();
}
// The stack of elements that will be output.
$elements = array();
// Dynamically add each option to this setting.
$base_element = isset($this->info['element']) ? $this->info['element'] : array();
// Combine the base configuration for this meta tag with the value.
$element = $base_element + array(
'#theme' => 'metatag',
'#tag' => 'link',
'#id' => 'metatag_' . $this->info['name'] . '_' . 1,
'#rel' => $this->info['name'],
'#name' => $this->info['name'],
'#value' => $value,
'#color' => $color,
'#weight' => $this
->getWeight(),
);
// Add header information if desired.
if (!empty($this->info['header'])) {
$element['#attached']['drupal_add_http_header'][] = array(
$this->info['header'],
$value,
);
}
$elements[] = array(
$element,
$element['#id'],
);
return array(
'#attached' => array(
'drupal_add_html_head' => $elements,
),
);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalDefaultMetaTag:: |
protected | property | The values submitted for this tag. | |
DrupalDefaultMetaTag:: |
protected | property | All of the basic information about this tag. | |
DrupalDefaultMetaTag:: |
protected | property | This item's weight; used for sorting the output. | |
DrupalDefaultMetaTag:: |
protected | function | Make sure a given URL is absolute. | |
DrupalDefaultMetaTag:: |
public | function |
Calculate the weight of this meta tag. Overrides DrupalMetaTagInterface:: |
|
DrupalDefaultMetaTag:: |
protected | function | Identify the maximum length of which strings will be allowed. | |
DrupalDefaultMetaTag:: |
public static | function |
Copied from text.module with the following changes:. Overrides DrupalMetaTagInterface:: |
|
DrupalDefaultMetaTag:: |
protected | function | Remove unwanted formatting from a meta tag. | |
DrupalDefaultMetaTag:: |
protected | function | Shorten a string to a certain length using ::textSummary(). | |
DrupalDefaultMetaTag:: |
public | function |
Constructor. Overrides DrupalMetaTagInterface:: |
1 |
DrupalMaskIconMetaTag:: |
public | function |
Get the HTML tag for this meta tag. Overrides DrupalDefaultMetaTag:: |
|
DrupalMaskIconMetaTag:: |
public | function |
Build the form for this meta tag. Overrides DrupalTextMetaTag:: |
|
DrupalMaskIconMetaTag:: |
public | function |
Get the string value of this meta tag. Overrides DrupalTextMetaTag:: |