<?php
// functions help

function open($visited, &$aberto) {
    $html = "";

    if ($visited['hasSon']) {
        for ($i = $aberto; $i >= $visited['fathersLevel']; $i--) {
            $aberto--;
            $html .= "   </ul>\n";
            $html .= "</li>\n";
        }
        $html .= "<li class=\"menuparent\"><a title=\"" . $this->escapeTitle($visited['titulo']) . "\" href=\"#\">" . $this->escapeTitle($visited['titulo']) . "</a>\n\t";
        $html .= "  <ul>\n\t\t";
        $aberto++;
    } else {
        if (($aberto > $visited['fathersLevel']) && (!$visited['hasBrother'])) {
            for ($i = $aberto; $i >= $visited['fathersLevel']; $i--) {
                $aberto--;
                $html .= "   </ul>\n";
                $html .= "</li>\n";
            }
        }
        $html .= "<li><a title=\"" . $this->escapeTitle($visited['titulo']) . "\" href=\"" . Goweb::link("/cms/view/id/" . $visited['id'] . "/") . "\">" . $this->escapeTitle($visited['titulo']) . "</a></li>\n\t";
    }
    
    return $html;
}

function close($visited, &$aberto) {
    $html = "";
    if ((!$visited['hasBrother']) && (!$visited['hasSon'])) {
        if ($aberto > 0) {
            $aberto--;
            $html .= "   </ul>\n";
            $html .= "</li>\n";
        } else {
            if ($visited['hasBrother']) {
                $aberto--;
                $html .= "   </ul>\n";
                $html .= "</li>\n";
            }
        }
    }
    return $html;
}
?>
