/**
  * returns HTML code for the filters
  *
  * @param  SimpleXMLElement[]  $items           The xml items to parse output
  * @param  string              $type            The type of xml items (e.g. filter, batch, import, export...)
  * @param  RegistryEditView    $editRowView     The edit view for the row
  * @param  string              $htmlFormatting  The HTML formatting for the filters ( 'table', 'td', 'none' )
  * @return array
  */
 function xmlItems($items, $type, $editRowView, $htmlFormatting = 'none')
 {
     $lists = array();
     if (count($items) > 0) {
         $valueObj = new Registry();
         $saveName = array();
         foreach ($items as $k => $v) {
             $valname = $type . '_' . $v['name'];
             $valueObj->set($valname, $v['value']);
             /** @var $v SimpleXMLElement[] */
             $saveName[$k] = $v['xml']->attributes('name');
             /** @noinspection PhpUndefinedMethodInspection */
             $items[$k]['xml']->addAttribute('name', $type . '_' . $saveName[$k]);
             /** @var $v array */
             $editRowView->setSelectValues($v['xml'], $v['selectValues']);
         }
         $renderedViews = array();
         foreach ($items as $k => $v) {
             /** @var $v SimpleXMLElement[] */
             $viewName = $v['xml']->attributes('view');
             if ($viewName) {
                 /** @noinspection PhpUndefinedMethodInspection */
                 $view = $items[$k]['xmlparent']->getChildByNameAttr('view', 'name', $viewName);
                 if (!$view) {
                     echo 'filter view ' . $viewName . ' not defined in filters';
                 }
             } else {
                 /** @noinspection PhpUndefinedMethodInspection */
                 $view = $items[$k]['xml']->getElementByPath('view');
             }
             $value = $items[$k]['value'];
             if ($value !== null && $value !== '') {
                 /** @noinspection PhpUndefinedMethodInspection */
                 $classes = $items[$k]['xml']->attributes('cssclass');
                 /** @noinspection PhpUndefinedMethodInspection */
                 $items[$k]['xml']->addAttribute('cssclass', $classes . ' focus');
             }
             if ($view) {
                 if (!$viewName || !in_array($viewName, $renderedViews)) {
                     /** @var SimpleXMLElement $view */
                     $htmlFormattingView = $view->attributes('viewformatting');
                     if ($htmlFormattingView == '') {
                         $htmlFormattingView = $htmlFormatting;
                     }
                     $lists[$k] = '<div class="cb' . htmlspecialchars(ucfirst($type)) . ' cb' . htmlspecialchars(ucfirst($type)) . 'View">' . $editRowView->renderEditRowView($view, $valueObj, $this, $this->_options, 'param', $htmlFormattingView) . '</div>';
                 }
                 if ($viewName) {
                     $renderedViews[] = $viewName;
                 }
             } else {
                 $editRowView->pushModelOfData($valueObj);
                 $editRowView->extendParamAttributes($items[$k]['xml'], $this->control_name());
                 $result = $editRowView->renderParam($items[$k]['xml'], $this->control_name(), false);
                 $editRowView->popModelOfData();
                 if ($result[0] || $result[1] || $result[2]) {
                     $lists[$k] = '<div class="cb' . htmlspecialchars(ucfirst($type)) . '">' . ($result[0] ? '<span class="cbLabelSpan">' . $result[0] . '</span> ' : null) . '<span class="cbFieldSpan">' . $result[1] . '</span>' . ($result[2] ? ' <span class="cbDescrSpan">' . $result[2] . '</span>' : null) . '</div>';
                 }
             }
         }
         foreach ($items as $k => $v) {
             /** @noinspection PhpUndefinedMethodInspection */
             $items[$k]['xml']->addAttribute('name', $saveName[$k]);
         }
     }
     return $lists;
 }