The error is HTML error because you have duplicated class. In HTML it is ok to have empty class attribute. So you can append classes then add them to the HTML class attribute. See the code:
$classes = '';
if($this->hasChilds($item, $nazev)) $classes .= ' qmparent';
if ((empty($view) && $item->view == 'main') || (empty($display) && $view == $item->view) || (!empty($display) && $display == $item->display)) $classes .= ' active';
$html .= '<a href="'.$href.'"class ="'.$classes.'"/>';
To have better structure, it is common to separate the view from model. So you can create a data array that contains or your HTML elements with final classes, type and id. Then pass this array to view to construct the view correctly.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…