/**
 * Parses the configuration array and displays the configuration screen
 *
 * @access public
 * @param   array       Configuration superarray
 * @param   array       The previous values submitted by the user
 * @param   boolean     If true, no HTML FORM container will be emitted
 * @param   boolean     If true, the configuration sections will all be folded
 * @param   boolean     If true, the user can turn config sections on and off
 * @param   boolean     If true, the user can NOT display possibly dangerous options
 * @return null
 */
function serendipity_printConfigTemplate($config, $from = false, $noForm = false, $folded = true, $allowToggle = true, $showDangerous = false)
{
    global $serendipity;
    $data = array();
    $data['noForm'] = $noForm;
    $data['formToken'] = serendipity_setFormToken();
    $data['allowToggle'] = $allowToggle;
    foreach ($config as &$category) {
        foreach ($category['items'] as &$item) {
            $value = $from[$item['var']];
            /* Calculate value if we are not installed, how clever :) */
            if ($from == false) {
                $value = serendipity_query_default($item['var'], $item['default']);
            }
            /* Check for installOnly flag */
            if (in_array('installOnly', $item['flags']) && IS_installed === true) {
                continue;
            }
            if (in_array('hideValue', $item['flags'])) {
                $value = '';
            }
            if (!$showDangerous && $item['view'] == 'dangerous') {
                continue;
            }
            if (in_array('config', $item['flags']) && isset($from['authorid'])) {
                $value = serendipity_get_user_config_var($item['var'], $from['authorid'], $item['default']);
            }
            if (in_array('parseDescription', $item['flags'])) {
                $item['description'] = serendipity_replaceEmbeddedConfigVars($item['description']);
            }
            if (in_array('probeDefault', $item['flags'])) {
                $item['default'] = serendipity_probeInstallation($item['var']);
            }
            if (in_array('ifEmpty', $item['flags']) && empty($value)) {
                $value = serendipity_query_default($item['var'], $item['default']);
            }
            $item['guessedInput'] = serendipity_guessInput($item['type'], $item['var'], $value, $item['default']);
        }
    }
    $data['config'] = $config;
    return serendipity_smarty_show('admin/config_template.tpl', $data);
}
/**
 * Parses the configuration array and displays the configuration screen
 *
 * @access public
 * @param   array       Configuration superarray
 * @param   array       The previous values submitted by the user
 * @param   boolean     If true, no HTML FORM container will be emitted
 * @param   boolean     If true, the configuration sections will all be folded
 * @param   boolean     If true, the user can turn config sections on and off
 * @param   boolean     If true, the user can NOT display possibly dangerous options
 * @return null
 */
