Example #1
0
function testSet()
{
    // first we'll check legal settings
    $legalVals = array('autoLink' => array(true, false), 'cacheAge' => array(-1, 0, 1, 200, 100000000), 'failureTag' => array(null, '', 'pre', 'table', 'div'), 'format' => array('html', 'html-full', 'html-inline', 'latex', null, 'none'), 'htmlStrict' => array(true, false), 'includeJavascript' => array(true, false), 'includeJquery' => array(true, false), 'lineNumbers' => array(true, false), 'startLine' => array(1, 2, 3, 100, 10000, 9999999), 'maxHeight' => array(-1, 0, 1, 2, 3, 100, '100', '200px', '250%'), 'relativeRoot' => array(null, '', 'xyz', '/path/to/somewhere/'), 'theme' => Luminous::themes(), 'wrapWidth' => array(-1, 0, 2, 3, 100, 10000000, 999999999), 'highlightLines' => array(array(0, 1, 2)));
    foreach ($legalVals as $k => $vs) {
        foreach ($vs as $v) {
            assertSet($k, $v);
        }
    }
    // now the illegal ones should throw exceptions
    $illegalVals = array('autoLink' => array(1, 0, 'yes', 'no', null), 'cacheAge' => array(true, false, 1.1, 'all year', null), 'failureTag' => array(true, false, array()), 'format' => array('someformatter', '', true, false, 1, 2, 3), 'htmlStrict' => array(1, 0, 'yes', 'no', null, array()), 'includeJavascript' => array(1, 0, 'yes', 'no', null, array()), 'includeJquery' => array(1, 0, 'yes', 'no', null, array()), 'lineNumbers' => array(1, 0, 'yes', 'no', null, array()), 'startLine' => array(0, -1, true, false, null, array()), 'maxHeight' => array(null, true, false, array()), 'relativeRoot' => array(1, 0, true, false, array()), 'theme' => array('mytheme', null, true, false, 1, array()), 'wrapWidth' => array('wide', 1.5, true, false, null, array()), 'highlightLines' => array(1, 2, 3));
    foreach ($illegalVals as $k => $vs) {
        foreach ($vs as $v) {
            assertSetException($k, $v);
        }
    }
    // finally, we're going to use the old fashioned array indices and check that
    // they still correspond to the new keys. The old fashioned way used dashes
    // to separate words in the array. For impl. reasons we had to switch these
    // to underscores, but they should be aliases of each other as far as the
    // API is concerned.
    // FIXME: The conversion needs to be adjusted for new camelCaps option names
    foreach ($legalVals as $k => $vs) {
        foreach ($vs as $v) {
            $kOld = str_replace('_', '-', $k);
            Luminous::set($k, $v);
            assert(Luminous::setting($kOld) === $v);
            Luminous::set($kOld, $v);
            assert(Luminous::setting($k) === $v);
        }
    }
}
Example #2
0
    </head>
    <body>
        <p>
            <form action='themeswitcher.php'>
                Change Theme: <select name='theme_switcher' id='theme_switcher'>
                    <?php 
// Build the theme switcher by getting a list of legal themes from Luminous.
// The luminous_get_html_head() function by default outputs the theme
// in LUMINOUS_THEME. This can be overridden by the first argument, but as we
// didn't, that's what we need to check against to determine the default
// theme for the selector. However, it might not have the .css suffix.
$defaultTheme = Luminous::setting('theme');
if (!preg_match('/\\.css$/', $defaultTheme)) {
    $defaultTheme .= '.css';
}
foreach (Luminous::themes() as $theme) {
    ?>
                        <option id='<?php 
    echo $theme;
    ?>
'
                            <?php 
    echo $theme == $defaultTheme ? ' selected' : '';
    ?>
>
                            <?php 
    echo $theme;
    ?>
                        </option>
                    <?php 
}