Esempio n. 1
0
function drawTree($x1, $y1, $angle, $depth)
{
    global $img;
    if ($depth != 0) {
        $x2 = $x1 + (int) (cos(deg2rad($angle)) * $depth * 10.0);
        $y2 = $y1 + (int) (sin(deg2rad($angle)) * $depth * 10.0);
        imageline($img, $x1, $y1, $x2, $y2, imagecolorallocate($img, 0, 0, 0));
        drawTree($x2, $y2, $angle - 20, $depth - 1);
        drawTree($x2, $y2, $angle + 20, $depth - 1);
    }
}
Esempio n. 2
0
function drawTree($elements, $ctr, $depth = 0)
{
    if (!empty($elements)) {
        $class = $ctr->class;
        if (isset($ctr->classes[$depth])) {
            $class .= " " . $ctr->classes[$depth];
        }
        foreach ($elements as $elem) {
            if ($elem->isVisible() || $ctr->showHidden) {
                echo '<li class="uk-parent ' . $class . '">';
                ?>
                                            <?php 
                if ($ctr->link != null) {
                    ?>
                                                    <a href="<?php 
                    echo $ctr->link . $elem->getId();
                    ?>
">
                                            <?php 
                }
                echo $elem->getName();
                if ($ctr->link != null) {
                    ?>
                                            </a>
                                            <?php 
                }
                ?>
                                    <?php 
                $childrens = $elem->getChildrens();
                ?>
                                    <?php 
                if (!empty($childrens)) {
                    ?>
                                    <ul class="uk-parent">
                                        <?php 
                    drawTree($childrens, $ctr, $depth + 1);
                    ?>
                                    </ul>
                                    <?php 
                }
                ?>
                            </li>
                    <?php 
            }
        }
    }
}
Esempio n. 3
0
function template_children($args)
{
    template_common_prologue(array('norobots' => 1, 'title' => 'Children of ' . $args['page'], 'heading' => 'Children of ', 'headlink' => $args['page'], 'headsufx' => '', 'toolbar' => 1, 'button_selected' => '', 'button_view' => 1, 'timestamp' => $args['timestamp'], 'editver' => $args['editver'], 'button_backlinks' => 1));
    global $pagestore;
    $page = $args['page'];
    $children = $args['children'];
    ?>

<div class="content childtree">

<p>
<table cellspacing="0" cellpadding="0" border="0">
<tr valign="top">
<td>

<p>
<?php 
    if ($children) {
        $tree = array();
        $tree[$page] = array();
        foreach ($children as $child) {
            $tree[$page][$child] = array();
        }
        drawTree($tree);
    } else {
        print 'No children';
    }
    ?>

</td>
</tr>
</table>
</div>

<?php 
    template_common_epilogue(array('twin' => '', 'edit' => '', 'editver' => 0, 'history' => '', 'euser' => $args['edituser'], 'timestamp' => $args['timestamp'], 'headlink' => $args['page'], 'button_selected' => '', 'button_view' => 1, 'button_backlinks' => 1));
}
Esempio n. 4
0
function action_content()
{
    global $page, $pagestore, $HomePage;
    // get all branches
    $tree = $pagestore->getTreeFromLeaves($HomePage);
    // get other nodes that could not fit in a branch
    $allPages = $pagestore->getAllPageNames();
    $treePages = getAllNodesNames($tree);
    $otherPages = array_diff($allPages, $treePages);
    if ($tree[$HomePage]) {
        $content = array();
        $content[$HomePage] = $tree[$HomePage];
        unset($tree[$HomePage]);
        $drawFrontPage = 1;
    }
    if (count($tree)) {
        $drawOutside = 1;
    }
    if (count($otherPages)) {
        $drawOther = 1;
    }
    print "<html>\n";
    print "<head>\n";
    print "<meta name=\"ROBOTS\" content=\"NOINDEX, NOFOLLOW\">\n";
    print "<link rel=\"SHORTCUT ICON\" href=\"images/niti-logo.ico\">\n";
    print "<title>Wiki Content</title>\n";
    print "</head>\n";
    print "<body>";
    if (isset($drawFrontPage)) {
        print '<a href="#content">Wiki Content</a><br>';
    }
    if (isset($drawOutside)) {
        print '<a href="#outside">Singletons, Lost Branches and Cycles</a><br>';
    }
    if (isset($drawOther)) {
        print '<a href="#other">Other Mysterious Cases</a><br>';
    }
    if (isset($drawFrontPage)) {
        print '<a name="content"><h3>Wiki Content</h3></a>';
        drawTree($content, false, $page);
    }
    if (isset($drawOutside)) {
        print '<a name="outside"><h3>Singletons, Lost Branches and Cycles</h3></a>';
        drawTree($tree, false, $page);
    }
    if (isset($drawOther)) {
        print '<a name="other"><h3>Other Mysterious Cases</h3></a>';
        foreach ($otherPages as $page) {
            print html_ref($page, $page) . '<br>';
        }
    }
    print '<h3>Bad Parenting</h3>';
    ob_flush();
    $pages = $pagestore->getAllPageNames();
    $found = 0;
    foreach ($pages as $page) {
        $backlinks = $pagestore->getBacklinks($page);
        $parents = $pagestore->getParents($page);
        foreach ($parents as $parent) {
            if (!in_array($parent, $backlinks)) {
                print '<a href="?action=backlinks&page=' . rawurlencode($page) . '">' . htmlspecialchars($page) . '</a> -- ' . htmlspecialchars($parent) . '<br>';
                ob_flush();
                $found = 1;
            }
        }
    }
    if (!$found) {
        print 'None';
    }
    print '</body></html>';
}
<?php

