Merge branch 'release-0.3'
This commit is contained in:
@@ -25,11 +25,12 @@ class RippingCluster_Main extends SihnonFramework_Main {
|
||||
$this->smarty->compile_dir = static::makeAbsolutePath($smarty_tmp . '/tmp/templates');
|
||||
$this->smarty->cache_dir = static::makeAbsolutePath($smarty_tmp . '/tmp/cache');
|
||||
$this->smarty->config_dir = static::makeAbsolutePath($smarty_tmp . '/config');
|
||||
$this->smarty->plugins_dir[]= static::makeAbsolutePath('./source/smarty/plugins');
|
||||
|
||||
$this->smarty->registerPlugin('modifier', 'formatDuration', array('RippingCluster_Main', 'formatDuration'));
|
||||
$this->smarty->registerPlugin('modifier', 'formatFilesize', array('RippingCluster_Main', 'formatFilesize'));
|
||||
|
||||
$this->smarty->assign('version', '0.2.1');
|
||||
$this->smarty->assign('version', '0.3');
|
||||
$this->smarty->assign('messages', array());
|
||||
|
||||
$this->smarty->assign('base_uri', $this->base_uri);
|
||||
|
||||
@@ -23,7 +23,8 @@ var rc = {
|
||||
},
|
||||
|
||||
post: function(url, data) {
|
||||
$.ajax(url, {
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: data,
|
||||
@@ -35,6 +36,7 @@ var rc = {
|
||||
success: function(d, s, x) {
|
||||
rc.page.update(d);
|
||||
rc.dialog.prepare(d);
|
||||
rc.trigger_all(d);
|
||||
},
|
||||
|
||||
failure: function(x, s, e) {
|
||||
@@ -54,6 +56,23 @@ var rc = {
|
||||
|
||||
if (d.dialog.buttons) {
|
||||
switch (d.dialog.buttons.type) {
|
||||
case 'ok':
|
||||
$("#dialogfooterok").click(
|
||||
function() {
|
||||
rc.trigger(d.dialog.buttons.actions.ok, d.dialog.buttons.params);
|
||||
}
|
||||
);
|
||||
$("#dialogfooterok").show();
|
||||
break;
|
||||
case 'okcancel':
|
||||
$("#dialogfooterokcancel_ok").click(function() {
|
||||
rc.trigger(d.dialog.buttons.actions.ok, d.dialog.buttons.params);
|
||||
});
|
||||
$("#dialogfooterokcancel_cancel").click(function() {
|
||||
rc.trigger(d.dialog.buttons.actions.cancel, d.dialog.buttons.params);
|
||||
});
|
||||
$("#dialogfooterokcancel").show();
|
||||
break;
|
||||
case 'yesno':
|
||||
$("#dialogfooteryes").click(
|
||||
function() {
|
||||
@@ -70,15 +89,56 @@ var rc = {
|
||||
}
|
||||
}
|
||||
|
||||
if (d.dialog.title) {
|
||||
$('#dialogheadertitle').html(d.dialog.title);
|
||||
}
|
||||
|
||||
if (d.dialog.content) {
|
||||
$('#dialogcontent').html(d.dialog.content);
|
||||
}
|
||||
|
||||
$("#dialog").show();
|
||||
}
|
||||
},
|
||||
|
||||
close: function() {
|
||||
// Hide the dialog
|
||||
$("#dialog").hide();
|
||||
$(".dialogfooterbuttonset").hide();
|
||||
|
||||
// Remove the dialog content
|
||||
$("#dialogcontent").html();
|
||||
}
|
||||
|
||||
// Hide all buttons
|
||||
$(".dialogfooterbuttonset").hide();
|
||||
// Strip all event handlers
|
||||
$(".dialogfooterbuttonset input[type='button']").unbind('click');
|
||||
},
|
||||
|
||||
error: function(title, content, messages) {
|
||||
var formatted_content = $('<div>').append($('<p>').text('content'));
|
||||
if (messages) {
|
||||
var formatted_messages = $('<ul>');
|
||||
for (var message in messages) {
|
||||
formatted_messages.append($('<li>').text(message));
|
||||
}
|
||||
|
||||
formatted_content.append($('<p>').text('These messages were reported:').append(formatted_messages));
|
||||
}
|
||||
|
||||
rc.dialog.prepare({
|
||||
dialog: {
|
||||
show: true,
|
||||
title: title,
|
||||
content: formatted_content,
|
||||
buttons: {
|
||||
type: 'ok',
|
||||
actions: {
|
||||
ok: 'close-dialog'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@@ -115,6 +175,31 @@ var rc = {
|
||||
|
||||
'delete-source-confirm': function(params) {
|
||||
rc.sources.remove_confirmed(params['plugin'], params['id']);
|
||||
},
|
||||
|
||||
'add-setting': function(params) {
|
||||
rc.ajax.post(base_url + 'ajax/admin/add-setting/name/' + $('#'+params.name).val() + '/type/' + $('#'+params.type).val() + '/');
|
||||
},
|
||||
|
||||
'add_setting_row': function(params) {
|
||||
$("#settings tbody").append(params.content);
|
||||
},
|
||||
|
||||
'rename_setting': function(params) {
|
||||
rc.ajax.post(base_url + 'ajax/admin/rename-setting/name/' + params.name + '/new-name/' + $('#'+params.new_name_field).val() + '/confirm/');
|
||||
},
|
||||
|
||||
'rename_setting_confirm': function(params) {
|
||||
$('#setting_'+params.old_id+'_row').replaceWith($(params.content));
|
||||
},
|
||||
|
||||
'remove_setting': function(params) {
|
||||
rc.ajax.post(base_url + 'ajax/admin/remove-setting/name/' + params.name + '/');
|
||||
rc.trigger('remove_setting_row', params);
|
||||
},
|
||||
|
||||
'remove_setting_row': function(params) {
|
||||
$('#setting_' + params.id + '_row').remove();
|
||||
}
|
||||
|
||||
},
|
||||
@@ -134,6 +219,119 @@ var rc = {
|
||||
} else {
|
||||
console.log("Action not supported: " +action);
|
||||
}
|
||||
},
|
||||
|
||||
trigger_all: function(params) {
|
||||
if (params.actions) {
|
||||
for (var action in params.actions) {
|
||||
rc.trigger(action, params.actions[action]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
settings: {
|
||||
|
||||
init: function() {
|
||||
$("#settings_save").click(function() {
|
||||
rc.settings.save();
|
||||
});
|
||||
|
||||
$("#settings_new").click(function() {
|
||||
rc.settings.new_setting();
|
||||
});
|
||||
},
|
||||
|
||||
new_setting: function() {
|
||||
rc.ajax.get(base_url + "ajax/admin/new-setting/");
|
||||
},
|
||||
|
||||
rename_setting: function(id, name) {
|
||||
rc.ajax.get(base_url + "ajax/admin/rename-setting/name/" + name + "/");
|
||||
},
|
||||
|
||||
remove_setting: function(id, name) {
|
||||
rc.dialog.prepare({
|
||||
dialog: {
|
||||
show: true,
|
||||
title: 'Remove setting',
|
||||
content: "Do you really want to remove setting '" + name + "'",
|
||||
buttons: {
|
||||
type: 'okcancel',
|
||||
actions: {
|
||||
ok: [
|
||||
'remove_setting',
|
||||
'close-dialog'
|
||||
],
|
||||
cancel: 'close-dialog'
|
||||
},
|
||||
params: {
|
||||
id: id,
|
||||
name: name
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
add_stringlist_field: function(id) {
|
||||
var container = $('#container_'+id);
|
||||
var next = $('#settings_'+id+'_next');
|
||||
var next_value = next.val();
|
||||
|
||||
var line = $('<div>');
|
||||
line.attr('id', 'settings_'+id+'_line'+next.val());
|
||||
line.append($('<input type="text" class="settings_field_string" />'));
|
||||
line.append(' ');
|
||||
var button = $('<input type="button" value="-" class="settings_field_remove"/>');
|
||||
button.click(function() {
|
||||
rc.settings.remove_field(id, next_value);
|
||||
});
|
||||
line.append(button);
|
||||
|
||||
// Add the new item
|
||||
container.append(line);
|
||||
|
||||
// Increment the next counter
|
||||
next.val(parseInt(next_value)+1);
|
||||
|
||||
},
|
||||
|
||||
remove_stringlist_field: function(id, line) {
|
||||
$("#settings_"+id+"_line"+line).remove();
|
||||
},
|
||||
|
||||
save: function() {
|
||||
|
||||
var settings = {};
|
||||
|
||||
var fields = $("input.setting").get();
|
||||
for (var i in fields) {
|
||||
var setting = fields[i];
|
||||
var name = setting.name;
|
||||
var value;
|
||||
|
||||
switch(setting.type) {
|
||||
case 'checkbox':
|
||||
value = $(setting).is(':checked') ? 1 : 0;
|
||||
break;
|
||||
default:
|
||||
value = setting.value;
|
||||
}
|
||||
|
||||
if (/\[\]$/.test(name)) {
|
||||
if (! settings[name]) {
|
||||
settings[name] = [];
|
||||
}
|
||||
settings[name].push(value);
|
||||
} else {
|
||||
settings[name] = value;
|
||||
}
|
||||
}
|
||||
|
||||
rc.ajax.post(base_url + "ajax/update-settings/", settings);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
11
webui/source/pages/admin/settings.php
Normal file
11
webui/source/pages/admin/settings.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
$main = RippingCluster_Main::instance();
|
||||
$config = $main->config();
|
||||
|
||||
$settings = $config->enumerateAll();
|
||||
asort($settings);
|
||||
$this->smarty->assign('settings', $settings);
|
||||
$this->smarty->assign('config', $config);
|
||||
|
||||
?>
|
||||
51
webui/source/pages/ajax/admin/add-setting.php
Normal file
51
webui/source/pages/ajax/admin/add-setting.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
// 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
webui/source/pages/ajax/admin/remove-setting.php
Normal file
23
webui/source/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
webui/source/pages/ajax/admin/rename-setting.php
Normal file
39
webui/source/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);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
22
webui/source/pages/ajax/update-settings.php
Normal file
22
webui/source/pages/ajax/update-settings.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
$main = RippingCluster_Main::instance();
|
||||
$config = $main->config();
|
||||
|
||||
$messages = array();
|
||||
|
||||
// Iterate over the settings and store each one back to the backend
|
||||
foreach($_POST as $key => $value) {
|
||||
// Convert - to . (to work around the PHP register global backwards compatibility that renames input variables)
|
||||
$key = str_replace("-", ".", $key);
|
||||
|
||||
if ($config->exists($key)) {
|
||||
$config->set($key, $value);
|
||||
} else {
|
||||
$messages[] = "Unknown config key '{$key}', value not updated.";
|
||||
}
|
||||
}
|
||||
|
||||
$this->smarty->assign('messages', $messages);
|
||||
|
||||
?>
|
||||
292
webui/source/smarty/plugins/compiler.switch.php
Normal file
292
webui/source/smarty/plugins/compiler.switch.php
Normal file
@@ -0,0 +1,292 @@
|
||||
<?php
|
||||
/**
|
||||
* Switch statement plugin for smarty.
|
||||
* This smarty plugin provides php switch statement functionality in smarty tags.
|
||||
* To install this plugin drop it into your smarty plugins folder. You will also need to manually
|
||||
* load the plugin sot hat all the hooks are registered properly. Add the following line after
|
||||
* you load smarty and create an instance of it in your source code.
|
||||
*
|
||||
* <code>
|
||||
* $this->smartyObj->loadPlugin('smarty_compiler_switch');
|
||||
* </code>
|
||||
*
|
||||
* @author Jeremy Pyne <jeremy.pyne@gmail.com>
|
||||
* - Donations: Accepted via PayPal at the above address.
|
||||
* - Updated: 02/10/2010 - Version 3.2
|
||||
* - File: smarty/plugins/compiler.switch.php
|
||||
* - Licence: CC:BY/NC/SA http://creativecommons.org/licenses/by-nc-sa/3.0/
|
||||
*
|
||||
* - Updates
|
||||
* Version 2:
|
||||
* Changed the break attribute to cause a break to be printed before the next case, instead of before this
|
||||
* case. This way makes more sense and simplifies the code. This change in incompatible with code in
|
||||
* from version one. This is written to support nested switches and will work as expected.
|
||||
* Version 2.1:
|
||||
* Added {/case} tag, this is identical to {break}.
|
||||
* Version 3:
|
||||
* Updated switch statment to support Smarty 3. This update is NOT backwards compatible but the old version is still maintained.
|
||||
* Version 3.1:
|
||||
* Added a prefilter to re-enable the shorthand {switch $myvar} support. To use the shorthand form you will need to add the following line to your code.
|
||||
* $smarty->loadPlugin('smarty_compiler_switch');
|
||||
* Version 3.2:
|
||||
* Fixed a bug when chaining multiple {case} statements without a {break}.
|
||||
* Version 3.5:
|
||||
* Updated to work with Smarty 3.0 release. (Tested and working with 3.0.5, no longer compatible with 3.0rcx releases.)
|
||||
*
|
||||
* - Bugs/Notes:
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage plugins
|
||||
*
|
||||
* Sample usage:
|
||||
* <code>
|
||||
* {foreach item=$debugItem from=$debugData}
|
||||
* // Switch on $debugItem.type
|
||||
* {switch $debugItem.type}
|
||||
* {case 1}
|
||||
* {case "invalid_field"}
|
||||
* // Case checks for string and numbers.
|
||||
* {/case}
|
||||
* {case $postError}
|
||||
* {case $getError|cat:"_ajax"|lower}
|
||||
* // Case checks can also use variables and modifiers.
|
||||
* {break}
|
||||
* {default}
|
||||
* // Default case is supported.
|
||||
* {/switch}
|
||||
* {/foreach}
|
||||
* </code>
|
||||
*
|
||||
* Note in the above example that the break statements work exactly as expected. Also the switch and default
|
||||
* tags can take the break attribute. If set they will break automatically before the next case is printed.
|
||||
*
|
||||
* Both blocks produce the same switch logic:
|
||||
* <code>
|
||||
* {case 1 break}
|
||||
* Code 1
|
||||
* {case 2}
|
||||
* Code 2
|
||||
* {default break}
|
||||
* Code 3
|
||||
* </code>
|
||||
*
|
||||
* <code>
|
||||
* {case 1}
|
||||
* Code 1
|
||||
* {break}
|
||||
* {case 2}
|
||||
* Code 2
|
||||
* {default}
|
||||
* Code 3
|
||||
* {break}
|
||||
* </code>
|
||||
*
|
||||
* Finally, there is an alternate long hand style for the switch statments that you may need to use in some cases.
|
||||
*
|
||||
* <code>
|
||||
* {switch var=$type}
|
||||
* {case value="box" break}
|
||||
* {case value="line"}
|
||||
* {break}
|
||||
* {default}
|
||||
* {/switch}
|
||||
* </code>
|
||||
*/
|
||||
|
||||
//Register the post and pre filters as they are not auto-registered.
|
||||
$this->registerFilter('post', 'smarty_postfilter_switch');
|
||||
|
||||
class Smarty_Compiler_Switch extends Smarty_Internal_CompileBase {
|
||||
public $required_attributes = array('var');
|
||||
public $optional_attributes = array();
|
||||
public $shorttag_order = array('var');
|
||||
|
||||
/**
|
||||
* Start a new switch statement.
|
||||
* A variable must be passed to switch on.
|
||||
* Also, the switch can only directly contain {case} and {default} tags.
|
||||
*
|
||||
* @param string $tag_arg
|
||||
* @param Smarty_Compiler $smarty
|
||||
* @return string
|
||||
*/
|
||||
public function compile($args, $compiler){
|
||||
$this->compiler = $compiler;
|
||||
$attr = $this->_get_attributes($args);
|
||||
$_output = '';
|
||||
|
||||
$this->_open_tag('switch',array($compiler->tag_nocache));
|
||||
|
||||
if (is_array($attr['var'])) {
|
||||
$_output .= "<?php if (!isset(\$_smarty_tpl->tpl_vars[".$attr['var']['var']."])) \$_smarty_tpl->tpl_vars[".$attr['var']['var']."] = new Smarty_Variable;";
|
||||
$_output .= "switch (\$_smarty_tpl->tpl_vars[".$attr['var']['var']."]->value = ".$attr['var']['value']."){?>";
|
||||
} else {
|
||||
$_output .= '<?php switch (' . $attr['var'] . '){?>';
|
||||
}
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
class Smarty_Compiler_Case extends Smarty_Internal_CompileBase {
|
||||
public $required_attributes = array('value');
|
||||
public $optional_attributes = array('break');
|
||||
public $shorttag_order = array('value', 'break');
|
||||
|
||||
/**
|
||||
* Print out a case line for this switch.
|
||||
* A condition must be passed to match on.
|
||||
* This can only go in {switch} tags.
|
||||
* If break is passed, a {break} will be rendered before the next case.
|
||||
*
|
||||
* @param string $tag_arg
|
||||
* @param Smarty_Compiler $smarty
|
||||
* @return string
|
||||
*/
|
||||
public function compile($args, $compiler){
|
||||
$this->compiler = $compiler;
|
||||
$attr = $this->_get_attributes($args);
|
||||
$_output = '';
|
||||
|
||||
list($last_tag, $last_attr) = $this->compiler->_tag_stack[count($this->compiler->_tag_stack) - 1];
|
||||
|
||||
if($last_tag == 'case')
|
||||
{
|
||||
list($break, $compiler->tag_nocache) = $this->_close_tag(array('case'));
|
||||
if($last_attr[0])
|
||||
$_output .= '<?php break;?>';
|
||||
}
|
||||
$this->_open_tag('case', array(isset($attr['break']) ? $attr['break'] : false, $compiler->tag_nocache));
|
||||
|
||||
if (is_array($attr['value'])) {
|
||||
$_output .= "<?php if (!isset(\$_smarty_tpl->tpl_vars[".$attr['value']['var']."])) \$_smarty_tpl->tpl_vars[".$attr['value']['var']."] = new Smarty_Variable;";
|
||||
$_output .= "case \$_smarty_tpl->tpl_vars[".$attr['value']['var']."]->value = ".$attr['value']['value'].":?>";
|
||||
} else {
|
||||
$_output .= '<?php case ' . $attr['value'] . ':?>';
|
||||
}
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
class Smarty_Compiler_Default extends Smarty_Internal_CompileBase {
|
||||
public $required_attributes = array();
|
||||
public $optional_attributes = array('break');
|
||||
public $shorttag_order = array('break');
|
||||
|
||||
/**
|
||||
* Print out a default line for this switch.
|
||||
* This can only go in {switch} tags.
|
||||
* If break is passed, a {break} will be rendered before the next case.
|
||||
*
|
||||
* @param string $tag_arg
|
||||
* @param Smarty_Compiler $smarty
|
||||
* @return string
|
||||
*/
|
||||
public function compile($args, $compiler){
|
||||
$this->compiler = $compiler;
|
||||
$attr = $this->_get_attributes($args);
|
||||
$_output = '';
|
||||
|
||||
list($last_tag, $last_attr) = $this->compiler->_tag_stack[count($this->compiler->_tag_stack) - 1];
|
||||
if($last_tag == 'case')
|
||||
{
|
||||
list($break, $compiler->tag_nocache) = $this->_close_tag(array('case'));
|
||||
if($last_attr[0])
|
||||
$_output .= '<?php break;?>';
|
||||
}
|
||||
$this->_open_tag('case', array(isset($attr['break']) ? $attr['break'] : false, $compiler->tag_nocache));
|
||||
|
||||
$_output .= '<?php default:?>';
|
||||
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Smarty_Compiler_Break extends Smarty_Internal_CompileBase {
|
||||
public $required_attributes = array();
|
||||
public $optional_attributes = array();
|
||||
public $shorttag_order = array();
|
||||
|
||||
/**
|
||||
* Print out a break command for the switch.
|
||||
* This can only go inside of {case} tags.
|
||||
*
|
||||
* @param string $tag_arg
|
||||
* @param Smarty_Compiler $smarty
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function compile($args, $compiler){
|
||||
$this->compiler = $compiler;
|
||||
$attr = $this->_get_attributes($args);
|
||||
|
||||
list($break, $compiler->tag_nocache) = $this->_close_tag(array('case'));
|
||||
|
||||
return '<?php break;?>';
|
||||
}
|
||||
}
|
||||
|
||||
class Smarty_Compiler_Caseclose extends Smarty_Internal_CompileBase {
|
||||
public $required_attributes = array();
|
||||
public $optional_attributes = array();
|
||||
public $shorttag_order = array();
|
||||
|
||||
/**
|
||||
* Print out a break command for the switch.
|
||||
* This can only go inside of {case} tags.
|
||||
*
|
||||
* @param string $tag_arg
|
||||
* @param Smarty_Compiler $smarty
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function compile($args, $compiler){
|
||||
$this->compiler = $compiler;
|
||||
$attr = $this->_get_attributes($args);
|
||||
|
||||
list($break, $compiler->tag_nocache) = $this->_close_tag(array('case'));
|
||||
|
||||
return '<?php break;?>';
|
||||
}
|
||||
}
|
||||
|
||||
class Smarty_Compiler_Switchclose extends Smarty_Internal_CompileBase {
|
||||
public $required_attributes = array();
|
||||
public $optional_attributes = array();
|
||||
public $shorttag_order = array();
|
||||
|
||||
/**
|
||||
* End a switch statement.
|
||||
*
|
||||
* @param string $tag_arg
|
||||
* @param Smarty_Compiler $smarty
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function compile($args, $compiler){
|
||||
$this->compiler = $compiler;
|
||||
$attr = $this->_get_attributes($args);
|
||||
|
||||
list($last_tag, $last_attr) = $this->compiler->_tag_stack[count($this->compiler->_tag_stack) - 1];
|
||||
if(($last_tag == 'case' || $last_tag == 'default'))
|
||||
list($break, $compiler->tag_nocache) = $this->_close_tag(array('case'));
|
||||
list($compiler->tag_nocache) = $this->_close_tag(array('switch'));
|
||||
|
||||
return '<?php }?>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the template after it is generated to fix switch bugs.
|
||||
* Remove any spaces after the 'switch () {' code and before the first case. Any tabs or spaces
|
||||
* for layout would cause php errors witch this reged will fix.
|
||||
*
|
||||
* @param string $compiled
|
||||
* @param Smarty_Compiler $smarty
|
||||
* @return string
|
||||
*/
|
||||
function smarty_postfilter_switch($compiled, &$smarty) {
|
||||
// Remove the extra spaces after the start of the switch tag and before the first case statement.
|
||||
return preg_replace('/({ ?\?>)\s+(<\?php case)/', "$1\n$2", $compiled);
|
||||
}
|
||||
?>
|
||||
@@ -1 +1,29 @@
|
||||
Not yet implemented.
|
||||
<h2>Settings</h2>
|
||||
|
||||
<table id="settings">
|
||||
<thead>
|
||||
<th>Name</th>
|
||||
<th>Value</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$settings item=name}
|
||||
{assign var='value' value=$config->get($name)}
|
||||
{assign var='type' value=$config->type($name)}
|
||||
{assign var='id' value=str_replace('.', '-',$name)}
|
||||
|
||||
{include file="fragments/admin-setting-row.tpl"}
|
||||
{/foreach}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input type="button" id="settings_save" name="save" value="Save" />
|
||||
<input type="button" id="settings_new" name="new_setting" value="New Setting" />
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
<script type="text/javascript">
|
||||
rc.settings.init();
|
||||
</script>
|
||||
@@ -1,11 +1,12 @@
|
||||
{
|
||||
{if $messages}
|
||||
messages: [
|
||||
{foreach from=$messages item=message}
|
||||
'{$message}',
|
||||
"messages": [
|
||||
{foreach from=$messages item=message name=messages}
|
||||
{$message|json_encode}{if ! $smarty.foreach.messages.last},{/if}
|
||||
{/foreach}
|
||||
],
|
||||
]{if $page_content},{/if}
|
||||
{/if}
|
||||
|
||||
{$page_content}
|
||||
|
||||
}
|
||||
11
webui/source/templates/ajax/admin/add-setting.tpl
Normal file
11
webui/source/templates/ajax/admin/add-setting.tpl
Normal file
@@ -0,0 +1,11 @@
|
||||
{if $success}
|
||||
"actions": {
|
||||
"add_setting_row": {
|
||||
{include file="fragments/admin-setting-row.tpl" assign=content}
|
||||
"content": {$content|json_encode}
|
||||
}
|
||||
},
|
||||
{/if}
|
||||
|
||||
"success": {$success|json_encode}
|
||||
|
||||
30
webui/source/templates/ajax/admin/new-setting.tpl
Normal file
30
webui/source/templates/ajax/admin/new-setting.tpl
Normal file
@@ -0,0 +1,30 @@
|
||||
"page_replacements": {
|
||||
|
||||
"dialogheadertitle": {
|
||||
"content": "Add Setting"
|
||||
},
|
||||
|
||||
"dialogcontent": {
|
||||
{include file="fragments/new-setting-dialog.tpl" assign=new_setting_dialog_content}
|
||||
"content": {$new_setting_dialog_content|json_encode}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"dialog": {
|
||||
"show": true,
|
||||
"buttons": {
|
||||
"type": "okcancel",
|
||||
"actions": {
|
||||
"ok": [
|
||||
"add-setting",
|
||||
"close-dialog"
|
||||
],
|
||||
"cancel": "close-dialog"
|
||||
},
|
||||
"params": {
|
||||
"name": "settings_add_name",
|
||||
"type": "settings_add_type"
|
||||
}
|
||||
}
|
||||
}
|
||||
1
webui/source/templates/ajax/admin/remove-setting.tpl
Normal file
1
webui/source/templates/ajax/admin/remove-setting.tpl
Normal file
@@ -0,0 +1 @@
|
||||
"success": {$success|json_encode}
|
||||
44
webui/source/templates/ajax/admin/rename-setting.tpl
Normal file
44
webui/source/templates/ajax/admin/rename-setting.tpl
Normal file
@@ -0,0 +1,44 @@
|
||||
{if $confirm}
|
||||
{if $success}
|
||||
"actions": {
|
||||
"rename_setting_confirm": {
|
||||
"old_name": {$old_name|json_encode},
|
||||
"old_id": {$old_id|json_encode},
|
||||
"name": {$name|json_encode},
|
||||
{include file="fragments/admin-setting-row.tpl" assign="content"}
|
||||
"content": {$content|json_encode}
|
||||
}
|
||||
},
|
||||
{/if}
|
||||
|
||||
"success": {$success|json_encode}
|
||||
{else}
|
||||
"page_replacements": {
|
||||
"dialogheadertitle": {
|
||||
"content": "Rename Setting"
|
||||
},
|
||||
|
||||
"dialogcontent": {
|
||||
{include file="fragments/rename-setting-dialog.tpl" assign="content"}
|
||||
"content": {$content|json_encode}
|
||||
}
|
||||
},
|
||||
|
||||
"dialog": {
|
||||
"show": true,
|
||||
"buttons": {
|
||||
"type": "okcancel",
|
||||
"actions": {
|
||||
"ok": [
|
||||
"rename_setting",
|
||||
"close-dialog"
|
||||
],
|
||||
"cancel": "close-dialog"
|
||||
},
|
||||
"params": {
|
||||
"name": {$name|json_encode},
|
||||
"new_name_field": "settings_rename_name"
|
||||
}
|
||||
}
|
||||
}
|
||||
{/if}
|
||||
@@ -6,6 +6,10 @@
|
||||
"content": {$sources_html|json_encode}
|
||||
}
|
||||
{else}
|
||||
"dialogheadertitle" {
|
||||
"content": "Delete Source"
|
||||
},
|
||||
|
||||
"dialogcontent": {
|
||||
{include file="fragments/delete-source.tpl" assign="delete_source_html"}
|
||||
"content": {$delete_source_html|json_encode}
|
||||
|
||||
22
webui/source/templates/ajax/update-settings.tpl
Normal file
22
webui/source/templates/ajax/update-settings.tpl
Normal file
@@ -0,0 +1,22 @@
|
||||
"page_replacements": {
|
||||
|
||||
"dialogheadertitle": {
|
||||
"content": "Update Settings"
|
||||
},
|
||||
|
||||
"dialogcontent": {
|
||||
{include file="fragments/update-settings-dialog.tpl" assign=dialog_content}
|
||||
"content": {$dialog_content|json_encode}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
"dialog": {
|
||||
"show": true,
|
||||
"buttons": {
|
||||
"type": "ok",
|
||||
"actions": {
|
||||
"ok": "close-dialog"
|
||||
}
|
||||
}
|
||||
}
|
||||
12
webui/source/templates/fragments/admin-setting-row.tpl
Normal file
12
webui/source/templates/fragments/admin-setting-row.tpl
Normal file
@@ -0,0 +1,12 @@
|
||||
<tr id="setting_{$id}_row">
|
||||
<td>
|
||||
<p>
|
||||
{$name}<br />
|
||||
<input type="button" id="setting_{$id}_rename" value="Rename" onclick="rc.settings.rename_setting('{$id}', '{$name}');" />
|
||||
<input type="button" id="setting_{$id}_remove" value="Remove" onclick="rc.settings.remove_setting('{$id}', '{$name}');" />
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
{include file="fragments/admin-setting-value.tpl"}
|
||||
</td>
|
||||
</tr>
|
||||
25
webui/source/templates/fragments/admin-setting-value.tpl
Normal file
25
webui/source/templates/fragments/admin-setting-value.tpl
Normal file
@@ -0,0 +1,25 @@
|
||||
{switch $type}
|
||||
{case Sihnon_Config::TYPE_BOOL}
|
||||
<input type="checkbox" id="setting_{$id}" name="{$id}" value="1" {if $value}checked="checked" {/if} class="setting" />
|
||||
{/case}
|
||||
{case Sihnon_Config::TYPE_INT}
|
||||
<input type="text" id="setting_{$id}" name="{$id}" value="{$value}" class="setting settings_field_numeric" />
|
||||
{/case}
|
||||
{case Sihnon_Config::TYPE_STRING}
|
||||
<input type="text" id="setting_{$id}" name="{$id}" value="{$value}" class="setting settings_field_string" />
|
||||
{/case}
|
||||
{case Sihnon_Config::TYPE_STRING_LIST}
|
||||
<div id="container_{$id}">
|
||||
{foreach from=$value item=line name=settings}
|
||||
<div id="settings_{$id}_line{$smarty.foreach.settings.iteration}">
|
||||
<input type="text" name="{$id}[]" value="{$line}" class="setting settings_field_string" />
|
||||
<input type="button" value="-" class="settings_field_remove" onclick="rc.settings.remove_stringlist_field('{$id}', '{$smarty.foreach.settings.iteration}')" />
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
<div class="settings_addfieldcontainer">
|
||||
<input type="hidden" id="settings_{$id}_next" value="{$smarty.foreach.settings.iteration+1}" />
|
||||
<input type="button" value="+" class="settings_field_add" onclick="rc.settings.add_stringlist_field('{$id}')" />
|
||||
</div>
|
||||
{/case}
|
||||
{/switch}
|
||||
7
webui/source/templates/fragments/messages.tpl
Normal file
7
webui/source/templates/fragments/messages.tpl
Normal file
@@ -0,0 +1,7 @@
|
||||
{if $messages}
|
||||
<ul>
|
||||
{foreach from=$messages item=message}
|
||||
<li>{$message|escape}</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
{/if}
|
||||
21
webui/source/templates/fragments/new-setting-dialog.tpl
Normal file
21
webui/source/templates/fragments/new-setting-dialog.tpl
Normal file
@@ -0,0 +1,21 @@
|
||||
<table>
|
||||
<thead>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" id="settings_add_name" value="" />
|
||||
</td>
|
||||
<td>
|
||||
<select id="settings_add_type">
|
||||
<option value="int">Integer</option>
|
||||
<option value="bool">Boolean</option>
|
||||
<option value="string">String</option>
|
||||
<option value="string-list">String List</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -0,0 +1,6 @@
|
||||
<div>
|
||||
<p>
|
||||
Enter a new name for setting '{$name|escape}' below.
|
||||
</p>
|
||||
<input type="text" id="settings_rename_name" value="" />
|
||||
</div>
|
||||
10
webui/source/templates/fragments/update-settings-dialog.tpl
Normal file
10
webui/source/templates/fragments/update-settings-dialog.tpl
Normal file
@@ -0,0 +1,10 @@
|
||||
<p>
|
||||
Settings have been saved.
|
||||
</p>
|
||||
|
||||
{if $messages}
|
||||
<p>
|
||||
Some messages were generated during this operation:
|
||||
{include file="fragments/messages.tpl"}
|
||||
</p>
|
||||
{/if}
|
||||
@@ -64,6 +64,17 @@
|
||||
</div>
|
||||
<div id="dialogcontent"></div>
|
||||
<div id="dialogfooter">
|
||||
<div id="dialogfooterok" class="dialogfooterbuttonset">
|
||||
<fieldset>
|
||||
<input type="button" class="dialogbutton" id="dialogfooterok" value="Ok" />
|
||||
</fieldset>
|
||||
</div>
|
||||
<div id="dialogfooterokcancel" class="dialogfooterbuttonset">
|
||||
<fieldset>
|
||||
<input type="button" class="dialogbutton" id="dialogfooterokcancel_ok" value="Ok" />
|
||||
<input type="button" class="dialogbutton" id="dialogfooterokcancel_cancel" value="Cancel" />
|
||||
</fieldset>
|
||||
</div>
|
||||
<div id="dialogfooteryesno" class="dialogfooterbuttonset">
|
||||
<fieldset>
|
||||
<input type="button" class="dialogbutton" id="dialogfooteryes" value="Yes" />
|
||||
|
||||
@@ -8,4 +8,10 @@
|
||||
<li><a href="{$base_uri}sources/list" title="Browse Sources">Sources</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li>Admin
|
||||
<ul>
|
||||
<li><a href="{$base_uri}admin/settings" title="Edit Settings">Settings</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -142,6 +142,23 @@ label {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
table#settings {
|
||||
|
||||
}
|
||||
|
||||
table#settings td {
|
||||
padding: 1.0em;
|
||||
border: 1px solid;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table#settings input[type=text] {
|
||||
width: 40em;
|
||||
}
|
||||
.settings_addfieldcontainer {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.default {
|
||||
background: beige;
|
||||
color: darkgray;
|
||||
|
||||
0
webui/tmp/cache/.gitignore
vendored
0
webui/tmp/cache/.gitignore
vendored
0
webui/tmp/templates/.gitignore
vendored
0
webui/tmp/templates/.gitignore
vendored
Reference in New Issue
Block a user