<?php $idBase = 'kriatree_'.rand_str('1234567890', 10); ?>
<?php $idBase_div = $idBase.'_div'; ?>
<?php if($value === NULL) { ?>
  <b><?php echo htmlspecialchars($key,ENT_QUOTES,'UTF-8'); ?></b>
  <i><?php echo htmlspecialchars('NULL',ENT_QUOTES,'UTF-8'); ?></i>
<?php } else { ?>
  <?php if(is_object($value)) { ?>
    $value = (array)$value
  <?php } ?>
  <?php if(is_array($value)) { ?>
    <div <?php echo MtHaml\Runtime::renderAttributes(array(array('class', 'kriatree'), array('id', $idBase)), 'html5', 'UTF-8'); ?>>
      <b><?php echo htmlspecialchars($key,ENT_QUOTES,'UTF-8'); ?></b>
      <img <?php echo MtHaml\Runtime::renderAttributes(array(array('src', (url('/images/plus.gif')))), 'html5', 'UTF-8'); ?> />
      <?php echo htmlspecialchars(t('Click to expand/collapse'),ENT_QUOTES,'UTF-8'); ?>
    </div>
    <div <?php echo MtHaml\Runtime::renderAttributes(array(array('id', $idBase_div), array('style', 'display: none;')), 'html5', 'UTF-8'); ?>>
      <?php ksort($value); ?>
      <ul style="list-style: none;">
        <?php if(count($value) <= 0) { ?>
          <li>
            <i><?php echo htmlspecialchars('('.t('Empty').')',ENT_QUOTES,'UTF-8'); ?></i>
          </li>
        <?php } else { ?>
          <?php foreach($value as $k => $v) { ?>
            <li>
              <?php $this->renderPartial('/shared/_treeBuilder', array('key' => $k,'value' => $v)); ?>
            </li>
          <?php } ?>
        <?php } ?>
      </ul>
    </div>
  <?php } else { ?>
    <b><?php echo htmlspecialchars($key,ENT_QUOTES,'UTF-8'); ?></b>
    <i><?php echo htmlspecialchars("".var_export($value, true)." (".gettype($value).")",ENT_QUOTES,'UTF-8'); ?></i>
  <?php } ?>
<?php } ?>
