Update directory layout to fit with other projects
This commit is contained in:
55
source/webui/pages/ajax/admin/add-setting.php
Normal file
55
source/webui/pages/ajax/admin/add-setting.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
$main = RippingCluster_Main::instance();
|
||||
$req = $main->request();
|
||||
$config = $main->config();
|
||||
|
||||
$messages = array();
|
||||
$result = false;
|
||||
|
||||
try {
|
||||
$name = $req->get('name', 'RippingCluster_Exception_InvalidParameters');
|
||||
$type = $req->get('type', 'RippingCluster_Exception_InvalidParameters');
|
||||
|
||||
// Convert the web-friendly type field into the correct internal name
|
||||
$value = null;
|
||||
switch($type) {
|
||||
case 'bool': {
|
||||
$type = Sihnon_Config::TYPE_BOOL;
|
||||
$value = false;
|
||||
} break;
|
||||
case 'int': {
|
||||
$type = Sihnon_Config::TYPE_INT;
|
||||
$value = 0;
|
||||
} break;
|
||||
case 'string': {
|
||||
$type = Sihnon_Config::TYPE_STRING;
|
||||
$value = '';
|
||||
} break;
|
||||
case 'string-list': {
|
||||
$type = Sihnon_Config::TYPE_STRING_LIST;
|
||||
$value = array();
|
||||
} break;
|
||||
case 'hash': {
|
||||
$type = Sihnon_Config::TYPE_HASH;
|
||||
$value = array();
|
||||
} break;
|
||||
}
|
||||
|
||||
// Add the new (empty) value. This is because no suitable UI has been presented yet.
|
||||
// Possible future fix, to insert intermediate dialog to capture the value using the correct UI.
|
||||
$result = $config->add($name, $type, $value);
|
||||
$this->smarty->assign('success', $result);
|
||||
|
||||
$this->smarty->assign('name', $name);
|
||||
$this->smarty->assign('id', str_replace('.', '-',$name));
|
||||
$this->smarty->assign('type', $type);
|
||||
$this->smarty->assign('value', '');
|
||||
|
||||
} catch(RippingCluster_Exception $e) {
|
||||
$messages[] = get_class($e) . ':' . $e->getMessage();
|
||||
$this->smarty->assign('messages', $messages);
|
||||
$this->smarty->assign('success', false);
|
||||
}
|
||||
|
||||
?>
|
||||
23
source/webui/pages/ajax/admin/remove-setting.php
Normal file
23
source/webui/pages/ajax/admin/remove-setting.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
$main = RippingCluster_Main::instance();
|
||||
$req = $main->request();
|
||||
$config = $main->config();
|
||||
|
||||
$messages = array();
|
||||
$result = false;
|
||||
|
||||
try {
|
||||
$name = $req->get('name', 'RippingCluster_Exception_InvalidParameters');
|
||||
|
||||
$result = $config->remove($name);
|
||||
$this->smarty->assign('success', $result);
|
||||
|
||||
} catch(RippingCluster_Exception $e) {
|
||||
$messages[] = get_class($e) . ':' . $e->getMessage();
|
||||
$this->smarty->assign('messages', $messages);
|
||||
$this->smarty->assign('success', false);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
39
source/webui/pages/ajax/admin/rename-setting.php
Normal file
39
source/webui/pages/ajax/admin/rename-setting.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
$main = RippingCluster_Main::instance();
|
||||
$req = $main->request();
|
||||
$config = $main->config();
|
||||
|
||||
$messages = array();
|
||||
$result = false;
|
||||
|
||||
$confirm = $req->exists('confirm');
|
||||
$this->smarty->assign('confirm', $confirm);
|
||||
|
||||
if ($confirm) {
|
||||
try {
|
||||
$name = $req->get('name', 'RippingCluster_Exception_InvalidParameters');
|
||||
$new_name = $req->get('new-name', 'RippingCluster_Exception_InvalidParameters');
|
||||
|
||||
$result = $config->rename($name, $new_name);
|
||||
$this->smarty->assign('success', $result);
|
||||
|
||||
$this->smarty->assign('old_name', $name);
|
||||
$this->smarty->assign('old_id', str_replace('.', '-', $name));
|
||||
$this->smarty->assign('name', $new_name);
|
||||
$this->smarty->assign('id', str_replace('.', '-', $new_name));
|
||||
$this->smarty->assign('type', $config->type($new_name));
|
||||
$this->smarty->assign('value', $config->get($new_name));
|
||||
|
||||
} catch(RippingCluster_Exception $e) {
|
||||
$messages[] = get_class($e) . ':' . $e->getMessage();
|
||||
$this->smarty->assign('messages', $messages);
|
||||
$this->smarty->assign('success', false);
|
||||
}
|
||||
} else {
|
||||
$name = $req->get('name', 'RippingCluster_Exception_InvalidParameters');
|
||||
$this->smarty->assign('name', $name);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user