Пример #1
0
 function test_exists()
 {
     $this->assertTrue(exists($GLOBALS['_name']));
     $foo = '';
     $bar = array();
     $this->assertFalse(exists($foo));
     $this->assertFalse(exists($bar));
     $this->assertEqual(use_default('', 'foo'), 'foo');
     $this->assertEqual(use_default('bar', 'foo'), 'bar');
     $this->assertNotEqual(use_default('bar', 'foo'), 'foo');
     $this->assertNotEqual(use_default('', 'foo'), '');
 }
Пример #2
0
/**
 * Determines the link for the current section.
 *
 * If the section's sub items are an array
 * the 'slug name' is used for the link,
 * if the section's sub item is a string,
 * the string is used for the link.
 *
 * Optionally check any section given as a parameter.
 */
function get_section_link($section = '', $section_sub = '')
{
    global $_section;
    # Use the current section unless a specific section is given as a parameter
    $section = use_default($section, $_section);
    # if $section_sub is undefined, get it from the sitemap
    if (!$section_sub) {
        $sitemap = get_sitemap();
        $section_sub = $sitemap[$section];
    }
    $link = '';
    if (is_array($section_sub)) {
        if (has_index_pages()) {
            $link .= slug_name($section);
            $link .= '.php';
        } else {
            $link .= get_first_unnested_item($section_sub);
            # link to first sub item that isn't a nested array
        }
    } elseif (is_string($section_sub)) {
        $link = $section_sub;
    }
    return $link;
}