Exemplo n.º 1
0
/**
 * Renders a custom menu
 * @param string $menu
 */
function render_menu($menu = null)
{
    if (is_null($menu)) {
        $menu = load_menu('menu.php');
    }
    $nav = '<ul class="navbar menu">';
    foreach ($menu as $child) {
        if (sfContext::getInstance()->getUser()->hasCredential($child->getCredentials())) {
            $nav .= '<li class="menu-item ' . ($child->hasChildren() ? 'has-sub-menu' : '') . '" id="' . Scss::slugify($child->getName()) . '-menu-item">' . $child->renderLink();
            //link_to($child->getName(),$child->getRoute(),$child->getLinkOptions());
            if ($child->hasChildren()) {
                $nav .= '<ul class="sub-menu">';
                foreach ($child as $baby) {
                    if ($baby->checkUserAccess()) {
                        $nav .= '<li class="menu-item" id="' . Scss::slugify($baby->getName()) . '">' . link_to($baby->getName(), $baby->getRoute(), $baby->getLinkOptions()) . '</li>';
                    }
                }
                $nav .= '</ul>';
            }
            $nav .= '</li>';
        }
    }
    $nav .= '</ul>';
    print_r($nav);
}
Exemplo n.º 2
0
function scss_link_to($name, $url, $opts = array())
{
    // get user
    $sf_user = sfContext::getInstance()->getUser();
    // get route data for given route
    $sf_route = sfContext::getInstance()->getRouting()->getRoutes();
    $sf_route = $sf_route[$url];
    // use active enrollment troop or assigned troop
    $use_active = isset($opts['use_active']) ? $opts['use_active'] : false;
    unset($opts['use_active']);
    // get slug array
    $_p = array();
    foreach ($sf_route->getDefaultParameters() as $r) {
        $_p[$r] = Scss::genSlugArray(array(($use_active ? 'a_' : '') . $r));
    }
    return link_to($name, $url, array_merge($opts, $_p));
}