bug fixing tode_url_outbound_alter
Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
parent
7ce8d94ed9
commit
35a5eb3a60
63
tode.module
63
tode.module
@ -779,7 +779,7 @@ function DESACTIVATED_tode_field_widget_form_alter(&$element, &$form_state, $con
|
||||
|
||||
foreach ($field['settings']['allowed_values'] as $key => $value) {
|
||||
|
||||
if($tode = _tode_get_voc_tode_fields_def($value['vocabulary'])){
|
||||
if($tode = _tode_get_voc_tode_field_def($value['vocabulary'])){
|
||||
|
||||
ctools_include('ajax');
|
||||
ctools_include('modal');
|
||||
@ -974,34 +974,41 @@ function tode_delete_submit($form, &$form_state){
|
||||
* Implements hook_url_outbound_alter().
|
||||
*/
|
||||
function tode_url_outbound_alter(&$path, &$options, $original_path) {
|
||||
|
||||
// dsm('tode_url_outbound_alter');
|
||||
# terms url
|
||||
$term = false;
|
||||
if(isset($options['entity_type']) && $options['entity_type'] == 'taxonomy_term'){
|
||||
// dsm('- - - - tode_url_outbound_alter');
|
||||
// dsm($path, '$path');
|
||||
// dsm($options, '$options');
|
||||
// dsm($original_path, '$original_path');
|
||||
|
||||
$term = $options['entity'];
|
||||
|
||||
}else{
|
||||
$args = explode('/', $original_path);
|
||||
// dsm($args, 'args');
|
||||
if($args[0] == 'taxonomy' && $args[1] == 'term' && is_numeric($args[2]) ){
|
||||
$term = taxonomy_term_load($args[2]);
|
||||
}
|
||||
|
||||
}
|
||||
// if(isset($options['entity_type']) && $options['entity_type'] == 'taxonomy_term'){
|
||||
// // dsm('- - - - tode_url_outbound_alter');
|
||||
// // dsm($path, '$path');
|
||||
// // dsm($options, '$options');
|
||||
// // dsm($original_path, '$original_path');
|
||||
//
|
||||
// $term = $options['entity'];
|
||||
//
|
||||
// }else{
|
||||
// $args = explode('/', $original_path);
|
||||
// // dsm($args, 'args');
|
||||
// if($args[0] == 'taxonomy' && $args[1] == 'term' && is_numeric($args[2]) ){
|
||||
// $term = taxonomy_term_load($args[2]);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
# WARNING works only because nodeandtermrelink_url_outbound_alter() is trigered before this
|
||||
if (preg_match('/^taxonomy\/term\/([0-9]*)$/', $path, $matches)) {
|
||||
$term = taxonomy_term_load($matches[1]);
|
||||
}
|
||||
|
||||
if($term){
|
||||
// dsm($term, '$term');
|
||||
if($field = _tode_get_voc_tode_fields_def($term->vocabulary_machine_name)){
|
||||
# add if widget setting;
|
||||
// dsm($term, '$term : '.$term->name);
|
||||
if($field = _tode_get_voc_tode_field_def($term->vocabulary_machine_name)){
|
||||
// dsm($field, '$field');
|
||||
// $field_settings = field_info_instance_settings($field->type);//field_info_widget_settings($field->field_name); //
|
||||
// dsm($field_settings, '$field_settings');
|
||||
# TODO add if widget setting; how to get the settings
|
||||
if (isset($field['widget']['settings']['redirect_term_to_node']) && $field['widget']['settings']['redirect_term_to_node']) {
|
||||
// dsm($field, '$field');
|
||||
// dsm($options, '$options');
|
||||
$sr = $field['storage']['details']['sql']['FIELD_LOAD_CURRENT'];
|
||||
$sr = $field['field_info_field']['storage']['details']['sql']['FIELD_LOAD_CURRENT'];
|
||||
foreach ($sr as $table => $column) {
|
||||
$query = db_select($table, 'ft');
|
||||
$query->join('node', 'n', 'ft.entity_id = n.nid AND n.language = :language OR n.language = :language', array(':language' => $options['language']->language, ':language' => 'und'));
|
||||
@ -1139,15 +1146,18 @@ function _tode_get_node_tode_fields_def($node){
|
||||
return $tode_fields;
|
||||
}
|
||||
|
||||
function _tode_get_voc_tode_fields_def($voc_name){
|
||||
function _tode_get_voc_tode_field_def($voc_name){
|
||||
$type_fields = field_info_instances('node');
|
||||
// dsm($type_fields, '$type_fields');
|
||||
foreach ($type_fields as $nodetype => $fields)
|
||||
foreach ($fields as $field_name => $field)
|
||||
if($field['widget']['type'] == 'tode'){
|
||||
// dsm($field, '$field');
|
||||
$fieldinfos = field_info_field($field_name);
|
||||
// dsm($fieldinfos, '$fieldinfos');
|
||||
$field['field_info_field'] = $fieldinfos;
|
||||
if($voc_name == $fieldinfos['settings']['allowed_values'][0]['vocabulary'])
|
||||
return $fieldinfos;
|
||||
return $field;
|
||||
}
|
||||
|
||||
|
||||
@ -1156,9 +1166,10 @@ function _tode_get_voc_tode_fields_def($voc_name){
|
||||
}
|
||||
|
||||
function tode_get_nids_from_term($term, $language = false){
|
||||
$todefield = _tode_get_voc_tode_fields_def($term->vocabulary_machine_name);
|
||||
|
||||
|
||||
if($todefield){
|
||||
if($todefield = _tode_get_voc_tode_field_def($term->vocabulary_machine_name)){
|
||||
// $fieldinfos = field_info_field($todefield->field_name);
|
||||
$query = new EntityFieldQuery();
|
||||
$query->entityCondition('entity_type', 'node')
|
||||
->fieldCondition($todefield['field_name'], 'tid', $term->tid);
|
||||
|
Loading…
x
Reference in New Issue
Block a user