<commit_before><?
/**
 * @package     Nooku_Server
 * @subpackage  Comments
 * @copyright	Copyright (C) 2011 - 2012 Timble CVBA and Contributors. (http://www.timble.net)
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link		http://www.nooku.org
 */
?>

<script src="media://js/mootools.js" />

<script>
    window.addEvent('domready', function() {
        $$('.icon-trash').addEvent('click',function(){
            var id = $(this).getAttribute('data-id');
            var request = new Request.JSON({
                url: '?view=comment&id='+id,
                method: 'delete',
                data: {
                    action: 'delete',
                    id: id,
                    _token:'<?= @object('user')->getSession()->getToken() ?>'
                },
//                action: delete,
                onComplete: function(response){
                    $('comment-'+id).remove()
                }
            }).send();
        });
    });
</script>

<?if(@object('com:comments.controller.comment')->canAdd()):?>
    <?= @template('com:comments.view.comment.form.html'); ?>
<?endif;?>

<? foreach($comments as $comment) : ?>

    <div class="comment" id="comment-<?=$comment->id;?>">
        <div class="comment-header">
           <span class="comment-header-author">
                <?= $comment->created_by == @object('user')->id ? @text('You') : $comment->created_by_name ?>&nbsp;<?= @text('wrote') ?>
           </span>
           <span class="comment-header-time">
                <time datetime="<?= $comment->created_on ?>" pubdate><?= @helper('date.humanize', array('date' => $comment->created_on)) ?></time>
            </span>
            <?if($comment->created_by == @object('user')->getId() || $this->getUser()->getRole() >= 23):?>
                <span class="comment-header-options">
                    <i class="icon-trash" data-id="<?=$comment->id;?>"></i>
                </span>
            <? endif;?>
        </div>
        <div class="comment-content">
            <p><?= @escape($comment->text) ?></p>
        </div>

    </div>

<? endforeach ?>

<commit_msg>If the merge is done with the comments branche editing of the comments will work inline re #392<commit_after><?
/**
 * @package     Nooku_Server
 * @subpackage  Comments
 * @copyright	Copyright (C) 2011 - 2012 Timble CVBA and Contributors. (http://www.timble.net)
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link		http://www.nooku.org
 */
?>

<script src="media://js/mootools.js" />


<script src="media:///wysiwyg/ckeditor/ckeditor.js" />
<script type='text/javascript' language='javascript'>

    function ClickToSave (comment_id) {
        var request = new Request.JSON({
            url: '?view=comment&id='+comment_id,
            data: {
                id: comment_id,
                text: CKEDITOR.instances['comment-'+comment_id].getData(),
                _token:'<?= @object('user')->getSession()->getToken() ?>'
            },
            onComplete: function(response){

            }
        }).send();
    }

    CKEDITOR.on( 'instanceCreated', function( event ) {
        var editor = event.editor,

        editor.config.toolbar = 'title';
    });

    window.addEvent('domready', function() {
        $$('.icon-trash').addEvent('click',function(){
            var id = $(this).getAttribute('data-id');
            var request = new Request.JSON({
                url: '?view=comment&id='+id,
                method: 'delete',
                data: {
                    id: id,
                    _token:'<?= @object('user')->getSession()->getToken() ?>'
                },
                onComplete: function(response){
                    $('comment-'+id).remove()
                }
            }).send();
        });
    });
</script>

<?if(@object('com:comments.controller.comment')->canAdd()):?>
    <?= @template('com:comments.view.comment.form.html'); ?>
<?endif;?>

<? foreach($comments as $comment) : ?>

    <div class="comment" id="comment-<?=$comment->id;?>">
        <div class="comment-header">
           <span class="comment-header-author">
                <?= $comment->created_by == @object('user')->id ? @text('You') : $comment->created_by_name ?>&nbsp;<?= @text('wrote') ?>
           </span>
           <span class="comment-header-time">
                <time datetime="<?= $comment->created_on ?>" pubdate><?= @helper('date.humanize', array('date' => $comment->created_on)) ?></time>
            </span>
            <?if($comment->created_by == @object('user')->getId() || $this->getUser()->getRole() >= 23):?>
                <span class="comment-header-options">
                    <i class="icon-trash" data-id="<?=$comment->id;?>"></i>
                </span>
            <? endif;?>
        </div>
        <div class="comment-content" id="comment-<?=$comment->id;?>" contenteditable="<?= $comment->editable ? 'true':'true';?>" onBlur="ClickToSave(<?=$comment->id?>)">
            <p><?= @escape($comment->text) ?></p>
        </div>

    </div>

<? endforeach ?>


{'fraction_non_alphanumeric': 0.20771513353115728, 'fraction_numerical': 0.004945598417408506, 'mean_word_length': 2.1325898389095417, 'pattern_counts': {'":': 0, '<': 84, '<?xml version=': 0, '>': 123, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4742969', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1496, 'n_words': 256}