<?php $odd = false; ?>
<?php if (!empty($this->historyArray)) { ?>
<table class="separated-vertical" id="history-list">
    <thead>
    <!-- history table headers -->
    <tr class="odd">
        <th><?php echo $this->_('select'); ?>          </th>
        <th><?php echo $this->_('ID'); ?>              </th>
        <?php if(!$this->singleResource){?><th><?php echo $this->_('resource'); ?> </th><?php } ?>
        <th><?php echo $this->_('user'); ?>            </th>
        <th><?php echo $this->_('timestamp'); ?>       </th>
        <th><?php echo $this->_('action-type'); ?>     </th>
    </tr>
    </thead>
    <tbody>
    <!-- history table contents -->
    <?php $i = 0; ?>      
    <?php foreach ($this->historyArray as $abschnitt) :?>
    <tr class="<?php echo $odd ? 'odd' : 'even'; $odd = !$odd; ?> ">
        <td class="selector">
            <input
                <?php if (!$this->rollbackAllowed) echo 'disabled'; ?> 
                type="radio"
                id="actionid-<?php echo $abschnitt['id']; ?>"
                name="actionid"
                <?php 
                    $chunk = array_chunk($this->idArray,$i++ + 1); 
                    $idString = htmlentities(serialize($chunk[0]));
                ?>
                value="<?php echo $idString; ?>"/>
        </td>
        <td class="enumeration">
            <label for="actionid-<?php echo $abschnitt['id']; ?>"><?php echo $abschnitt['id']; ?></label>
        </td>
        <?php if(!$this->singleResource){?><td><a href="<?php echo $abschnitt['url']; ?>"><?php echo $this->titleHelper->getTitle($abschnitt['resource']); ?></a></td><?php } ?>
        <td><?php echo $this->userArray[$abschnitt['useruri']]; ?></td>
        <td>
            <?php $timestamp = date('c', (int) $abschnitt['tstamp']); ?>
            <?php echo OntoWiki_Utils::dateDifference($timestamp) . ' ('.substr($timestamp,0,strlen($timestamp) - 6).')'; ?>
        </td>
        <td class="history-detail"><a><?php echo $this->_('HISTORY_ACTIONTYPE_' . $abschnitt['action_type']); ?></a>
            <div style="display:none;" class="is-processing"><?php echo $abschnitt['id']; ?></div>
        </td>
    </tr>
    <?php endforeach; ?>
                    
    </tbody>
</table>
<?php } ?>

<script type="text/javascript">

    $(document).ready(function() {
        $('#history-list .history-detail').livequery('click', function (event) {

            var node = $(this).children('div');
            if (node.hasClass('is-processing')) {
                var param = node.text();
                node.text('');
                $.get(urlBase + "history/details/id/" + param, function(data){
                        node.html(data);
                        node.removeClass('is-processing');
                    });
            }
            node.toggle();
            event.stopPropagation();
        });
    });
</script>
