Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
default values of stream settings are now editable
- Loading branch information
Showing
4 changed files
with
125 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,58 @@ | ||
<?php | ||
/** | ||
* User: peaceman | ||
* Date: 4/24/12 | ||
* Time: 10:30 PM | ||
*/ | ||
class SettingController extends \SAP\Controller\Action | ||
{ | ||
public function defaultStreamSettingsAction() | ||
{ | ||
$defaultStreamSettings = $this->_getServerSettingMapper()->fetchAll(); | ||
$this->view->assign('settings', $defaultStreamSettings); | ||
} | ||
|
||
public function editDefaultStreamSettingAction() | ||
{ | ||
$serverSettingModel = $this->_getSettingModelFromRequestOrRedirectToListing(); | ||
$editServerSettingForm = new Application_Form_ServerSettingEdit(array('model' => $serverSettingModel)); | ||
|
||
/** @var $request Zend_Controller_Request_Http */ | ||
$request = $this->getRequest(); | ||
if ($request->isPost() && $editServerSettingForm->isValid($request->getPost())) { | ||
$serverSettingModel->setFromArray($editServerSettingForm->getValues()); | ||
$this->_getServerSettingMapper()->save($serverSettingModel); | ||
|
||
$this->getFlashMessenger()->addSuccessMessage(sprintf('successfully edited default stream setting (%s)', $serverSettingModel->getName())); | ||
$this->_redirect($this->url('default-stream-settings'), array('exit' => true)); | ||
} | ||
|
||
$this->view->assign(array( | ||
'form' => $editServerSettingForm, | ||
'setting' => $serverSettingModel, | ||
)); | ||
} | ||
|
||
protected function _getSettingModelFromRequestOrRedirectToListing() | ||
{ | ||
$id = $this->_getParam('id'); | ||
$settingModel = $this->_getServerSettingMapper()->find($id); | ||
|
||
if (!$settingModel) { | ||
$this->getFlashMessenger()->addErrorMessage(sprintf('unknown setting with id %d', $id)); | ||
$this->_redirect($this->url('default-stream-settings'), array('exit' => true)); | ||
} | ||
|
||
return $settingModel; | ||
} | ||
|
||
protected function _getServerSettingMapper() | ||
{ | ||
static $serverSettingMapper; | ||
if ($serverSettingMapper === null) { | ||
$serverSettingMapper = new Application_Model_ServerSettingMapper; | ||
} | ||
|
||
return $serverSettingMapper; | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
/** | ||
* User: peaceman | ||
* Date: 4/24/12 | ||
* Time: 10:49 PM | ||
*/ | ||
class Application_Form_ServerSettingEdit extends \SAP\Form | ||
{ | ||
public function init() | ||
{ | ||
$defaultValueField = new Zend_Form_Element_Text('default_value'); | ||
$defaultValueField->setLabel('Default value'); | ||
|
||
$submitButton = new Zend_Form_Element_Submit('edit'); | ||
|
||
$this->addElements(array( | ||
$defaultValueField, | ||
$submitButton, | ||
)); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
application/views/scripts/setting/default-stream-settings.phtml
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,37 @@ | ||
<?php | ||
/** | ||
* User: peaceman | ||
* Date: 4/24/12 | ||
* Time: 10:34 PM | ||
*/ | ||
?> | ||
<h3>list default stream settings</h3> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>id</th> | ||
<th>name</th> | ||
<th>value</th> | ||
<th>#</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<?php foreach ($this->settings as $setting): ?> | ||
<?php /* @var $setting Application_Model_ServerSetting */ ?> | ||
<tr> | ||
<td> | ||
<?php echo $this->escape($setting->getId()) ?> | ||
</td> | ||
<td> | ||
<?php echo $this->escape($setting->getName()) ?> | ||
</td> | ||
<td> | ||
<?php echo $this->escape($setting->getDefaultValue()) ?> | ||
</td> | ||
<td> | ||
<a href="<?php echo $this->url(array('controller' => 'setting', 'action' => 'edit-default-stream-setting', 'id' => $setting->getId())) ?>">edit</a> | ||
</td> | ||
</tr> | ||
<?php endforeach ?> | ||
</tbody> | ||
</table> |
9 changes: 9 additions & 0 deletions
9
application/views/scripts/setting/edit-default-stream-setting.phtml
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,9 @@ | ||
<?php | ||
/** | ||
* User: peaceman | ||
* Date: 4/24/12 | ||
* Time: 10:45 PM | ||
*/ | ||
?> | ||
<h3>edit default stream setting - <?php echo $this->escape($this->setting->getName()) ?></h3> | ||
<?php echo $this->form ?> |