class DrupalDateIntervalMetaTag in Metatag 7
Date interval meta tag controller.
Hierarchy
- class \DrupalDefaultMetaTag implements DrupalMetaTagInterface
- class \DrupalDateIntervalMetaTag
Expanded class hierarchy of DrupalDateIntervalMetaTag
1 string reference to 'DrupalDateIntervalMetaTag'
- metatag_metatag_info in ./
metatag.metatag.inc - Implements hook_metatag_info().
File
- ./
metatag.inc, line 756 - Metatag primary classes.
View source
class DrupalDateIntervalMetaTag extends DrupalDefaultMetaTag {
/**
* {@inheritdoc}
*/
public function getForm(array $options = array()) {
$form['value'] = array(
'#type' => 'textfield',
'#title' => t('!title interval', array(
'!title' => $this->info['label'],
)),
'#default_value' => isset($this->data['value']) ? $this->data['value'] : '',
'#element_validate' => array(
'element_validate_integer_positive',
),
'#maxlength' => 4,
'#description' => isset($this->info['description']) ? $this->info['description'] : '',
);
$form['period'] = array(
'#type' => 'select',
'#title' => t('!title interval type', array(
'!title' => $this->info['label'],
)),
'#default_value' => isset($this->data['period']) ? $this->data['period'] : '',
'#options' => array(
'' => t('- none -'),
'day' => t('Day(s)'),
'week' => t('Week(s)'),
'month' => t('Month(s)'),
'year' => t('Year(s)'),
),
);
return $form;
}
/**
* {@inheritdoc}
*/
public function getValue(array $options = array()) {
$value = '';
if (!empty($this->data['value'])) {
$interval = intval($this->data['value']);
if (!empty($interval) && !empty($this->data['period'])) {
$period = $this->data['period'];
$value = format_plural($interval, '@count ' . $period, '@count ' . $period . 's');
}
}
// Translate the final output string prior to output. Use the 'output'
// i18n_string object type, and pass along the meta tag's options as the
// context so it can be handled appropriately.
$value = metatag_translate_metatag($value, $this->info['name'], $options, NULL, TRUE);
return $value;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalDateIntervalMetaTag:: |
public | function |
Build the form for this meta tag. Overrides DrupalDefaultMetaTag:: |
|
DrupalDateIntervalMetaTag:: |
public | function |
Get the string value of this meta tag. Overrides DrupalDefaultMetaTag:: |
|
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 |
Get the HTML tag for this meta tag. Overrides DrupalMetaTagInterface:: |
4 |
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 |