svn: /pear2/sandbox/Pyrus_WebFrontend/trunk/ src/pear2/Pyrus/WebFrontend/EditConfiguration.php www/templates/WebFrontend/EditConfiguration.tpl.php
| From: | Brett Bieber | Date: | Tue, 23 Mar 2010 18:01:11 +0000 |
| Subject: | svn: /pear2/sandbox/Pyrus_WebFrontend/trunk/ src/pear2/Pyrus/WebFrontend/EditConfiguration.php www/templates/WebFrontend/EditConfiguration.tpl.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-9326@lists.php.net to get a copy of this message | ||
saltybeagle Tue, 23 Mar 2010 18:01:11 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=296684
Log:
Follow some DRY principles for the fieldset sections and get config saving.
Changed paths:
U pear2/sandbox/Pyrus_WebFrontend/trunk/src/pear2/Pyrus/WebFrontend/EditConfiguration.php
U pear2/sandbox/Pyrus_WebFrontend/trunk/www/templates/WebFrontend/EditConfiguration.tpl.php
Modified: pear2/sandbox/Pyrus_WebFrontend/trunk/src/pear2/Pyrus/WebFrontend/EditConfiguration.php
===================================================================
---
pear2/sandbox/Pyrus_WebFrontend/trunk/src/pear2/Pyrus/WebFrontend/EditConfiguration.php 2010-03-23
17:34:11 UTC (rev 296683)
+++
pear2/sandbox/Pyrus_WebFrontend/trunk/src/pear2/Pyrus/WebFrontend/EditConfiguration.php 2010-03-23
18:01:11 UTC (rev 296684)
@@ -6,10 +6,10 @@
function __construct($options = array())
{
+ $this->config = Controller::getConfig();
if (isset($_POST)) {
$this->handlePost();
}
- $this->config = Controller::getConfig();
}
function handlePost()
@@ -17,6 +17,14 @@
if (isset($_POST['_type'], $_POST['config'])
&& is_array($_POST['config'])) {
// OK
+ foreach ($_POST['config'] as $var=>$value) {
+ if (in_array($var, $this->config->uservars)
+ || in_array($var, $this->config->systemvars)) {
+ $this->config->$var = $value;
+ }
+ $this->config->$var = $value;
+ }
+ $this->config->saveConfig();
}
}
Modified: pear2/sandbox/Pyrus_WebFrontend/trunk/www/templates/WebFrontend/EditConfiguration.tpl.php
===================================================================
---
pear2/sandbox/Pyrus_WebFrontend/trunk/www/templates/WebFrontend/EditConfiguration.tpl.php 2010-03-23
17:34:11 UTC (rev 296683)
+++
pear2/sandbox/Pyrus_WebFrontend/trunk/www/templates/WebFrontend/EditConfiguration.tpl.php 2010-03-23
18:01:11 UTC (rev 296684)
@@ -1,51 +1,33 @@
+<?php $parent->context->page_title = 'Edit Configuration'; ?>
<h2>Edit Configuration</h2>
<form method="post" action="?view=config">
+ <input type="hidden" name="_type" value="config" />
+ <?php
+ $non_editable = array('php_dir', 'data_dir');
+ $sections = array(
+ 'mainsystemvars' => 'System Paths:',
+ 'customsystemvars' => 'Custom System paths:',
+ 'mainuservars' => 'User config (from
'.$context->userfile.'):',
+ 'mainchannelvars' => '(variables specific to
'.$context->default_channel.'):',
+ 'customuservars' => 'Custom User config (from
'.$context->userfile.'):',
+ 'customchannelvars' => '(variables specific to
'.$context->default_channel.'):'
+ );
+ foreach ($sections as $section=>$legend) :
+ ?>
<fieldset>
- <legend>System paths:</legend>
+ <legend><?php echo $legend; ?></legend>
<?php
- foreach ($context->mainsystemvars as $var) {
- echo "<label>$var:</label><input name=\"$var\"
type=\"text\" value=\"{$context->$var}\" /><br />\n";
+ foreach ($context->$section as $var) {
+ echo "<label>$var:</label>";
+ if (!in_array($var, $non_editable)) {
+ echo "<input name=\"config[$var]\" type=\"text\"
value=\"{$context->$var}\" /><br />\n";
+ } else {
+ echo $context->$var.'<br />';
+ }
}
?>
</fieldset>
- <fieldset>
- <legend>Custom System paths:</legend>
- <?php
- foreach ($context->customsystemvars as $var) {
- echo "<label>$var:</label><input name=\"$var\"
type=\"text\" value=\"{$context->$var}\" /><br />\n";
- }
- ?>
- </fieldset>
- <fieldset>
- <legend>User config (from <?php echo $context->userfile; ?>):</legend>
- <?php
- foreach ($context->mainuservars as $var) {
- echo "<label>$var:</label><input name=\"$var\"
type=\"text\" value=\"{$context->$var}\" /><br />\n";
- }
- ?>
- </fieldset>
- <fieldset>
- <legend>(variables specific to <?php echo $context->default_channel;
?>):</legend>
- <?php
- foreach ($context->mainchannelvars as $var) {
- echo "<label>$var:</label><input name=\"$var\"
type=\"text\" value=\"{$context->$var}\" /><br />\n";
- }
- ?>
- </fieldset>
- <fieldset>
- <legend>Custom User config (from <?php echo $context->userfile;
?>):</legend>
- <?php
- foreach ($context->customuservars as $var) {
- echo "<label>$var:</label><input name=\"$var\"
type=\"text\" value=\"{$context->$var}\" /><br />\n";
- }
- ?>
- </fieldset>
- <fieldset>
- <legend>(variables specific to <?php echo $context->default_channel;
?>):</legend>
- <?php
- foreach ($context->customchannelvars as $var) {
- echo "<label>$var:</label><input name=\"$var\"
type=\"text\" value=\"{$context->$var}\" /><br />\n";
- }
- ?>
- </fieldset>
+ <?php endforeach; ?>
+
+ <input type="submit" value="Submit" />
</form>
\ No newline at end of file