root > WikiSense-trunk > web > TickerMatrix.php

TickerMatrix.php

application/x-php, 5609 bytes (load raw)
<?
if ( defined( 'WS_TOC' ) ) {
        $info['description'] = "Overview of CommonsTicker configuration";
        return;
}

define( 'WS_WEB', true );
require_once('common/WebInit.php');

function getValueHtml($key, $value, $isset) {
        if ($value === NULL) {
                if ($isset) return '<span class="null">NULL</span>';
                else return '';
        }
        else if ($value === true) return '<span class="true">Y</span>';
        else if ($value === false) return '<span class="false">N</span>';
        else if (is_int($value)) return '<span class="int">'.$value.'</span>';
        else if (is_float($value)) return '<span class="float">'.$value.'</span>';
        else if (is_string($value)) {
                if ($value === '') return '<span class="empty-string">""</span>';
                else return '<span class="string">'.escapeHtml($value).'</span>';
        }
        else return '<span class="other">'.escapeHtml($value).'</span>';
}

function listTickers($title, $glob, $settings) {
        print "\n<h2>".escapeHtml($title)."</h2>\n";

        print "<table>\n";
        print "<tr>\n";
        foreach ($settings as $key => $info) {
                print '<th><span class="title">'.escapeHtml($info['name']).'</span><br/><span class="key">'.escapeHtml($key).'</span></th>';
        }
        print "</tr>\n";

        $ff = glob($glob);
        foreach ($ff as $f) {
                if (!is_file($f) || !is_readable($f)) continue;
       
                $n = basename($f);
                unset($config);
                include($f);

                $wiki = getWikiInfoFromDomain( $config[0] );
                if ($wiki) {
                        $config['_domain'] = $wiki->domain;
       
                        if (isset($config['file'])) {
                                $file = $config['file'];
                        }
                        else {
                                $file = $GLOBALS['wsgPersistentStateDir'] . '/' . str_replace('.', '-', $wiki->domain) . '.ticker';
                        }
       
                        $pending = glob($file.'*.pending');#
                        if ($pending) $config['_pending'] = sizeof($pending);
                }
                else {
                        $config['_domain'] = NULL;
                }

                print "<tr>\n";
                foreach ($settings as $key => $info) {
                        $isset = isset($config[$key]);

                        if ($isset) $value = @$config[$key];
                        else $value = @$info['default'];

                        $cls = '';
                        if (!$isset) {
                                if ($value === NULL) $cls = 'no-value';
                                else $cls = 'default-value';
                        }

                        $cls .= ' key-' . $key;

                        $html = getValueHtml($key, $value, $isset);

                        print "\t<td class='$cls'>$html</td>\n";
                }

                print "</tr>\n";
        }
        print "</table>\n";
}

$tickerDir = "/home/daniel/.wikisense";

$classicSettings = array(
        '_domain' =>          array( 'name' => 'Wiki' ),
        'local-contact' =>   array( 'name' => 'Contact' ),
        'post' =>            array( 'name' => 'Page', 'default' => 'Project:CommonsTicker' ),
        'notify' =>          array( 'name' => 'Notify' ),
        'incremental' =>     array( 'name' => 'Append''default' => false  ),
        'rotating' =>        array( 'name' => 'Replace''default' => false ),
        'reverse' =>         array( 'name' => 'Reverse''default' => false ),
        'since' =>           array( 'name' => 'Span' ),
        'nominor' =>         array( 'name' => 'No Minor''default' => false ),
        'template' =>        array( 'name' => 'Template', 'default' => 'TickerEntry'  ),
        'notify-template' => array( 'name' => 'Template', 'default' => 'TickerNotification'  ),
        '_pending' =>         array( 'name' => 'Pending'  ),
);

$ngSettings = array(
        '_domain' =>          array( 'name' => 'Wiki' ),
        'local-contact' =>   array( 'name' => 'Contact' ),
        'post' =>            array( 'name' => 'Page', 'default' => 'Project:CommonsTicker' ),
        'notify' =>          array( 'name' => 'Notify' ),
        'mode' =>            array( 'name' => 'Mode''default' => 'subpage'  ),
        'reverse' =>         array( 'name' => 'Reverse''default' => false ),
        'since' =>           array( 'name' => 'Span' ),
        'nominor' =>         array( 'name' => 'No Minor''default' => false ),
        'template' =>        array( 'name' => 'Template', 'default' => 'TickerEntry'  ),
        'notify-template' => array( 'name' => 'Template', 'default' => 'TickerNotification'  ),
        'date-pattern' =>    array( 'name' => 'Date Pattern'  ),
        '_pending' =>         array( 'name' => 'Pending'  ),
);


header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
        <head>
                <title>ToolTOC</title>
                <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />

                <style type="text/css">
                        table { border: 1px solid #888888; }
                        th { background-color: #CCCCFF; white-space:nowrap; vertical-align: top; text-align:left; }
                        .key { font-family: monospace; font-weight:normal; font-size:100%; }
                        .title { font-weight:bold; font-size:80%; }
                        td { background-color: #EEEEEE; vertical-align: top;  text-align:left; }
                        .default-value { background-color: white; color: #888888; }
                        .no-value { background-color: white; }
                        .null, .true, .false, .empty-string { font-style: italic; font-size:100%; font-family: monospace; }
                        .string { font-family: monospace; }
                        .key-_pending { font-weight: bold; color:red; }
                </style>
        </head>
       
        <body>
               <? wsfHeader(); ?>

               <h1>TickerMatrix</h1>

                <?
                        listTickers("Tickers NG", "$tickerDir/tickersNG/*.config", $ngSettings);
                        listTickers("Tickers", "$tickerDir/tickers/*.config", $classicSettings);
                        listTickers("Experimental (trunk)", "$tickerDir/experimental-tickers/*.config", $classicSettings);
                        listTickers("Disabled Tickers", "$tickerDir/disabled-tickers/*.config", $classicSettings);
                        listTickers("Inactive/Incomplete", "$tickerDir/inactive-tickers/*.config", $classicSettings);
                        listTickers("Testing", "$tickerDir/test-tickers/*.config", $classicSettings);
                ?>

               <? wsfFooter(false); ?>
        </body>
</html>