<?php


function template_preprocess_blockentrees(&$vars){

  $entrees = array (
    '#theme' => 'item_list',
    '#items' => array(),
  );

  foreach ($vars['entrees_items'] as $entree) {

    $tid = $entree['tid'];

    $term_link = $entree['term_link']->toRenderable();
    $term_link['#prefix'] = '<span class="oblique-wrapper">';
    $term_link['#suffix'] = "</span>";

    $index_link = $entree['index_link']->toRenderable();
    $index_link['#prefix'] = '<span class="oblique-wrapper">';
    $index_link['#suffix'] = "</span>";

    $notice_link = $entree['notice_link']->toRenderable();
    $notice_link['#prefix'] = '<span class="oblique-wrapper">';
    $notice_link['#suffix'] = "</span>";

    $entree = array(
      '#wrapper_attributes' => array(
        'class' => array('term-'.$tid, 'entree'),
        'tid' => $tid
      ),
      'term_link' => $term_link,
      'entree_content' => array(
        '#type' => 'container',
        '#attributes' => array(
          'class' => 'entree-content'
        ),
        'index_link' => $index_link,
        'notice_link' => $notice_link,
        'description' => array(
          '#type' => 'container',
          '#markup' => $entree['description'],
          '#attributes' => array('class'=>'term-description')
        )
      )
    );

    // if (isset($entrees) && count($entrees) == count($terms)-3) {
    //   $entree['#wrapper_attributes']['class'][] = 'opened';
    // }

    // dpm($entree);

    $entrees['#items'][] = $entree;
  }

  $vars['entrees'] = render($entrees);

}
