コード例 #1
0
function build_toc_category($category, $current = null)
{
    $inCategory = false;
    $out = '';
    for ($i = 0, $ien = count($category['files']); $i < $ien; $i++) {
        $example = $category['files'][$i];
        if ($example['name'] !== 'index') {
            $class = '';
            if ($example === $current) {
                $class = ' class="active"';
                $inCategory = true;
            }
            $link = '';
            if ($current) {
                $link = path_resolve($current['path'] . '/' . $current['name'] . '.html', $example['path'] . '/' . $example['name'] . '.html') . "\n";
            }
            $out .= '<li' . $class . '><a href="' . $link . '">' . $example['title'] . '</a></li>';
        }
    }
    $link = '';
    if ($current) {
        $link = path_resolve($current['path'] . '/' . $current['name'] . '.html', $category['path'] . '/' . $category['name'] . '/index.html') . "\n";
    }
    return '<div class="toc-group">' . '<h3><a href="' . $link . '">' . $category['title'] . '</a></h3>' . '<ul class="toc' . ($inCategory ? ' active' : '') . '">' . $out . '</ul>' . '</div>';
}
コード例 #2
0
ファイル: build.php プロジェクト: saarze/base2
function print_package($package, $pbase)
{
    global $REG_XML, $BASE;
    $before = $package->getAttribute('before');
    if ($before) {
        readfile(path_resolve($before, $pbase));
    }
    $name = $package->getAttribute('name');
    $publish = $package->getAttribute('publish') != 'false';
    $closure = $package->getAttribute('closure') != 'false';
    if ($closure) {
        $shrink = $package->getAttribute('shrink') == 'true' ? '' : '_no_shrink_';
        print "\r\nnew function({$shrink}) { ///////////////  BEGIN: CLOSURE  ///////////////\r\n";
    }
    $includes = $package->getElementsByTagName('include');
    foreach ($includes as $include) {
        $src = path_resolve($include->getAttribute('src'), $pbase);
        $var = $include->getAttribute('var');
        if (preg_match($REG_XML, $src)) {
            load_package($src);
        } else {
            if ($include->getAttribute('header') != 'false') {
                print "\r\n// =========================================================================\r\n";
                print '// ' . preg_replace('/^\\//', '', preg_replace('/[\\w\\-]+\\/\\.\\./', '', $name . '/' . $include->getAttribute('src')));
                print "\r\n// =========================================================================\r\n";
            }
            if ($var) {
                print "var " . $var . "=" . json_encode(file_get_contents($src)) . ";\r\n";
            } else {
                if (!readfile($src)) {
                    print "alert('BOO! The file \"" . $src . "\" from your package was not found.');";
                }
            }
        }
    }
    if ($publish) {
        print "\r\neval(this.exports);\r\n";
    }
    if ($closure) {
        print "\r\n}; ////////////////////  END: CLOSURE  /////////////////////////////////////\r\n";
    }
    $after = $package->getAttribute('after');
    if ($after) {
        readfile(path_resolve($after, $pbase));
    }
}