<?php
/* @var $this ArticleController */
/* @var $data Article */
?>
<?php if ($index < 5): ?>
    <div class="view">
        <div class="inner" class="article-view-index">
            <?php if ($data->image): ?>
                <?php $path = Yii::app()->params['uploadUrl'] . get_class($data) . '/'; ?>
                <div class="thumbnail-container span-4">
                    <?php $image = CHtml::image($path . $data->image, $data->title, array('class' => 'thumbnail')); ?>
                    <?php echo CHtml::link($image, array('/article/view', 'slug' => $data->slug)); ?>
                </div>
            <?php endif; ?>
            <h3>
                <?php echo CHtml::link(CHtml::encode($data->title), array('/article/view', 'slug' => $data->slug)); ?>
            </h3>
            <small>
                <?php if (Yii::app()->options->get('SHOW_AUTHOR', false)): ?>
                <?php echo Yii::t('admin', 'Author:') . ' ' . $data->createUser->getFullName(); ?>
                &nbsp;|&nbsp;
                <?php endif; ?>
                <?php echo Yii::app()->dateFormatter->formatDateTime($data->update_datetime, 'medium', null); ?>
            </small>
            <p>
                <?php
                $purify = new CHtmlPurifier();
                $content = $data->content;
                $content = strip_tags($content);
                $content = ShortCodeManager::strip($content);
                $content = Common::tokenTruncate($content, 180);
                $content = $purify->purify($content);
                echo trim($content) . CHtml::link('&#8230;', array('/article/view', 'slug' => $data->slug));
                ?>
            </p>
        </div>
        <?php echo CHtml::link(Yii::t('site', 'Continue Reading'), array('/article/view', 'slug' => $data->slug), array('class' => 'continue-reading')); ?>
    </div>
<?php else: ?>
    <?php
    if ($index == 5) {
        echo '<div class="view"><ul class="more-articles-list">';
    }
    ?>
    <li>
        <h4>
            <?php echo CHtml::link(CHtml::encode($data->title), array('/article/view', 'slug' => $data->slug)); ?>
        </h4>
    </li>
    <?php
    if ($index == (count($widget->dataProvider->data) - 1)) {
        echo '</ul></div>';
    }
    ?>
<?php endif; ?>