mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Update php-codesniffer (#11368)
* PHPCS 3.5+ * Fix newly detected style issues
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
use LibreNMS\Config;
|
||||
|
||||
if (Auth::user()->hasGlobalAdmin()) {
|
||||
?>
|
||||
?>
|
||||
<!--Modal for adding or updating an alert transport -->
|
||||
<div class="modal fade" id="edit-alert-transport" tabindex="-1" role="dialog"
|
||||
aria-labelledby="Edit-transport" aria-hidden="true">
|
||||
@@ -39,22 +39,22 @@ if (Auth::user()->hasGlobalAdmin()) {
|
||||
<label for='transport-choice' class='col-sm-3 col-md-2 control-label'>Transport type: </label>
|
||||
<div class="col-sm-3">
|
||||
<select name='transport-choice' id='transport-choice' class='form-control'>
|
||||
<?php
|
||||
<?php
|
||||
|
||||
// Create list of transport
|
||||
$transport_dir = Config::get('install_dir').'/LibreNMS/Alert/Transport';
|
||||
$transports_list = array();
|
||||
foreach (scandir($transport_dir) as $transport) {
|
||||
$transport = strstr($transport, '.', true);
|
||||
if (empty($transport)) {
|
||||
continue;
|
||||
$transport_dir = Config::get('install_dir').'/LibreNMS/Alert/Transport';
|
||||
$transports_list = array();
|
||||
foreach (scandir($transport_dir) as $transport) {
|
||||
$transport = strstr($transport, '.', true);
|
||||
if (empty($transport)) {
|
||||
continue;
|
||||
}
|
||||
$transports_list[] = $transport;
|
||||
}
|
||||
$transports_list[] = $transport;
|
||||
}
|
||||
foreach ($transports_list as $transport) {
|
||||
echo '<option value="'.strtolower($transport).'-form">'.$transport.'</option>';
|
||||
}
|
||||
?>
|
||||
foreach ($transports_list as $transport) {
|
||||
echo '<option value="'.strtolower($transport).'-form">'.$transport.'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -65,80 +65,80 @@ foreach ($transports_list as $transport) {
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
<?php
|
||||
|
||||
$switches = []; // store names of bootstrap switches
|
||||
foreach ($transports_list as $transport) {
|
||||
$class = 'LibreNMS\\Alert\\Transport\\'.$transport;
|
||||
$switches = []; // store names of bootstrap switches
|
||||
foreach ($transports_list as $transport) {
|
||||
$class = 'LibreNMS\\Alert\\Transport\\'.$transport;
|
||||
|
||||
if (!method_exists($class, 'configTemplate')) {
|
||||
// Skip since support has not been added
|
||||
continue;
|
||||
}
|
||||
|
||||
echo '<form method="post" role="form" id="'.strtolower($transport).'-form" class="form-horizontal transport">';
|
||||
echo csrf_field();
|
||||
echo '<input type="hidden" name="transport-type" id="transport-type" value="'.strtolower($transport).'">';
|
||||
|
||||
$tmp = call_user_func($class.'::configTemplate');
|
||||
|
||||
foreach ($tmp['config'] as $item) {
|
||||
if ($item['type'] !== 'hidden') {
|
||||
echo '<div class="form-group" title="' . $item['descr'] . '">';
|
||||
echo '<label for="' . $item['name'] . '" class="col-sm-3 col-md-2 control-label">' . $item['title'] . ': </label>';
|
||||
if ($item['type'] == 'text' || $item['type'] == 'password') {
|
||||
echo '<div class="col-sm-9 col-md-10">';
|
||||
echo '<input type="' . $item['type'] . '" id="' . $item['name'] . '" name="' . $item['name'] . '" class="form-control" ';
|
||||
if ($item['required']) {
|
||||
echo 'required>';
|
||||
} else {
|
||||
echo '>';
|
||||
}
|
||||
echo '</div>';
|
||||
} elseif ($item['type'] == 'checkbox') {
|
||||
echo '<div class="col-sm-2">';
|
||||
echo '<input type="checkbox" name="' . $item['name'] . '" id="' . $item['name'] . '">';
|
||||
echo '</div>';
|
||||
$switches[$item['name']] = $item['default'];
|
||||
} elseif ($item['type'] == 'select') {
|
||||
echo '<div class="col-sm-3">';
|
||||
echo '<select name="' . $item['name'] . '" id="' . $item['name'] . '" class="form-control">';
|
||||
foreach ($item['options'] as $descr => $opt) {
|
||||
echo '<option value="' . $opt . '">' . $descr . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
echo '</div>';
|
||||
} elseif ($item['type'] === 'textarea') {
|
||||
echo '<div class="col-sm-9 col-md-10">';
|
||||
echo '<textarea name="' . $item['name'] . '" id="' . $item['name'] . '" class="form-control" placeholder="' . $item['descr'] . '">';
|
||||
echo '</textarea>';
|
||||
echo '</div>';
|
||||
} elseif ($item['type'] === 'oauth') {
|
||||
$class = isset($item['class']) ? $item['class'] : 'btn-success';
|
||||
$callback = urlencode(url()->current() . '/?oauthtransport=' . $transport);
|
||||
$url = $item['url'] . $callback;
|
||||
|
||||
echo '<a class="btn btn-oauth ' . $class . '"';
|
||||
echo '" href="' . $url . '" data-base-url="' . $url . '">';
|
||||
if (isset($item['icon'])) {
|
||||
echo '<img src="' . asset('images/transports/' . $item['icon']) . '" width="24" height="24"> ';
|
||||
}
|
||||
echo $item['descr'];
|
||||
echo '</a>';
|
||||
}
|
||||
echo '</div>';
|
||||
if (!method_exists($class, 'configTemplate')) {
|
||||
// Skip since support has not been added
|
||||
continue;
|
||||
}
|
||||
|
||||
echo '<form method="post" role="form" id="'.strtolower($transport).'-form" class="form-horizontal transport">';
|
||||
echo csrf_field();
|
||||
echo '<input type="hidden" name="transport-type" id="transport-type" value="'.strtolower($transport).'">';
|
||||
|
||||
$tmp = call_user_func($class.'::configTemplate');
|
||||
|
||||
foreach ($tmp['config'] as $item) {
|
||||
if ($item['type'] !== 'hidden') {
|
||||
echo '<div class="form-group" title="' . $item['descr'] . '">';
|
||||
echo '<label for="' . $item['name'] . '" class="col-sm-3 col-md-2 control-label">' . $item['title'] . ': </label>';
|
||||
if ($item['type'] == 'text' || $item['type'] == 'password') {
|
||||
echo '<div class="col-sm-9 col-md-10">';
|
||||
echo '<input type="' . $item['type'] . '" id="' . $item['name'] . '" name="' . $item['name'] . '" class="form-control" ';
|
||||
if ($item['required']) {
|
||||
echo 'required>';
|
||||
} else {
|
||||
echo '>';
|
||||
}
|
||||
echo '</div>';
|
||||
} elseif ($item['type'] == 'checkbox') {
|
||||
echo '<div class="col-sm-2">';
|
||||
echo '<input type="checkbox" name="' . $item['name'] . '" id="' . $item['name'] . '">';
|
||||
echo '</div>';
|
||||
$switches[$item['name']] = $item['default'];
|
||||
} elseif ($item['type'] == 'select') {
|
||||
echo '<div class="col-sm-3">';
|
||||
echo '<select name="' . $item['name'] . '" id="' . $item['name'] . '" class="form-control">';
|
||||
foreach ($item['options'] as $descr => $opt) {
|
||||
echo '<option value="' . $opt . '">' . $descr . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
echo '</div>';
|
||||
} elseif ($item['type'] === 'textarea') {
|
||||
echo '<div class="col-sm-9 col-md-10">';
|
||||
echo '<textarea name="' . $item['name'] . '" id="' . $item['name'] . '" class="form-control" placeholder="' . $item['descr'] . '">';
|
||||
echo '</textarea>';
|
||||
echo '</div>';
|
||||
} elseif ($item['type'] === 'oauth') {
|
||||
$class = isset($item['class']) ? $item['class'] : 'btn-success';
|
||||
$callback = urlencode(url()->current() . '/?oauthtransport=' . $transport);
|
||||
$url = $item['url'] . $callback;
|
||||
|
||||
echo '<a class="btn btn-oauth ' . $class . '"';
|
||||
echo '" href="' . $url . '" data-base-url="' . $url . '">';
|
||||
if (isset($item['icon'])) {
|
||||
echo '<img src="' . asset('images/transports/' . $item['icon']) . '" width="24" height="24"> ';
|
||||
}
|
||||
echo $item['descr'];
|
||||
echo '</a>';
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
echo '<div class="form-group">';
|
||||
echo '<div class="col-sm-12 text-center">';
|
||||
echo '<button type="button" class="btn btn-success btn-save" name="save-transport">';
|
||||
echo 'Save Transport';
|
||||
echo '</button>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
}
|
||||
echo '<div class="form-group">';
|
||||
echo '<div class="col-sm-12 text-center">';
|
||||
echo '<button type="button" class="btn btn-success btn-save" name="save-transport">';
|
||||
echo 'Save Transport';
|
||||
echo '</button>';
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
}
|
||||
?>
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user