<?php use_helper('tvtl', 'I18N', 'Javascript', 'ModalBox') ?>

<?php $stylesheet = array('entry'=>'entrygroup', 'document'=>'document doc', 'present'=>'document doc') ?>
<?php $index = 0 ?>
<?php foreach ($pagers as $key => $pager): ?>
  <?php include_component('block', 'advbanner', array('name'=>'inside'.$index, 'moduleindex'=>$index++)); ?>
  <?php $catItem = blogStore::$catTree->getCatItem($key) ?>
  <?php $moduleName = $catItem->mod ?>
  <div class="<?php echo $stylesheet[$moduleName] ?>">
    <h2>
      <label>
        <?php echo link_to(__('View all'), '/'.$moduleName.'/list?cat_id='.$key) ?> |
        <?php echo blogStore::getPostLink($key, $moduleName) ?>
      </label>
      <?php echo link_to(myUtility::vietUpcase($catItem->name), '/'.$moduleName.'/list?cat_id='.$key);?>
      <span>&nbsp;<?php echo '('.$pager->getTotalRecordCount().' bài)' ?></span>
    </h2>

    <div class="content">
      <?php $tblblogcategoryentrys = $pager->getResult() ?>
      <?php if ($catItem->type == 2): ?>
        <?php $style = blogStore::getNewsStyle() ?>
        <?php if ($catentry = array_shift($tblblogcategoryentrys)): ?>
          <div class="news<?php echo $style ?>-first">
            <?php echo $catentry->getObject()->getThumbWithLink() ?>
            <?php echo content_tag('h4', $catentry->getObject()->getTitleWithLink()) ?>
            <?php echo $catentry->getObject()->getEntryIntro() ?>
          </div>
        <?php endif ?>
        <?php if (count($tblblogcategoryentrys) > 0): ?>
          <div class="news<?php echo $style ?>-next">
            <?php foreach ($tblblogcategoryentrys as $i => $catentry):?>
              <?php $thumbTag = ($i == 0 && $style == 2)? $catentry->getObject()->getThumbWithLink(): '' ?>
              <?php $titleTag = $catentry->getObject()->getTitleWithLink() ?>
              <?php echo $thumbTag? ($thumbTag. $titleTag): content_tag('li', $titleTag) ?>
            <?php endforeach;?>
          </div>
        <?php endif ?>
      <?php else: ?>
        <?php foreach ($tblblogcategoryentrys as $i => $catentry):?>
          <?php echo $catentry->getObject()->getGlobalThumb(blogStore::getDisplayStyle($i)) ?>
        <?php endforeach;?>
      <?php endif; ?>
    </div>
  </div>
<?php endforeach ?>
