コード例 #1
0
ファイル: refcount.php プロジェクト: BogusCurry/pmwiki
function PrintRefCount($pagename)
{
    global $GroupPattern, $NamePattern, $PageRefCountFmt, $RefCountTimeFmt;
    $pagelist = ListPages();
    $grouplist = array();
    foreach ($pagelist as $pname) {
        if (!preg_match("/^({$GroupPattern})[\\/.]({$NamePattern})\$/", $pname, $m)) {
            continue;
        }
        $grouplist[$m[1]] = $m[1];
    }
    asort($grouplist);
    $grouplist = array_merge(array('all' => 'all groups'), $grouplist);
    $wlist = array('all', 'missing', 'existing', 'orphaned');
    $tlist = isset($_REQUEST['tlist']) ? $_REQUEST['tlist'] : array('all');
    $flist = isset($_REQUEST['flist']) ? $_REQUEST['flist'] : array('all');
    $whichrefs = @$_REQUEST['whichrefs'];
    $showrefs = @$_REQUEST['showrefs'];
    $submit = @$_REQUEST['submit'];
    echo FmtPageName($PageRefCountFmt, $pagename);
    echo "<form method='post'><input type='hidden' action='refcount'>\n    <table cellspacing='10'><tr><td valign='top'>Show\n    <br><select name='whichrefs'>";
    foreach ($wlist as $w) {
        echo "<option ", $whichrefs == $w ? 'selected' : '', " value='{$w}'>{$w}\n";
    }
    echo "</select></td><td valign='top'> page names in group<br>\n    <select name='tlist[]' multiple size='4'>";
    foreach ($grouplist as $g => $t) {
        echo "<option ", in_array($g, $tlist) ? 'selected' : '', " value='{$g}'>{$t}\n";
    }
    echo "</select></td><td valign='top'> referenced from pages in<br>\n    <select name='flist[]' multiple size='4'>";
    foreach ($grouplist as $g => $t) {
        echo "<option ", in_array($g, $flist) ? 'selected' : '', " value='{$g}'>{$t}\n";
    }
    echo "</select></td></tr></table>\n    <p><input type='checkbox' name='showrefs' value='checked' {$showrefs}>\n      Display referencing pages\n    <p><input type='submit' name='submit' value='Search'></form><p><hr>";
    if ($submit) {
        foreach ($pagelist as $pname) {
            $ref = array();
            $page = ReadPage($pname, READPAGE_CURRENT);
            if (!$page) {
                continue;
            }
            $tref[$pname]['time'] = $page['time'];
            if (!in_array('all', $flist) && !in_array(FmtPageName('$Group', $pname), $flist)) {
                continue;
            }
            $rc = preg_match('/RecentChanges$/', $pname);
            foreach (explode(',', @$page['targets']) as $r) {
                if ($r == '') {
                    continue;
                }
                if ($rc) {
                    @$tref[$r]['rc']++;
                } else {
                    @$tref[$r]['page']++;
                    @$pref[$r][$pname]++;
                }
            }
        }
        uasort($tref, 'RefCountCmp');
        echo "<table >\n      <tr><th></th><th colspan='2'>Referring pages</th></tr>\n      <tr><th>Name / Time</th><th>All</th><th>R.C.</th></tr>";
        reset($tref);
        foreach ($tref as $p => $c) {
            if (!in_array('all', $tlist) && !in_array(FmtPageName('$Group', $p), $tlist)) {
                continue;
            }
            if ($whichrefs == 'missing' && PageExists($p)) {
                continue;
            } elseif ($whichrefs == 'existing' && !PageExists($p)) {
                continue;
            } elseif ($whichrefs == 'orphaned' && (@$tref[$p]['page'] > 0 || !PageExists($p))) {
                continue;
            }
            echo "<tr><td valign='top'>", LinkPage($pagename, '', $p, '', $p);
            if (@$tref[$p]['time']) {
                echo strftime($RefCountTimeFmt, $tref[$p]['time']);
            }
            if ($showrefs && is_array(@$pref[$p])) {
                foreach ($pref[$p] as $pr => $pc) {
                    echo "<dd>", LinkPage($pagename, '', $pr, '', $pr);
                }
            }
            echo "</td>";
            echo "<td align='center' valign='top'>", @$tref[$p]['page'] + 0, "</td>";
            echo "<td align='center' valign='top'>", @$tref[$p]['rc'] + 0, "</td>";
            echo "</tr>";
        }
        echo "</table>";
    }
}
コード例 #2
0
ファイル: index.php プロジェクト: jhunkeler/bayonetcms
global $db;
/**
 * List available pages.
 * Only right now I don't know if the _pages table has been deprecated.
 * I'm confused.  -jhunk
 */
if (isset($_GET['list'])) {
    if ($_GET['list'] == "true") {
        $results = $db->Query("SELECT title, page_id FROM bayonet_articles");
        $pages = $db->Fetch($results);
        OpenContent();
        echo "<div class=\"contentHeading\">Page Map</div>";
        echo "<div class=\"content\">";
        echo "<ul>";
        foreach ($pages as $page) {
            echo "<li>" . LinkPage($page['page_id'], $page['title']) . "</li>";
        }
        echo "</ul>";
        echo "</div>";
        CloseContent();
        /* Kill module execution to prevent odd page results */
        return;
    }
}
if (!isset($_GET['id'])) {
    //ReportError("No page has been requested.<br>\n");
    // return 1;
    $id = 1;
    //makes it so that the default page is the home page
} else {
    $id = $_GET['id'];