Skip to content

Commit

Permalink
[feat] Display edit fields for extra config files
Browse files Browse the repository at this point in the history
This will read any extra config files and display basic text inputs
so they values can be adjusted and preserved upon save.
  • Loading branch information
zooley committed Apr 16, 2019
1 parent bb418e1 commit e8acdaf
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/components/com_config/admin/controllers/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,12 @@ public function saveTask()
return false;
}

// 'other' is passed as a separate array because form validation
// above will strip it out,
$other = Request::getArray('hzother', array(), 'post');
$data = array_merge($return, $other);

// Attempt to save the configuration.
$data = $return;
$return = $model->save($data);

// Check the return value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ COM_CONFIG_TEXT_FILTERS="Text Filters"
COM_CONFIG_TEXT_FILTERS_DESC="These text filter settings will be applied to all text editor fields submitted by users in the selected groups.<br />These filtering options give more control over the HTML your content providers submit. You can be as strict or as liberal as you require to suit your site needs. The filtering is opt-in and the default settings provide good protection against markup commonly associated with Web site attacks."
COM_CONFIG_XML_DESCRIPTION="Configuration Manager"
JLIB_RULES_SETTING_NOTES="1. If you change the setting, it will apply to this and all child groups, components and content. Note that:<br /> <em>Inherited</em> means that the permissions from the parent group will be used.<br /> <em>Denied</em> means that no matter what the parent group's setting is, the group being edited cannot take this action.<br /> <em>Allowed</em> means that the group being edited will be able to take this action (but if this is in conflict with the parent group it will have no impact; a conflict will be indicated by <em>Not Allowed (Locked)</em> under Calculated Settings).<br /> <em>Not Set</em> is used only for the Public group in global configuration. The Public group is the parent of all other groups. If a permission is not set, it is treated as deny but can be changed for child groups, components, categories and items.<br />2. If you select a new setting, click <em>Save</em> to refresh the calculated settings."
COM_CONFIG_OTHER_SETTINGS="%s settings"

; API
COM_CONFIG_API="API"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@
Html::behavior('switcher', 'submenu');
Html::behavior('tooltip');

$ignore = array(
'app', 'site', 'offline', 'meta', 'seo', 'cookie', 'system',
'debug', 'cache', 'session', 'server', 'locale', 'ftp', 'database',
'mail', 'api', 'permissions', 'filters', 'rate_limit', 'asset_id'
);

$others = array();
foreach ($this->data as $section => $values):
if (in_array($section, $ignore)):
continue;
endif;

if (empty($values) || !is_array($values)):
continue;
endif;

$this->others[$section] = $values;
endforeach;

// Load submenu template, using element id 'submenu' as needed by behavior.switcher
Document::setBuffer($this->loadTemplate('navigation'), 'modules', 'submenu');

Expand Down Expand Up @@ -113,6 +132,19 @@
<?php echo $this->loadTemplate('filters'); ?>
</div>
</div>
<?php
foreach ($this->others as $section => $values):
$this->section = $section;
$this->values = $values;
?>
<div id="page-<?php echo $section; ?>" class="tab">
<div class="noshow">
<?php echo $this->loadTemplate('other'); ?>
</div>
</div>
<?php
endforeach;
?>
<input type="hidden" name="task" value="" />
<?php echo Html::input('token'); ?>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
<li><a href="#page-api" id="api"><?php echo Lang::txt('COM_CONFIG_API'); ?></a></li>
<li><a href="#page-permissions" id="permissions"><?php echo Lang::txt('COM_CONFIG_PERMISSIONS'); ?></a></li>
<li><a href="#page-filters" id="filters"><?php echo Lang::txt('COM_CONFIG_TEXT_FILTERS')?></a></li>
<?php foreach ($this->others as $key => $data): ?>
<li><a href="#page-<?php echo $key; ?>" id="<?php echo $key; ?>"><?php echo $key; ?></a></li>
<?php endforeach; ?>
</ul>
<div class="clr"></div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* HUBzero CMS
*
* Copyright 2005-2015 HUBzero Foundation, LLC.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* HUBzero is a registered trademark of Purdue University.
*
* @package hubzero-cms
* @author Shawn Rice <[email protected]>
* @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
* @license http://opensource.org/licenses/MIT MIT
*/

// No direct access
defined('_HZEXEC_') or die();
?>
<div class="width-100">
<fieldset class="adminform">
<legend><span><?php echo Lang::txt('COM_CONFIG_OTHER_SETTINGS', $this->section); ?></span></legend>

<?php
foreach ($this->values as $key => $val):
if (is_array($val)):
foreach ($val as $k => $v):
?>
<div class="input-wrap">
<label for="hzform_<?php echo $this->section; ?>_<?php echo $key; ?>_<?php echo $k; ?>"><?php echo $key; ?></label>
<input type="text" name="hzother[<?php echo $this->section; ?>][<?php echo $key; ?>][<?php echo $k; ?>]" id="hzform_<?php echo $this->section; ?>_<?php echo $key; ?>_<?php echo $k; ?>" value="<?php echo $this->escape($v); ?>" />
</div>
<?php
endforeach;
else:
?>
<div class="input-wrap">
<label for="hzform_<?php echo $this->section; ?>_<?php echo $key; ?>"><?php echo $key; ?></label>
<input type="text" name="hzother[<?php echo $this->section; ?>][<?php echo $key; ?>]" id="hzform_<?php echo $this->section; ?>_<?php echo $key; ?>" value="<?php echo $this->escape($val); ?>" />
</div>
<?php
endif;
endforeach;
?>
</fieldset>
</div>

0 comments on commit e8acdaf

Please sign in to comment.