$url = 'http://www.google.com/basepages/producttype/taxonomy.en-US.txt';
$out = array();
foreach (file($url) as $line) {
    explodeDropdown($line, $out, ' > ');
}
drawTree($out);
function explodeDropdown($line, &$outarr, $delim = ',')
{
    $parts = explode($delim, trim($line), 2);
    if (count($parts) == 2) {
        list($key, $value) = $parts;
        if (strpos($value, $delim)) {
            explodeDropdown($value, $outarr[$key]['children'], $delim);
        } else {
            $outarr[$key]['nodes'][] = $value;
        }
    }
}
function drawNode($node, $tag = 'ul')
{
    foreach ($node['nodes'] as $key) {
        echo '<li>' . $key;
        if (isset($node['children'][$key])) {
            echo "<{$tag}>";
            drawNode($node['children'][$key]);
            echo "</{$tag}>";
        }
        echo '</li>';
    }
Esempio n. 6
0
function template_common_prologue($args)
{
    global $AdditionalHeader, $CommonScript, $FindScript, $HomePage;
    global $MetaDescription, $MetaKeywords, $page, $pagestore, $ScriptBase;
    global $SeparateHeaderWords, $SeparateTitleWords, $ShortcutIcon;
    global $StyleScript, $TableSortScript, $UserName, $UseSpamRevert, $WikiLogo;
    global $WikiName;
    if ($SeparateTitleWords) {
        $args['title'] = html_split_name($args['title']);
    }
    ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<meta name="KEYWORDS" content="<?php 
    print $MetaKeywords;
    ?>
">
<meta name="DESCRIPTION" content="<?php 
    print $MetaDescription;
    ?>
">
<?php 
    if ($args['norobots']) {
        ?>
    <meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
<?php 
    }
    ?>
<link type="text/css" rel="stylesheet" href="<?php 
    print $StyleScript;
    ?>
">
<link type="text/css" rel="stylesheet" media="print" href="<?php 
    print $StyleScript;
    ?>
&amp;csstype=print">
<script src="<?php 
    print $TableSortScript;
    ?>
" type="text/javascript"></script>
<script src="<?php 
    print $CommonScript;
    ?>
" type="text/javascript"></script>
<?php 
    if ($ShortcutIcon) {
        ?>
    <link rel="SHORTCUT ICON" href="<?php 
        echo $ShortcutIcon;
        ?>
">
<?php 
    }
    ?>
<link rel="ALTERNATE" title="<?php 
    echo htmlspecialchars($WikiName);
    ?>
" href="<?php 
    echo $ScriptBase;
    ?>
?action=rss&page=<?php 
    echo htmlspecialchars($page);
    ?>
" TYPE="application/rss+xml">
<title><?php 
    print $args['title'] . ' - ' . htmlspecialchars($WikiName);
    ?>
</title>
</head>

<body onLoad="bodyOnLoad();">
<NOINDEX>

<?php 
    if ($AdditionalHeader) {
        print '<span class="printhide">';
        include $AdditionalHeader;
        print '</span>';
    }
    ?>

<div id="header">

  <div id="toprightbox" class="printhide">
    <div class="jumpsearch">
        <form method="get" action="<?php 
    print $FindScript;
    ?>
">
        <input type="hidden" name="action" value="find">

        Search:&nbsp;<input 
	type="text" name="find" size="20" accesskey=","><?php 
    $jumpSearchPage = $pagestore->page('JumpSearch');
    if ($jumpSearchPage->exists()) {
        print '&nbsp;<a href="' . viewURL('JumpSearch') . '">JumpSearch&nbsp;Help</a>';
    }
    ?>

        <?php 
    if ($args['headlink'] && $args['headlink'] != $HomePage && $args['headlink'] != 'RecentChanges' && $pagestore->getChildren($args['headlink'])) {
        ?>
        <br><input type="checkbox" name="branch_search" value="<?php 
        print htmlspecialchars($args['headlink']);
        ?>
">
        <label name="branch_search">Search only children of <b><?php 
        echo $args['headlink'];
        ?>
</b></label>
        <?php 
    }
    ?>
	
        </form>
    </div>
	
    <?php 
    if (isset($args['tree'])) {
        $tree = $pagestore->getTreeFromLeaves($HomePage, $args['headlink']);
        drawTree($tree, true, $args['headlink']);
    }
    ?>

  </div>

  <div id="topleftbox">
    <div class="logo printhide">
    <a href="<?php 
    print viewURL($HomePage);
    ?>
"><img src="<?php 
    print $WikiLogo;
    ?>
" alt="[Home]"></a>
    </div>
    <h1>
	
    <?php 
    print $args['heading'];
    if ($args['headlink'] != '') {
        if ($SeparateHeaderWords) {
            print html_split_name($args['headlink']);
        } else {
            print $args['headlink'];
        }
    }
    if (count($twin = $pagestore->twinpages($args['headlink']))) {
        // point at the sisterwiki's version
        print '<sup class="printhide">';
        foreach ($twin as $site) {
            print " " . html_twin($site[0], $site[1]);
        }
        print '</sup>';
    }
    print $args['headsufx'] . "</h1>\n";
    if (isset($args['redirect_from']) && $args['redirect_from']) {
        print '(Redirected from <a href="' . viewURL($args['redirect_from']) . '&no_redirect=1">';
        if ($SeparateHeaderWords) {
            print htmlspecialchars(html_split_name($args['redirect_from']));
        } else {
            print htmlspecialchars($args['redirect_from']);
        }
        print "</a>)\n";
    }
    ?>
	
    <div class="quote printhide">
    <?php 
    if (isset($args['quote'])) {
        $quotepage = $pagestore->page('AnnoyingQuote');
        $quote = $quotepage->read();
        if ($quotepage->exists()) {
            global $ParseEngine;
            $paragraphs = explode("\n\n", $quotepage->text);
            $last_paragraph = parseText(trim(array_pop($paragraphs)), $ParseEngine, $page);
            print $last_paragraph;
        }
    }
    ?>
    </div>
  </div>

</div>
</NOINDEX>
	
<div id="contentbox">

 <?php 
    if (isset($args["toolbar"])) {
        ?>
  <div class="toolbar" id="toolbar-top">
    <?php 
        if ($args['spam_revert'] && $UseSpamRevert && $UserName) {
            ?>
        <form name="revertForm" method="post" action="<?php 
            print revertURL($page);
            ?>
"></form>
        <?php 
            print toolbar_button('javascript:spamRevert();', 'Spam Revert', 0);
            ?>
    <?php 
        }
        ?>
    <td><?php 
        toolbar($page, $args);
        ?>
  </div>
 <?php 
    }
    ?>

<?php 
}