Now all modules are in core modules folder
This commit is contained in:
parent
5ba1cdfa0b
commit
05b6a91b0c
1907 changed files with 0 additions and 0 deletions
56
modules/content_taxonomy/includes/content_taxonomy.token.inc
Normal file
56
modules/content_taxonomy/includes/content_taxonomy.token.inc
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Implementation of hook_token_list().
|
||||
*/
|
||||
function content_taxonomy_token_list($type = 'all') {
|
||||
if ($type == 'field' || $type == 'all') {
|
||||
$tokens = array();
|
||||
|
||||
$tokens['content_taxonomy']['term'] = t('Name of top taxonomy term');
|
||||
$tokens['content_taxonomy']['term-raw'] = t('Unfiltered name of top taxonomy term. WARNING - raw user input.');
|
||||
$tokens['content_taxonomy']['tid'] = t('ID of top taxonomy term');
|
||||
$tokens['content_taxonomy']['terms'] = t('Names of all taxonomy terms separated by commas');
|
||||
$tokens['content_taxonomy']['terms-raw'] = t('Unfiltered names of all taxonomy terms separated by commas. WARNING - raw user input.');
|
||||
$tokens['content_taxonomy']['tids'] = t('IDs of all taxonomy terms separated by commas');
|
||||
$tokens['content_taxonomy']['vocab'] = t('Name of terms vocabulary');
|
||||
$tokens['content_taxonomy']['vid'] = t('ID of terms vocabulary');
|
||||
|
||||
return $tokens;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_token_values().
|
||||
*/
|
||||
function content_taxonomy_token_values($type, $object = NULL) {
|
||||
if ($type == 'field') {
|
||||
$items = $object;
|
||||
$terms = array();
|
||||
$tids = array();
|
||||
|
||||
foreach ($items as $item) {
|
||||
$tid = $item['value'];
|
||||
if ($tid) {
|
||||
$term = taxonomy_get_term($tid);
|
||||
$tids[] = $tid;
|
||||
$terms[] = $term->name;
|
||||
$vid = $term->vid;
|
||||
}
|
||||
}
|
||||
if ($vid) {
|
||||
$vocabulary = taxonomy_vocabulary_load($vid);
|
||||
}
|
||||
|
||||
$tokens['terms-raw'] = implode(', ', $terms);
|
||||
$tokens['terms'] = check_plain($tokens['terms-raw']);
|
||||
$tokens['tids'] = implode(', ', $tids);
|
||||
$tokens['term-raw'] = $terms[0];
|
||||
$tokens['term'] = check_plain($tokens['term-raw']);
|
||||
$tokens['tid'] = $tids[0];
|
||||
$tokens['vocab'] = isset($vocabulary) ? $vocabulary->name : '';
|
||||
$tokens['vid'] = $vid;
|
||||
|
||||
return $tokens;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Implementation of hook_views_handlers().
|
||||
*/
|
||||
function content_taxonomy_views_handlers() {
|
||||
return array(
|
||||
'info' => array(
|
||||
'path' => drupal_get_path('module', 'content_taxonomy') . '/includes/views',
|
||||
),
|
||||
'handlers' => array(
|
||||
'content_taxonomy_handler_filter_many_to_one' => array(
|
||||
'parent' => 'content_handler_filter_many_to_one',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Subclass of views_handler_filter_many_to_one_content
|
||||
*
|
||||
* provides values for the filters
|
||||
* unsets the empty value for non required fields, which is added content_taxonomy_allowed_values
|
||||
*/
|
||||
class content_taxonomy_handler_filter_many_to_one extends content_handler_filter_many_to_one {
|
||||
var $content_field;
|
||||
|
||||
function construct() {
|
||||
parent::construct();
|
||||
}
|
||||
|
||||
function get_value_options() {
|
||||
$options = content_taxonomy_allowed_values($this->content_field);
|
||||
unset($options['']);
|
||||
$this->value_options = $options;
|
||||
}
|
||||
}
|
Reference in a new issue