Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d2b40c1
Showing
5 changed files
with
292 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
All source code included in the "Configuration Settings" Symphony Extension | ||
archive is, unless otherwise specified, released under the MIT licence as | ||
follows: | ||
|
||
----- begin license block ----- | ||
|
||
Copyright 2009 Stephen Bau | ||
|
||
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. | ||
|
||
----- end license block ----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Configuration Settings Extension | ||
------------------------------------ | ||
|
||
Version: 1.0 | ||
Author: Stephen Bau (stephen@domain7.com) | ||
Build Date: 2 January 2009 | ||
Requirements: Symphony 2.0 | ||
|
||
|
||
[INSTALLATION] | ||
|
||
1. Upload the 'configuration' folder in this archive to your Symphony 'extensions' folder. | ||
|
||
2. Enable it by selecting the "Configuration Settings" Extension, choose Enable from the with-selected menu, then click Apply. | ||
|
||
3. You can now edit the Configuration Settings file (/manifest/config.php) from within the Symphony administration interface. | ||
|
||
|
||
[USAGE] | ||
|
||
- A "Configuration" menu is added to the Symphony administration interface that provides an Overview page and an Edit page. | ||
|
||
- Edit only the setting values unless you want to add additional rows to the $settings array. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
table.selectable input{ | ||
display:inline; | ||
float:none; | ||
width:100%; | ||
} | ||
div.actions input:first-child { | ||
color:#000; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
<?php | ||
|
||
require_once(TOOLKIT . '/class.administrationpage.php'); | ||
|
||
define_safe('BASE_URL', URL . '/symphony/extension/configuration/settings'); | ||
|
||
Class contentExtensionConfigurationSettings extends AdministrationPage{ | ||
|
||
private $_driver; | ||
private $_page; | ||
private $_flag; | ||
|
||
function __construct(&$parent){ | ||
parent::__construct($parent); | ||
|
||
$this->_driver = $this->_Parent->ExtensionManager->create('configuration'); | ||
} | ||
|
||
function view(){ | ||
$this->__switchboard(); | ||
} | ||
|
||
function action(){ | ||
$this->__switchboard('action'); | ||
if (array_key_exists('save', $_POST['action'])) $this->save(); | ||
if (array_key_exists('edit', $_POST['action'])) $this->edit(); | ||
} | ||
|
||
function __switchboard($type='view'){ | ||
|
||
$this->_page = $this->_context['0']; | ||
$this->_flag = $this->_context['1']; | ||
|
||
$function = ($type == 'action' ? '__action' : '__view') . (isset($this->_page) ? ucfirst($this->_page) : 'Index') ; | ||
|
||
if(!method_exists($this, $function)) { | ||
|
||
## If there is no action function, just return without doing anything | ||
if($type == 'action') return; | ||
|
||
$this->_Parent->errorPageNotFound(); | ||
|
||
} | ||
|
||
$this->$function(); | ||
|
||
} | ||
|
||
function __viewIndex(){ | ||
|
||
$link = new XMLElement('link'); | ||
$link->setAttributeArray(array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen', 'href' => URL . '/extensions/configuration/assets/configuration.css')); | ||
$this->addElementToHead($link, 500); | ||
|
||
$this->setTitle('Symphony – Configuration Settings'); | ||
$this->setPageType('table'); | ||
|
||
$this->appendSubheading('Configuration Settings'); | ||
|
||
## Table Headings | ||
$aTableHead = array( | ||
array('Group', 'col'), | ||
array('Setting', 'col'), | ||
array('Value', 'col') | ||
); | ||
|
||
## Get Configuration Settings and display as a table list | ||
$config_settings = $this->_Parent->Configuration->get(); | ||
|
||
$tableData = array(); | ||
|
||
foreach($config_settings as $key => $groups) | ||
{ | ||
foreach($groups as $name => $value) { | ||
$setting_group = $key; | ||
$setting_name = $name; | ||
$setting_value = $value; | ||
|
||
$tableData[] = Widget::TableData($setting_group); | ||
$tableData[] = Widget::TableData($setting_name); | ||
$tableData[] = Widget::TableData($setting_value); | ||
|
||
$aTableBody[] = Widget::TableRow($tableData, ($bEven ? 'even' : NULL)); | ||
|
||
$bEven = !$bEven; | ||
|
||
unset($tableData); | ||
} | ||
} | ||
|
||
$table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody)); | ||
$this->Form->appendChild($table); | ||
|
||
## Edit Button | ||
$tableActions = new XMLElement('div'); | ||
$tableActions->setAttribute('class', 'actions'); | ||
$tableActions->appendChild(Widget::Input('action[edit]', 'Edit Settings', 'submit')); | ||
$this->Form->appendChild($tableActions); | ||
} | ||
|
||
function __viewEdit(){ | ||
|
||
$link = new XMLElement('link'); | ||
$link->setAttributeArray(array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen', 'href' => URL . '/extensions/configuration/assets/configuration.css')); | ||
$this->addElementToHead($link, 500); | ||
|
||
$this->setTitle('Symphony – Configuration – Edit Settings'); | ||
$this->setPageType('table'); | ||
|
||
$this->appendSubheading('Edit Configuration Settings'); | ||
|
||
## Table Headings | ||
$aTableHead = array( | ||
array('Group', 'col'), | ||
array('Setting', 'col'), | ||
array('Value', 'col') | ||
); | ||
|
||
## Get Configuration Settings and display as a table list | ||
$config_settings = $this->_Parent->Configuration->get(); | ||
|
||
$tableData = array(); | ||
$count = 0; | ||
|
||
foreach($config_settings as $key => $groups) | ||
{ | ||
foreach($groups as $name => $value) { | ||
$setting_group = $key; | ||
$setting_name = $name; | ||
$setting_value = $value; | ||
|
||
$tableData[] = Widget::TableData(Widget::Input('settings[' . $count . '][group]', $setting_group, 'text')); | ||
$tableData[] = Widget::TableData(Widget::Input('settings[' . $count . '][name]', $setting_name, 'text')); | ||
$tableData[] = Widget::TableData(Widget::Input('settings[' . $count . '][value]', $setting_value, 'text')); | ||
|
||
$count++; | ||
|
||
$aTableBody[] = Widget::TableRow($tableData, ($bEven ? 'even' : NULL)); | ||
|
||
$bEven = !$bEven; | ||
|
||
unset($tableData); | ||
} | ||
} | ||
|
||
$table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody)); | ||
$this->Form->appendChild($table); | ||
|
||
## Save Button | ||
$div = new XMLElement('div'); | ||
$div->setAttribute('class', 'actions'); | ||
$div->appendChild(Widget::Input('action[save]', 'Save Settings', 'submit', array('accesskey' => 's'))); | ||
$this->Form->appendChild($div); | ||
|
||
## Notice Messages | ||
if(isset($this->_flag)) | ||
{ | ||
switch($this->_flag){ | ||
|
||
case 'saved': | ||
$this->pageAlert('Configuration Settings updated successfully.', AdministrationPage::PAGE_ALERT_NOTICE); | ||
break; | ||
|
||
case 'error': | ||
$this->pageAlert('An error occurred.', AdministrationPage::PAGE_ALERT_NOTICE); | ||
break; | ||
|
||
} | ||
} | ||
} | ||
|
||
/* function __actionEdit(){ | ||
redirect(BASE_URL . '/edit/'); | ||
} | ||
*/ | ||
|
||
function save() { | ||
$settings = $_POST['settings']; | ||
$count = count($settings) - 1; | ||
for ($i=0; $i<=$count; $i++) { | ||
$setting_group = $settings[$i]['group']; | ||
$setting_name = $settings[$i]['name']; | ||
$setting_value = $settings[$i]['value']; | ||
|
||
$this->_Parent->Configuration->set($setting_name, $setting_value, $setting_group); | ||
} | ||
$this->_Parent->saveConfig(); | ||
return redirect(BASE_URL . '/edit/saved/'); | ||
} | ||
|
||
function edit() { | ||
return redirect(BASE_URL . '/edit/'); | ||
} | ||
|
||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
class extension_configuration extends Extension { | ||
public function about() { | ||
return array( | ||
'name' => 'Configuration Settings', | ||
'version' => '1.0', | ||
'release-date' => '2009-01-02', | ||
'author' => array( | ||
'name' => 'Stephen Bau', | ||
'website' => 'http://www.domain7.com/', | ||
'email' => 'stephen@domain7.com' | ||
), | ||
'description' => 'Admin interface for Symphony System Preferences' | ||
); | ||
} | ||
|
||
public function fetchNavigation(){ | ||
return array( | ||
array( | ||
'location' => 400, | ||
'name' => 'Configuration', | ||
'children' => array( | ||
array( | ||
'name' => 'Overview', | ||
'link' => '/settings/' | ||
), | ||
array( | ||
'name' => 'Edit Settings', | ||
'link' => '/settings/edit/' | ||
) | ||
) | ||
) | ||
); | ||
} | ||
} | ||
|
||
?> |