コード例 #1
0
ファイル: doozer.php プロジェクト: gruner/doozer
/**
 * Recursively formats the navigation sitemap, building a string of nested <ul>s.
 */
function format_navigation($input, $exclusions = array(), $include_sub_nav = false, $top_level = true)
{
    global $_section, $_name;
    # only include the item's id for top level nav items
    $include_id = $top_level;
    $nav_string = '';
    foreach ($input as $key => $value) {
        if (!in_array($key, $exclusions)) {
            $current = $top_level ? $_section : $_name;
            $li_string = '';
            if (is_string($value)) {
                $li_string .= format_nav_link($key, $value, $include_id);
            } else {
                $section_link = get_section_link($key, $value);
                # add .head class for jquery accordion
                $class = is_array($value) && $include_sub_nav && $top_level ? 'head' : '';
                $li_string .= format_nav_link($key, $section_link, $include_id, $class);
                if (is_array($value) && $include_sub_nav) {
                    # recurse through nested navigation
                    $li_string .= format_navigation($value, $exclusions, true, false);
                }
            }
            $li_tag_options = get_nav_attributes($current, $key, $input);
            # append class names to <li>
            $nav_string .= content_tag('li', $li_string, $li_tag_options);
        }
    }
    return content_tag('ul', $nav_string);
}
コード例 #2
0
ファイル: TestFramework.php プロジェクト: gruner/doozer
 function test_format_nav_link()
 {
     $this->assertIdentical(format_nav_link('Lorem Ipsum'), '<a href="lorem-ipsum.php">Lorem Ipsum</a>' . "\n");
     $this->assertIdentical(format_nav_link('Lorem Ipsum&reg;'), '<a href="lorem-ipsum.php">Lorem Ipsum&reg;</a>' . "\n");
     $this->assertIdentical(format_nav_link('Lorem Ipsum', 'http://google.com'), '<a href="http://google.com">Lorem Ipsum</a>' . "\n");
     $this->assertIdentical(format_nav_link('Lorem Ipsum&reg;', '', true), '<a href="lorem-ipsum.php" id="lorem-ipsum">Lorem Ipsum&reg;</a>' . "\n");
 }