2008-07-14 21:54:50 +08:00
|
|
|
<?php
|
2021-10-06 07:21:17 +08:00
|
|
|
if (!canView('Control')) return;
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2019-08-13 23:45:50 +08:00
|
|
|
$monitor = ZM\Monitor::find_one(array('Id'=>$_REQUEST['mid']));
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2019-08-13 23:45:50 +08:00
|
|
|
$zmuCommand = getZmuCommand(' -m '.escapeshellarg($_REQUEST['mid']).' -B -C -H -O');
|
2008-09-26 17:47:20 +08:00
|
|
|
$zmuOutput = exec( $zmuCommand );
|
2021-10-06 07:21:17 +08:00
|
|
|
if ($zmuOutput) {
|
2020-08-26 00:39:44 +08:00
|
|
|
list($brightness, $contrast, $hue, $colour) = explode(' ', $zmuOutput);
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2020-08-26 00:39:44 +08:00
|
|
|
$monitor->Brightness($brightness);
|
|
|
|
$monitor->Contrast($contrast);
|
|
|
|
$monitor->Hue($hue);
|
|
|
|
$monitor->Colour($colour);
|
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
?>
|
2020-10-04 05:51:25 +08:00
|
|
|
<div class="modal" id="settingsModal" tabindex="-1">
|
|
|
|
<div class="modal-dialog">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<h5 class="modal-title"><?php echo validHtmlStr($monitor->Name()) ?> - <?php echo translate('Settings') ?></h5>
|
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<form name="contentForm" id="settingsForm" method="post" action="?">
|
|
|
|
<?php
|
|
|
|
// We have to manually insert the csrf key into the form when using a modal generated via ajax call
|
|
|
|
echo getCSRFinputHTML();
|
|
|
|
?>
|
2014-12-05 07:44:23 +08:00
|
|
|
<input type="hidden" name="view" value="<?php echo $view ?>"/>
|
2008-07-14 21:54:50 +08:00
|
|
|
<input type="hidden" name="action" value="settings"/>
|
2014-12-05 07:44:23 +08:00
|
|
|
<input type="hidden" name="mid" value="<?php echo validInt($_REQUEST['mid']) ?>"/>
|
2020-08-26 00:39:44 +08:00
|
|
|
<table id="contentTable" class="major">
|
2008-07-14 21:54:50 +08:00
|
|
|
<tbody>
|
2021-10-06 07:21:17 +08:00
|
|
|
<?php
|
|
|
|
$ctls = shell_exec('v4l2-ctl -d '.$monitor->Device().' --list-ctrls');
|
|
|
|
$ctls = trim($ctls);
|
|
|
|
$ctls = explode("\n", $ctls);
|
|
|
|
|
|
|
|
foreach ($ctls as $line) {
|
|
|
|
$ctl = explode(':', $line);
|
|
|
|
$type_info = explode(' ', trim($ctl[0]));
|
|
|
|
|
|
|
|
$setting = trim($type_info[0]);
|
|
|
|
if ($setting == 'saturation')
|
|
|
|
$setting = 'colour';
|
|
|
|
$setting_uc = ucwords($setting);
|
|
|
|
$type = $type[2];
|
|
|
|
|
|
|
|
$min = '';
|
|
|
|
$max = '';
|
|
|
|
$step = '';
|
|
|
|
$value = '';
|
|
|
|
$default = '';
|
|
|
|
|
|
|
|
# The purpose is security
|
|
|
|
foreach (explode(' ', trim($ctl[1])) as $index=>$prop) {
|
|
|
|
list($key,$val) = explode('=', $prop);
|
|
|
|
|
|
|
|
// get current value
|
|
|
|
if ($key == 'value') {
|
|
|
|
$value = validInt($val);
|
|
|
|
} else if ($key == 'default') {
|
|
|
|
$default = validInt($val);
|
|
|
|
} else if ($key == 'min') {
|
|
|
|
$min = validInt($val);
|
|
|
|
} else if ($key == 'max') {
|
|
|
|
$max = validInt($val);
|
|
|
|
} else if ($key == 'step') {
|
|
|
|
$step = validInt($val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($setting == 'brightness' or $setting == 'colour' or $setting == 'contrast' or $setting == 'hue') {
|
|
|
|
echo '
|
2008-07-14 21:54:50 +08:00
|
|
|
<tr>
|
2021-10-06 07:21:17 +08:00
|
|
|
<th scope="row">'.translate($setting_uc).'</th>
|
|
|
|
<td>'.$min.'</td><td><input type="range" title="'.$value.'" min="'.$min.'" max="'.$max.'" step="'.$step.'" default="'.$default.'" value="'.$value.'" id="new'.$setting_uc.'" name="new'.$setting_uc.'" '.(canEdit('Control') ? '' : 'disabled="disabled"') .'/></td><td>'.$max.'</td>
|
2008-07-14 21:54:50 +08:00
|
|
|
</tr>
|
2021-10-06 07:21:17 +08:00
|
|
|
';
|
|
|
|
} else {
|
|
|
|
if ($type == '(bool)') {
|
|
|
|
echo '
|
2008-07-14 21:54:50 +08:00
|
|
|
<tr>
|
2021-10-06 07:21:17 +08:00
|
|
|
<th scope="row">'.translate($setting_uc).'</th>
|
|
|
|
<td></td><td>'.html_radio('new'.$setting_uc, array('0'=>translate('True'), '1', translate('False')), $value, array('disabled'=>'disabled')).'
|
|
|
|
</td><td></td>
|
2008-07-14 21:54:50 +08:00
|
|
|
</tr>
|
2021-10-06 07:21:17 +08:00
|
|
|
';
|
|
|
|
} else if ($type == '(int)') {
|
|
|
|
echo '
|
2008-07-14 21:54:50 +08:00
|
|
|
<tr>
|
2021-10-06 07:21:17 +08:00
|
|
|
<th scope="row">'.translate($setting_uc).'</th>
|
|
|
|
<td></td><td><input type="range" '.$ctl[1].' disabled="disabled"/></td><td></td>
|
2008-07-14 21:54:50 +08:00
|
|
|
</tr>
|
2021-10-06 07:21:17 +08:00
|
|
|
';
|
|
|
|
} else {
|
|
|
|
echo '
|
2008-07-14 21:54:50 +08:00
|
|
|
<tr>
|
2021-10-06 07:21:17 +08:00
|
|
|
<th scope="row">'.translate($setting_uc).'</th>
|
|
|
|
<td></td><td>'.$value.'</td><td></td>
|
2008-07-14 21:54:50 +08:00
|
|
|
</tr>
|
2021-10-06 07:21:17 +08:00
|
|
|
';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} # end foreach ctrl
|
|
|
|
?>
|
2008-07-14 21:54:50 +08:00
|
|
|
</tbody>
|
|
|
|
</table>
|
2020-10-04 05:51:25 +08:00
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="submit" class="btn btn-primary" id="settingsSubmitModal" value="Save"<?php echo canView('Control') ? '' : ' disabled="disabled"' ?>><?php echo translate('Save') ?></button>
|
|
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
2008-07-14 21:54:50 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-10-04 05:51:25 +08:00
|
|
|
</div>
|