function serendipity_printConfigTemplate($config, $from = false, $noForm = false, $folded = true, $allowToggle = true, $showDangerous = false)
{
    global $serendipity;
    if ($allowToggle) {
        ?>
<script type="text/javascript" language="JavaScript">
function showConfig(id) {
    if (document.getElementById) {
        el = document.getElementById(id);
        if (el.style.display == 'none') {
            document.getElementById('option' + id).src = '<?php 
        echo serendipity_getTemplateFile('img/minus.png');
        ?>
';
            el.style.display = '';
        } else {
            document.getElementById('option' + id).src = '<?php 
        echo serendipity_getTemplateFile('img/plus.png');
        ?>
';
            el.style.display = 'none';
        }
    }
}

var state='<?php 
        echo $folded === true ? '' : 'none';
        ?>
';
function showConfigAll(count) {
    if (document.getElementById) {
        for (i = 1; i <= count; i++) {
            document.getElementById('el' + i).style.display = state;
            document.getElementById('optionel' + i).src = (state == '' ? '<?php 
        echo serendipity_getTemplateFile('img/minus.png');
        ?>
' : '<?php 
        echo serendipity_getTemplateFile('img/plus.png');
        ?>
');
        }

        if (state == '') {
            document.getElementById('optionall').src = '<?php 
        echo serendipity_getTemplateFile('img/minus.png');
        ?>
';
            state = 'none';
        } else {
            document.getElementById('optionall').src = '<?php 
        echo serendipity_getTemplateFile('img/plus.png');
        ?>
';
            state = '';
        }
    }
}
</script>

<?php 
    }
    if (!$noForm) {
        ?>
<form action="?" method="POST">
    <div>
        <input type="hidden" name="serendipity[adminModule]" value="installer" />
        <input type="hidden" name="installAction" value="check" />
        <?php 
        echo serendipity_setFormToken();
        ?>
        <br />
<?php 
    }
    if (sizeof($config) > 1 && $allowToggle) {
        ?>
        <div align="right">
            <a style="border:0; text-decoration: none" href="#" onClick="showConfigAll(<?php 
        echo sizeof($config);
        ?>
)" title="<?php 
        echo TOGGLE_ALL;
        ?>
"><img src="<?php 
        echo serendipity_getTemplateFile('img/' . ($folded === true ? 'plus' : 'minus') . '.png');
        ?>
" id="optionall" alt="+/-" border="0" />&nbsp;<?php 
        echo TOGGLE_ALL;
        ?>
</a></a><br />
        </div>
<?php 
    }
    $el_count = 0;
    foreach ($config as $category) {
        $el_count++;
        ?>
        <table width="100%" cellspacing="2">
<?php 
        if (sizeof($config) > 1) {
            ?>
            <tr>
                <th align="left" colspan="2" style="padding-left: 15px;">
<?php 
            if ($allowToggle) {
                ?>
                    <a style="border:0; text-decoration: none;" href="#" onClick="showConfig('el<?php 
                echo $el_count;
                ?>
'); return false" title="<?php 
                echo TOGGLE_OPTION;
                ?>
"><img src="<?php 
                echo serendipity_getTemplateFile('img/' . ($folded === true ? 'plus' : 'minus') . '.png');
                ?>
" id="optionel<?php 
                echo $el_count;
                ?>
" alt="+/-" border="0" />&nbsp;<?php 
                echo $category['title'];
                ?>
</a>
<?php 
            } else {
                ?>
                    <?php 
                echo $category['title'];
            }
            ?>
                </th>
            </tr>
<?php 
        }
        ?>
            <tr>
                <td>
                    <table width="100%" cellspacing="0" cellpadding="3" id="el<?php 
        echo $el_count;
        ?>
">
                        <tr>
                            <td style="padding-left: 20px;" colspan="2">
                                <?php 
        echo $category['description'];
        ?>
                            </td>
                        </tr>

<?php 
        foreach ($category['items'] as $item) {
            $value = $from[$item['var']];
            /* Calculate value if we are not installed, how clever :) */
            if ($from == false) {
                $value = serendipity_query_default($item['var'], $item['default']);
            }
            /* Check for installOnly flag */
            if (in_array('installOnly', $item['flags']) && IS_installed === true) {
                continue;
            }
            if (in_array('hideValue', $item['flags'])) {
                $value = '';
            }
            if (!$showDangerous && $item['view'] == 'dangerous') {
                continue;
            }
            if (in_array('config', $item['flags']) && isset($from['authorid'])) {
                $value = serendipity_get_user_config_var($item['var'], $from['authorid'], $item['default']);
            }
            if (in_array('parseDescription', $item['flags'])) {
                $item['description'] = serendipity_replaceEmbeddedConfigVars($item['description']);
            }
            if (in_array('probeDefault', $item['flags'])) {
                $item['default'] = serendipity_probeInstallation($item['var']);
            }
            if (in_array('ifEmpty', $item['flags']) && empty($value)) {
                $value = serendipity_query_default($item['var'], $item['default']);
            }
            ?>
                        <tr>
                            <td style="border-bottom: 1px #000000 solid" align="left" valign="top" width="75%">
                                <strong><?php 
            echo $item['title'];
            ?>
</strong>
                                <br />
                                <span style="color: #5E7A94; font-size: 8pt;"><?php 
            echo $item['description'];
            ?>
</span>
                            </td>
                            <td style="border-bottom: 1px #000000 solid; font-size: 8pt" align="left" valign="middle" width="25%">
                                <span style="white-space: nowrap"><?php 
            echo serendipity_guessInput($item['type'], $item['var'], $value, $item['default']);
            ?>
</span>
                            </td>
                        </tr>
<?php 
        }
        ?>
                    </table><br /><br />
                </td>
            </tr>
        </table>
<?php 
    }
    if ($folded && $allowToggle) {
        echo '<script type="text/javascript" language="JavaScript">';
        for ($i = 1; $i <= $el_count; $i++) {
            echo 'document.getElementById("el' . $i . '").style.display = "none";' . "\n";
        }
        echo '</script>';
    }
    if (!$noForm) {
        ?>
        <input type="submit" value="<?php 
        echo CHECK_N_SAVE;
        ?>
" class="serendipityPrettyButton input_button" />
    </div>
</form>
<?php 
    }
}
示例#3
0
<br />
<form action="" method="POST" enctype="multipart/form-data">
  <?php 
        echo serendipity_setFormToken();
        ?>
  <table cellpadding="3" cellspacing="2">
    <?php 
        foreach ($importer->getInputFields() as $field) {
            ?>
    <tr>
      <td><?php 
            echo $field['text'];
            ?>
</td>
      <td><?php 
            serendipity_guessInput($field['type'], 'serendipity[import][' . $field['name'] . ']', isset($serendipity['POST']['import'][$field['name']]) ? $serendipity['POST']['import'][$field['name']] : $field['default'], $field['default']);
            ?>
</td>
    </tr>
    <?php 
        }
        ?>
    <?php 
        if ($notes = $importer->getImportNotes()) {
            ?>
    <tr>
      <td colspan="2">
        <b><?php 
            echo IMPORT_NOTES;
            ?>
</b><br />