<?php if (!empty($this->facetList) || !empty($this->checkboxFacets)): ?>
  <fieldset class="solr-facets">
    <legend><?=$this->transEsc('Limit To')?></legend>
    <?php if (!empty($this->checkboxFacets)): ?>
      <?=$this->render('search/advanced/checkbox-filters.phtml')?>
    <?php endif; ?>
    <div class="solr-facet-container">
      <?php foreach ($this->facetList as $field => $list): ?>
        <div class="solr-adv-facet">
          <label for="limit_<?=$this->escapeHtmlAttr(str_replace(' ', '', $field))?>"><?=$this->transEsc($list['label'])?>:</label>
          <select class="form-control" id="limit_<?=$this->escapeHtmlAttr(str_replace(' ', '', $field))?>" name="filter[]" multiple="multiple" size="10">
            <?php if (is_array($this->hierarchicalFacets) && in_array($field, $this->hierarchicalFacets)): ?>
              <?php foreach ($list['list'] as $value): ?>
                <?php $display = str_pad('', 4 * $value['level'] * 6, '&nbsp;', STR_PAD_LEFT) . $this->transEsc($value['displayText']); ?>
                <option value="<?=$this->escapeHtmlAttr(($value['operator'] == 'OR' ? '~' : '') . $field . ':"' . $value['value'] . '"')?>"<?=(isset($value['selected']) && $value['selected'])?' selected="selected"':''?>><?=$display?></option>
              <?php endforeach; ?>
            <?php else: ?>
              <?
              // Sort the current facet list alphabetically; we'll use this data
              // along with the foreach below to display facet options in the
              // correct order.
              $sorted = array();

              foreach ($list['list'] as $i => $value) {
                if (!empty($value['displayText'])) {
                  $sorted[$i] = $this->transEsc($value['displayText']);
                }
              }
              natcasesort($sorted);
              ?>
              <?php foreach ($sorted as $i => $display): ?>
                <?php $value = $list['list'][$i]; ?>
                <option value="<?=$this->escapeHtmlAttr(($value['operator'] == 'OR' ? '~' : '') . $field . ':"' . $value['value'] . '"')?>"<?=(isset($value['selected']) && $value['selected'])?' selected="selected"':''?>><?=$this->escapeHtml($display)?></option>
              <?php endforeach; ?>
            <?php endif; ?>
          </select>
        </div>
      <?php endforeach; ?>
    </div>
  </fieldset>
<?php endif; ?>
<div class="advanced-search-image-range">
<?php if (isset($this->illustratedLimit)): ?>
  <fieldset class="solr">
    <legend><?=$this->transEsc("Illustrated")?>:</legend>
    <?php foreach ($this->illustratedLimit as $current): ?>
      <input id="illustrated_<?=$this->escapeHtmlAttr($current['value'])?>" type="radio" name="illustration" value="<?=$this->escapeHtmlAttr($current['value'])?>"<?=$current['selected']?' checked="checked"':''?>/>
      <label for="illustrated_<?=$this->escapeHtmlAttr($current['value'])?>"><?=$this->transEsc($current['text'])?></label><br/>
    <?php endforeach; ?>
  </fieldset>
<?php endif; ?>
<?=$this->render('search/advanced/limit.phtml')?>
<?=$this->render('search/advanced/ranges.phtml')?>
</div>
