You are here

class DrupalDateIntervalMetaTag in Metatag 7

Date interval meta tag controller.

Hierarchy

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

Namesort descending Modifiers Type Description Overrides
DrupalDateIntervalMetaTag::getForm public function Build the form for this meta tag. Overrides DrupalDefaultMetaTag::getForm
DrupalDateIntervalMetaTag::getValue public function Get the string value of this meta tag. Overrides DrupalDefaultMetaTag::getValue
DrupalDefaultMetaTag::$data protected property The values submitted for this tag.
DrupalDefaultMetaTag::$info protected property All of the basic information about this tag.
DrupalDefaultMetaTag::$weight protected property This item's weight; used for sorting the output.
DrupalDefaultMetaTag::convertUrlToAbsolute protected function Make sure a given URL is absolute.
DrupalDefaultMetaTag::getElement public function Get the HTML tag for this meta tag. Overrides DrupalMetaTagInterface::getElement 4
DrupalDefaultMetaTag::getWeight public function Calculate the weight of this meta tag. Overrides DrupalMetaTagInterface::getWeight
DrupalDefaultMetaTag::maxlength protected function Identify the maximum length of which strings will be allowed.
DrupalDefaultMetaTag::textSummary public static function Copied from text.module with the following changes:. Overrides DrupalMetaTagInterface::textSummary
DrupalDefaultMetaTag::tidyValue protected function Remove unwanted formatting from a meta tag.
DrupalDefaultMetaTag::truncate protected function Shorten a string to a certain length using ::textSummary().
DrupalDefaultMetaTag::__construct public function Constructor. Overrides DrupalMetaTagInterface::__construct 1