You are here

class DrupalListMetaTag in Metatag 7

Multiple value meta tag controller.

Hierarchy

Expanded class hierarchy of DrupalListMetaTag

7 string references to 'DrupalListMetaTag'
metatag_context_i18n_object_info in metatag_context/metatag_context.i18n.inc
Implements hook_i18n_object_info().
metatag_devel_node_insert in metatag_devel/metatag_devel.module
Implements hook_node_insert().
metatag_i18n_object_info in ./metatag.i18n.inc
Implements hook_i18n_object_info().
metatag_metatag_info in ./metatag.metatag.inc
Implements hook_metatag_info().
metatag_panels_i18n_object_info in metatag_panels/metatag_panels.i18n.inc
Implements hook_i18n_object_info().

... See full list

File

./metatag.inc, line 703
Metatag primary classes.

View source
class DrupalListMetaTag extends DrupalDefaultMetaTag {

  /**
   * {@inheritdoc}
   */
  public function __construct(array $info, array $data = NULL) {

    // Ensure that the $data['value] argument is an array.
    if (empty($data['value'])) {
      $data['value'] = array();
    }
    $data['value'] = (array) $data['value'];
    parent::__construct($info, $data);
  }

  /**
   * {@inheritdoc}
   */
  public function getForm(array $options = array()) {
    $form['value'] = isset($this->info['form']) ? $this->info['form'] : array();
    $form['value'] += array(
      '#type' => 'checkboxes',
      '#title' => $this->info['label'],
      '#description' => !empty($this->info['description']) ? $this->info['description'] : '',
      '#default_value' => isset($this->data['value']) ? $this->data['value'] : array(),
    );
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function getValue(array $options = array()) {
    $values = array_keys(array_filter($this->data['value']));
    sort($values);
    $value = implode(', ', $values);
    $value = $this
      ->tidyValue($value);

    // 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
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().
DrupalListMetaTag::getForm public function Build the form for this meta tag. Overrides DrupalDefaultMetaTag::getForm
DrupalListMetaTag::getValue public function Get the string value of this meta tag. Overrides DrupalDefaultMetaTag::getValue
DrupalListMetaTag::__construct public function Constructor. Overrides DrupalDefaultMetaTag::__construct