New version 6.x-1.4 of Node clone module

This commit is contained in:
Manuel Cillero 2017-08-05 11:51:57 +02:00
parent cd51ed4595
commit 2f7b56d013
9 changed files with 437 additions and 248 deletions

View file

@ -1,4 +1,8 @@
<?php
/**
* @file
* Views settings for Node_Clone module.
*/
/**
* Implementation of hook_views_handlers()

View file

@ -1,4 +1,8 @@
<?php
/**
* @file
* Views field handler for Node_Clone module.
*/
/**
* Field handler to present a clone node link.
@ -13,6 +17,33 @@ class views_handler_field_node_link_clone extends views_handler_field_node_link
$this->additional_fields['format'] = array('table' => 'node_revisions', 'field' => 'format');
}
/**
* Determine if this field can allow advanced rendering.
*
* Fields can set this to FALSE if they do not wish to allow
* token based rewriting or link-making.
*/
function allow_advanced_render() {
return FALSE;
}
function option_definition() {
$options = parent::option_definition();
$options['destination'] = array('default' => 1, 'translatable' => FALSE);
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['destination'] = array(
'#type' => 'checkbox',
'#title' => t('Add destination query string to return to the View'),
'#default_value' => $this->options['destination'],
);
}
function render($values) {
// Insure that user has access to clone this node.
$node = new stdClass();
@ -26,6 +57,10 @@ class views_handler_field_node_link_clone extends views_handler_field_node_link
}
$text = !empty($this->options['text']) ? $this->options['text'] : t('clone');
return l($text, "node/$node->nid/clone", array('query' => drupal_get_destination()));
$options = array();
if ($this->options['destination']) {
$options['query'] = drupal_get_destination();
}
return l($text, "node/$node->nid/clone", $options);
}
}