/*
 * Usable values
 * $node : currently viewed node
 * $state: workflow state of the currently viewed node revision
 * $live: live version of the node
 * $live_link: revision and link to the live node
 * $links: actions on the different revisions (compare_with_live,compare,delete_revision, edit_revision, edit_live)
 */
$current_user = user_load($node->revision_uid);
$edit_icon = '<span class="tinyicon t_editicon"></span>';
$rev_icon = '<span class="tinyicon t_revisionicon"></span>';
$edit_state_icon = '<span class="tinyicon t_changestateicon"></span>';
$delete_icon = '<span class="tinyicon t_deleteicon"></span>';
$view_icon = '<span class="tinyicon t_viewicon"></span>';
/* actions */
if (_content_moderation_statechange_allowed($node->vid)) {
    $edit_state = l($edit_state_icon, $links['edit_state'], array('html' => true, 'attributes' => array('title' => t('Edit the state of this revision.'))));
}
if ($live != NULL) {
    $view_live_link = l($view_icon, $links['live_view'], array('html' => true, 'attributes' => array('title' => t('View live revision'))));
}
$check_revisions = _content_moderation_get_latest_revisions($node->nid, 2);
$rev_url = _content_moderation_determine_revision_url($check_revisions, $node->nid, $node->vid, FALSE);
$view_current_link = l($view_icon, $rev_url, array('html' => true, 'attributes' => array('title' => t('View this revision.'))));
$current_rev_link = l($node->vid, $rev_url, array('html' => true, 'attributes' => array('title' => t('View this revision.'))));
if (module_exists('diff')) {
    $compare_live = l($rev_icon, $links['compare_with_live'], array('html' => true, 'attributes' => array('title' => t('Compare this revision with the live revision.'))));
    $compare = l($rev_icon, $links['compare'], array('html' => true, 'attributes' => array('title' => t('List all revisions.'))));
}
// TODO: first see how revision deleting, esp. the live ones, should be handled
//$delete_current = l($delete_icon,$links['delete_revision'],array('html' => true, 'attributes' => array( 'title' => t('Delete this revision') ) ));
    return "";
}
?>
<div class='revision_list'>
<?php 
$edit_icon = '<span class="tinyicon t_editicon"></span>';
$rev_icon = '<span class="tinyicon t_revisionicon"></span>';
$view_icon = '<span class="tinyicon t_viewicon"></span>';
$edit_state_icon = '<span class="tinyicon t_changestateicon"></span>';
foreach ($revisions as $rev) {
    $edit_state_link = '';
    $compare_live = '';
    $compare = '';
    $view_link = l($view_icon, "node/{$rev->nid}/revisions/{$rev->vid}/view", array('html' => true, 'attributes' => array('title' => t('View revision @rev.', array('@rev' => $rev->vid)))));
    $revision_link = l($rev->vid, "node/{$rev->nid}/revisions/{$rev->vid}/view", array('html' => true, 'attributes' => array('title' => t('View revision @rev.', array('@rev' => $rev->vid)))));
    if (_content_moderation_statechange_allowed($rev->vid) !== false) {
        $edit_state_link = l($edit_state_icon, _content_moderation_change_state_link($rev->vid, $rev->nid), array('html' => true, 'attributes' => array('title' => t('Change state of revision @rev.', array('@rev' => $rev->vid)))));
    }
    if (module_exists('diff')) {
        $live = _content_moderation_live_revision($node->nid);
        if ($live != NULL) {
            $compare_live = l($rev_icon, "node/{$rev->nid}/revisions/view/{$live->vid}/{$rev->vid}", array('html' => true, 'attributes' => array('title' => t('Compare this revision with the current live revision.'))));
        }
        $compare = l($rev_icon, $links['compare'], array('html' => true, 'attributes' => array('title' => t('List all revisions.'))));
    }
    $compare = 'compare';
    if ($rev->state != NULL) {
        $state = ucfirst(t($rev->state));
    } else {
        $state = ucfirst(t('none'));
    }