You are here

class LinkitPluginTaxonomy_Term in Linkit 7.2

@file Define Linkit term plugin class.

Hierarchy

Expanded class hierarchy of LinkitPluginTaxonomy_Term

File

plugins/linkit_plugins/linkit-plugin-taxonomy_term.class.php, line 7
Define Linkit term plugin class.

View source
class LinkitPluginTaxonomy_Term extends LinkitPluginEntity {
  function __construct($plugin, $profile) {

    /**
     * The term entity dont use the same column name as in the entity keys
     * bundle definition, so lets add it our self.
     */
    $this->entity_key_bundle = 'vid';
    parent::__construct($plugin, $profile);
  }

  /**
   * When "group_by_bundle" is active, we need to add the bundle name to the
   * group, else just return the entity label.
   *
   * @return a string with the group name.
   */
  function buildGroup($entity) {

    // Get the entity label.
    $group = $this->entity_info['label'];
    if (isset($this->conf['group_by_bundle']) && $this->conf['group_by_bundle']) {
      $bundles = $this->entity_info['bundles'];
      $bundle_name = $bundles[$entity->vocabulary_machine_name]['label'];
      $group .= ' · ' . check_plain($bundle_name);
    }
    return $group;
  }

  /**
   * Settings for the term plugin.
   */
  function buildSettingsForm() {
    $form = parent::buildSettingsForm();

    // The entity plugin uses the entity name for the #token_types, but terms
    // is a special case, its name is "Taxonomy_term" and the tokens are defined
    // (in the taxonomy module) with just "term".
    if (isset($form[$this->plugin['name']]['token_help']['help']['#token_types'])) {
      $form[$this->plugin['name']]['token_help']['help']['#token_types'] = array(
        'term',
      );
    }
    return $form;
  }

  /**
   * The autocomplete callback function for the Linkit Taxonomy term plugin.
   */
  function autocomplete_callback() {

    // The term entity dont use the entity keys bundle definition, its using the
    // vid instead, so lets 'translate' the bundle names to vids.
    if (isset($this->entity_key_bundle) && isset($this->conf['bundles'])) {
      $bundles = array_filter($this->conf['bundles']);

      // Get all vocabularies.
      $vocabularies = taxonomy_vocabulary_get_names();

      // Temp storage for values.
      $tmp_bundles = array();
      foreach ($bundles as $bundle) {
        $tmp_bundles[] = $vocabularies[$bundle]->{$this->entity_key_bundle};
      }

      // Assign the new values as the bundles.
      $this->conf['bundles'] = $tmp_bundles;
    }

    // Call the parent.
    return parent::autocomplete_callback();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LinkitPlugin::broken function Determine if the handler is considered 'broken', meaning it's a a placeholder used when a handler can't be found. 1
LinkitPlugin::buildRowClass function Returns a string with CSS classes that will be added to the search result row for this item. 1
LinkitPlugin::setSearchString function Set the search string.
LinkitPlugin::ui_description function Return a string representing this handler's description in the UI. 2
LinkitPlugin::ui_title function Return a string representing this handler's name in the UI. 2
LinkitPluginEntity::$conf property Plugin specific settings.
LinkitPluginEntity::$entity_field_label property The name of the property that contains the entity label.
LinkitPluginEntity::$entity_info property The entity info array of an entity type.
LinkitPluginEntity::$entity_key_bundle property The name of the property of the bundle object that contains the name of the bundle object.
LinkitPluginEntity::$query property Entity field query instance.
LinkitPluginEntity::buildDescription function Build the search row description. Overrides LinkitPlugin::buildDescription 1
LinkitPluginEntity::buildLabel function Build the label that will be used in the search result for each row. Overrides LinkitPlugin::buildLabel 1
LinkitPluginEntity::buildPath function Build an URL based in the path and the options. Overrides LinkitPlugin::buildPath 1
LinkitPluginEntity::buildReverseMenuTrail function Builds a reverse menu trail for the entity.
LinkitPluginEntity::getQueryInstance function Start a new EntityFieldQuery instance. 2
LinkitPluginTaxonomy_Term::autocomplete_callback function The autocomplete callback function for the Linkit Taxonomy term plugin. Overrides LinkitPluginEntity::autocomplete_callback
LinkitPluginTaxonomy_Term::buildGroup function When "group_by_bundle" is active, we need to add the bundle name to the group, else just return the entity label. Overrides LinkitPluginEntity::buildGroup
LinkitPluginTaxonomy_Term::buildSettingsForm function Settings for the term plugin. Overrides LinkitPluginEntity::buildSettingsForm
LinkitPluginTaxonomy_Term::__construct function Initialize this plugin with the plugin, profile, and entity specific variables. Overrides LinkitPluginEntity::__construct