Commit 1b622087 authored by das-peter's avatar das-peter

Issue #2546728 by anfor, shawn_smiley, sun, das-peter: Edition of a node...

Issue #2546728 by anfor, shawn_smiley, sun, das-peter: Edition of a node revision with Entity Translation language switcher
parent a2eb6e46
<?php
/**
* @file
* Node revision translation handler for the State Flow module.
*/
/**
* State Flow translation handler.
*
* Overrides Node behaviors for State Flow revision.
*
* @see state_flow_entity_info_alter().
*/
class EntityTranslationStateFlowHandler extends EntityTranslationNodeHandler {
/**
* @see EntityTranslationHandlerInterface::getCurrentEntityRevision()
*/
public function getCurrentEntityRevision() {
// If we're in the path scheme state_flow_entity a dedicated revision is
// edited thus don't overwrite it with the current one.
$this->initPathScheme();
if (!$this->isNewEntity() && $this->getPathScheme() == 'state_flow') {
return $this->entity;
}
return parent::getCurrentEntityRevision();
}
}
\ No newline at end of file
......@@ -21,3 +21,6 @@ files[] = includes/views/state_flow_handler_field_events.inc
files[] = includes/views/state_flow_handler_field_workflow_link.inc
files[] = includes/views/state_flow_handler_filter_state.inc
files[] = includes/views/state_flow_handler_field_is_node_revision_published.inc
; Entity Translation handlers
files[] = includes/entity_translation/state_flow_handler_node.inc
\ No newline at end of file
......@@ -22,8 +22,18 @@ function state_flow_menu() {
'weight' => 10,
'file' => 'state_flow.pages.inc',
);
$items['node/%node/revisions/%/edit'] = array(
// This item required to have a valid path scheme for entity_translation.
$items['node/%node/revisions/%state_flow_revision_node'] = array(
'title' => 'Revisions',
'load arguments' => array(3),
'page callback' => 'node_show',
'page arguments' => array(1, TRUE),
'access callback' => '_node_revision_access',
'access arguments' => array(1),
);
$items['node/%node/revisions/%state_flow_revision_node/edit'] = array(
'title' => 'Edit an earlier revision',
'type' => MENU_LOCAL_TASK,
'load arguments' => array(3),
'page callback' => 'node_page_edit',
'page arguments' => array(1, TRUE),
......@@ -32,8 +42,9 @@ function state_flow_menu() {
'file' => 'node.pages.inc',
'file path' => drupal_get_path('module', 'node'),
);
$items['node/%node/revisions/%/workflow'] = array(
$items['node/%node/revisions/%state_flow_revision_node/workflow'] = array(
'title' => 'Transition a revision to a new workflow state',
'type' => MENU_CALLBACK,
'load arguments' => array(3),
'page callback' => 'drupal_get_form',
'page arguments' => array('state_flow_entity_events_revision', 1, 'node', 5, array()),
......@@ -54,6 +65,17 @@ function state_flow_menu() {
return $items;
}
/**
+ * Menu argument loader.
+ */
function state_flow_revision_node_load($vid) {
$nid = arg(1);
if (empty($vid) || empty($nid)) {
return FALSE;
}
return node_load($nid, $vid, TRUE);
}
/**
* Implements hook_menu_alter().
*/
......@@ -205,6 +227,23 @@ function state_flow_entity_info_alter(&$entity_info) {
'revision_delete_path' => 'node/%entity_id/revisions/%revision_id/delete',
'revision_edit_path' => 'node/%entity_id/revisions/%revision_id/edit',
);
// Add revision handling path schemes for entity translation.
if (module_exists('entity_translation')) {
if (!isset($entity_info['node']['translation']['entity_translation'])) {
$entity_info['node']['translation']['entity_translation'] = array();
}
$et_info = &$entity_info['node']['translation']['entity_translation'];
$et_info['class'] = 'EntityTranslationStateFlowHandler';
$et_info['path schemes']['state_flow'] = array(
'admin theme' => 1,
'base path' => 'node/%node/revisions/%state_flow_revision_node',
'view path' => 'node/%node/revisions/%/view',
'edit path' => 'node/%node/revisions/%state_flow_revision_node/edit',
'path wildcard' => '%node',
'edit tabs' => TRUE,
);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment