class LinkitPluginTaxonomy_Term in Linkit 7.2
@file Define Linkit term plugin class.
Hierarchy
- class \LinkitPlugin implements LinkitPluginInterface
- class \LinkitPluginEntity
- class \LinkitPluginTaxonomy_Term
- class \LinkitPluginEntity
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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LinkitPlugin:: |
function | Determine if the handler is considered 'broken', meaning it's a a placeholder used when a handler can't be found. | 1 | |
LinkitPlugin:: |
function | Returns a string with CSS classes that will be added to the search result row for this item. | 1 | |
LinkitPlugin:: |
function | Set the search string. | ||
LinkitPlugin:: |
function | Return a string representing this handler's description in the UI. | 2 | |
LinkitPlugin:: |
function | Return a string representing this handler's name in the UI. | 2 | |
LinkitPluginEntity:: |
property | Plugin specific settings. | ||
LinkitPluginEntity:: |
property | The name of the property that contains the entity label. | ||
LinkitPluginEntity:: |
property | The entity info array of an entity type. | ||
LinkitPluginEntity:: |
property | The name of the property of the bundle object that contains the name of the bundle object. | ||
LinkitPluginEntity:: |
property | Entity field query instance. | ||
LinkitPluginEntity:: |
function |
Build the search row description. Overrides LinkitPlugin:: |
1 | |
LinkitPluginEntity:: |
function |
Build the label that will be used in the search result for each row. Overrides LinkitPlugin:: |
1 | |
LinkitPluginEntity:: |
function |
Build an URL based in the path and the options. Overrides LinkitPlugin:: |
1 | |
LinkitPluginEntity:: |
function | Builds a reverse menu trail for the entity. | ||
LinkitPluginEntity:: |
function | Start a new EntityFieldQuery instance. | 2 | |
LinkitPluginTaxonomy_Term:: |
function |
The autocomplete callback function for the Linkit Taxonomy term plugin. Overrides LinkitPluginEntity:: |
||
LinkitPluginTaxonomy_Term:: |
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:: |
||
LinkitPluginTaxonomy_Term:: |
function |
Settings for the term plugin. Overrides LinkitPluginEntity:: |
||
LinkitPluginTaxonomy_Term:: |
function |
Initialize this plugin with the plugin, profile, and entity specific
variables. Overrides LinkitPluginEntity:: |